OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
12 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
13 #include "src/compiler/operator-properties.h" | 13 #include "src/compiler/operator-properties.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 namespace compiler { | 17 namespace compiler { |
18 | 18 |
19 static CallDescriptor::Flags AdjustFrameStatesForCall(Node* node) { | 19 namespace { |
20 int count = OperatorProperties::GetFrameStateInputCount(node->op()); | 20 |
21 if (count > 1) { | 21 CallDescriptor::Flags FrameStateFlagForCall(Node* node) { |
22 int index = NodeProperties::FirstFrameStateIndex(node) + 1; | 22 return OperatorProperties::HasFrameStateInput(node->op()) |
23 do { | 23 ? CallDescriptor::kNeedsFrameState |
24 node->RemoveInput(index); | 24 : CallDescriptor::kNoFlags; |
25 } while (--count > 1); | |
26 } | |
27 return count > 0 ? CallDescriptor::kNeedsFrameState | |
28 : CallDescriptor::kNoFlags; | |
29 } | 25 } |
30 | 26 |
| 27 } // namespace |
| 28 |
31 JSGenericLowering::JSGenericLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {} | 29 JSGenericLowering::JSGenericLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {} |
32 | 30 |
33 JSGenericLowering::~JSGenericLowering() {} | 31 JSGenericLowering::~JSGenericLowering() {} |
34 | 32 |
35 | 33 |
36 Reduction JSGenericLowering::Reduce(Node* node) { | 34 Reduction JSGenericLowering::Reduce(Node* node) { |
37 switch (node->opcode()) { | 35 switch (node->opcode()) { |
38 #define DECLARE_CASE(x) \ | 36 #define DECLARE_CASE(x) \ |
39 case IrOpcode::k##x: \ | 37 case IrOpcode::k##x: \ |
40 Lower##x(node); \ | 38 Lower##x(node); \ |
41 break; | 39 break; |
42 JS_OP_LIST(DECLARE_CASE) | 40 JS_OP_LIST(DECLARE_CASE) |
43 #undef DECLARE_CASE | 41 #undef DECLARE_CASE |
44 default: | 42 default: |
45 // Nothing to see. | 43 // Nothing to see. |
46 return NoChange(); | 44 return NoChange(); |
47 } | 45 } |
48 return Changed(node); | 46 return Changed(node); |
49 } | 47 } |
50 #define REPLACE_RUNTIME_CALL(op, fun) \ | 48 #define REPLACE_RUNTIME_CALL(op, fun) \ |
51 void JSGenericLowering::Lower##op(Node* node) { \ | 49 void JSGenericLowering::Lower##op(Node* node) { \ |
52 ReplaceWithRuntimeCall(node, fun); \ | 50 ReplaceWithRuntimeCall(node, fun); \ |
53 } | 51 } |
54 REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) | 52 REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) |
55 REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver) | 53 REPLACE_RUNTIME_CALL(JSConvertReceiver, Runtime::kConvertReceiver) |
56 #undef REPLACE_RUNTIME_CALL | 54 #undef REPLACE_RUNTIME_CALL |
57 | 55 |
58 #define REPLACE_STUB_CALL(Name) \ | 56 #define REPLACE_STUB_CALL(Name) \ |
59 void JSGenericLowering::LowerJS##Name(Node* node) { \ | 57 void JSGenericLowering::LowerJS##Name(Node* node) { \ |
60 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); \ | 58 CallDescriptor::Flags flags = FrameStateFlagForCall(node); \ |
61 Callable callable = CodeFactory::Name(isolate()); \ | 59 Callable callable = CodeFactory::Name(isolate()); \ |
62 ReplaceWithStubCall(node, callable, flags); \ | 60 ReplaceWithStubCall(node, callable, flags); \ |
63 } | 61 } |
64 REPLACE_STUB_CALL(Add) | 62 REPLACE_STUB_CALL(Add) |
65 REPLACE_STUB_CALL(Subtract) | 63 REPLACE_STUB_CALL(Subtract) |
66 REPLACE_STUB_CALL(Multiply) | 64 REPLACE_STUB_CALL(Multiply) |
67 REPLACE_STUB_CALL(Divide) | 65 REPLACE_STUB_CALL(Divide) |
68 REPLACE_STUB_CALL(Modulus) | 66 REPLACE_STUB_CALL(Modulus) |
69 REPLACE_STUB_CALL(BitwiseAnd) | 67 REPLACE_STUB_CALL(BitwiseAnd) |
70 REPLACE_STUB_CALL(BitwiseOr) | 68 REPLACE_STUB_CALL(BitwiseOr) |
71 REPLACE_STUB_CALL(BitwiseXor) | 69 REPLACE_STUB_CALL(BitwiseXor) |
72 REPLACE_STUB_CALL(ShiftLeft) | 70 REPLACE_STUB_CALL(ShiftLeft) |
(...skipping 26 matching lines...) Expand all Loading... |
99 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 97 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
100 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 98 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
101 node->InsertInput(zone(), 0, stub_code); | 99 node->InsertInput(zone(), 0, stub_code); |
102 NodeProperties::ChangeOp(node, common()->Call(desc)); | 100 NodeProperties::ChangeOp(node, common()->Call(desc)); |
103 } | 101 } |
104 | 102 |
105 | 103 |
106 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, | 104 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, |
107 Runtime::FunctionId f, | 105 Runtime::FunctionId f, |
108 int nargs_override) { | 106 int nargs_override) { |
109 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 107 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
110 Operator::Properties properties = node->op()->properties(); | 108 Operator::Properties properties = node->op()->properties(); |
111 const Runtime::Function* fun = Runtime::FunctionForId(f); | 109 const Runtime::Function* fun = Runtime::FunctionForId(f); |
112 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; | 110 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; |
113 CallDescriptor* desc = | 111 CallDescriptor* desc = |
114 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags); | 112 Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags); |
115 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); | 113 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate())); |
116 Node* arity = jsgraph()->Int32Constant(nargs); | 114 Node* arity = jsgraph()->Int32Constant(nargs); |
117 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); | 115 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size)); |
118 node->InsertInput(zone(), nargs + 1, ref); | 116 node->InsertInput(zone(), nargs + 1, ref); |
119 node->InsertInput(zone(), nargs + 2, arity); | 117 node->InsertInput(zone(), nargs + 2, arity); |
(...skipping 26 matching lines...) Expand all Loading... |
146 node->AppendInput(zone(), graph()->start()); | 144 node->AppendInput(zone(), graph()->start()); |
147 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate, | 145 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate, |
148 Operator::kEliminatable); | 146 Operator::kEliminatable); |
149 } | 147 } |
150 | 148 |
151 | 149 |
152 void JSGenericLowering::LowerJSLoadProperty(Node* node) { | 150 void JSGenericLowering::LowerJSLoadProperty(Node* node) { |
153 Node* closure = NodeProperties::GetValueInput(node, 2); | 151 Node* closure = NodeProperties::GetValueInput(node, 2); |
154 Node* effect = NodeProperties::GetEffectInput(node); | 152 Node* effect = NodeProperties::GetEffectInput(node); |
155 Node* control = NodeProperties::GetControlInput(node); | 153 Node* control = NodeProperties::GetControlInput(node); |
156 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 154 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
157 const PropertyAccess& p = PropertyAccessOf(node->op()); | 155 const PropertyAccess& p = PropertyAccessOf(node->op()); |
158 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); | 156 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); |
159 // Load the type feedback vector from the closure. | 157 // Load the type feedback vector from the closure. |
160 Node* literals = effect = graph()->NewNode( | 158 Node* literals = effect = graph()->NewNode( |
161 machine()->Load(MachineType::AnyTagged()), closure, | 159 machine()->Load(MachineType::AnyTagged()), closure, |
162 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 160 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
163 effect, control); | 161 effect, control); |
164 Node* vector = effect = graph()->NewNode( | 162 Node* vector = effect = graph()->NewNode( |
165 machine()->Load(MachineType::AnyTagged()), literals, | 163 machine()->Load(MachineType::AnyTagged()), literals, |
166 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 164 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
167 kHeapObjectTag), | 165 kHeapObjectTag), |
168 effect, control); | 166 effect, control); |
169 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 167 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
170 node->ReplaceInput(3, vector); | 168 node->ReplaceInput(3, vector); |
171 node->ReplaceInput(6, effect); | 169 node->ReplaceInput(6, effect); |
172 ReplaceWithStubCall(node, callable, flags); | 170 ReplaceWithStubCall(node, callable, flags); |
173 } | 171 } |
174 | 172 |
175 | 173 |
176 void JSGenericLowering::LowerJSLoadNamed(Node* node) { | 174 void JSGenericLowering::LowerJSLoadNamed(Node* node) { |
177 Node* closure = NodeProperties::GetValueInput(node, 1); | 175 Node* closure = NodeProperties::GetValueInput(node, 1); |
178 Node* effect = NodeProperties::GetEffectInput(node); | 176 Node* effect = NodeProperties::GetEffectInput(node); |
179 Node* control = NodeProperties::GetControlInput(node); | 177 Node* control = NodeProperties::GetControlInput(node); |
180 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 178 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
181 NamedAccess const& p = NamedAccessOf(node->op()); | 179 NamedAccess const& p = NamedAccessOf(node->op()); |
182 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); | 180 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); |
183 // Load the type feedback vector from the closure. | 181 // Load the type feedback vector from the closure. |
184 Node* literals = effect = graph()->NewNode( | 182 Node* literals = effect = graph()->NewNode( |
185 machine()->Load(MachineType::AnyTagged()), closure, | 183 machine()->Load(MachineType::AnyTagged()), closure, |
186 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 184 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
187 effect, control); | 185 effect, control); |
188 Node* vector = effect = graph()->NewNode( | 186 Node* vector = effect = graph()->NewNode( |
189 machine()->Load(MachineType::AnyTagged()), literals, | 187 machine()->Load(MachineType::AnyTagged()), literals, |
190 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 188 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
191 kHeapObjectTag), | 189 kHeapObjectTag), |
192 effect, control); | 190 effect, control); |
193 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | 191 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
194 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 192 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
195 node->ReplaceInput(3, vector); | 193 node->ReplaceInput(3, vector); |
196 node->ReplaceInput(6, effect); | 194 node->ReplaceInput(6, effect); |
197 ReplaceWithStubCall(node, callable, flags); | 195 ReplaceWithStubCall(node, callable, flags); |
198 } | 196 } |
199 | 197 |
200 | 198 |
201 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { | 199 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { |
202 Node* closure = NodeProperties::GetValueInput(node, 0); | 200 Node* closure = NodeProperties::GetValueInput(node, 0); |
203 Node* effect = NodeProperties::GetEffectInput(node); | 201 Node* effect = NodeProperties::GetEffectInput(node); |
204 Node* control = NodeProperties::GetControlInput(node); | 202 Node* control = NodeProperties::GetControlInput(node); |
205 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 203 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
206 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); | 204 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); |
207 Callable callable = | 205 Callable callable = |
208 CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode()); | 206 CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode()); |
209 // Load the type feedback vector from the closure. | 207 // Load the type feedback vector from the closure. |
210 Node* literals = effect = graph()->NewNode( | 208 Node* literals = effect = graph()->NewNode( |
211 machine()->Load(MachineType::AnyTagged()), closure, | 209 machine()->Load(MachineType::AnyTagged()), closure, |
212 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 210 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
213 effect, control); | 211 effect, control); |
214 Node* vector = effect = graph()->NewNode( | 212 Node* vector = effect = graph()->NewNode( |
215 machine()->Load(MachineType::AnyTagged()), literals, | 213 machine()->Load(MachineType::AnyTagged()), literals, |
216 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 214 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
217 kHeapObjectTag), | 215 kHeapObjectTag), |
218 effect, control); | 216 effect, control); |
219 node->InsertInput(zone(), 0, jsgraph()->SmiConstant(p.feedback().index())); | 217 node->InsertInput(zone(), 0, jsgraph()->SmiConstant(p.feedback().index())); |
220 node->ReplaceInput(1, vector); | 218 node->ReplaceInput(1, vector); |
221 node->ReplaceInput(4, effect); | 219 node->ReplaceInput(4, effect); |
222 ReplaceWithStubCall(node, callable, flags); | 220 ReplaceWithStubCall(node, callable, flags); |
223 } | 221 } |
224 | 222 |
225 | 223 |
226 void JSGenericLowering::LowerJSStoreProperty(Node* node) { | 224 void JSGenericLowering::LowerJSStoreProperty(Node* node) { |
227 Node* receiver = NodeProperties::GetValueInput(node, 0); | 225 Node* receiver = NodeProperties::GetValueInput(node, 0); |
228 Node* key = NodeProperties::GetValueInput(node, 1); | 226 Node* key = NodeProperties::GetValueInput(node, 1); |
229 Node* value = NodeProperties::GetValueInput(node, 2); | 227 Node* value = NodeProperties::GetValueInput(node, 2); |
230 Node* closure = NodeProperties::GetValueInput(node, 3); | 228 Node* closure = NodeProperties::GetValueInput(node, 3); |
231 Node* effect = NodeProperties::GetEffectInput(node); | 229 Node* effect = NodeProperties::GetEffectInput(node); |
232 Node* control = NodeProperties::GetControlInput(node); | 230 Node* control = NodeProperties::GetControlInput(node); |
233 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 231 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
234 PropertyAccess const& p = PropertyAccessOf(node->op()); | 232 PropertyAccess const& p = PropertyAccessOf(node->op()); |
235 LanguageMode language_mode = p.language_mode(); | 233 LanguageMode language_mode = p.language_mode(); |
236 Callable callable = | 234 Callable callable = |
237 CodeFactory::KeyedStoreICInOptimizedCode(isolate(), language_mode); | 235 CodeFactory::KeyedStoreICInOptimizedCode(isolate(), language_mode); |
238 // Load the type feedback vector from the closure. | 236 // Load the type feedback vector from the closure. |
239 Node* literals = effect = graph()->NewNode( | 237 Node* literals = effect = graph()->NewNode( |
240 machine()->Load(MachineType::AnyTagged()), closure, | 238 machine()->Load(MachineType::AnyTagged()), closure, |
241 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 239 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
242 effect, control); | 240 effect, control); |
243 Node* vector = effect = graph()->NewNode( | 241 Node* vector = effect = graph()->NewNode( |
(...skipping 13 matching lines...) Expand all Loading... |
257 ReplaceWithStubCall(node, callable, flags); | 255 ReplaceWithStubCall(node, callable, flags); |
258 } | 256 } |
259 | 257 |
260 | 258 |
261 void JSGenericLowering::LowerJSStoreNamed(Node* node) { | 259 void JSGenericLowering::LowerJSStoreNamed(Node* node) { |
262 Node* receiver = NodeProperties::GetValueInput(node, 0); | 260 Node* receiver = NodeProperties::GetValueInput(node, 0); |
263 Node* value = NodeProperties::GetValueInput(node, 1); | 261 Node* value = NodeProperties::GetValueInput(node, 1); |
264 Node* closure = NodeProperties::GetValueInput(node, 2); | 262 Node* closure = NodeProperties::GetValueInput(node, 2); |
265 Node* effect = NodeProperties::GetEffectInput(node); | 263 Node* effect = NodeProperties::GetEffectInput(node); |
266 Node* control = NodeProperties::GetControlInput(node); | 264 Node* control = NodeProperties::GetControlInput(node); |
267 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 265 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
268 NamedAccess const& p = NamedAccessOf(node->op()); | 266 NamedAccess const& p = NamedAccessOf(node->op()); |
269 Callable callable = | 267 Callable callable = |
270 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); | 268 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); |
271 // Load the type feedback vector from the closure. | 269 // Load the type feedback vector from the closure. |
272 Node* literals = effect = graph()->NewNode( | 270 Node* literals = effect = graph()->NewNode( |
273 machine()->Load(MachineType::AnyTagged()), closure, | 271 machine()->Load(MachineType::AnyTagged()), closure, |
274 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 272 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
275 effect, control); | 273 effect, control); |
276 Node* vector = effect = graph()->NewNode( | 274 Node* vector = effect = graph()->NewNode( |
277 machine()->Load(MachineType::AnyTagged()), literals, | 275 machine()->Load(MachineType::AnyTagged()), literals, |
(...skipping 12 matching lines...) Expand all Loading... |
290 ReplaceWithStubCall(node, callable, flags); | 288 ReplaceWithStubCall(node, callable, flags); |
291 } | 289 } |
292 | 290 |
293 | 291 |
294 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { | 292 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { |
295 Node* value = NodeProperties::GetValueInput(node, 0); | 293 Node* value = NodeProperties::GetValueInput(node, 0); |
296 Node* closure = NodeProperties::GetValueInput(node, 1); | 294 Node* closure = NodeProperties::GetValueInput(node, 1); |
297 Node* context = NodeProperties::GetContextInput(node); | 295 Node* context = NodeProperties::GetContextInput(node); |
298 Node* effect = NodeProperties::GetEffectInput(node); | 296 Node* effect = NodeProperties::GetEffectInput(node); |
299 Node* control = NodeProperties::GetControlInput(node); | 297 Node* control = NodeProperties::GetControlInput(node); |
300 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 298 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
301 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); | 299 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); |
302 Callable callable = | 300 Callable callable = |
303 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); | 301 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); |
304 // Load the type feedback vector from the closure. | 302 // Load the type feedback vector from the closure. |
305 Node* literals = effect = graph()->NewNode( | 303 Node* literals = effect = graph()->NewNode( |
306 machine()->Load(MachineType::AnyTagged()), closure, | 304 machine()->Load(MachineType::AnyTagged()), closure, |
307 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | 305 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), |
308 effect, control); | 306 effect, control); |
309 Node* vector = effect = graph()->NewNode( | 307 Node* vector = effect = graph()->NewNode( |
310 machine()->Load(MachineType::AnyTagged()), literals, | 308 machine()->Load(MachineType::AnyTagged()), literals, |
(...skipping 25 matching lines...) Expand all Loading... |
336 | 334 |
337 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 335 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
338 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 336 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
339 ReplaceWithRuntimeCall(node, is_strict(language_mode) | 337 ReplaceWithRuntimeCall(node, is_strict(language_mode) |
340 ? Runtime::kDeleteProperty_Strict | 338 ? Runtime::kDeleteProperty_Strict |
341 : Runtime::kDeleteProperty_Sloppy); | 339 : Runtime::kDeleteProperty_Sloppy); |
342 } | 340 } |
343 | 341 |
344 | 342 |
345 void JSGenericLowering::LowerJSInstanceOf(Node* node) { | 343 void JSGenericLowering::LowerJSInstanceOf(Node* node) { |
346 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 344 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
347 Callable callable = CodeFactory::InstanceOf(isolate()); | 345 Callable callable = CodeFactory::InstanceOf(isolate()); |
348 ReplaceWithStubCall(node, callable, flags); | 346 ReplaceWithStubCall(node, callable, flags); |
349 } | 347 } |
350 | 348 |
351 | 349 |
352 void JSGenericLowering::LowerJSLoadContext(Node* node) { | 350 void JSGenericLowering::LowerJSLoadContext(Node* node) { |
353 const ContextAccess& access = ContextAccessOf(node->op()); | 351 const ContextAccess& access = ContextAccessOf(node->op()); |
354 for (size_t i = 0; i < access.depth(); ++i) { | 352 for (size_t i = 0; i < access.depth(); ++i) { |
355 node->ReplaceInput( | 353 node->ReplaceInput( |
356 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()), | 354 0, graph()->NewNode(machine()->Load(MachineType::AnyTagged()), |
(...skipping 24 matching lines...) Expand all Loading... |
381 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); | 379 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); |
382 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( | 380 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( |
383 static_cast<int>(access.index())))); | 381 static_cast<int>(access.index())))); |
384 NodeProperties::ChangeOp( | 382 NodeProperties::ChangeOp( |
385 node, machine()->Store(StoreRepresentation(MachineRepresentation::kTagged, | 383 node, machine()->Store(StoreRepresentation(MachineRepresentation::kTagged, |
386 kFullWriteBarrier))); | 384 kFullWriteBarrier))); |
387 } | 385 } |
388 | 386 |
389 | 387 |
390 void JSGenericLowering::LowerJSCreate(Node* node) { | 388 void JSGenericLowering::LowerJSCreate(Node* node) { |
391 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 389 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
392 Callable callable = CodeFactory::FastNewObject(isolate()); | 390 Callable callable = CodeFactory::FastNewObject(isolate()); |
393 ReplaceWithStubCall(node, callable, flags); | 391 ReplaceWithStubCall(node, callable, flags); |
394 } | 392 } |
395 | 393 |
396 | 394 |
397 void JSGenericLowering::LowerJSCreateArguments(Node* node) { | 395 void JSGenericLowering::LowerJSCreateArguments(Node* node) { |
398 CreateArgumentsType const type = CreateArgumentsTypeOf(node->op()); | 396 CreateArgumentsType const type = CreateArgumentsTypeOf(node->op()); |
399 switch (type) { | 397 switch (type) { |
400 case CreateArgumentsType::kMappedArguments: | 398 case CreateArgumentsType::kMappedArguments: |
401 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic); | 399 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic); |
(...skipping 17 matching lines...) Expand all Loading... |
419 : jsgraph()->HeapConstant(site); | 417 : jsgraph()->HeapConstant(site); |
420 node->RemoveInput(1); | 418 node->RemoveInput(1); |
421 node->InsertInput(zone(), 1 + arity, new_target); | 419 node->InsertInput(zone(), 1 + arity, new_target); |
422 node->InsertInput(zone(), 2 + arity, type_info); | 420 node->InsertInput(zone(), 2 + arity, type_info); |
423 ReplaceWithRuntimeCall(node, Runtime::kNewArray, arity + 3); | 421 ReplaceWithRuntimeCall(node, Runtime::kNewArray, arity + 3); |
424 } | 422 } |
425 | 423 |
426 | 424 |
427 void JSGenericLowering::LowerJSCreateClosure(Node* node) { | 425 void JSGenericLowering::LowerJSCreateClosure(Node* node) { |
428 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); | 426 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
429 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 427 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
430 Handle<SharedFunctionInfo> const shared_info = p.shared_info(); | 428 Handle<SharedFunctionInfo> const shared_info = p.shared_info(); |
431 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info)); | 429 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info)); |
432 | 430 |
433 // Use the FastNewClosureStub only for functions allocated in new space. | 431 // Use the FastNewClosureStub only for functions allocated in new space. |
434 if (p.pretenure() == NOT_TENURED) { | 432 if (p.pretenure() == NOT_TENURED) { |
435 Callable callable = CodeFactory::FastNewClosure(isolate()); | 433 Callable callable = CodeFactory::FastNewClosure(isolate()); |
436 ReplaceWithStubCall(node, callable, flags); | 434 ReplaceWithStubCall(node, callable, flags); |
437 } else { | 435 } else { |
438 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED) | 436 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED) |
439 ? Runtime::kNewClosure_Tenured | 437 ? Runtime::kNewClosure_Tenured |
440 : Runtime::kNewClosure); | 438 : Runtime::kNewClosure); |
441 } | 439 } |
442 } | 440 } |
443 | 441 |
444 | 442 |
445 void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) { | 443 void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) { |
446 int const slot_count = OpParameter<int>(node->op()); | 444 int const slot_count = OpParameter<int>(node->op()); |
447 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 445 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
448 | 446 |
449 Callable callable = CodeFactory::FastNewFunctionContext(isolate()); | 447 Callable callable = CodeFactory::FastNewFunctionContext(isolate()); |
450 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count)); | 448 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count)); |
451 ReplaceWithStubCall(node, callable, flags); | 449 ReplaceWithStubCall(node, callable, flags); |
452 } | 450 } |
453 | 451 |
454 | 452 |
455 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { | 453 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { |
456 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); | 454 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); |
457 } | 455 } |
458 | 456 |
459 | 457 |
460 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { | 458 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { |
461 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 459 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
462 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 460 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
463 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 461 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
464 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 462 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
465 | 463 |
466 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the | 464 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the |
467 // initial length limit for arrays with "fast" elements kind. | 465 // initial length limit for arrays with "fast" elements kind. |
468 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && | 466 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && |
469 p.length() < JSArray::kInitialMaxFastElementArray) { | 467 p.length() < JSArray::kInitialMaxFastElementArray) { |
470 Callable callable = CodeFactory::FastCloneShallowArray(isolate()); | 468 Callable callable = CodeFactory::FastCloneShallowArray(isolate()); |
471 ReplaceWithStubCall(node, callable, flags); | 469 ReplaceWithStubCall(node, callable, flags); |
472 } else { | 470 } else { |
473 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 471 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
474 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); | 472 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); |
475 } | 473 } |
476 } | 474 } |
477 | 475 |
478 | 476 |
479 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { | 477 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { |
480 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 478 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
481 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 479 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
482 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 480 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
483 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 481 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
484 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 482 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
485 | 483 |
486 // Use the FastCloneShallowObjectStub only for shallow boilerplates without | 484 // Use the FastCloneShallowObjectStub only for shallow boilerplates without |
487 // elements up to the number of properties that the stubs can handle. | 485 // elements up to the number of properties that the stubs can handle. |
488 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && | 486 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && |
489 p.length() <= FastCloneShallowObjectStub::kMaximumClonedProperties) { | 487 p.length() <= FastCloneShallowObjectStub::kMaximumClonedProperties) { |
490 Callable callable = | 488 Callable callable = |
491 CodeFactory::FastCloneShallowObject(isolate(), p.length()); | 489 CodeFactory::FastCloneShallowObject(isolate(), p.length()); |
492 ReplaceWithStubCall(node, callable, flags); | 490 ReplaceWithStubCall(node, callable, flags); |
493 } else { | 491 } else { |
494 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); | 492 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); |
495 } | 493 } |
496 } | 494 } |
497 | 495 |
498 | 496 |
499 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { | 497 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { |
500 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 498 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
501 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 499 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
502 Callable callable = CodeFactory::FastCloneRegExp(isolate()); | 500 Callable callable = CodeFactory::FastCloneRegExp(isolate()); |
503 Node* literal_index = jsgraph()->SmiConstant(p.index()); | 501 Node* literal_index = jsgraph()->SmiConstant(p.index()); |
504 Node* literal_flags = jsgraph()->SmiConstant(p.flags()); | 502 Node* literal_flags = jsgraph()->SmiConstant(p.flags()); |
505 Node* pattern = jsgraph()->HeapConstant(p.constant()); | 503 Node* pattern = jsgraph()->HeapConstant(p.constant()); |
506 node->InsertInput(graph()->zone(), 1, literal_index); | 504 node->InsertInput(graph()->zone(), 1, literal_index); |
507 node->InsertInput(graph()->zone(), 2, pattern); | 505 node->InsertInput(graph()->zone(), 2, pattern); |
508 node->InsertInput(graph()->zone(), 3, literal_flags); | 506 node->InsertInput(graph()->zone(), 3, literal_flags); |
509 ReplaceWithStubCall(node, callable, flags); | 507 ReplaceWithStubCall(node, callable, flags); |
510 } | 508 } |
511 | 509 |
(...skipping 15 matching lines...) Expand all Loading... |
527 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 525 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
528 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 526 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
529 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 527 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
530 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 528 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); |
531 } | 529 } |
532 | 530 |
533 | 531 |
534 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 532 void JSGenericLowering::LowerJSCallConstruct(Node* node) { |
535 CallConstructParameters const& p = CallConstructParametersOf(node->op()); | 533 CallConstructParameters const& p = CallConstructParametersOf(node->op()); |
536 int const arg_count = static_cast<int>(p.arity() - 2); | 534 int const arg_count = static_cast<int>(p.arity() - 2); |
537 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 535 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
538 Callable callable = CodeFactory::Construct(isolate()); | 536 Callable callable = CodeFactory::Construct(isolate()); |
539 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 537 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
540 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 538 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
541 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 539 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
542 Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 540 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
543 Node* new_target = node->InputAt(arg_count + 1); | 541 Node* new_target = node->InputAt(arg_count + 1); |
544 Node* receiver = jsgraph()->UndefinedConstant(); | 542 Node* receiver = jsgraph()->UndefinedConstant(); |
545 node->RemoveInput(arg_count + 1); // Drop new target. | 543 node->RemoveInput(arg_count + 1); // Drop new target. |
546 node->InsertInput(zone(), 0, stub_code); | 544 node->InsertInput(zone(), 0, stub_code); |
547 node->InsertInput(zone(), 2, new_target); | 545 node->InsertInput(zone(), 2, new_target); |
548 node->InsertInput(zone(), 3, stub_arity); | 546 node->InsertInput(zone(), 3, stub_arity); |
549 node->InsertInput(zone(), 4, receiver); | 547 node->InsertInput(zone(), 4, receiver); |
550 NodeProperties::ChangeOp(node, common()->Call(desc)); | 548 NodeProperties::ChangeOp(node, common()->Call(desc)); |
551 } | 549 } |
552 | 550 |
553 | 551 |
554 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 552 void JSGenericLowering::LowerJSCallFunction(Node* node) { |
555 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 553 CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); |
556 int const arg_count = static_cast<int>(p.arity() - 2); | 554 int const arg_count = static_cast<int>(p.arity() - 2); |
557 ConvertReceiverMode const mode = p.convert_mode(); | 555 ConvertReceiverMode const mode = p.convert_mode(); |
558 Callable callable = CodeFactory::Call(isolate(), mode); | 556 Callable callable = CodeFactory::Call(isolate(), mode); |
559 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 557 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
560 if (p.tail_call_mode() == TailCallMode::kAllow) { | 558 if (p.tail_call_mode() == TailCallMode::kAllow) { |
561 flags |= CallDescriptor::kSupportsTailCalls; | 559 flags |= CallDescriptor::kSupportsTailCalls; |
562 } | 560 } |
563 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 561 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
564 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 562 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
565 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 563 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
566 Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 564 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
567 node->InsertInput(zone(), 0, stub_code); | 565 node->InsertInput(zone(), 0, stub_code); |
568 node->InsertInput(zone(), 2, stub_arity); | 566 node->InsertInput(zone(), 2, stub_arity); |
569 NodeProperties::ChangeOp(node, common()->Call(desc)); | 567 NodeProperties::ChangeOp(node, common()->Call(desc)); |
570 } | 568 } |
571 | 569 |
572 | 570 |
573 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 571 void JSGenericLowering::LowerJSCallRuntime(Node* node) { |
574 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 572 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); |
575 AdjustFrameStatesForCall(node); | |
576 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 573 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); |
577 } | 574 } |
578 | 575 |
579 | 576 |
580 void JSGenericLowering::LowerJSForInDone(Node* node) { | 577 void JSGenericLowering::LowerJSForInDone(Node* node) { |
581 ReplaceWithRuntimeCall(node, Runtime::kForInDone); | 578 ReplaceWithRuntimeCall(node, Runtime::kForInDone); |
582 } | 579 } |
583 | 580 |
584 | 581 |
585 void JSGenericLowering::LowerJSForInNext(Node* node) { | 582 void JSGenericLowering::LowerJSForInNext(Node* node) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 684 } |
688 | 685 |
689 | 686 |
690 MachineOperatorBuilder* JSGenericLowering::machine() const { | 687 MachineOperatorBuilder* JSGenericLowering::machine() const { |
691 return jsgraph()->machine(); | 688 return jsgraph()->machine(); |
692 } | 689 } |
693 | 690 |
694 } // namespace compiler | 691 } // namespace compiler |
695 } // namespace internal | 692 } // namespace internal |
696 } // namespace v8 | 693 } // namespace v8 |
OLD | NEW |