Make context register implicit for CallInterfaceDescriptors

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.

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

Cr-Commit-Position: refs/heads/master@{#29402}
This commit is contained in:
danno 2015-07-01 01:45:05 -07:00 committed by Commit bot
parent d82c163de4
commit 7015fd2053
33 changed files with 478 additions and 484 deletions

View File

@ -112,15 +112,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 ||
r0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
r0.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);
}

View File

@ -64,91 +64,91 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return r3; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r2};
Register registers[] = {r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1};
Register registers[] = {r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r0};
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r0};
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3};
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3, r2, r1};
Register registers[] = {r3, r2, r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3, r2, r1, r0};
Register registers[] = {r3, r2, r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r2, r3};
Register registers[] = {r2, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r2, r3, r1};
Register registers[] = {r2, r3, r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r3, r0};
Register registers[] = {r3, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1};
Register registers[] = {r1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1, r3};
Register registers[] = {r1, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1, r3, r2};
Register registers[] = {r1, r3, r2};
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, r0, r1, r2};
Register registers[] = {r0, r1, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r2, r1, r0};
Register registers[] = {r2, r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r0, r1};
Register registers[] = {r0, r1};
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
// r0 -- number of arguments
// r1 -- function
// r2 -- allocation site with elements kind
Register registers[] = {cp, r1, r2};
Register registers[] = {r1, r2};
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, r1, r2, r0};
Register registers[] = {r1, r2, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -213,10 +209,9 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// register state
// cp -- context
// r0 -- number of arguments
// r1 -- constructor function
Register registers[] = {cp, r1};
Register registers[] = {r1};
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, r1, r0};
Register registers[] = {r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1, r0};
Register registers[] = {r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r0};
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r0};
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1, r0};
Register registers[] = {r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r2, r1, r0};
Register registers[] = {r2, r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r1, r0};
Register registers[] = {r1, r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -277,7 +272,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r2, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -291,7 +285,6 @@ void NamedDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r2, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -305,7 +298,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r0, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -319,7 +311,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r1, // JSFunction
r0, // actual number of arguments
r2, // expected number of arguments
@ -335,7 +326,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r0, // callee
r4, // call_data
r2, // holder
@ -353,7 +343,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
r0, // callee
r4, // call_data
r2, // holder
@ -367,7 +356,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
r1, // math rounding function
r3, // vector slot id
};

View File

@ -1092,10 +1092,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
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());
}
@ -2501,7 +2509,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);
}
}

View File

@ -1847,8 +1847,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);
}
@ -1858,6 +1862,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")

View File

@ -102,17 +102,17 @@ 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.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK((param_count == 0) ||
x0.Is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
x0.Is(descriptor.GetRegisterParameter(param_count - 1)));
// Push arguments
MacroAssembler::PushPopQueue queue(masm);
for (int i = 0; i < param_count; ++i) {
queue.Queue(descriptor.GetEnvironmentParameterRegister(i));
queue.Queue(descriptor.GetRegisterParameter(i));
}
queue.PushQueued();

View File

@ -70,94 +70,86 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return x3; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x2: function info
Register registers[] = {cp, x2};
Register registers[] = {x2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x1: function
Register registers[] = {cp, x1};
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x0: value
Register registers[] = {cp, x0};
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x0: value
Register registers[] = {cp, x0};
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, x3};
Register registers[] = {x3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x3: array literals array
// x2: array literal index
// x1: constant elements
Register registers[] = {cp, x3, x2, x1};
Register registers[] = {x3, x2, x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x3: object literals array
// x2: object literal index
// x1: constant properties
// x0: object literal flags
Register registers[] = {cp, x3, x2, x1, x0};
Register registers[] = {x3, x2, x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x2: feedback vector
// x3: call feedback slot
Register registers[] = {cp, x2, x3};
Register registers[] = {x2, x3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x2: feedback vector
// x3: call feedback slot
// x1: tagged value to put in the weak cell
Register registers[] = {cp, x2, x3, x1};
Register registers[] = {x2, x3, x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, x3, x0};
Register registers[] = {x3, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -165,21 +157,21 @@ void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1 function the function to call
Register registers[] = {cp, x1};
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, x1, x3};
Register registers[] = {x1, x3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, x1, x3, x2};
Register registers[] = {x1, x3, x2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -192,47 +184,42 @@ void CallConstructDescriptor::InitializePlatformSpecific(
// x3 : slot in feedback vector (smi) (if r2 is not the megamorphic symbol)
// 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, x0, x1, x2};
Register registers[] = {x0, x1, x2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x2: length
// x1: index (of last match)
// x0: string
Register registers[] = {cp, x2, x1, x0};
Register registers[] = {x2, x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x0: value (js_array)
// x1: to_map
Register registers[] = {cp, x0, x1};
Register registers[] = {x0, x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
Register registers[] = {cp};
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
data->InitializePlatformSpecific(0, nullptr, nullptr);
}
void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x1: function
// x2: allocation site with elements kind
// x0: number of arguments to the constructor function
Register registers[] = {cp, x1, x2};
Register registers[] = {x1, x2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -240,17 +227,16 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, x1, x2, x0};
Register registers[] = {x1, x2, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// cp: context
// x1: constructor function
// x0: number of arguments to the constructor function
Register registers[] = {cp, x1};
Register registers[] = {x1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -258,66 +244,60 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, x1, x0};
Register registers[] = {x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x1: left operand
// x0: right operand
Register registers[] = {cp, x1, x0};
Register registers[] = {x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x0: value to compare
Register registers[] = {cp, x0};
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x0: value
Register registers[] = {cp, x0};
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x1: left operand
// x0: right operand
Register registers[] = {cp, x1, x0};
Register registers[] = {x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x2: allocation site
// x1: left operand
// x0: right operand
Register registers[] = {cp, x2, x1, x0};
Register registers[] = {x2, x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// cp: context
// x1: left operand
// x0: right operand
Register registers[] = {cp, x1, x0};
Register registers[] = {x1, x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -328,7 +308,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x2, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -342,7 +321,6 @@ void NamedDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x2, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -356,7 +334,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x0, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers,
@ -370,7 +347,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x1, // JSFunction
x0, // actual number of arguments
x2, // expected number of arguments
@ -386,7 +362,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x0, // callee
x4, // call_data
x2, // holder
@ -404,7 +379,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
Register registers[] = {
cp, // context
x0, // callee
x4, // call_data
x2, // holder
@ -418,7 +392,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
x1, // math rounding function
x3, // vector slot id
};

View File

@ -1050,10 +1050,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
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());
}
@ -2014,7 +2022,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);
}
}

View File

@ -1532,8 +1532,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);
}
@ -1543,6 +1547,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")

View File

@ -41,17 +41,27 @@ class CodeStubGraphBuilderBase : public HGraphBuilder {
info_(info),
descriptor_(info->code_stub()),
context_(NULL) {
int parameter_count = descriptor_.GetEnvironmentParameterCount();
int parameter_count = GetParameterCount();
parameters_.Reset(new HParameter*[parameter_count]);
}
virtual bool BuildGraph();
protected:
virtual HValue* BuildCodeStub() = 0;
int GetParameterCount() const {
return descriptor_.GetRegisterParameterCount();
}
HParameter* GetParameter(int parameter) {
DCHECK(parameter < descriptor_.GetEnvironmentParameterCount());
DCHECK(parameter < GetParameterCount());
return parameters_[parameter];
}
Representation GetParameterRepresentation(int parameter) {
return RepresentationFromType(descriptor_.GetParameterType(parameter));
}
bool IsParameterCountRegister(int index) const {
return descriptor_.GetRegisterParameter(index)
.is(descriptor_.stack_parameter_count());
}
HValue* GetArgumentsLength() {
// This is initialized in BuildGraph()
DCHECK(arguments_length_ != NULL);
@ -127,7 +137,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
isolate()->GetHTracer()->TraceCompilation(info());
}
int param_count = descriptor_.GetEnvironmentParameterCount();
int param_count = GetParameterCount();
HEnvironment* start_environment = graph()->start_environment();
HBasicBlock* next_block = CreateBasicBlock(start_environment);
Goto(next_block);
@ -137,13 +147,12 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid();
HInstruction* stack_parameter_count = NULL;
for (int i = 0; i < param_count; ++i) {
Representation r =
RepresentationFromType(descriptor_.GetEnvironmentParameterType(i));
Representation r = GetParameterRepresentation(i);
HParameter* param = Add<HParameter>(i,
HParameter::REGISTER_PARAMETER, r);
start_environment->Bind(i, param);
parameters_[i] = param;
if (descriptor_.IsEnvironmentParameterCountRegister(i)) {
if (IsParameterCountRegister(i)) {
param->set_type(HType::Smi());
stack_parameter_count = param;
arguments_length_ = stack_parameter_count;

View File

@ -644,7 +644,7 @@ void HandlerStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
}
CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() {
CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const {
if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
return LoadWithVectorDescriptor(isolate());
} else {
@ -666,7 +666,8 @@ void ElementsTransitionAndStoreStub::InitializeDescriptor(
}
CallInterfaceDescriptor StoreTransitionStub::GetCallInterfaceDescriptor() {
CallInterfaceDescriptor StoreTransitionStub::GetCallInterfaceDescriptor()
const {
return StoreTransitionDescriptor(isolate());
}

View File

@ -214,7 +214,7 @@ class CodeStub BASE_EMBEDDED {
// Lookup the code in the (possibly custom) cache.
bool FindCodeInCache(Code** code_out);
virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() = 0;
virtual CallInterfaceDescriptor GetCallInterfaceDescriptor() const = 0;
virtual int GetStackParameterCount() const { return 0; }
@ -322,7 +322,7 @@ struct FakeStubForTesting : public CodeStub {
// Only used by pipeline.cc's GetDebugName in DEBUG mode.
Major MajorKey() const override { return CodeStub::NoCache; }
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
UNREACHABLE();
return CallInterfaceDescriptor();
}
@ -365,20 +365,20 @@ struct FakeStubForTesting : public CodeStub {
Handle<Code> GenerateCode() override; \
DEFINE_CODE_STUB(NAME, SUPER)
#define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \
public: \
CallInterfaceDescriptor GetCallInterfaceDescriptor() override { \
return NAME##Descriptor(isolate()); \
#define DEFINE_CALL_INTERFACE_DESCRIPTOR(NAME) \
public: \
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
return NAME##Descriptor(isolate()); \
}
// There are some code stubs we just can't describe right now with a
// CallInterfaceDescriptor. Isolate behavior for those cases with this macro.
// An attempt to retrieve a descriptor will fail.
#define DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR() \
public: \
CallInterfaceDescriptor GetCallInterfaceDescriptor() override { \
UNREACHABLE(); \
return CallInterfaceDescriptor(); \
#define DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR() \
public: \
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override { \
UNREACHABLE(); \
return CallInterfaceDescriptor(); \
}
@ -427,12 +427,16 @@ class CodeStubDescriptor {
void set_call_descriptor(CallInterfaceDescriptor d) { call_descriptor_ = d; }
CallInterfaceDescriptor call_descriptor() const { return call_descriptor_; }
int GetEnvironmentParameterCount() const {
return call_descriptor().GetEnvironmentParameterCount();
int GetRegisterParameterCount() const {
return call_descriptor().GetRegisterParameterCount();
}
Type* GetEnvironmentParameterType(int index) const {
return call_descriptor().GetEnvironmentParameterType(index);
Register GetRegisterParameter(int index) const {
return call_descriptor().GetRegisterParameter(index);
}
Type* GetParameterType(int index) const {
return call_descriptor().GetParameterType(index);
}
ExternalReference miss_handler() const {
@ -444,13 +448,8 @@ class CodeStubDescriptor {
return has_miss_handler_;
}
bool IsEnvironmentParameterCountRegister(int index) const {
return call_descriptor().GetEnvironmentParameterRegister(index).is(
stack_parameter_count_);
}
int GetHandlerParameterCount() const {
int params = call_descriptor().GetEnvironmentParameterCount();
int params = GetRegisterParameterCount();
if (handler_arguments_mode_ == PASS_ARGUMENTS) {
params += 1;
}
@ -531,6 +530,10 @@ class TurboFanCodeStub : public CodeStub {
// Retrieve the code for the stub. Generate the code if needed.
Handle<Code> GenerateCode() override;
virtual int GetStackParameterCount() const override {
return GetCallInterfaceDescriptor().GetStackParameterCount();
}
Code::StubType GetStubType() const override { return Code::FAST; }
protected:
@ -852,7 +855,7 @@ class InstanceofStub: public PlatformCodeStub {
static Register left() { return InstanceofDescriptor::left(); }
static Register right() { return InstanceofDescriptor::right(); }
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
if (HasArgsInRegisters()) {
return InstanceofDescriptor(isolate());
}
@ -933,7 +936,7 @@ class MathPowStub: public PlatformCodeStub {
minor_key_ = ExponentTypeBits::encode(exponent_type);
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
if (exponent_type() == TAGGED) {
return MathPowTaggedDescriptor(isolate());
} else if (exponent_type() == INTEGER) {
@ -1021,7 +1024,7 @@ class FunctionPrototypeStub : public PlatformCodeStub {
// TODO(mvstanton): only the receiver register is accessed. When this is
// translated to a hydrogen code stub, a new CallInterfaceDescriptor
// should be created that just uses that register for more efficient code.
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
return LoadWithVectorDescriptor(isolate());
}
@ -1064,7 +1067,7 @@ class HandlerStub : public HydrogenCodeStub {
void InitializeDescriptor(CodeStubDescriptor* descriptor) override;
CallInterfaceDescriptor GetCallInterfaceDescriptor() override;
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override;
protected:
explicit HandlerStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
@ -1258,7 +1261,7 @@ class StoreTransitionStub : public HandlerStub {
return StoreModeBits::decode(sub_minor_key());
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() override;
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override;
protected:
Code::Kind kind() const override { return Code::STORE_IC; }
@ -1789,7 +1792,7 @@ class ArgumentsAccessStub: public PlatformCodeStub {
minor_key_ = TypeBits::encode(type);
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
if (type() == READ_ELEMENT) {
return ArgumentsAccessReadDescriptor(isolate());
}
@ -1816,7 +1819,7 @@ class RestParamAccessStub: public PlatformCodeStub {
public:
explicit RestParamAccessStub(Isolate* isolate) : PlatformCodeStub(isolate) { }
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
return ContextOnlyDescriptor(isolate());
}
@ -2110,7 +2113,7 @@ class LoadDictionaryElementStub : public HydrogenCodeStub {
minor_key_ = state.GetExtraICState();
}
CallInterfaceDescriptor GetCallInterfaceDescriptor() override {
CallInterfaceDescriptor GetCallInterfaceDescriptor() const override {
return LoadWithVectorDescriptor(isolate());
}

View File

@ -145,8 +145,7 @@ class LinkageHelper {
Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor,
int stack_parameter_count, CallDescriptor::Flags flags,
Operator::Properties properties, MachineType return_type) {
const int register_parameter_count =
descriptor.GetEnvironmentParameterCount();
const int register_parameter_count = descriptor.GetRegisterParameterCount();
const int js_parameter_count =
register_parameter_count + stack_parameter_count;
const int context_count = 1;
@ -165,9 +164,9 @@ class LinkageHelper {
for (int i = 0; i < js_parameter_count; i++) {
if (i < register_parameter_count) {
// The first parameters go in registers.
Register reg = descriptor.GetEnvironmentParameterRegister(i);
Register reg = descriptor.GetRegisterParameter(i);
Representation rep =
RepresentationFromType(descriptor.GetEnvironmentParameterType(i));
RepresentationFromType(descriptor.GetParameterType(i));
locations.AddParam(regloc(reg));
types.AddParam(reptyp(rep));
} else {

View File

@ -1445,7 +1445,7 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
// and the standard stack frame slots. Include space for an argument
// object to the callee and optionally the space to pass the argument
// object to the stub failure handler.
int param_count = descriptor.GetEnvironmentParameterCount();
int param_count = descriptor.GetRegisterParameterCount();
CHECK_EQ(translated_frame->height(), param_count);
CHECK_GE(param_count, 0);
@ -1564,7 +1564,9 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator,
WriteTranslatedValueToOutput(&value_iterator, &input_index, 0,
output_frame_offset);
if (!arg_count_known && descriptor.IsEnvironmentParameterCountRegister(i)) {
if (!arg_count_known &&
descriptor.GetRegisterParameter(i)
.is(descriptor.stack_parameter_count())) {
arguments_length_offset = output_frame_offset;
}
}

View File

@ -2261,9 +2261,9 @@ class HCallWithDescriptor final : public HInstruction {
CallInterfaceDescriptor descriptor,
const Vector<HValue*>& operands,
CallMode call_mode = NORMAL_CALL) {
DCHECK(operands.length() == descriptor.GetEnvironmentLength());
HCallWithDescriptor* res = new (zone) HCallWithDescriptor(
target, argument_count, descriptor, operands, call_mode, zone);
DCHECK(operands.length() == res->GetParameterCount());
return res;
}
@ -2271,11 +2271,12 @@ class HCallWithDescriptor final : public HInstruction {
HValue* OperandAt(int index) const final { return values_[index]; }
Representation RequiredInputRepresentation(int index) final {
if (index == 0) {
if (index == 0 || index == 1) {
// Target + context
return Representation::Tagged();
} else {
int par_index = index - 1;
DCHECK(par_index < descriptor_.GetEnvironmentLength());
int par_index = index - 2;
DCHECK(par_index < GetParameterCount());
return RepresentationFromType(descriptor_.GetParameterType(par_index));
}
}
@ -2307,7 +2308,7 @@ class HCallWithDescriptor final : public HInstruction {
const Vector<HValue*>& operands, CallMode call_mode,
Zone* zone)
: descriptor_(descriptor),
values_(descriptor.GetEnvironmentLength() + 1, zone),
values_(GetParameterCount() + 1, zone),
argument_count_(argument_count),
call_mode_(call_mode) {
// We can only tail call without any stack arguments.
@ -2325,6 +2326,10 @@ class HCallWithDescriptor final : public HInstruction {
SetOperandAt(values_.length() - 1, v);
}
int GetParameterCount() const {
return descriptor_.GetRegisterParameterCount() + 1;
}
void InternalSetOperandAt(int index, HValue* value) final {
values_[index] = value;
}

View File

@ -3500,8 +3500,8 @@ HGraph::HGraph(CompilationInfo* info)
if (info->IsStub()) {
CallInterfaceDescriptor descriptor =
info->code_stub()->GetCallInterfaceDescriptor();
start_environment_ = new (zone_)
HEnvironment(zone_, descriptor.GetEnvironmentParameterCount());
start_environment_ =
new (zone_) HEnvironment(zone_, descriptor.GetRegisterParameterCount());
} else {
if (info->is_tracking_positions()) {
info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown(),
@ -7707,9 +7707,8 @@ HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall(
isolate()->builtins()->ArgumentsAdaptorTrampoline();
HConstant* adaptor_value = Add<HConstant>(adaptor);
return New<HCallWithDescriptor>(
adaptor_value, argument_count, descriptor,
Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
return New<HCallWithDescriptor>(adaptor_value, argument_count, descriptor,
Vector<HValue*>(op_vals, arraysize(op_vals)));
}
@ -8965,19 +8964,17 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
Handle<Code> code = stub.GetCode();
HConstant* code_value = Add<HConstant>(code);
ApiAccessorDescriptor descriptor(isolate());
DCHECK(arraysize(op_vals) - 1 == descriptor.GetEnvironmentLength());
call = New<HCallWithDescriptor>(
code_value, argc + 1, descriptor,
Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
Vector<HValue*>(op_vals, arraysize(op_vals) - 1));
} else if (argc <= CallApiFunctionWithFixedArgsStub::kMaxFixedArgs) {
CallApiFunctionWithFixedArgsStub stub(isolate(), argc, call_data_undefined);
Handle<Code> code = stub.GetCode();
HConstant* code_value = Add<HConstant>(code);
ApiFunctionWithFixedArgsDescriptor descriptor(isolate());
DCHECK(arraysize(op_vals) - 1 == descriptor.GetEnvironmentLength());
call = New<HCallWithDescriptor>(
code_value, argc + 1, descriptor,
Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
Vector<HValue*>(op_vals, arraysize(op_vals) - 1));
Drop(1); // Drop function.
} else {
op_vals[arraysize(op_vals) - 1] = Add<HConstant>(argc);
@ -8985,10 +8982,9 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
Handle<Code> code = stub.GetCode();
HConstant* code_value = Add<HConstant>(code);
ApiFunctionDescriptor descriptor(isolate());
DCHECK(arraysize(op_vals) == descriptor.GetEnvironmentLength());
call = New<HCallWithDescriptor>(
code_value, argc + 1, descriptor,
Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
call =
New<HCallWithDescriptor>(code_value, argc + 1, descriptor,
Vector<HValue*>(op_vals, arraysize(op_vals)));
Drop(1); // Drop function.
}

View File

@ -106,15 +106,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.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
eax.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
eax.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);
}

View File

@ -65,14 +65,14 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ebx};
Register registers[] = {ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edi};
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -80,77 +80,77 @@ void FastNewContextDescriptor::InitializePlatformSpecific(
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// ToNumberStub invokes a function, and therefore needs a context.
Register registers[] = {esi, eax};
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax};
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ebx};
Register registers[] = {ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax, ebx, ecx};
Register registers[] = {eax, ebx, ecx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax, ebx, ecx, edx};
Register registers[] = {eax, ebx, ecx, edx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ebx, edx};
Register registers[] = {ebx, edx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ebx, edx, edi};
Register registers[] = {ebx, edx, edi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ecx, eax};
Register registers[] = {ecx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edi};
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edi, edx};
Register registers[] = {edi, edx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edi, edx, ebx};
Register registers[] = {edi, edx, ebx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -164,21 +164,21 @@ void CallConstructDescriptor::InitializePlatformSpecific(
// edi : constructor function
// 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[] = {esi, eax, edi, ebx};
Register registers[] = {eax, edi, ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ecx, ebx, eax};
Register registers[] = {ecx, ebx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax, ebx};
Register registers[] = {eax, ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -186,9 +186,7 @@ void TransitionElementsKindDescriptor::InitializePlatformSpecific(
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// esi -- context
Register registers[] = {esi};
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
data->InitializePlatformSpecific(0, nullptr, nullptr);
}
@ -198,7 +196,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
// eax -- number of arguments
// edi -- function
// ebx -- allocation site with elements kind
Register registers[] = {esi, edi, ebx};
Register registers[] = {edi, ebx};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -206,7 +204,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {esi, edi, ebx, eax};
Register registers[] = {edi, ebx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -216,7 +214,7 @@ void InternalArrayConstructorConstantArgCountDescriptor::
// register state
// eax -- number of arguments
// edi -- function
Register registers[] = {esi, edi};
Register registers[] = {edi};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -224,49 +222,49 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {esi, edi, eax};
Register registers[] = {edi, eax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edx, eax};
Register registers[] = {edx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax};
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, eax};
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edx, eax};
Register registers[] = {edx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, ecx, edx, eax};
Register registers[] = {ecx, edx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {esi, edx, eax};
Register registers[] = {edx, eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -274,7 +272,6 @@ void StringAddDescriptor::InitializePlatformSpecific(
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
ecx, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -284,7 +281,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
ecx, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -294,7 +290,6 @@ void NamedDescriptor::InitializePlatformSpecific(
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
edx, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -304,7 +299,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
edi, // JSFunction
eax, // actual number of arguments
ebx, // expected number of arguments
@ -316,7 +310,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ApiFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
edi, // callee
ebx, // call_data
ecx, // holder
@ -330,7 +323,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
void ApiAccessorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
edi, // callee
ebx, // call_data
ecx, // holder
@ -343,7 +335,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
esi, // context
edi, // math rounding function
edx, // vector slot id
};

View File

@ -1133,10 +1133,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
CallInterfaceDescriptor descriptor = instr->descriptor();
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), esi);
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());
}
@ -2547,7 +2555,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);
}
}

View File

@ -1861,8 +1861,12 @@ class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
public:
LCallWithDescriptor(CallInterfaceDescriptor descriptor,
const ZoneList<LOperand*>& operands, Zone* zone)
: 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);
}
@ -1870,6 +1874,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")

View File

@ -51,10 +51,6 @@ void CallInterfaceDescriptorData::InitializePlatformSpecific(
platform_specific_descriptor_ = platform_descriptor;
register_param_count_ = register_parameter_count;
// An interface descriptor must have a context register.
DCHECK(register_parameter_count > 0 &&
registers[0].is(CallInterfaceDescriptor::ContextRegister()));
// InterfaceDescriptor owns a copy of the registers array.
register_params_.Reset(NewArray<Register>(register_parameter_count));
for (int i = 0; i < register_parameter_count; i++) {
@ -83,63 +79,60 @@ const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const {
Type::FunctionType* LoadDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, AnyTagged());
function->InitParameter(3, SmiType());
function->InitParameter(2, SmiType());
return function;
}
void LoadDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
SlotRegister()};
Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
ValueRegister()};
Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreTransitionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
ValueRegister(), MapRegister()};
Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
MapRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ElementTransitionAndStoreDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ValueRegister(), MapRegister(),
NameRegister(), ReceiverRegister()};
Register registers[] = {ValueRegister(), MapRegister(), NameRegister(),
ReceiverRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InstanceofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), left(), right()};
Register registers[] = {left(), right()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void MathPowTaggedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), exponent()};
Register registers[] = {exponent()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void MathPowIntegerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), exponent()};
Register registers[] = {exponent()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -147,6 +140,27 @@ void MathPowIntegerDescriptor::InitializePlatformSpecific(
Type::FunctionType*
LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, SmiType());
function->InitParameter(3, AnyTagged());
return function;
}
void LoadWithVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister(),
VectorRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
Type::FunctionType*
VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
@ -158,34 +172,10 @@ LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType(
}
void LoadWithVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
SlotRegister(), VectorRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
Type::FunctionType*
VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 6, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, AnyTagged());
function->InitParameter(3, AnyTagged());
function->InitParameter(4, SmiType());
function->InitParameter(5, AnyTagged());
return function;
}
void VectorStoreICDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(),
NameRegister(), ValueRegister(),
SlotRegister(), VectorRegister()};
Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
SlotRegister(), VectorRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -194,20 +184,19 @@ Type::FunctionType*
VectorStoreICTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, AnyTagged());
function->InitParameter(3, AnyTagged());
function->InitParameter(4, SmiType());
function->InitParameter(3, SmiType());
return function;
}
void VectorStoreICTrampolineDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ReceiverRegister(), NameRegister(),
ValueRegister(), SlotRegister()};
Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
SlotRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -216,37 +205,35 @@ Type::FunctionType*
ApiGetterDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, ExternalPointer());
AnyTagged(), Type::Undefined(), 1, isolate->interface_descriptor_zone());
function->InitParameter(0, ExternalPointer());
return function;
}
void ApiGetterDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), function_address()};
Register registers[] = {function_address()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentsAccessReadDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), index(), parameter_count()};
Register registers[] = {index(), parameter_count()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ContextOnlyDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
data->InitializePlatformSpecific(0, nullptr);
}
void GrowArrayElementsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ContextRegister(), ObjectRegister(), KeyRegister()};
Register registers[] = {ObjectRegister(), KeyRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -255,11 +242,10 @@ Type::FunctionType*
FastCloneShallowArrayDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, SmiType());
function->InitParameter(3, AnyTagged());
function->InitParameter(1, SmiType());
function->InitParameter(2, AnyTagged());
return function;
}
@ -268,10 +254,9 @@ Type::FunctionType*
CreateAllocationSiteDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, SmiType());
function->InitParameter(1, SmiType());
return function;
}
@ -280,11 +265,10 @@ Type::FunctionType*
CreateWeakCellDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, AnyTagged());
function->InitParameter(2, SmiType());
function->InitParameter(3, AnyTagged());
function->InitParameter(1, SmiType());
function->InitParameter(2, AnyTagged());
return function;
}
@ -293,10 +277,9 @@ Type::FunctionType*
CallFunctionWithFeedbackDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, Type::Receiver()); // JSFunction
function->InitParameter(2, SmiType());
AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, SmiType());
return function;
}
@ -305,11 +288,10 @@ Type::FunctionType* CallFunctionWithFeedbackAndVectorDescriptor::
BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, Type::Receiver()); // JSFunction
function->InitParameter(2, SmiType());
function->InitParameter(3, AnyTagged());
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, SmiType());
function->InitParameter(2, AnyTagged());
return function;
}
@ -318,11 +300,10 @@ Type::FunctionType*
ArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, Type::Receiver()); // JSFunction
function->InitParameter(2, AnyTagged());
function->InitParameter(3, UntaggedSigned32());
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, AnyTagged());
function->InitParameter(2, UntaggedSigned32());
return function;
}
@ -331,10 +312,9 @@ Type::FunctionType*
InternalArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged());
function->InitParameter(1, Type::Receiver()); // JSFunction
function->InitParameter(2, UntaggedSigned32());
AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, UntaggedSigned32());
return function;
}
@ -343,11 +323,10 @@ Type::FunctionType*
ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged()); // context
function->InitParameter(1, Type::Receiver()); // JSFunction
function->InitParameter(2, UntaggedSigned32()); // actual number of arguments
function->InitParameter(3,
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, UntaggedSigned32()); // actual number of arguments
function->InitParameter(2,
UntaggedSigned32()); // expected number of arguments
return function;
}
@ -357,13 +336,12 @@ Type::FunctionType*
ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 6, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged()); // context
function->InitParameter(1, AnyTagged()); // callee
function->InitParameter(2, AnyTagged()); // call_data
function->InitParameter(3, AnyTagged()); // holder
function->InitParameter(4, ExternalPointer()); // api_function_address
function->InitParameter(5, UntaggedSigned32()); // actual number of arguments
AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged()); // callee
function->InitParameter(1, AnyTagged()); // call_data
function->InitParameter(2, AnyTagged()); // holder
function->InitParameter(3, ExternalPointer()); // api_function_address
function->InitParameter(4, UntaggedSigned32()); // actual number of arguments
return function;
}
@ -372,12 +350,11 @@ Type::FunctionType*
ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged()); // context
function->InitParameter(1, AnyTagged()); // callee
function->InitParameter(2, AnyTagged()); // call_data
function->InitParameter(3, AnyTagged()); // holder
function->InitParameter(4, ExternalPointer()); // api_function_address
AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
function->InitParameter(0, AnyTagged()); // callee
function->InitParameter(1, AnyTagged()); // call_data
function->InitParameter(2, AnyTagged()); // holder
function->InitParameter(3, ExternalPointer()); // api_function_address
return function;
}
@ -386,10 +363,9 @@ Type::FunctionType*
MathRoundVariantDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Type::FunctionType* function = Type::FunctionType::New(
AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
function->InitParameter(0, Type::Receiver());
function->InitParameter(1, SmiType());
function->InitParameter(2, AnyTagged());
AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
function->InitParameter(0, SmiType());
function->InitParameter(1, AnyTagged());
return function;
}

View File

@ -140,13 +140,15 @@ class CallInterfaceDescriptor {
CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key)
: data_(isolate->call_descriptor_data(key)) {}
int GetEnvironmentLength() const { return data()->register_param_count(); }
int GetRegisterParameterCount() const {
return data()->register_param_count();
}
Register GetParameterRegister(int index) const {
int GetStackParameterCount() const {
return data()->function_type()->Arity() - data()->register_param_count();
}
Register GetRegisterParameter(int index) const {
return data()->register_param(index);
}
@ -155,20 +157,6 @@ class CallInterfaceDescriptor {
return data()->register_param_type(index);
}
// "Environment" versions of parameter functions. The first register
// parameter (context) is not included.
int GetEnvironmentParameterCount() const {
return GetEnvironmentLength() - 1;
}
Register GetEnvironmentParameterRegister(int index) const {
return GetParameterRegister(index + 1);
}
Type* GetEnvironmentParameterType(int index) const {
return GetParameterType(index + 1);
}
// Some platforms have extra information to associate with the descriptor.
PlatformInterfaceDescriptor* platform_specific_descriptor() const {
return data()->platform_specific_descriptor();

View File

@ -112,17 +112,17 @@ 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.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
a0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
a0.is(descriptor.GetRegisterParameter(param_count - 1)));
// Push arguments, adjust sp.
__ Subu(sp, sp, Operand(param_count * kPointerSize));
for (int i = 0; i < param_count; ++i) {
// Store argument to stack.
__ sw(descriptor.GetEnvironmentParameterRegister(i),
__ sw(descriptor.GetRegisterParameter(i),
MemOperand(sp, (param_count - 1 - i) * kPointerSize));
}
__ CallExternalReference(miss, param_count);

View File

@ -64,91 +64,91 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2};
Register registers[] = {a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3};
Register registers[] = {a3};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a2, a1};
Register registers[] = {a3, a2, a1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a2, a1, a0};
Register registers[] = {a3, a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3};
Register registers[] = {a2, a3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3, a1};
Register registers[] = {a2, a3, a1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a0};
Register registers[] = {a3, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a3};
Register registers[] = {a1, a3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a3, a2};
Register registers[] = {a1, a3, a2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -162,21 +162,21 @@ 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, a0, a1, a2};
Register registers[] = {a0, a1, a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a1, a0};
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0, a1};
Register registers[] = {a0, a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -184,20 +184,17 @@ void TransitionElementsKindDescriptor::InitializePlatformSpecific(
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
// a0 -- number of arguments
// a1 -- function
// a2 -- allocation site with elements kind
Register registers[] = {cp, a1, a2};
Register registers[] = {a1, a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -205,7 +202,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, a1, a2, a0};
Register registers[] = {a1, a2, a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -213,10 +210,9 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// register state
// cp -- context
// a0 -- number of arguments
// a1 -- constructor function
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -224,49 +220,49 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a1, a0};
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -274,7 +270,6 @@ void StringAddDescriptor::InitializePlatformSpecific(
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a2, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -284,7 +279,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a2, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -294,7 +288,6 @@ void NamedDescriptor::InitializePlatformSpecific(
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -304,7 +297,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a1, // JSFunction
a0, // actual number of arguments
a2, // expected number of arguments
@ -316,7 +308,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ApiFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // callee
t0, // call_data
a2, // holder
@ -330,7 +321,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
void ApiAccessorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // callee
t0, // call_data
a2, // holder
@ -343,7 +333,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a1, // math rounding function
a3, // vector slot id
};

View File

@ -1097,10 +1097,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
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());
}
@ -2448,7 +2456,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);
}
}

