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" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); | 299 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); |
300 Callable callable = CodeFactory::LoadICInOptimizedCode( | 300 Callable callable = CodeFactory::LoadICInOptimizedCode( |
301 isolate(), NOT_INSIDE_TYPEOF, p.language_mode(), UNINITIALIZED); | 301 isolate(), NOT_INSIDE_TYPEOF, p.language_mode(), UNINITIALIZED); |
302 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | 302 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
303 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 303 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
304 ReplaceWithStubCall(node, callable, flags); | 304 ReplaceWithStubCall(node, callable, flags); |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { | 308 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { |
| 309 Node* context = NodeProperties::GetContextInput(node); |
| 310 Node* effect = NodeProperties::GetEffectInput(node); |
309 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 311 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
310 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); | 312 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); |
311 if (p.slot_index() >= 0) { | 313 Callable callable = CodeFactory::LoadICInOptimizedCode( |
312 Callable callable = CodeFactory::LoadGlobalViaContext(isolate(), 0); | 314 isolate(), p.typeof_mode(), SLOPPY, UNINITIALIZED); |
313 Node* script_context = node->InputAt(0); | 315 // Load global object from the context. |
314 node->ReplaceInput(0, jsgraph()->Int32Constant(p.slot_index())); | 316 Node* global = graph()->NewNode(machine()->Load(kMachAnyTagged), context, |
315 node->ReplaceInput(1, script_context); // Set new context... | 317 jsgraph()->IntPtrConstant(Context::SlotOffset( |
316 node->RemoveInput(2); | 318 Context::GLOBAL_OBJECT_INDEX)), |
317 node->RemoveInput(2); // ...instead of old one. | 319 effect, graph()->start()); |
318 ReplaceWithStubCall(node, callable, flags); | 320 node->InsertInput(zone(), 0, global); |
319 | 321 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
320 } else { | 322 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
321 Callable callable = CodeFactory::LoadICInOptimizedCode( | 323 ReplaceWithStubCall(node, callable, flags); |
322 isolate(), p.typeof_mode(), SLOPPY, UNINITIALIZED); | |
323 node->RemoveInput(0); // script context | |
324 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | |
325 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | |
326 ReplaceWithStubCall(node, callable, flags); | |
327 } | |
328 } | 324 } |
329 | 325 |
330 | 326 |
331 void JSGenericLowering::LowerJSStoreProperty(Node* node) { | 327 void JSGenericLowering::LowerJSStoreProperty(Node* node) { |
332 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 328 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
333 const StorePropertyParameters& p = StorePropertyParametersOf(node->op()); | 329 const StorePropertyParameters& p = StorePropertyParametersOf(node->op()); |
334 LanguageMode language_mode = p.language_mode(); | 330 LanguageMode language_mode = p.language_mode(); |
335 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( | 331 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( |
336 isolate(), language_mode, UNINITIALIZED); | 332 isolate(), language_mode, UNINITIALIZED); |
337 if (FLAG_vector_stores) { | 333 if (FLAG_vector_stores) { |
(...skipping 18 matching lines...) Expand all Loading... |
356 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index())); | 352 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index())); |
357 } else { | 353 } else { |
358 node->RemoveInput(3); | 354 node->RemoveInput(3); |
359 } | 355 } |
360 ReplaceWithStubCall(node, callable, | 356 ReplaceWithStubCall(node, callable, |
361 CallDescriptor::kPatchableCallSite | flags); | 357 CallDescriptor::kPatchableCallSite | flags); |
362 } | 358 } |
363 | 359 |
364 | 360 |
365 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { | 361 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { |
| 362 Node* context = NodeProperties::GetContextInput(node); |
| 363 Node* effect = NodeProperties::GetEffectInput(node); |
366 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 364 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
367 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); | 365 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); |
368 if (p.slot_index() >= 0) { | 366 Callable callable = CodeFactory::StoreICInOptimizedCode( |
369 Callable callable = | 367 isolate(), p.language_mode(), UNINITIALIZED); |
370 CodeFactory::StoreGlobalViaContext(isolate(), 0, p.language_mode()); | 368 // Load global object from the context. |
371 Node* script_context = node->InputAt(0); | 369 Node* global = graph()->NewNode(machine()->Load(kMachAnyTagged), context, |
372 Node* value = node->InputAt(2); | 370 jsgraph()->IntPtrConstant(Context::SlotOffset( |
373 node->ReplaceInput(0, jsgraph()->Int32Constant(p.slot_index())); | 371 Context::GLOBAL_OBJECT_INDEX)), |
374 node->ReplaceInput(1, value); | 372 effect, graph()->start()); |
375 node->ReplaceInput(2, script_context); // Set new context... | 373 node->InsertInput(zone(), 0, global); |
| 374 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
| 375 if (FLAG_vector_stores) { |
| 376 DCHECK(p.feedback().index() != -1); |
| 377 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index())); |
| 378 } else { |
376 node->RemoveInput(3); | 379 node->RemoveInput(3); |
377 node->RemoveInput(3); // ...instead of old one. | |
378 ReplaceWithStubCall(node, callable, flags); | |
379 | |
380 } else { | |
381 Callable callable = CodeFactory::StoreICInOptimizedCode( | |
382 isolate(), p.language_mode(), UNINITIALIZED); | |
383 node->RemoveInput(0); // script context | |
384 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | |
385 if (FLAG_vector_stores) { | |
386 DCHECK(p.feedback().index() != -1); | |
387 node->InsertInput(zone(), 3, | |
388 jsgraph()->SmiConstant(p.feedback().index())); | |
389 } else { | |
390 node->RemoveInput(3); | |
391 } | |
392 ReplaceWithStubCall(node, callable, | |
393 CallDescriptor::kPatchableCallSite | flags); | |
394 } | 380 } |
| 381 ReplaceWithStubCall(node, callable, |
| 382 CallDescriptor::kPatchableCallSite | flags); |
395 } | 383 } |
396 | 384 |
397 | 385 |
398 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { | 386 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { |
399 LanguageMode language_mode = OpParameter<LanguageMode>(node); | 387 LanguageMode language_mode = OpParameter<LanguageMode>(node); |
400 ReplaceWithRuntimeCall(node, is_strict(language_mode) | 388 ReplaceWithRuntimeCall(node, is_strict(language_mode) |
401 ? Runtime::kDeleteProperty_Strict | 389 ? Runtime::kDeleteProperty_Strict |
402 : Runtime::kDeleteProperty_Sloppy); | 390 : Runtime::kDeleteProperty_Sloppy); |
403 } | 391 } |
404 | 392 |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 } | 838 } |
851 | 839 |
852 | 840 |
853 MachineOperatorBuilder* JSGenericLowering::machine() const { | 841 MachineOperatorBuilder* JSGenericLowering::machine() const { |
854 return jsgraph()->machine(); | 842 return jsgraph()->machine(); |
855 } | 843 } |
856 | 844 |
857 } // namespace compiler | 845 } // namespace compiler |
858 } // namespace internal | 846 } // namespace internal |
859 } // namespace v8 | 847 } // namespace v8 |
OLD | NEW |