From a0129a25ba2f4d00138887cb2008d5b76e2b0068 Mon Sep 17 00:00:00 2001 From: rmcilroy Date: Mon, 13 Jul 2015 01:27:40 -0700 Subject: [PATCH] [turbofan] Add an InterpreterDispatch linkage type. BUG=v8:4280 LOG=N Review URL: https://codereview.chromium.org/1234443004 Cr-Commit-Position: refs/heads/master@{#29591} --- src/compiler/arm/instruction-selector-arm.cc | 1 + src/compiler/arm/linkage-arm.cc | 6 ++++++ src/compiler/arm64/instruction-selector-arm64.cc | 1 + src/compiler/arm64/linkage-arm64.cc | 6 ++++++ src/compiler/code-generator.cc | 5 ++++- src/compiler/ia32/instruction-selector-ia32.cc | 1 + src/compiler/ia32/linkage-ia32.cc | 6 ++++++ src/compiler/instruction-selector.cc | 3 +++ src/compiler/linkage-impl.h | 21 +++++++++++++++++++++ src/compiler/linkage.cc | 3 +++ src/compiler/linkage.h | 15 ++++++++++++--- src/compiler/mips/instruction-selector-mips.cc | 1 + src/compiler/mips/linkage-mips.cc | 6 ++++++ src/compiler/mips64/instruction-selector-mips64.cc | 1 + src/compiler/mips64/linkage-mips64.cc | 6 ++++++ src/compiler/x64/instruction-selector-x64.cc | 1 + src/compiler/x64/linkage-x64.cc | 6 ++++++ 17 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/compiler/arm/instruction-selector-arm.cc b/src/compiler/arm/instruction-selector-arm.cc index 8855388..6c1baa2 100644 --- a/src/compiler/arm/instruction-selector-arm.cc +++ b/src/compiler/arm/instruction-selector-arm.cc @@ -1190,6 +1190,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/arm/linkage-arm.cc b/src/compiler/arm/linkage-arm.cc index a923f1b..93cc773 100644 --- a/src/compiler/arm/linkage-arm.cc +++ b/src/compiler/arm/linkage-arm.cc @@ -69,6 +69,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/arm64/instruction-selector-arm64.cc b/src/compiler/arm64/instruction-selector-arm64.cc index ca0ec4e..03dfd73 100644 --- a/src/compiler/arm64/instruction-selector-arm64.cc +++ b/src/compiler/arm64/instruction-selector-arm64.cc @@ -1492,6 +1492,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/arm64/linkage-arm64.cc b/src/compiler/arm64/linkage-arm64.cc index afedefb..141d62a 100644 --- a/src/compiler/arm64/linkage-arm64.cc +++ b/src/compiler/arm64/linkage-arm64.cc @@ -71,6 +71,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc index 2903c3d..a705189 100644 --- a/src/compiler/code-generator.cc +++ b/src/compiler/code-generator.cc @@ -245,7 +245,10 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle object, bool CodeGenerator::IsMaterializableFromRoot( Handle object, Heap::RootListIndex* index_return) { - if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { + const CallDescriptor* incoming_descriptor = + linkage()->GetIncomingDescriptor(); + if (incoming_descriptor->IsJSFunctionCall() || + incoming_descriptor->IsInterpreterDispatch()) { RootIndexMap map(isolate()); int root_index = map.Lookup(*object); if (root_index != RootIndexMap::kInvalidRootIndex) { diff --git a/src/compiler/ia32/instruction-selector-ia32.cc b/src/compiler/ia32/instruction-selector-ia32.cc index 105ca82..460384c 100644 --- a/src/compiler/ia32/instruction-selector-ia32.cc +++ b/src/compiler/ia32/instruction-selector-ia32.cc @@ -921,6 +921,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/ia32/linkage-ia32.cc b/src/compiler/ia32/linkage-ia32.cc index 930a86c..7ea80b2 100644 --- a/src/compiler/ia32/linkage-ia32.cc +++ b/src/compiler/ia32/linkage-ia32.cc @@ -60,6 +60,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc index 813da4f..4981f64 100644 --- a/src/compiler/instruction-selector.cc +++ b/src/compiler/instruction-selector.cc @@ -345,6 +345,9 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, g.UseLocation(callee, buffer->descriptor->GetInputLocation(0), buffer->descriptor->GetInputType(0))); break; + case CallDescriptor::kInterpreterDispatch: + buffer->instruction_args.push_back(g.UseRegister(callee)); + break; } DCHECK_EQ(1u, buffer->instruction_args.size()); diff --git a/src/compiler/linkage-impl.h b/src/compiler/linkage-impl.h index 27b0235..5b63803 100644 --- a/src/compiler/linkage-impl.h +++ b/src/compiler/linkage-impl.h @@ -233,6 +233,27 @@ class LinkageHelper { "c-call"); } + static CallDescriptor* GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* msig) { + DCHECK_EQ(0, msig->parameter_count()); + LocationSignature::Builder locations(zone, msig->return_count(), + msig->parameter_count()); + AddReturnLocations(&locations); + LinkageLocation target_loc = LinkageLocation::AnyRegister(); + return new (zone) CallDescriptor( // -- + CallDescriptor::kInterpreterDispatch, // kind + kMachNone, // target MachineType + target_loc, // target location + msig, // machine_sig + locations.Build(), // location_sig + 0, // js_parameter_count + Operator::kNoProperties, // properties + kNoCalleeSaved, // callee-saved registers + kNoCalleeSaved, // callee-saved fp regs + CallDescriptor::kSupportsTailCalls, // flags + "interpreter-dispatch"); + } + static LinkageLocation regloc(Register reg) { return LinkageLocation(Register::ToAllocationIndex(reg)); } diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc index 6ef0142..0c43c2d 100644 --- a/src/compiler/linkage.cc +++ b/src/compiler/linkage.cc @@ -26,6 +26,9 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) { case CallDescriptor::kCallAddress: os << "Addr"; break; + case CallDescriptor::kInterpreterDispatch: + os << "InterpreterDispatch"; + break; } return os; } diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h index 31b9fac..45d15c9 100644 --- a/src/compiler/linkage.h +++ b/src/compiler/linkage.h @@ -63,9 +63,10 @@ class CallDescriptor final : public ZoneObject { public: // Describes the kind of this call, which determines the target. enum Kind { - kCallCodeObject, // target is a Code object - kCallJSFunction, // target is a JSFunction object - kCallAddress // target is a machine pointer + kCallCodeObject, // target is a Code object + kCallJSFunction, // target is a JSFunction object + kCallAddress, // target is a machine pointer + kInterpreterDispatch // target is an interpreter bytecode handler }; enum Flag { @@ -111,6 +112,8 @@ class CallDescriptor final : public ZoneObject { // Returns {true} if this descriptor is a call to a JSFunction. bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; } + bool IsInterpreterDispatch() const { return kind_ == kInterpreterDispatch; } + // The number of return values from this call. size_t ReturnCount() const { return machine_sig_->return_count(); } @@ -235,6 +238,12 @@ class Linkage : public ZoneObject { static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, const MachineSignature* sig); + // Creates a call descriptor for interpreter handler code stubs. These are not + // intended to be called directly but are instead dispatched to by the + // interpreter. + static CallDescriptor* GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig); + // Get the location of an (incoming) parameter to this function. LinkageLocation GetParameterLocation(int index) const { return incoming_->GetInputLocation(index + 1); // + 1 to skip target. diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips/instruction-selector-mips.cc index c2420ac..7c0876d 100644 --- a/src/compiler/mips/instruction-selector-mips.cc +++ b/src/compiler/mips/instruction-selector-mips.cc @@ -610,6 +610,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/mips/linkage-mips.cc b/src/compiler/mips/linkage-mips.cc index 7b03340..839657f 100644 --- a/src/compiler/mips/linkage-mips.cc +++ b/src/compiler/mips/linkage-mips.cc @@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/mips64/instruction-selector-mips64.cc b/src/compiler/mips64/instruction-selector-mips64.cc index e4d8795..e25e7d7 100644 --- a/src/compiler/mips64/instruction-selector-mips64.cc +++ b/src/compiler/mips64/instruction-selector-mips64.cc @@ -759,6 +759,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/mips64/linkage-mips64.cc b/src/compiler/mips64/linkage-mips64.cc index acfedb7..5c8c58c 100644 --- a/src/compiler/mips64/linkage-mips64.cc +++ b/src/compiler/mips64/linkage-mips64.cc @@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc index 6d7fca4..8a0615c 100644 --- a/src/compiler/x64/instruction-selector-x64.cc +++ b/src/compiler/x64/instruction-selector-x64.cc @@ -1129,6 +1129,7 @@ void InstructionSelector::VisitTailCall(Node* node) { InstructionCode opcode; switch (descriptor->kind()) { case CallDescriptor::kCallCodeObject: + case CallDescriptor::kInterpreterDispatch: opcode = kArchTailCallCodeObject; break; case CallDescriptor::kCallJSFunction: diff --git a/src/compiler/x64/linkage-x64.cc b/src/compiler/x64/linkage-x64.cc index b272eb6..8bfbce0 100644 --- a/src/compiler/x64/linkage-x64.cc +++ b/src/compiler/x64/linkage-x64.cc @@ -88,6 +88,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, return LH::GetSimplifiedCDescriptor(zone, sig); } + +CallDescriptor* Linkage::GetInterpreterDispatchDescriptor( + Zone* zone, const MachineSignature* sig) { + return LH::GetInterpreterDispatchDescriptor(zone, sig); +} + } // namespace compiler } // namespace internal } // namespace v8 -- 2.7.4