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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 graph()->start())); | 422 graph()->start())); |
423 } | 423 } |
424 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); | 424 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); |
425 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( | 425 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset( |
426 static_cast<int>(access.index())))); | 426 static_cast<int>(access.index())))); |
427 NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation( | 427 NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation( |
428 kMachAnyTagged, kFullWriteBarrier))); | 428 kMachAnyTagged, kFullWriteBarrier))); |
429 } | 429 } |
430 | 430 |
431 | 431 |
| 432 void JSGenericLowering::LowerJSLoadNativeContext(Node* node) { |
| 433 node->ReplaceInput( |
| 434 1, jsgraph()->IntPtrConstant(JSGlobalObject::kNativeContextOffset - |
| 435 kHeapObjectTag)); |
| 436 node->AppendInput(zone(), graph()->start()); |
| 437 NodeProperties::ChangeOp(node, machine()->Load(kMachAnyTagged)); |
| 438 } |
| 439 |
| 440 |
432 void JSGenericLowering::LowerJSLoadDynamic(Node* node) { | 441 void JSGenericLowering::LowerJSLoadDynamic(Node* node) { |
433 const DynamicAccess& access = DynamicAccessOf(node->op()); | 442 const DynamicAccess& access = DynamicAccessOf(node->op()); |
434 Runtime::FunctionId function_id = | 443 Runtime::FunctionId function_id = |
435 (access.typeof_mode() == NOT_INSIDE_TYPEOF) | 444 (access.typeof_mode() == NOT_INSIDE_TYPEOF) |
436 ? Runtime::kLoadLookupSlot | 445 ? Runtime::kLoadLookupSlot |
437 : Runtime::kLoadLookupSlotNoReferenceError; | 446 : Runtime::kLoadLookupSlotNoReferenceError; |
438 Node* projection = graph()->NewNode(common()->Projection(0), node); | 447 Node* projection = graph()->NewNode(common()->Projection(0), node); |
439 NodeProperties::ReplaceUses(node, projection, node, node, node); | 448 NodeProperties::ReplaceUses(node, projection, node, node, node); |
440 node->RemoveInput(NodeProperties::FirstValueIndex(node)); | 449 node->RemoveInput(NodeProperties::FirstValueIndex(node)); |
441 node->InsertInput(zone(), 1, jsgraph()->Constant(access.name())); | 450 node->InsertInput(zone(), 1, jsgraph()->Constant(access.name())); |
(...skipping 16 matching lines...) Expand all Loading... |
458 case CreateArgumentsParameters::kUnmappedArguments: | 467 case CreateArgumentsParameters::kUnmappedArguments: |
459 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments_Generic); | 468 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments_Generic); |
460 break; | 469 break; |
461 case CreateArgumentsParameters::kRestArray: | 470 case CreateArgumentsParameters::kRestArray: |
462 UNIMPLEMENTED(); | 471 UNIMPLEMENTED(); |
463 break; | 472 break; |
464 } | 473 } |
465 } | 474 } |
466 | 475 |
467 | 476 |
| 477 void JSGenericLowering::LowerJSCreateArray(Node* node) { |
| 478 CreateArrayParameters const& p = CreateArrayParametersOf(node->op()); |
| 479 int const arity = static_cast<int>(p.arity()); |
| 480 Node* new_target = node->InputAt(1); |
| 481 // TODO(turbofan): We embed the AllocationSite from the Operator at this |
| 482 // point, which we should not do once we want to both consume the feedback |
| 483 // but at the same time shared the optimized code across native contexts, |
| 484 // as the AllocationSite is associated with a single native context (it's |
| 485 // stored in the type feedback vector after all). Once we go for cross |
| 486 // context code generation, we should somehow find a way to get to the |
| 487 // allocation site for the actual native context at runtime. |
| 488 Node* type_info = p.site().is_null() ? jsgraph()->UndefinedConstant() |
| 489 : jsgraph()->HeapConstant(p.site()); |
| 490 node->RemoveInput(1); |
| 491 node->InsertInput(zone(), 1 + arity, new_target); |
| 492 node->InsertInput(zone(), 2 + arity, type_info); |
| 493 ReplaceWithRuntimeCall(node, Runtime::kNewArray, arity + 3); |
| 494 } |
| 495 |
| 496 |
468 void JSGenericLowering::LowerJSCreateClosure(Node* node) { | 497 void JSGenericLowering::LowerJSCreateClosure(Node* node) { |
469 CreateClosureParameters p = CreateClosureParametersOf(node->op()); | 498 CreateClosureParameters p = CreateClosureParametersOf(node->op()); |
470 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.shared_info())); | 499 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.shared_info())); |
471 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED) | 500 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED) |
472 ? Runtime::kNewClosure_Tenured | 501 ? Runtime::kNewClosure_Tenured |
473 : Runtime::kNewClosure); | 502 : Runtime::kNewClosure); |
474 } | 503 } |
475 | 504 |
476 | 505 |
477 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { | 506 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { |
(...skipping 25 matching lines...) Expand all Loading... |
503 | 532 |
504 | 533 |
505 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 534 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
506 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 535 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
507 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 536 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
508 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 537 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); |
509 } | 538 } |
510 | 539 |
511 | 540 |
512 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 541 void JSGenericLowering::LowerJSCallConstruct(Node* node) { |
| 542 CallConstructParameters const& p = CallConstructParametersOf(node->op()); |
| 543 int const arity = static_cast<int>(p.arity()); |
513 // TODO(bmeurer): Use the Construct builtin here. | 544 // TODO(bmeurer): Use the Construct builtin here. |
514 int arity = OpParameter<int>(node); | |
515 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 545 CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); |
516 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 546 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |
517 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 547 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
518 CallDescriptor* desc = | 548 CallDescriptor* desc = |
519 Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); | 549 Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); |
520 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 550 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); |
521 Node* target = NodeProperties::GetValueInput(node, 0); | 551 Node* target = NodeProperties::GetValueInput(node, 0); |
522 Node* new_target = NodeProperties::GetValueInput(node, arity - 1); | 552 Node* new_target = NodeProperties::GetValueInput(node, arity - 1); |
523 node->RemoveInput(arity - 1); // Drop new target. | 553 node->RemoveInput(arity - 1); // Drop new target. |
524 node->InsertInput(zone(), 0, stub_code); | 554 node->InsertInput(zone(), 0, stub_code); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 873 } |
844 | 874 |
845 | 875 |
846 MachineOperatorBuilder* JSGenericLowering::machine() const { | 876 MachineOperatorBuilder* JSGenericLowering::machine() const { |
847 return jsgraph()->machine(); | 877 return jsgraph()->machine(); |
848 } | 878 } |
849 | 879 |
850 } // namespace compiler | 880 } // namespace compiler |
851 } // namespace internal | 881 } // namespace internal |
852 } // namespace v8 | 882 } // namespace v8 |
OLD | NEW |