namespace internal {
-CodeStubInterfaceDescriptor*
- KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) {
- static CodeStubInterfaceDescriptor* result = NULL;
- if (result == NULL) {
- Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss();
- static Register registers[] = { r1, r0 };
- static CodeStubInterfaceDescriptor info = {
- 2,
- registers,
- miss
- };
- result = &info;
- }
- return result;
+void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor) {
+ static Register registers[] = { r1, r0 };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->deoptimization_handler_ =
+ isolate->builtins()->KeyedLoadIC_Miss();
}
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
- isolate_->code_stub_interface_descriptors()[major_key];
- Handle<Code> miss_ic(descriptor->deoptimization_handler);
+ isolate_->code_stub_interface_descriptor(major_key);
+ Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
- Register reg = descriptor->register_params[instr->index()];
+ Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg);
}
}
set_current_block(next_block);
int major_key = stub()->MajorKey();
- CodeStubInterfaceDescriptor** descriptors =
- info_.isolate()->code_stub_interface_descriptors();
- if (descriptors[major_key] == NULL) {
- descriptors[major_key] = stub()->GetInterfaceDescriptor(info_.isolate());
+ CodeStubInterfaceDescriptor* descriptor =
+ info_.isolate()->code_stub_interface_descriptor(major_key);
+ if (descriptor->register_param_count_ < 0) {
+ stub()->InitializeInterfaceDescriptor(info_.isolate(), descriptor);
}
-
- CodeStubInterfaceDescriptor* descriptor = descriptors[major_key];
- parameters_.Reset(new HParameter*[descriptor->number_of_register_params]);
+ parameters_.Reset(new HParameter*[descriptor->register_param_count_]);
HGraph* graph = this->graph();
Zone* zone = this->zone();
- for (int i = 0; i < descriptor->number_of_register_params; ++i) {
+ for (int i = 0; i < descriptor->register_param_count_; ++i) {
HParameter* param = new(zone) HParameter(i);
AddInstruction(param);
graph->start_environment()->Push(param);
struct CodeStubInterfaceDescriptor {
- int number_of_register_params;
- Register* register_params;
- Handle<Code> deoptimization_handler;
+ CodeStubInterfaceDescriptor()
+ : register_param_count_(-1),
+ register_params_(NULL) { }
+ int register_param_count_;
+ Register* register_params_;
+ Handle<Code> deoptimization_handler_;
};
virtual int GetCodeKind() { return Code::COMPILED_STUB; }
- virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
- Isolate* isolate) = 0;
+ CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) {
+ return isolate->code_stub_interface_descriptor(MajorKey());
+ }
+
+ virtual void InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor) = 0;
protected:
Handle<Code> CodeFromGraph(HGraph* graph);
virtual Handle<Code> GenerateCode();
- virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
- Isolate* isolate);
+ virtual void InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor);
private:
class IsJSArrayBits: public BitField<bool, 8, 1> {};
namespace internal {
-CodeStubInterfaceDescriptor*
- KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) {
- static CodeStubInterfaceDescriptor* result = NULL;
- if (result == NULL) {
- Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss();
- static Register registers[] = { edx, ecx };
- static CodeStubInterfaceDescriptor info = {
- 2,
- registers,
- miss
- };
- result = &info;
- }
- return result;
+void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor) {
+ static Register registers[] = { edx, ecx };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->deoptimization_handler_ =
+ isolate->builtins()->KeyedLoadIC_Miss();
}
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
- isolate_->code_stub_interface_descriptors()[major_key];
- Handle<Code> miss_ic(descriptor->deoptimization_handler);
+ isolate_->code_stub_interface_descriptor(major_key);
+ Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
- Register reg = descriptor->register_params[instr->index()];
+ Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg);
}
}
regexp_stack_->isolate_ = this;
date_cache_ = new DateCache();
code_stub_interface_descriptors_ =
- new CodeStubInterfaceDescriptor*[CodeStub::NUMBER_OF_IDS];
+ new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS];
memset(code_stub_interface_descriptors_, 0,
kPointerSize * CodeStub::NUMBER_OF_IDS);
}
+CodeStubInterfaceDescriptor*
+ Isolate::code_stub_interface_descriptor(int index) {
+ return code_stub_interface_descriptors_ + index;
+}
+
+
#ifdef DEBUG
#define ISOLATE_FIELD_OFFSET(type, name, ignored) \
const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
date_cache_ = date_cache;
}
- CodeStubInterfaceDescriptor** code_stub_interface_descriptors() {
- return code_stub_interface_descriptors_;
- }
+ CodeStubInterfaceDescriptor*
+ code_stub_interface_descriptor(int index);
void IterateDeferredHandles(ObjectVisitor* visitor);
void LinkDeferredHandles(DeferredHandles* deferred_handles);
RegExpStack* regexp_stack_;
DateCache* date_cache_;
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
- CodeStubInterfaceDescriptor** code_stub_interface_descriptors_;
+ CodeStubInterfaceDescriptor* code_stub_interface_descriptors_;
// The garbage collector should be a little more aggressive when it knows
// that a context was recently exited.
namespace internal {
-CodeStubInterfaceDescriptor*
- KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) {
- static CodeStubInterfaceDescriptor* result = NULL;
- if (result == NULL) {
- Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss();
- static Register registers[] = { rdx, rax };
- static CodeStubInterfaceDescriptor info = {
- 2,
- registers,
- miss
- };
- result = &info;
- }
- return result;
+void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
+ Isolate* isolate,
+ CodeStubInterfaceDescriptor* descriptor) {
+ static Register registers[] = { rdx, rax };
+ descriptor->register_param_count_ = 2;
+ descriptor->register_params_ = registers;
+ descriptor->deoptimization_handler_ =
+ isolate->builtins()->KeyedLoadIC_Miss();
}
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor =
- isolate_->code_stub_interface_descriptors()[major_key];
- Handle<Code> miss_ic(descriptor->deoptimization_handler);
+ isolate_->code_stub_interface_descriptor(major_key);
+ Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
- Register reg = descriptor->register_params[instr->index()];
+ Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg);
}
}