OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ | 5 #ifndef V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
6 #define V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ | 6 #define V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
7 | 7 |
8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
9 #include "src/compiler/graph-reducer.h" | 9 #include "src/compiler/graph-reducer.h" |
10 #include "src/deoptimize-reason.h" | 10 #include "src/deoptimize-reason.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Flags that control the mode of operation. | 39 // Flags that control the mode of operation. |
40 enum Flag { | 40 enum Flag { |
41 kNoFlags = 0u, | 41 kNoFlags = 0u, |
42 kAccessorInliningEnabled = 1u << 0, | 42 kAccessorInliningEnabled = 1u << 0, |
43 kBailoutOnUninitialized = 1u << 1, | 43 kBailoutOnUninitialized = 1u << 1, |
44 kDeoptimizationEnabled = 1u << 2, | 44 kDeoptimizationEnabled = 1u << 2, |
45 }; | 45 }; |
46 typedef base::Flags<Flag> Flags; | 46 typedef base::Flags<Flag> Flags; |
47 | 47 |
48 JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, | 48 JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, |
49 MaybeHandle<Context> native_context, | 49 Handle<Context> native_context, |
50 CompilationDependencies* dependencies, | 50 CompilationDependencies* dependencies, |
51 Zone* zone); | 51 Zone* zone); |
52 | 52 |
53 Reduction Reduce(Node* node) final; | 53 Reduction Reduce(Node* node) final; |
54 | 54 |
55 private: | 55 private: |
56 Reduction ReduceJSLoadContext(Node* node); | 56 Reduction ReduceJSLoadContext(Node* node); |
57 Reduction ReduceJSLoadNamed(Node* node); | 57 Reduction ReduceJSLoadNamed(Node* node); |
58 Reduction ReduceJSStoreNamed(Node* node); | 58 Reduction ReduceJSStoreNamed(Node* node); |
59 Reduction ReduceJSLoadProperty(Node* node); | 59 Reduction ReduceJSLoadProperty(Node* node); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Node* const value_; | 96 Node* const value_; |
97 Node* const effect_; | 97 Node* const effect_; |
98 Node* const control_; | 98 Node* const control_; |
99 }; | 99 }; |
100 | 100 |
101 // Construct the appropriate subgraph for property access. | 101 // Construct the appropriate subgraph for property access. |
102 ValueEffectControl BuildPropertyAccess(Node* receiver, Node* value, | 102 ValueEffectControl BuildPropertyAccess(Node* receiver, Node* value, |
103 Node* context, Node* frame_state, | 103 Node* context, Node* frame_state, |
104 Node* effect, Node* control, | 104 Node* effect, Node* control, |
105 Handle<Name> name, | 105 Handle<Name> name, |
106 Handle<Context> native_context, | |
107 PropertyAccessInfo const& access_info, | 106 PropertyAccessInfo const& access_info, |
108 AccessMode access_mode); | 107 AccessMode access_mode); |
109 | 108 |
110 // Construct the appropriate subgraph for element access. | 109 // Construct the appropriate subgraph for element access. |
111 ValueEffectControl BuildElementAccess( | 110 ValueEffectControl BuildElementAccess(Node* receiver, Node* index, |
112 Node* receiver, Node* index, Node* value, Node* effect, Node* control, | 111 Node* value, Node* effect, |
113 Handle<Context> native_context, ElementAccessInfo const& access_info, | 112 Node* control, |
114 AccessMode access_mode, KeyedAccessStoreMode store_mode); | 113 ElementAccessInfo const& access_info, |
| 114 AccessMode access_mode, |
| 115 KeyedAccessStoreMode store_mode); |
115 | 116 |
116 // Construct an appropriate map check. | 117 // Construct an appropriate map check. |
117 Node* BuildCheckMaps(Node* receiver, Node* effect, Node* control, | 118 Node* BuildCheckMaps(Node* receiver, Node* effect, Node* control, |
118 std::vector<Handle<Map>> const& maps); | 119 std::vector<Handle<Map>> const& maps); |
119 | 120 |
120 // Construct an appropriate heap object check. | 121 // Construct an appropriate heap object check. |
121 Node* BuildCheckHeapObject(Node* receiver, Node* effect, Node* control); | 122 Node* BuildCheckHeapObject(Node* receiver, Node* effect, Node* control); |
122 | 123 |
123 // Adds stability dependencies on all prototypes of every class in | 124 // Adds stability dependencies on all prototypes of every class in |
124 // {receiver_type} up to (and including) the {holder}. | 125 // {receiver_type} up to (and including) the {holder}. |
125 void AssumePrototypesStable(std::vector<Handle<Map>> const& receiver_maps, | 126 void AssumePrototypesStable(std::vector<Handle<Map>> const& receiver_maps, |
126 Handle<Context> native_context, | |
127 Handle<JSObject> holder); | 127 Handle<JSObject> holder); |
128 | 128 |
129 // Checks if we can turn the hole into undefined when loading an element | 129 // Checks if we can turn the hole into undefined when loading an element |
130 // from an object with one of the {receiver_maps}; sets up appropriate | 130 // from an object with one of the {receiver_maps}; sets up appropriate |
131 // code dependencies and might use the array protector cell. | 131 // code dependencies and might use the array protector cell. |
132 bool CanTreatHoleAsUndefined(std::vector<Handle<Map>> const& receiver_maps, | 132 bool CanTreatHoleAsUndefined(std::vector<Handle<Map>> const& receiver_maps); |
133 Handle<Context> native_context); | |
134 | 133 |
135 // Extract receiver maps from {nexus} and filter based on {receiver} if | 134 // Extract receiver maps from {nexus} and filter based on {receiver} if |
136 // possible. | 135 // possible. |
137 bool ExtractReceiverMaps(Node* receiver, Node* effect, | 136 bool ExtractReceiverMaps(Node* receiver, Node* effect, |
138 FeedbackNexus const& nexus, | 137 FeedbackNexus const& nexus, |
139 MapHandleList* receiver_maps); | 138 MapHandleList* receiver_maps); |
140 | 139 |
141 // Try to infer a map for the given {receiver} at the current {effect}. | 140 // Try to infer a map for the given {receiver} at the current {effect}. |
142 // If a map is returned then you can be sure that the {receiver} definitely | 141 // If a map is returned then you can be sure that the {receiver} definitely |
143 // has the returned map at this point in the program (identified by {effect}). | 142 // has the returned map at this point in the program (identified by {effect}). |
144 MaybeHandle<Map> InferReceiverMap(Node* receiver, Node* effect); | 143 MaybeHandle<Map> InferReceiverMap(Node* receiver, Node* effect); |
145 // Try to infer a root map for the {receiver} independent of the current | 144 // Try to infer a root map for the {receiver} independent of the current |
146 // program location. | 145 // program location. |
147 MaybeHandle<Map> InferReceiverRootMap(Node* receiver); | 146 MaybeHandle<Map> InferReceiverRootMap(Node* receiver); |
148 | 147 |
149 // Retrieve the native context from the given {node} if known. | |
150 MaybeHandle<Context> GetNativeContext(Node* node); | |
151 | |
152 Graph* graph() const; | 148 Graph* graph() const; |
153 JSGraph* jsgraph() const { return jsgraph_; } | 149 JSGraph* jsgraph() const { return jsgraph_; } |
154 Isolate* isolate() const; | 150 Isolate* isolate() const; |
155 Factory* factory() const; | 151 Factory* factory() const; |
156 CommonOperatorBuilder* common() const; | 152 CommonOperatorBuilder* common() const; |
157 JSOperatorBuilder* javascript() const; | 153 JSOperatorBuilder* javascript() const; |
158 SimplifiedOperatorBuilder* simplified() const; | 154 SimplifiedOperatorBuilder* simplified() const; |
159 MachineOperatorBuilder* machine() const; | 155 MachineOperatorBuilder* machine() const; |
160 Flags flags() const { return flags_; } | 156 Flags flags() const { return flags_; } |
161 MaybeHandle<Context> native_context() const { return native_context_; } | 157 Handle<Context> native_context() const { return native_context_; } |
162 CompilationDependencies* dependencies() const { return dependencies_; } | 158 CompilationDependencies* dependencies() const { return dependencies_; } |
163 Zone* zone() const { return zone_; } | 159 Zone* zone() const { return zone_; } |
164 | 160 |
165 JSGraph* const jsgraph_; | 161 JSGraph* const jsgraph_; |
166 Flags const flags_; | 162 Flags const flags_; |
167 MaybeHandle<Context> native_context_; | 163 Handle<Context> native_context_; |
168 CompilationDependencies* const dependencies_; | 164 CompilationDependencies* const dependencies_; |
169 Zone* const zone_; | 165 Zone* const zone_; |
170 TypeCache const& type_cache_; | 166 TypeCache const& type_cache_; |
171 | 167 |
172 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); | 168 DISALLOW_COPY_AND_ASSIGN(JSNativeContextSpecialization); |
173 }; | 169 }; |
174 | 170 |
175 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) | 171 DEFINE_OPERATORS_FOR_FLAGS(JSNativeContextSpecialization::Flags) |
176 | 172 |
177 } // namespace compiler | 173 } // namespace compiler |
178 } // namespace internal | 174 } // namespace internal |
179 } // namespace v8 | 175 } // namespace v8 |
180 | 176 |
181 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ | 177 #endif // V8_COMPILER_JS_NATIVE_CONTEXT_SPECIALIZATION_H_ |
OLD | NEW |