Commit a0129a25 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[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}
parent 2027335f
...@@ -1190,6 +1190,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -1190,6 +1190,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -69,6 +69,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -69,6 +69,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -1492,6 +1492,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -1492,6 +1492,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -71,6 +71,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -71,6 +71,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -245,7 +245,10 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle<HeapObject> object, ...@@ -245,7 +245,10 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle<HeapObject> object,
bool CodeGenerator::IsMaterializableFromRoot( bool CodeGenerator::IsMaterializableFromRoot(
Handle<HeapObject> object, Heap::RootListIndex* index_return) { Handle<HeapObject> 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()); RootIndexMap map(isolate());
int root_index = map.Lookup(*object); int root_index = map.Lookup(*object);
if (root_index != RootIndexMap::kInvalidRootIndex) { if (root_index != RootIndexMap::kInvalidRootIndex) {
......
...@@ -921,6 +921,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -921,6 +921,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -60,6 +60,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -60,6 +60,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -345,6 +345,9 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, ...@@ -345,6 +345,9 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer,
g.UseLocation(callee, buffer->descriptor->GetInputLocation(0), g.UseLocation(callee, buffer->descriptor->GetInputLocation(0),
buffer->descriptor->GetInputType(0))); buffer->descriptor->GetInputType(0)));
break; break;
case CallDescriptor::kInterpreterDispatch:
buffer->instruction_args.push_back(g.UseRegister(callee));
break;
} }
DCHECK_EQ(1u, buffer->instruction_args.size()); DCHECK_EQ(1u, buffer->instruction_args.size());
......
...@@ -233,6 +233,27 @@ class LinkageHelper { ...@@ -233,6 +233,27 @@ class LinkageHelper {
"c-call"); "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) { static LinkageLocation regloc(Register reg) {
return LinkageLocation(Register::ToAllocationIndex(reg)); return LinkageLocation(Register::ToAllocationIndex(reg));
} }
......
...@@ -26,6 +26,9 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) { ...@@ -26,6 +26,9 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k) {
case CallDescriptor::kCallAddress: case CallDescriptor::kCallAddress:
os << "Addr"; os << "Addr";
break; break;
case CallDescriptor::kInterpreterDispatch:
os << "InterpreterDispatch";
break;
} }
return os; return os;
} }
......
...@@ -63,9 +63,10 @@ class CallDescriptor final : public ZoneObject { ...@@ -63,9 +63,10 @@ class CallDescriptor final : public ZoneObject {
public: public:
// Describes the kind of this call, which determines the target. // Describes the kind of this call, which determines the target.
enum Kind { enum Kind {
kCallCodeObject, // target is a Code object kCallCodeObject, // target is a Code object
kCallJSFunction, // target is a JSFunction object kCallJSFunction, // target is a JSFunction object
kCallAddress // target is a machine pointer kCallAddress, // target is a machine pointer
kInterpreterDispatch // target is an interpreter bytecode handler
}; };
enum Flag { enum Flag {
...@@ -111,6 +112,8 @@ class CallDescriptor final : public ZoneObject { ...@@ -111,6 +112,8 @@ class CallDescriptor final : public ZoneObject {
// Returns {true} if this descriptor is a call to a JSFunction. // Returns {true} if this descriptor is a call to a JSFunction.
bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; } bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; }
bool IsInterpreterDispatch() const { return kind_ == kInterpreterDispatch; }
// The number of return values from this call. // The number of return values from this call.
size_t ReturnCount() const { return machine_sig_->return_count(); } size_t ReturnCount() const { return machine_sig_->return_count(); }
...@@ -235,6 +238,12 @@ class Linkage : public ZoneObject { ...@@ -235,6 +238,12 @@ class Linkage : public ZoneObject {
static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone,
const MachineSignature* sig); 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. // Get the location of an (incoming) parameter to this function.
LinkageLocation GetParameterLocation(int index) const { LinkageLocation GetParameterLocation(int index) const {
return incoming_->GetInputLocation(index + 1); // + 1 to skip target. return incoming_->GetInputLocation(index + 1); // + 1 to skip target.
......
...@@ -610,6 +610,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -610,6 +610,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -759,6 +759,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -759,6 +759,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -68,6 +68,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -1129,6 +1129,7 @@ void InstructionSelector::VisitTailCall(Node* node) { ...@@ -1129,6 +1129,7 @@ void InstructionSelector::VisitTailCall(Node* node) {
InstructionCode opcode; InstructionCode opcode;
switch (descriptor->kind()) { switch (descriptor->kind()) {
case CallDescriptor::kCallCodeObject: case CallDescriptor::kCallCodeObject:
case CallDescriptor::kInterpreterDispatch:
opcode = kArchTailCallCodeObject; opcode = kArchTailCallCodeObject;
break; break;
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
......
...@@ -88,6 +88,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, ...@@ -88,6 +88,12 @@ CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone,
return LH::GetSimplifiedCDescriptor(zone, sig); return LH::GetSimplifiedCDescriptor(zone, sig);
} }
CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(
Zone* zone, const MachineSignature* sig) {
return LH::GetInterpreterDispatchDescriptor(zone, sig);
}
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment