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