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/handles.h" 11 #include "src/objects/map.h" 12 #include "src/zone/zone-containers.h" 13 14 namespace v8 { 15 namespace internal { 16 namespace compiler { 17 18 class CommonOperatorBuilder; 19 class CompilationDependencies; 20 class Graph; 21 class JSGraph; 22 class JSHeapBroker; 23 class Node; 24 class PropertyAccessInfo; 25 class SimplifiedOperatorBuilder; 26 27 class PropertyAccessBuilder { 28 public: PropertyAccessBuilder(JSGraph * jsgraph,JSHeapBroker * js_heap_broker,CompilationDependencies * dependencies)29 PropertyAccessBuilder(JSGraph* jsgraph, JSHeapBroker* js_heap_broker, 30 CompilationDependencies* dependencies) 31 : jsgraph_(jsgraph), 32 js_heap_broker_(js_heap_broker), 33 dependencies_(dependencies) {} 34 35 // Builds the appropriate string check if the maps are only string 36 // maps. 37 bool TryBuildStringCheck(MapHandles const& maps, Node** receiver, 38 Node** effect, Node* control); 39 // Builds a number check if all maps are number maps. 40 bool TryBuildNumberCheck(MapHandles const& maps, Node** receiver, 41 Node** effect, Node* control); 42 43 Node* BuildCheckHeapObject(Node* receiver, Node** effect, Node* control); 44 void BuildCheckMaps(Node* receiver, Node** effect, Node* control, 45 std::vector<Handle<Map>> const& receiver_maps); 46 Node* BuildCheckValue(Node* receiver, Node** effect, Node* control, 47 Handle<HeapObject> value); 48 49 // Builds the actual load for data-field and data-constant-field 50 // properties (without heap-object or map checks). 51 Node* BuildLoadDataField(Handle<Name> name, 52 PropertyAccessInfo const& access_info, 53 Node* receiver, Node** effect, Node** control); 54 55 private: jsgraph()56 JSGraph* jsgraph() const { return jsgraph_; } js_heap_broker()57 JSHeapBroker* js_heap_broker() const { return js_heap_broker_; } dependencies()58 CompilationDependencies* dependencies() const { return dependencies_; } 59 Graph* graph() const; 60 Isolate* isolate() const; 61 CommonOperatorBuilder* common() const; 62 SimplifiedOperatorBuilder* simplified() const; 63 64 Node* TryBuildLoadConstantDataField(Handle<Name> name, 65 PropertyAccessInfo const& access_info, 66 Node* receiver); 67 // Returns a node with the holder for the property access described by 68 // {access_info}. 69 Node* ResolveHolder(PropertyAccessInfo const& access_info, Node* receiver); 70 71 JSGraph* jsgraph_; 72 JSHeapBroker* js_heap_broker_; 73 CompilationDependencies* dependencies_; 74 }; 75 76 bool HasOnlyStringMaps(MapHandles const& maps); 77 78 } // namespace compiler 79 } // namespace internal 80 } // namespace v8 81 82 #endif // V8_COMPILER_PROPERTY_ACCESS_BUILDER_H_ 83