Cleanup CallInterfaceDescriptor

Make CallInterfaceDescriptor work like CodeStubInterfaceDescriptor, owning it's
register and representation arrays. This also eliminates a host of TSAN warnings
for static arrays.

This CL depends on https://codereview.chromium.org/352583002 landing first
(a conceptual dependency at least).

R=svenpanne@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22014 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mvstanton@chromium.org 2014-06-25 12:52:58 +00:00
parent 7e9fc63d66
commit 8f905ee9fd
9 changed files with 155 additions and 157 deletions

View File

@ -311,87 +311,77 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
static Register registers[] = { r1, // JSFunction
cp, // context
r0, // actual number of arguments
r2, // expected number of arguments
Register registers[] = { r1, // JSFunction
cp, // context
r0, // actual number of arguments
r2, // expected number of arguments
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // JSFunction
Representation::Tagged(), // context
Representation::Integer32(), // actual number of arguments
Representation::Integer32(), // expected number of arguments
};
descriptor->register_param_count_ = 4;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::KeyedCall);
static Register registers[] = { cp, // context
r2, // key
Register registers[] = { cp, // context
r2, // key
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // key
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &noInlineDescriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::NamedCall);
static Register registers[] = { cp, // context
r2, // name
Register registers[] = { cp, // context
r2, // name
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // name
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &noInlineDescriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::CallHandler);
static Register registers[] = { cp, // context
r0, // receiver
Register registers[] = { cp, // context
r0, // receiver
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ApiFunctionCall);
static Register registers[] = { r0, // callee
r4, // call_data
r2, // holder
r1, // api_function_address
cp, // context
Register registers[] = { r0, // callee
r4, // call_data
r2, // holder
r1, // api_function_address
cp, // context
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // callee
Representation::Tagged(), // call_data
Representation::Tagged(), // holder
Representation::External(), // api_function_address
Representation::Tagged(), // context
};
descriptor->register_param_count_ = 5;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
}

View File

@ -404,7 +404,8 @@ class NameDictionaryLookupStub: public PlatformCodeStub {
};
struct PlatformCallInterfaceDescriptor {
class PlatformCallInterfaceDescriptor {
public:
explicit PlatformCallInterfaceDescriptor(
TargetAddressStorageMode storage_mode)
: storage_mode_(storage_mode) { }

View File

@ -347,87 +347,77 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
static Register registers[] = { x1, // JSFunction
cp, // context
x0, // actual number of arguments
x2, // expected number of arguments
Register registers[] = { x1, // JSFunction
cp, // context
x0, // actual number of arguments
x2, // expected number of arguments
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // JSFunction
Representation::Tagged(), // context
Representation::Integer32(), // actual number of arguments
Representation::Integer32(), // expected number of arguments
};
descriptor->register_param_count_ = 4;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::KeyedCall);
static Register registers[] = { cp, // context
x2, // key
Register registers[] = { cp, // context
x2, // key
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // key
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &noInlineDescriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::NamedCall);
static Register registers[] = { cp, // context
x2, // name
Register registers[] = { cp, // context
x2, // name
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // name
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &noInlineDescriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::CallHandler);
static Register registers[] = { cp, // context
x0, // receiver
Register registers[] = { cp, // context
x0, // receiver
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ApiFunctionCall);
static Register registers[] = { x0, // callee
x4, // call_data
x2, // holder
x1, // api_function_address
cp, // context
Register registers[] = { x0, // callee
x4, // call_data
x2, // holder
x1, // api_function_address
cp, // context
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // callee
Representation::Tagged(), // call_data
Representation::Tagged(), // holder
Representation::External(), // api_function_address
Representation::Tagged(), // context
};
descriptor->register_param_count_ = 5;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->platform_specific_descriptor_ = &default_descriptor;
descriptor->Initialize(ARRAY_SIZE(registers), registers,
representations, &default_descriptor);
}
}

View File

@ -461,7 +461,8 @@ class StringCompareStub: public PlatformCodeStub {
};
struct PlatformCallInterfaceDescriptor {
class PlatformCallInterfaceDescriptor {
public:
explicit PlatformCallInterfaceDescriptor(
TargetAddressStorageMode storage_mode)
: storage_mode_(storage_mode) { }

View File

@ -77,6 +77,29 @@ void CodeStubInterfaceDescriptor::Initialize(
}
void CallInterfaceDescriptor::Initialize(
int register_parameter_count,
Register* registers,
Representation* param_representations,
PlatformCallInterfaceDescriptor* platform_descriptor) {
// CallInterfaceDescriptor owns a copy of the registers array.
register_param_count_ = register_parameter_count;
register_params_.Reset(NewArray<Register>(register_parameter_count));
for (int i = 0; i < register_parameter_count; i++) {
register_params_[i] = registers[i];
}
// Also the register parameter representations.
param_representations_.Reset(
NewArray<Representation>(register_parameter_count));
for (int i = 0; i < register_parameter_count; i++) {
param_representations_[i] = param_representations[i];
}
platform_specific_descriptor_ = platform_descriptor;
}
bool CodeStub::FindCodeInCache(Code** code_out) {
UnseededNumberDictionary* stubs = isolate()->heap()->code_stubs();
int index = stubs->FindEntry(GetKey());

View File

@ -367,16 +367,28 @@ class CodeStubInterfaceDescriptor {
};
struct PlatformCallInterfaceDescriptor;
class PlatformCallInterfaceDescriptor;
struct CallInterfaceDescriptor {
class CallInterfaceDescriptor {
public:
CallInterfaceDescriptor()
: register_param_count_(-1),
register_params_(NULL),
param_representations_(NULL),
platform_specific_descriptor_(NULL) { }
// A copy of the passed in registers and param_representations is made
// and owned by the CallInterfaceDescriptor.
// TODO(mvstanton): Instead of taking parallel arrays register and
// param_representations, how about a struct that puts the representation
// and register side by side (eg, RegRep(r1, Representation::Tagged()).
// The same should go for the CodeStubInterfaceDescriptor class.
void Initialize(int register_parameter_count, Register* registers,
Representation* param_representations,
PlatformCallInterfaceDescriptor* platform_descriptor = NULL);
bool initialized() const { return register_param_count_ >= 0; }
int environment_length() const {
@ -395,9 +407,10 @@ struct CallInterfaceDescriptor {
return platform_specific_descriptor_;
}
private:
int register_param_count_;
Register* register_params_;
Representation* param_representations_;
SmartArrayPointer<Register> register_params_;
SmartArrayPointer<Representation> param_representations_;
PlatformCallInterfaceDescriptor* platform_specific_descriptor_;
};

View File

@ -310,82 +310,72 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
static Register registers[] = { edi, // JSFunction
esi, // context
eax, // actual number of arguments
ebx, // expected number of arguments
Register registers[] = { edi, // JSFunction
esi, // context
eax, // actual number of arguments
ebx, // expected number of arguments
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // JSFunction
Representation::Tagged(), // context
Representation::Integer32(), // actual number of arguments
Representation::Integer32(), // expected number of arguments
};
descriptor->register_param_count_ = 4;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::KeyedCall);
static Register registers[] = { esi, // context
ecx, // key
Register registers[] = { esi, // context
ecx, // key
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // key
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::NamedCall);
static Register registers[] = { esi, // context
ecx, // name
Register registers[] = { esi, // context
ecx, // name
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // name
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::CallHandler);
static Register registers[] = { esi, // context
edx, // receiver
Register registers[] = { esi, // context
edx, // receiver
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ApiFunctionCall);
static Register registers[] = { eax, // callee
ebx, // call_data
ecx, // holder
edx, // api_function_address
esi, // context
Register registers[] = { eax, // callee
ebx, // call_data
ecx, // holder
edx, // api_function_address
esi, // context
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // callee
Representation::Tagged(), // call_data
Representation::Tagged(), // holder
Representation::External(), // api_function_address
Representation::Tagged(), // context
};
descriptor->register_param_count_ = 5;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
}

View File

@ -28,7 +28,7 @@ namespace v8 {
namespace internal {
class Bootstrapper;
struct CallInterfaceDescriptor;
class CallInterfaceDescriptor;
class CodeGenerator;
class CodeRange;
class CodeStubInterfaceDescriptor;

View File

@ -306,82 +306,72 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
static Register registers[] = { rdi, // JSFunction
rsi, // context
rax, // actual number of arguments
rbx, // expected number of arguments
Register registers[] = { rdi, // JSFunction
rsi, // context
rax, // actual number of arguments
rbx, // expected number of arguments
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // JSFunction
Representation::Tagged(), // context
Representation::Integer32(), // actual number of arguments
Representation::Integer32(), // expected number of arguments
};
descriptor->register_param_count_ = 4;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::KeyedCall);
static Register registers[] = { rsi, // context
rcx, // key
Register registers[] = { rsi, // context
rcx, // key
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // key
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::NamedCall);
static Register registers[] = { rsi, // context
rcx, // name
Register registers[] = { rsi, // context
rcx, // name
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // name
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::CallHandler);
static Register registers[] = { rsi, // context
rdx, // receiver
Register registers[] = { rsi, // context
rdx, // receiver
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // context
Representation::Tagged(), // receiver
};
descriptor->register_param_count_ = 2;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
{
CallInterfaceDescriptor* descriptor =
isolate->call_descriptor(Isolate::ApiFunctionCall);
static Register registers[] = { rax, // callee
rbx, // call_data
rcx, // holder
rdx, // api_function_address
rsi, // context
Register registers[] = { rax, // callee
rbx, // call_data
rcx, // holder
rdx, // api_function_address
rsi, // context
};
static Representation representations[] = {
Representation representations[] = {
Representation::Tagged(), // callee
Representation::Tagged(), // call_data
Representation::Tagged(), // holder
Representation::External(), // api_function_address
Representation::Tagged(), // context
};
descriptor->register_param_count_ = 5;
descriptor->register_params_ = registers;
descriptor->param_representations_ = representations;
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
}
}