1 // Copyright 2017 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 6 #define V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 7 8 #include <vector> 9 10 #include "src/codegen/machine-type.h" 11 #include "src/compiler/js-heap-broker.h" 12 #include "src/handles/handles.h" 13 #include "src/objects/map.h" 14 #include "src/zone/zone-containers.h" 15 16 namespace v8 { 17 namespace internal { 18 namespace compiler { 19 20 class CommonOperatorBuilder; 21 class CompilationDependencies; 22 class Graph; 23 class JSGraph; 24 class JSHeapBroker; 25 class Node; 26 class PropertyAccessInfo; 27 class SimplifiedOperatorBuilder; 28 29 class PropertyAccessBuilder { 30 public: PropertyAccessBuilder(JSGraph * jsgraph,JSHeapBroker * broker,CompilationDependencies * dependencies)31 PropertyAccessBuilder(JSGraph* jsgraph, JSHeapBroker* broker, 32 CompilationDependencies* dependencies) 33 : jsgraph_(jsgraph), broker_(broker), dependencies_(dependencies) {} 34 35 // Builds the appropriate string check if the maps are only string 36 // maps. 37 bool TryBuildStringCheck(JSHeapBroker* broker, 38 ZoneVector<Handle<Map>> const& maps, Node** receiver, 39 Node** effect, Node* control); 40 // Builds a number check if all maps are number maps. 41 bool TryBuildNumberCheck(JSHeapBroker* broker, 42 ZoneVector<Handle<Map>> const& maps, Node** receiver, 43 Node** effect, Node* control); 44 45 void BuildCheckMaps(Node* receiver, Node** effect, Node* control, 46 ZoneVector<Handle<Map>> const& receiver_maps); 47 Node* BuildCheckValue(Node* receiver, Node** effect, Node* control, 48 Handle<HeapObject> value); 49 50 // Builds the actual load for data-field and data-constant-field 51 // properties (without heap-object or map checks). 52 Node* BuildLoadDataField(NameRef const& name, 53 PropertyAccessInfo const& access_info, 54 Node* receiver, Node** effect, Node** control); 55 56 static MachineRepresentation ConvertRepresentation( 57 Representation representation); 58 59 private: jsgraph()60 JSGraph* jsgraph() const { return jsgraph_; } broker()61 JSHeapBroker* broker() const { return broker_; } dependencies()62 CompilationDependencies* dependencies() const { return dependencies_; } 63 Graph* graph() const; 64 Isolate* isolate() const; 65 CommonOperatorBuilder* common() const; 66 SimplifiedOperatorBuilder* simplified() const; 67 68 Node* TryBuildLoadConstantDataField(NameRef const& name, 69 PropertyAccessInfo const& access_info, 70 Node* receiver); 71 // Returns a node with the holder for the property access described by 72 // {access_info}. 73 Node* ResolveHolder(PropertyAccessInfo const& access_info, Node* receiver); 74 75 JSGraph* jsgraph_; 76 JSHeapBroker* broker_; 77 CompilationDependencies* dependencies_; 78 }; 79 80 bool HasOnlyStringMaps(JSHeapBroker* broker, 81 ZoneVector<Handle<Map>> const& maps); 82 83 } // namespace compiler 84 } // namespace internal 85 } // namespace v8 86 87 #endif // V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 88