[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}
This commit is contained in:
rmcilroy 2015-07-13 01:27:40 -07:00 committed by Commit bot
parent 2027335f1c
commit a0129a25ba
17 changed files with 85 additions and 4 deletions

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -245,7 +245,10 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle<HeapObject> object,
bool CodeGenerator::IsMaterializableFromRoot(
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());
int root_index = map.Lookup(*object);
if (root_index != RootIndexMap::kInvalidRootIndex) {

View File

@ -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:

View File

@ -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

View File

@ -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());

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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.

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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