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/compiler/js-generic-lowering.h" | 5 #include "src/compiler/js-generic-lowering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/builtins/builtins-constructor.h" | 8 #include "src/builtins/builtins-constructor.h" |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); | 483 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); |
484 } | 484 } |
485 | 485 |
486 | 486 |
487 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 487 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { |
488 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 488 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
489 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 489 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); |
490 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 490 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); |
491 } | 491 } |
492 | 492 |
493 | 493 void JSGenericLowering::LowerJSConstruct(Node* node) { |
494 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 494 ConstructParameters const& p = ConstructParametersOf(node->op()); |
495 CallConstructParameters const& p = CallConstructParametersOf(node->op()); | |
496 int const arg_count = static_cast<int>(p.arity() - 2); | 495 int const arg_count = static_cast<int>(p.arity() - 2); |
497 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 496 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
498 Callable callable = CodeFactory::Construct(isolate()); | 497 Callable callable = CodeFactory::Construct(isolate()); |
499 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 498 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
500 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 499 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
501 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 500 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
502 Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 501 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
503 Node* new_target = node->InputAt(arg_count + 1); | 502 Node* new_target = node->InputAt(arg_count + 1); |
504 Node* receiver = jsgraph()->UndefinedConstant(); | 503 Node* receiver = jsgraph()->UndefinedConstant(); |
505 node->RemoveInput(arg_count + 1); // Drop new target. | 504 node->RemoveInput(arg_count + 1); // Drop new target. |
506 node->InsertInput(zone(), 0, stub_code); | 505 node->InsertInput(zone(), 0, stub_code); |
507 node->InsertInput(zone(), 2, new_target); | 506 node->InsertInput(zone(), 2, new_target); |
508 node->InsertInput(zone(), 3, stub_arity); | 507 node->InsertInput(zone(), 3, stub_arity); |
509 node->InsertInput(zone(), 4, receiver); | 508 node->InsertInput(zone(), 4, receiver); |
510 NodeProperties::ChangeOp(node, common()->Call(desc)); | 509 NodeProperties::ChangeOp(node, common()->Call(desc)); |
511 } | 510 } |
512 | 511 |
513 void JSGenericLowering::LowerJSCallConstructWithSpread(Node* node) { | 512 void JSGenericLowering::LowerJSConstructWithSpread(Node* node) { |
514 CallConstructWithSpreadParameters const& p = | 513 ConstructWithSpreadParameters const& p = |
515 CallConstructWithSpreadParametersOf(node->op()); | 514 ConstructWithSpreadParametersOf(node->op()); |
516 int const arg_count = static_cast<int>(p.arity() - 2); | 515 int const arg_count = static_cast<int>(p.arity() - 2); |
517 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 516 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
518 Callable callable = CodeFactory::ConstructWithSpread(isolate()); | 517 Callable callable = CodeFactory::ConstructWithSpread(isolate()); |
519 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 518 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
520 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 519 isolate(), zone(), callable.descriptor(), arg_count + 1, flags); |
521 Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 520 Node* stub_code = jsgraph()->HeapConstant(callable.code()); |
522 Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 521 Node* stub_arity = jsgraph()->Int32Constant(arg_count); |
523 Node* new_target = node->InputAt(arg_count + 1); | 522 Node* new_target = node->InputAt(arg_count + 1); |
524 Node* receiver = jsgraph()->UndefinedConstant(); | 523 Node* receiver = jsgraph()->UndefinedConstant(); |
525 node->RemoveInput(arg_count + 1); // Drop new target. | 524 node->RemoveInput(arg_count + 1); // Drop new target. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 687 } |
689 | 688 |
690 | 689 |
691 MachineOperatorBuilder* JSGenericLowering::machine() const { | 690 MachineOperatorBuilder* JSGenericLowering::machine() const { |
692 return jsgraph()->machine(); | 691 return jsgraph()->machine(); |
693 } | 692 } |
694 | 693 |
695 } // namespace compiler | 694 } // namespace compiler |
696 } // namespace internal | 695 } // namespace internal |
697 } // namespace v8 | 696 } // namespace v8 |
OLD | NEW |