Commit a2fef3af authored by ishell's avatar ishell Committed by Commit bot

[stubs] An easier way of defining a stub call interface descriptor.

This CL introduces a DECLARE_DEFAULT_DESCRIPTOR macro that helps defining a CallInterfaceDescriptor in a cases where it is not important which registers to use for passing arguments. One can use such descriptors for new TurboFan stubs.

HasPropertyDescriptor now uses the new machinery.

Review-Url: https://codereview.chromium.org/2002143002
Cr-Commit-Position: refs/heads/master@{#36675}
parent 216bcf9f
...@@ -13,6 +13,14 @@ namespace internal { ...@@ -13,6 +13,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {r0, r1, r2, r3, r4};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return r1; } const Register LoadDescriptor::ReceiverRegister() { return r1; }
const Register LoadDescriptor::NameRegister() { return r2; } const Register LoadDescriptor::NameRegister() { return r2; }
...@@ -65,8 +73,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -65,8 +73,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return r0; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return r0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return r3; } const Register GrowArrayElementsDescriptor::KeyRegister() { return r3; }
const Register HasPropertyDescriptor::ObjectRegister() { return r0; }
const Register HasPropertyDescriptor::KeyRegister() { return r3; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -13,6 +13,14 @@ namespace internal { ...@@ -13,6 +13,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {x0, x1, x2, x3, x4};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return x1; } const Register LoadDescriptor::ReceiverRegister() { return x1; }
const Register LoadDescriptor::NameRegister() { return x2; } const Register LoadDescriptor::NameRegister() { return x2; }
...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() { return x12; } ...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() { return x12; }
const Register GrowArrayElementsDescriptor::ObjectRegister() { return x0; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return x0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return x3; } const Register GrowArrayElementsDescriptor::KeyRegister() { return x3; }
const Register HasPropertyDescriptor::ObjectRegister() { return x0; }
const Register HasPropertyDescriptor::KeyRegister() { return x3; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return esi; } const Register CallInterfaceDescriptor::ContextRegister() { return esi; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {eax, ebx, ecx, edx, edi};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return edx; } const Register LoadDescriptor::ReceiverRegister() { return edx; }
const Register LoadDescriptor::NameRegister() { return ecx; } const Register LoadDescriptor::NameRegister() { return ecx; }
...@@ -68,8 +76,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -68,8 +76,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; } const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; }
const Register HasPropertyDescriptor::ObjectRegister() { return eax; }
const Register HasPropertyDescriptor::KeyRegister() { return ebx; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -43,9 +43,8 @@ FunctionType* CallInterfaceDescriptor::BuildDefaultFunctionType( ...@@ -43,9 +43,8 @@ FunctionType* CallInterfaceDescriptor::BuildDefaultFunctionType(
return function; return function;
} }
void CallInterfaceDescriptorData::InitializePlatformSpecific( void CallInterfaceDescriptorData::InitializePlatformSpecific(
int register_parameter_count, Register* registers, int register_parameter_count, const Register* registers,
PlatformInterfaceDescriptor* platform_descriptor) { PlatformInterfaceDescriptor* platform_descriptor) {
platform_specific_descriptor_ = platform_descriptor; platform_specific_descriptor_ = platform_descriptor;
register_param_count_ = register_parameter_count; register_param_count_ = register_parameter_count;
...@@ -190,12 +189,6 @@ void TypeConversionDescriptor::InitializePlatformSpecific( ...@@ -190,12 +189,6 @@ void TypeConversionDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void HasPropertyDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {KeyRegister(), ObjectRegister()};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void MathPowTaggedDescriptor::InitializePlatformSpecific( void MathPowTaggedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = {exponent()}; Register registers[] = {exponent()};
......
...@@ -109,7 +109,7 @@ class CallInterfaceDescriptorData { ...@@ -109,7 +109,7 @@ class CallInterfaceDescriptorData {
// and register side by side (eg, RegRep(r1, Representation::Tagged()). // and register side by side (eg, RegRep(r1, Representation::Tagged()).
// The same should go for the CodeStubDescriptor class. // The same should go for the CodeStubDescriptor class.
void InitializePlatformSpecific( void InitializePlatformSpecific(
int register_parameter_count, Register* registers, int register_parameter_count, const Register* registers,
PlatformInterfaceDescriptor* platform_descriptor = NULL); PlatformInterfaceDescriptor* platform_descriptor = NULL);
bool IsInitialized() const { return register_param_count_ >= 0; } bool IsInitialized() const { return register_param_count_ >= 0; }
...@@ -218,6 +218,12 @@ class CallInterfaceDescriptor { ...@@ -218,6 +218,12 @@ class CallInterfaceDescriptor {
} }
} }
// Initializes |data| using the platform dependent default set of registers.
// It is intended to be used for TurboFan stubs when particular set of
// registers does not matter.
static void DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count);
private: private:
const CallInterfaceDescriptorData* data_; const CallInterfaceDescriptorData* data_;
}; };
...@@ -229,6 +235,17 @@ class CallInterfaceDescriptor { ...@@ -229,6 +235,17 @@ class CallInterfaceDescriptor {
} \ } \
static inline CallDescriptors::Key key(); static inline CallDescriptors::Key key();
#define DECLARE_DEFAULT_DESCRIPTOR(name, base, parameter_count) \
DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
protected: \
void InitializePlatformSpecific(CallInterfaceDescriptorData* data) \
override { \
DefaultInitializePlatformSpecific(data, parameter_count); \
} \
name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \
\
public:
#define DECLARE_DESCRIPTOR(name, base) \ #define DECLARE_DESCRIPTOR(name, base) \
DECLARE_DESCRIPTOR_WITH_BASE(name, base) \ DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
protected: \ protected: \
...@@ -424,10 +441,7 @@ class HasPropertyDescriptor final : public CallInterfaceDescriptor { ...@@ -424,10 +441,7 @@ class HasPropertyDescriptor final : public CallInterfaceDescriptor {
public: public:
enum ParameterIndices { kKeyIndex, kObjectIndex }; enum ParameterIndices { kKeyIndex, kObjectIndex };
DECLARE_DESCRIPTOR(HasPropertyDescriptor, CallInterfaceDescriptor) DECLARE_DEFAULT_DESCRIPTOR(HasPropertyDescriptor, CallInterfaceDescriptor, 2)
static const Register KeyRegister();
static const Register ObjectRegister();
}; };
class TypeofDescriptor : public CallInterfaceDescriptor { class TypeofDescriptor : public CallInterfaceDescriptor {
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {a0, a1, a2, a3, t0};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return a1; } const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; } const Register LoadDescriptor::NameRegister() { return a2; }
...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
const Register HasPropertyDescriptor::ObjectRegister() { return a0; }
const Register HasPropertyDescriptor::KeyRegister() { return a3; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {a0, a1, a2, a3, a4};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return a1; } const Register LoadDescriptor::ReceiverRegister() { return a1; }
const Register LoadDescriptor::NameRegister() { return a2; } const Register LoadDescriptor::NameRegister() { return a2; }
...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return a0; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; } const Register GrowArrayElementsDescriptor::KeyRegister() { return a3; }
const Register HasPropertyDescriptor::ObjectRegister() { return a0; }
const Register HasPropertyDescriptor::KeyRegister() { return a3; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {r3, r4, r5, r6, r7};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return r4; } const Register LoadDescriptor::ReceiverRegister() { return r4; }
const Register LoadDescriptor::NameRegister() { return r5; } const Register LoadDescriptor::NameRegister() { return r5; }
......
...@@ -11,6 +11,15 @@ namespace internal { ...@@ -11,6 +11,15 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; } const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {r2, r3, r4, r5, r6};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return r3; } const Register LoadDescriptor::ReceiverRegister() { return r3; }
const Register LoadDescriptor::NameRegister() { return r4; } const Register LoadDescriptor::NameRegister() { return r4; }
const Register LoadDescriptor::SlotRegister() { return r2; } const Register LoadDescriptor::SlotRegister() { return r2; }
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return rsi; } const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {rax, rbx, rcx, rdx, rdi};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return rdx; } const Register LoadDescriptor::ReceiverRegister() { return rdx; }
const Register LoadDescriptor::NameRegister() { return rcx; } const Register LoadDescriptor::NameRegister() { return rcx; }
...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -63,8 +71,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; } const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
const Register HasPropertyDescriptor::ObjectRegister() { return rax; }
const Register HasPropertyDescriptor::KeyRegister() { return rbx; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
...@@ -11,6 +11,14 @@ namespace internal { ...@@ -11,6 +11,14 @@ namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return esi; } const Register CallInterfaceDescriptor::ContextRegister() { return esi; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {eax, ebx, ecx, edx, edi};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register LoadDescriptor::ReceiverRegister() { return edx; } const Register LoadDescriptor::ReceiverRegister() { return edx; }
const Register LoadDescriptor::NameRegister() { return ecx; } const Register LoadDescriptor::NameRegister() { return ecx; }
...@@ -68,8 +76,6 @@ const Register MathPowIntegerDescriptor::exponent() { ...@@ -68,8 +76,6 @@ const Register MathPowIntegerDescriptor::exponent() {
const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; } const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; } const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; }
const Register HasPropertyDescriptor::ObjectRegister() { return eax; }
const Register HasPropertyDescriptor::KeyRegister() { return ebx; }
void FastNewClosureDescriptor::InitializePlatformSpecific( void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
......
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