View File

@ -1810,8 +1810,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);
}
@ -1821,6 +1825,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")

View File

@ -111,17 +111,17 @@ 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.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK((param_count == 0) ||
a0.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
a0.is(descriptor.GetRegisterParameter(param_count - 1)));
// Push arguments, adjust sp.
__ Dsubu(sp, sp, Operand(param_count * kPointerSize));
for (int i = 0; i < param_count; ++i) {
// Store argument to stack.
__ sd(descriptor.GetEnvironmentParameterRegister(i),
__ sd(descriptor.GetRegisterParameter(i),
MemOperand(sp, (param_count - 1 - i) * kPointerSize));
}
__ CallExternalReference(miss, param_count);

View File

@ -64,91 +64,91 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2};
Register registers[] = {a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3};
Register registers[] = {a3};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a2, a1};
Register registers[] = {a3, a2, a1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a2, a1, a0};
Register registers[] = {a3, a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3};
Register registers[] = {a2, a3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3, a1};
Register registers[] = {a2, a3, a1};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a3, a0};
Register registers[] = {a3, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a3};
Register registers[] = {a1, a3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a3, a2};
Register registers[] = {a1, a3, a2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -162,21 +162,21 @@ 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, a0, a1, a2};
Register registers[] = {a0, a1, a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a1, a0};
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0, a1};
Register registers[] = {a0, a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -184,20 +184,17 @@ void TransitionElementsKindDescriptor::InitializePlatformSpecific(
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
// a0 -- number of arguments
// a1 -- function
// a2 -- allocation site with elements kind
Register registers[] = {cp, a1, a2};
Register registers[] = {a1, a2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -205,7 +202,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, a1, a2, a0};
Register registers[] = {a1, a2, a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -213,10 +210,9 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// register state
// cp -- context
// a0 -- number of arguments
// a1 -- constructor function
Register registers[] = {cp, a1};
Register registers[] = {a1};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -224,49 +220,49 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a0};
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a1, a0};
Register registers[] = {a2, a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a1, a0};
Register registers[] = {a1, a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
@ -274,7 +270,6 @@ void StringAddDescriptor::InitializePlatformSpecific(
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a2, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -284,7 +279,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a2, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -294,7 +288,6 @@ void NamedDescriptor::InitializePlatformSpecific(
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -304,7 +297,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a1, // JSFunction
a0, // actual number of arguments
a2, // expected number of arguments
@ -316,7 +308,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ApiFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // callee
a4, // call_data
a2, // holder
@ -330,7 +321,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
void ApiAccessorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a0, // callee
a4, // call_data
a2, // holder
@ -343,7 +333,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
cp, // context
a1, // math rounding function
a3, // vector slot id
};

View File

@ -1097,11 +1097,19 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
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));
ops.Add(op, zone());
// 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());
}
LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(
@ -2453,7 +2461,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);
}
}

View File

@ -1872,8 +1872,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);
}
@ -1883,6 +1887,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")

View File

@ -98,15 +98,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.
FrameScope scope(masm, StackFrame::INTERNAL);
DCHECK(param_count == 0 ||
rax.is(descriptor.GetEnvironmentParameterRegister(param_count - 1)));
rax.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);
}

View File

@ -66,21 +66,21 @@ const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rbx};
Register registers[] = {rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastNewContextDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdi};
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rbx};
Register registers[] = {rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -88,70 +88,70 @@ void TypeofDescriptor::InitializePlatformSpecific(
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// ToNumberStub invokes a function, and therefore needs a context.
Register registers[] = {rsi, rax};
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax};
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax, rbx, rcx};
Register registers[] = {rax, rbx, rcx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax, rbx, rcx, rdx};
Register registers[] = {rax, rbx, rcx, rdx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rbx, rdx};
Register registers[] = {rbx, rdx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rbx, rdx, rdi};
Register registers[] = {rbx, rdx, rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rcx, rax};
Register registers[] = {rcx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdi};
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdi, rdx};
Register registers[] = {rdi, rdx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdi, rdx, rbx};
Register registers[] = {rdi, rdx, rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -165,31 +165,28 @@ void CallConstructDescriptor::InitializePlatformSpecific(
// rdi : constructor function
// 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[] = {rsi, rax, rdi, rbx};
Register registers[] = {rax, rdi, rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void RegExpConstructResultDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rcx, rbx, rax};
Register registers[] = {rcx, rbx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax, rbx};
Register registers[] = {rax, rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// rsi -- context
Register registers[] = {rsi};
data->InitializePlatformSpecific(arraysize(registers), registers, nullptr);
data->InitializePlatformSpecific(0, nullptr, nullptr);
}
@ -199,7 +196,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
// rax -- number of arguments
// rdi -- function
// rbx -- allocation site with elements kind
Register registers[] = {rsi, rdi, rbx};
Register registers[] = {rdi, rbx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -207,7 +204,7 @@ void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {rsi, rdi, rbx, rax};
Register registers[] = {rdi, rbx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -215,10 +212,9 @@ void ArrayConstructorDescriptor::InitializePlatformSpecific(
void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
// register state
// rsi -- context
// rax -- number of arguments
// rdi -- constructor function
Register registers[] = {rsi, rdi};
Register registers[] = {rdi};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -226,49 +222,49 @@ void InternalArrayConstructorConstantArgCountDescriptor::
void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {rsi, rdi, rax};
Register registers[] = {rdi, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdx, rax};
Register registers[] = {rdx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareNilDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax};
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rax};
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdx, rax};
Register registers[] = {rdx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rcx, rdx, rax};
Register registers[] = {rcx, rdx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rsi, rdx, rax};
Register registers[] = {rdx, rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
@ -276,7 +272,6 @@ void StringAddDescriptor::InitializePlatformSpecific(
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rcx, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -286,7 +281,6 @@ void KeyedDescriptor::InitializePlatformSpecific(
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rcx, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -296,7 +290,6 @@ void NamedDescriptor::InitializePlatformSpecific(
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rdx, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers);
@ -306,7 +299,6 @@ void CallHandlerDescriptor::InitializePlatformSpecific(
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rdi, // JSFunction
rax, // actual number of arguments
rbx, // expected number of arguments
@ -318,7 +310,6 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ApiFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rdi, // callee
rbx, // call_data
rcx, // holder
@ -332,7 +323,6 @@ void ApiFunctionDescriptor::InitializePlatformSpecific(
void ApiAccessorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rdi, // callee
rbx, // call_data
rcx, // holder
@ -345,7 +335,6 @@ void ApiAccessorDescriptor::InitializePlatformSpecific(
void MathRoundVariantDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rsi, // context
rdi, // math rounding function
rdx, // vector slot id
};

View File

@ -1113,10 +1113,18 @@ LInstruction* LChunkBuilder::DoCallWithDescriptor(
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), rsi);
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());
}
@ -2523,7 +2531,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);
}
}

View File

@ -1838,8 +1838,12 @@ class LCallWithDescriptor final : public LTemplateResultInstruction<1> {
public:
LCallWithDescriptor(CallInterfaceDescriptor descriptor,
const ZoneList<LOperand*>& operands, Zone* zone)
: 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);
}
@ -1847,6 +1851,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")