| 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 502 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 513 | 513 | 
| 514 | 514 | 
| 515 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 515 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { | 
| 516   Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 516   Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 
| 517   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 517   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); | 
| 518   ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 518   ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); | 
| 519 } | 519 } | 
| 520 | 520 | 
| 521 | 521 | 
| 522 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 522 void JSGenericLowering::LowerJSCallConstruct(Node* node) { | 
|  | 523   // TODO(bmeurer): Use the Construct builtin here. | 
| 523   int arity = OpParameter<int>(node); | 524   int arity = OpParameter<int>(node); | 
| 524   CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 525   CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); | 
| 525   CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 526   CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); | 
| 526   CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 527   CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 
| 527   CallDescriptor* desc = | 528   CallDescriptor* desc = | 
| 528       Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); | 529       Linkage::GetStubCallDescriptor(isolate(), zone(), d, arity - 1, flags); | 
| 529   Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 530   Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 
| 530   Node* actual_construct = NodeProperties::GetValueInput(node, 0); | 531   Node* actual_construct = NodeProperties::GetValueInput(node, 0); | 
| 531   Node* original_construct = NodeProperties::GetValueInput(node, arity - 1); | 532   Node* original_construct = NodeProperties::GetValueInput(node, arity - 1); | 
| 532   node->RemoveInput(arity - 1);  // Drop original constructor. | 533   node->RemoveInput(arity - 1);  // Drop original constructor. | 
| 533   node->InsertInput(zone(), 0, stub_code); | 534   node->InsertInput(zone(), 0, stub_code); | 
| 534   node->InsertInput(zone(), 1, jsgraph()->Int32Constant(arity - 2)); | 535   node->InsertInput(zone(), 1, jsgraph()->Int32Constant(arity - 2)); | 
| 535   node->InsertInput(zone(), 2, actual_construct); | 536   node->InsertInput(zone(), 2, actual_construct); | 
| 536   node->InsertInput(zone(), 3, original_construct); | 537   node->InsertInput(zone(), 3, original_construct); | 
| 537   node->InsertInput(zone(), 4, jsgraph()->UndefinedConstant()); | 538   node->InsertInput(zone(), 4, jsgraph()->UndefinedConstant()); | 
| 538   NodeProperties::ChangeOp(node, common()->Call(desc)); | 539   NodeProperties::ChangeOp(node, common()->Call(desc)); | 
| 539 } | 540 } | 
| 540 | 541 | 
| 541 | 542 | 
| 542 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 543 void JSGenericLowering::LowerJSCallFunction(Node* node) { | 
| 543   const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); | 544   CallFunctionParameters const& p = CallFunctionParametersOf(node->op()); | 
| 544   int arg_count = static_cast<int>(p.arity() - 2); | 545   int const arg_count = static_cast<int>(p.arity() - 2); | 
| 545   CallFunctionStub stub(isolate(), arg_count, p.flags()); | 546   Callable callable = CodeFactory::Call(isolate()); | 
| 546   CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); |  | 
| 547   CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 547   CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 
| 548   if (p.AllowTailCalls()) { | 548   if (p.tail_call_mode() == TailCallMode::kAllow) { | 
| 549     flags |= CallDescriptor::kSupportsTailCalls; | 549     flags |= CallDescriptor::kSupportsTailCalls; | 
| 550   } | 550   } | 
| 551   CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 551   CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 
| 552       isolate(), zone(), d, static_cast<int>(p.arity() - 1), flags); | 552       isolate(), zone(), callable.descriptor(), arg_count + 1, flags); | 
| 553   Node* stub_code = jsgraph()->HeapConstant(stub.GetCode()); | 553   Node* stub_code = jsgraph()->HeapConstant(callable.code()); | 
|  | 554   Node* stub_arity = jsgraph()->Int32Constant(arg_count); | 
| 554   node->InsertInput(zone(), 0, stub_code); | 555   node->InsertInput(zone(), 0, stub_code); | 
|  | 556   node->InsertInput(zone(), 2, stub_arity); | 
| 555   NodeProperties::ChangeOp(node, common()->Call(desc)); | 557   NodeProperties::ChangeOp(node, common()->Call(desc)); | 
| 556 } | 558 } | 
| 557 | 559 | 
| 558 | 560 | 
| 559 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 561 void JSGenericLowering::LowerJSCallRuntime(Node* node) { | 
| 560   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 562   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); | 
| 561   AdjustFrameStatesForCall(node); | 563   AdjustFrameStatesForCall(node); | 
| 562   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 564   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); | 
| 563 } | 565 } | 
| 564 | 566 | 
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 829 } | 831 } | 
| 830 | 832 | 
| 831 | 833 | 
| 832 MachineOperatorBuilder* JSGenericLowering::machine() const { | 834 MachineOperatorBuilder* JSGenericLowering::machine() const { | 
| 833   return jsgraph()->machine(); | 835   return jsgraph()->machine(); | 
| 834 } | 836 } | 
| 835 | 837 | 
| 836 }  // namespace compiler | 838 }  // namespace compiler | 
| 837 }  // namespace internal | 839 }  // namespace internal | 
| 838 }  // namespace v8 | 840 }  // namespace v8 | 
| OLD | NEW | 
|---|