Commit 524d0194 authored by bmeurer's avatar bmeurer Committed by Commit bot

[stubs] Unify the type conversion call interface descriptors.

Up until now all type conversions (i.e. ToNumber, ToString and friends)
had their own specific call interface descriptors, where some of them
had to match (i.e. ToString and NumberToString have to use the same
argument register). Instead of all the different descriptors, it's
sufficient to have a single TypeConversionDescriptor instead.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34916}
parent 27bce819
......@@ -111,35 +111,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return r0; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return r0; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return r0; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return r0; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return r0; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -319,13 +292,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r1, r0};
......
......@@ -114,37 +114,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x0: value
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return x0; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return x0; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return x0; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return x0; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x0: value
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return x0; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -346,14 +317,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x0: value
Register registers[] = {x0};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// x1: left operand
......
......@@ -1533,11 +1533,10 @@ HValue* CodeStubGraphBuilderBase::BuildToString(HValue* input, bool convert) {
}
if_inputisprimitive.End();
// Convert the primitive to a string value.
ToStringDescriptor descriptor(isolate());
ToStringStub stub(isolate());
HValue* values[] = {context(), Pop()};
Push(AddUncasted<HCallWithDescriptor>(
Add<HConstant>(stub.GetCode()), 0, descriptor,
Add<HConstant>(stub.GetCode()), 0, stub.GetCallInterfaceDescriptor(),
Vector<HValue*>(values, arraysize(values))));
}
if_inputisstring.End();
......@@ -1795,7 +1794,7 @@ Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<ToObjectStub>::BuildCodeStub() {
HValue* receiver = GetParameter(ToObjectDescriptor::kReceiverIndex);
HValue* receiver = GetParameter(TypeConversionDescriptor::kArgumentIndex);
return BuildToObject(receiver);
}
......
......@@ -2453,7 +2453,6 @@ void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {}
void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
NumberToStringDescriptor call_descriptor(isolate());
descriptor->Initialize(
Runtime::FunctionForId(Runtime::kNumberToString)->entry);
}
......
......@@ -773,7 +773,7 @@ class ToBooleanStub final : public TurboFanCodeStub {
public:
explicit ToBooleanStub(Isolate* isolate) : TurboFanCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_TURBOFAN_CODE_STUB(ToBoolean, TurboFanCodeStub);
};
......@@ -803,7 +803,7 @@ class NumberToStringStub final : public HydrogenCodeStub {
// Parameters accessed via CodeStubGraphBuilder::GetParameter()
static const int kNumber = 0;
DEFINE_CALL_INTERFACE_DESCRIPTOR(NumberToString);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_HYDROGEN_CODE_STUB(NumberToString, HydrogenCodeStub);
};
......@@ -2820,7 +2820,7 @@ class ToBooleanICStub : public HydrogenCodeStub {
class TypesBits : public BitField<uint16_t, 0, NUMBER_OF_TYPES> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToBoolean);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_HYDROGEN_CODE_STUB(ToBooleanIC, HydrogenCodeStub);
};
......@@ -2932,7 +2932,7 @@ class ToNumberStub final : public PlatformCodeStub {
public:
explicit ToNumberStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToNumber);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_PLATFORM_CODE_STUB(ToNumber, PlatformCodeStub);
};
......@@ -2941,7 +2941,7 @@ class ToLengthStub final : public PlatformCodeStub {
public:
explicit ToLengthStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToLength);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_PLATFORM_CODE_STUB(ToLength, PlatformCodeStub);
};
......@@ -2950,7 +2950,7 @@ class ToStringStub final : public PlatformCodeStub {
public:
explicit ToStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToString);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_PLATFORM_CODE_STUB(ToString, PlatformCodeStub);
};
......@@ -2959,7 +2959,7 @@ class ToNameStub final : public PlatformCodeStub {
public:
explicit ToNameStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToName);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_PLATFORM_CODE_STUB(ToName, PlatformCodeStub);
};
......@@ -2968,7 +2968,7 @@ class ToObjectStub final : public HydrogenCodeStub {
public:
explicit ToObjectStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToObject);
DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion);
DEFINE_HYDROGEN_CODE_STUB(ToObject, HydrogenCodeStub);
};
......
......@@ -114,36 +114,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// ToNumberStub invokes a function, and therefore needs a context.
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return eax; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -324,13 +296,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {edx, eax};
......
......@@ -197,31 +197,9 @@ void StringCompareDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToLengthDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ReceiverRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ReceiverRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNameDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ReceiverRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToObjectDescriptor::InitializePlatformSpecific(
void TypeConversionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {ReceiverRegister()};
Register registers[] = {ArgumentRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......
......@@ -29,12 +29,7 @@ class PlatformInterfaceDescriptor;
V(FastNewRestParameter) \
V(FastNewSloppyArguments) \
V(FastNewStrictArguments) \
V(ToNumber) \
V(ToLength) \
V(ToString) \
V(ToName) \
V(ToObject) \
V(NumberToString) \
V(TypeConversion) \
V(Typeof) \
V(FastCloneRegExp) \
V(FastCloneShallowArray) \
......@@ -58,7 +53,6 @@ class PlatformInterfaceDescriptor;
V(InternalArrayConstructorConstantArgCount) \
V(InternalArrayConstructor) \
V(Compare) \
V(ToBoolean) \
V(BinaryOp) \
V(BinaryOpWithAllocationSite) \
V(StringAdd) \
......@@ -416,56 +410,13 @@ class FastNewStrictArgumentsDescriptor : public CallInterfaceDescriptor {
CallInterfaceDescriptor)
};
class ToNumberDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(ToNumberDescriptor, CallInterfaceDescriptor)
};
class ToLengthDescriptor : public CallInterfaceDescriptor {
public:
enum ParameterIndices { kReceiverIndex };
DECLARE_DESCRIPTOR(ToLengthDescriptor, CallInterfaceDescriptor)
static const Register ReceiverRegister();
};
class ToStringDescriptor : public CallInterfaceDescriptor {
class TypeConversionDescriptor final : public CallInterfaceDescriptor {
public:
enum ParameterIndices { kReceiverIndex };
enum ParameterIndices { kArgumentIndex };
DECLARE_DESCRIPTOR(ToStringDescriptor, CallInterfaceDescriptor)
DECLARE_DESCRIPTOR(TypeConversionDescriptor, CallInterfaceDescriptor)
static const Register ReceiverRegister();
};
class ToNameDescriptor : public CallInterfaceDescriptor {
public:
enum ParameterIndices { kReceiverIndex };
DECLARE_DESCRIPTOR(ToNameDescriptor, CallInterfaceDescriptor)
static const Register ReceiverRegister();
};
class ToObjectDescriptor : public CallInterfaceDescriptor {
public:
enum ParameterIndices { kReceiverIndex };
DECLARE_DESCRIPTOR(ToObjectDescriptor, CallInterfaceDescriptor)
static const Register ReceiverRegister();
};
class NumberToStringDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(NumberToStringDescriptor, CallInterfaceDescriptor)
static const Register ArgumentRegister();
};
......@@ -650,12 +601,6 @@ class CompareDescriptor : public CallInterfaceDescriptor {
};
class ToBooleanDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(ToBooleanDescriptor, CallInterfaceDescriptor)
};
class BinaryOpDescriptor : public CallInterfaceDescriptor {
public:
DECLARE_DESCRIPTOR(BinaryOpDescriptor, CallInterfaceDescriptor)
......
......@@ -109,35 +109,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return a0; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -318,13 +291,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1, a0};
......
......@@ -109,35 +109,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return a0; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return a0; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return a0; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -318,13 +291,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a0};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {a1, a0};
......
......@@ -106,35 +106,9 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return r3; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return r3; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return r3; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return r3; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return r3; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -314,13 +288,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4, r3};
......
......@@ -89,29 +89,8 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return r2; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return r2; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return r2; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return r2; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return r2; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -269,12 +248,6 @@ void CompareDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2};
......
......@@ -114,36 +114,8 @@ void TypeofDescriptor::InitializePlatformSpecific(
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// ToNumberStub invokes a function, and therefore needs a context.
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return rax; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return rax; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return rax; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return rax; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return rax; }
void FastCloneRegExpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -315,13 +287,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rax};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {rdx, rax};
......
......@@ -111,36 +111,9 @@ void FastNewStrictArgumentsDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ToNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// ToNumberStub invokes a function, and therefore needs a context.
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
// static
const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToStringDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToNameDescriptor::ReceiverRegister() { return eax; }
// static
const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
void NumberToStringDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
const Register TypeConversionDescriptor::ArgumentRegister() { return eax; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
......@@ -321,13 +294,6 @@ void CompareDescriptor::InitializePlatformSpecific(
}
void ToBooleanDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {eax};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {edx, eax};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment