OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-call-reducer.h" | 5 #include "src/compiler/js-call-reducer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 // TODO(turbofan): Consider introducing a JSCallApiCallback operator for | 659 // TODO(turbofan): Consider introducing a JSCallApiCallback operator for |
660 // this and lower it during JSGenericLowering, and unify this with the | 660 // this and lower it during JSGenericLowering, and unify this with the |
661 // JSNativeContextSpecialization::InlineApiCall method a bit. | 661 // JSNativeContextSpecialization::InlineApiCall method a bit. |
662 Handle<CallHandlerInfo> call_handler_info( | 662 Handle<CallHandlerInfo> call_handler_info( |
663 CallHandlerInfo::cast(function_template_info->call_code()), isolate()); | 663 CallHandlerInfo::cast(function_template_info->call_code()), isolate()); |
664 Handle<Object> data(call_handler_info->data(), isolate()); | 664 Handle<Object> data(call_handler_info->data(), isolate()); |
665 CallApiCallbackStub stub(isolate(), argc, false); | 665 CallApiCallbackStub stub(isolate(), argc, false); |
666 CallInterfaceDescriptor cid = stub.GetCallInterfaceDescriptor(); | 666 CallInterfaceDescriptor cid = stub.GetCallInterfaceDescriptor(); |
667 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( | 667 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( |
668 isolate(), graph()->zone(), cid, | 668 isolate(), graph()->zone(), cid, |
669 cid.GetStackParameterCount() + argc + | 669 cid.GetStackParameterCount() + argc + 1 /* implicit receiver */, |
670 2 /* implicit receiver + accessor_holder */, | |
671 CallDescriptor::kNeedsFrameState, Operator::kNoProperties, | 670 CallDescriptor::kNeedsFrameState, Operator::kNoProperties, |
672 MachineType::AnyTagged(), 1); | 671 MachineType::AnyTagged(), 1); |
673 ApiFunction api_function(v8::ToCData<Address>(call_handler_info->callback())); | 672 ApiFunction api_function(v8::ToCData<Address>(call_handler_info->callback())); |
674 Node* holder = lookup == CallOptimization::kHolderFound | 673 Node* holder = lookup == CallOptimization::kHolderFound |
675 ? jsgraph()->HeapConstant(api_holder) | 674 ? jsgraph()->HeapConstant(api_holder) |
676 : receiver; | 675 : receiver; |
677 ExternalReference function_reference( | 676 ExternalReference function_reference( |
678 &api_function, ExternalReference::DIRECT_API_CALL, isolate()); | 677 &api_function, ExternalReference::DIRECT_API_CALL, isolate()); |
679 node->InsertInput(graph()->zone(), 0, | 678 node->InsertInput(graph()->zone(), 0, |
680 jsgraph()->HeapConstant(stub.GetCode())); | 679 jsgraph()->HeapConstant(stub.GetCode())); |
681 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(data)); | 680 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(data)); |
682 node->InsertInput(graph()->zone(), 3, holder); | 681 node->InsertInput(graph()->zone(), 3, holder); |
683 node->InsertInput(graph()->zone(), 4, | 682 node->InsertInput(graph()->zone(), 4, |
684 jsgraph()->ExternalConstant(function_reference)); | 683 jsgraph()->ExternalConstant(function_reference)); |
685 node->InsertInput(graph()->zone(), 5, holder /* as accessor_holder */); | 684 node->ReplaceInput(5, receiver); |
686 node->ReplaceInput(6, receiver); | |
687 NodeProperties::ChangeOp(node, common()->Call(call_descriptor)); | 685 NodeProperties::ChangeOp(node, common()->Call(call_descriptor)); |
688 return Changed(node); | 686 return Changed(node); |
689 } | 687 } |
690 | 688 |
691 Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread( | 689 Reduction JSCallReducer::ReduceCallOrConstructWithArrayLikeOrSpread( |
692 Node* node, int arity, CallFrequency const& frequency) { | 690 Node* node, int arity, CallFrequency const& frequency) { |
693 DCHECK(node->opcode() == IrOpcode::kJSCallWithArrayLike || | 691 DCHECK(node->opcode() == IrOpcode::kJSCallWithArrayLike || |
694 node->opcode() == IrOpcode::kJSCallWithSpread || | 692 node->opcode() == IrOpcode::kJSCallWithSpread || |
695 node->opcode() == IrOpcode::kJSConstructWithArrayLike || | 693 node->opcode() == IrOpcode::kJSConstructWithArrayLike || |
696 node->opcode() == IrOpcode::kJSConstructWithSpread); | 694 node->opcode() == IrOpcode::kJSConstructWithSpread); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 return jsgraph()->javascript(); | 1186 return jsgraph()->javascript(); |
1189 } | 1187 } |
1190 | 1188 |
1191 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { | 1189 SimplifiedOperatorBuilder* JSCallReducer::simplified() const { |
1192 return jsgraph()->simplified(); | 1190 return jsgraph()->simplified(); |
1193 } | 1191 } |
1194 | 1192 |
1195 } // namespace compiler | 1193 } // namespace compiler |
1196 } // namespace internal | 1194 } // namespace internal |
1197 } // namespace v8 | 1195 } // namespace v8 |
OLD | NEW |