Commit f4eb08f4 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Make context register implicit for CallInterfaceDescriptors

Port 7015fd20

Original commit message:
    Up until now the context register was listed explicitly in each stub's
    CallInterfaceDescriptor. This was problematic, because it was listed
    first in the list of register parameters--which is fine for Crankshaft,
    which is more or less built to handle the context as the first
    parameter-- but not ideal for TurboFan, which adds the context at
    the end of all function parameters. Now the context register is no
    longer in the register list and can be handled appropriately by both
    compilers. Specifically, this allows the FunctionType specified for
    each CallInterfaceDescriptor to exactly match the parameter register
    list.

R=danno@chromium.org, dstence@us.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1218463004

Cr-Commit-Position: refs/heads/master@{#29421}
parent 1ab39b49
......@@ -108,15 +108,15 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm,
isolate()->counters()->code_stubs()->Increment();
CallInterfaceDescriptor descriptor = GetCallInterfaceDescriptor();
int param_count = descriptor.GetEnvironmentParameterCount();
int param_count = descriptor.GetRegisterParameterCount();
{
// Call the runtime system in a fresh internal frame.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
r3.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
r3.is(descriptor.GetRegisterParameter(param_count - 1)));
// Push arguments
for (int i = 0; i < param_count; ++i) {
__ push(descriptor.GetEnvironmentParameterRegister(i));
__ push(descriptor.GetRegisterParameter(i));
}
__ CallExternalReference(miss, param_count);
}
......
......@@ -64,91 +64,91 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return r6; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r5};
Register registers[] = {r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4};
Register registers[] = {r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3};
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3};
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6};
Register registers[] = {r6};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6, r5, r4};
Register registers[] = {r6, r5, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6, r5, r4, r3};
Register registers[] = {r6, r5, r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r5, r6};
Register registers[] = {r5, r6};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r5, r6, r4};
Register registers[] = {r5, r6, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6, r3};
Register registers[] = {r6, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4};
Register registers[] = {r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4, r6};
Register registers[] = {r4, r6};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4, r6, r5};
Register registers[] = {r4, r6, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -162,42 +162,38 @@ void CallConstructDescriptor::InitializePlatformSpecific(
// vector (Smi)
// TODO(turbofan): So far we don't gather type feedback and hence skip the
// slot parameter, but ArrayConstructStub needs the vector to be undefined.
Register registers[] = {cp, r3, r4, r5};
Register registers[] = {r3, r4, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r5, r4, r3};
Register registers[] = {r5, r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3, r4};
Register registers[] = {r3, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// cp -- context
Register registers[] = {cp};
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
data->InitializePlatformSpecific(0, nullptr, nullptr);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// cp -- context
// r3 -- number of arguments
// r4 -- function
// r5 -- allocation site with elements kind
Register registers[] = {cp, r4, r5};
Register registers[] = {r4, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -205,7 +201,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, r4, r5, r3};
Register registers[] = {r4, r5, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -213,10 +209,9 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// register state
// cp -- context
// r3 -- number of arguments
// r4 -- constructor function
Register registers[] = {cp, r4};
Register registers[] = {r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -224,49 +219,49 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, r4, r3};
Register registers[] = {r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4, r3};
Register registers[] = {r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3};
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3};
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4, r3};
Register registers[] = {r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r5, r4, r3};
Register registers[] = {r5, r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r4, r3};
Register registers[] = {r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -274,7 +269,6 @@ void StringAddDescriptor::InitializePlatformSpecific(
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r5, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
......@@ -284,7 +278,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r5, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
......@@ -294,7 +287,6 @@ void NamedDescriptor::InitializePlatformSpecific(
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r3, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers);
......@@ -304,7 +296,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r4, // JSFunction
r3, // actual number of arguments
r5, // expected number of arguments
......@@ -316,7 +307,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ApiFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r3, // callee
r7, // call_data
r5, // holder
......@@ -330,7 +320,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
void ApiAccessorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r3, // callee
r7, // call_data
r5, // holder
......@@ -343,7 +332,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r4, // math rounding function
r6, // vector slot id
};
......
......@@ -1098,10 +1098,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(HCallWithDescriptor* instr) {
LOperand* target = UseRegisterOrConstantAtStart(instr->target());
ZoneList<LOperand*> ops(instr->OperandCount(), zone());
// Target
ops.Add(target, zone());
for (int i = 1; i < instr->OperandCount(); i++) {
LOperand* op =
UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1));
// Context
LOperand* op = UseFixed(instr->OperandAt(1), cp);
ops.Add(op, zone());
// Other register parameters
for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount;
i < instr->OperandCount(); i++) {
op =
UseFixed(instr->OperandAt(i),
descriptor.GetRegisterParameter(
i - LCallWithDescriptor::kImplicitRegisterParameterCount));
ops.Add(op, zone());
}
......@@ -2451,7 +2459,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
CallInterfaceDescriptor descriptor =
info()->code_stub()->GetCallInterfaceDescriptor();
int index = static_cast<int>(instr->index());
Register reg = descriptor.GetEnvironmentParameterRegister(index);
Register reg = descriptor.GetRegisterParameter(index);
return DefineFixed(result, reg);
}
}
......
......@@ -1777,8 +1777,12 @@ class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
LCallWithDescriptor(CallInterfaceDescriptor descriptor,
const ZoneList<LOperand*>& operands, Zone* zone)
: descriptor_(descriptor),
inputs_(descriptor.GetRegisterParameterCount() + 1, zone) {
DCHECK(descriptor.GetRegisterParameterCount() + 1 == operands.length());
inputs_(descriptor.GetRegisterParameterCount() +
kImplicitRegisterParameterCount,
zone) {
DCHECK(descriptor.GetRegisterParameterCount() +
kImplicitRegisterParameterCount ==
operands.length());
inputs_.AddAll(operands, zone);
}
......@@ -1788,6 +1792,10 @@ class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
// The target and context are passed as implicit parameters that are not
// explicitly listed in the descriptor.
static const int kImplicitRegisterParameterCount = 2;
private:
DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
......
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