Commit 84f2454e authored by danno@chromium.org's avatar danno@chromium.org

Fix isolate bug introduced by generated code stubs

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13145 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c75ca450
......@@ -37,20 +37,14 @@ namespace v8 {
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();
}
......
......@@ -493,8 +493,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
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);
......
......@@ -2213,7 +2213,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
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);
}
}
......
......@@ -78,18 +78,16 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
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);
......
......@@ -242,9 +242,12 @@ class PlatformCodeStub : public CodeStub {
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_;
};
......@@ -257,8 +260,13 @@ class HydrogenCodeStub : public CodeStub {
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);
......@@ -1084,8 +1092,9 @@ class KeyedLoadFastElementStub : public HydrogenCodeStub {
virtual Handle<Code> GenerateCode();
virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor(
Isolate* isolate);
virtual void InitializeInterfaceDescriptor(
Isolate* isolate,
CodeStubInterfaceDescriptor* descriptor);
private:
class IsJSArrayBits: public BitField<bool, 8, 1> {};
......
......@@ -41,20 +41,14 @@ namespace v8 {
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();
}
......
......@@ -601,8 +601,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
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);
......
......@@ -2284,7 +2284,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
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);
}
}
......
......@@ -1965,7 +1965,7 @@ bool Isolate::Init(Deserializer* des) {
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);
......@@ -2194,6 +2194,12 @@ void Isolate::UnlinkDeferredHandles(DeferredHandles* deferred) {
}
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##_);
......
......@@ -1060,9 +1060,8 @@ class Isolate {
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);
......@@ -1246,7 +1245,7 @@ class Isolate {
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.
......
......@@ -37,20 +37,14 @@ namespace v8 {
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();
}
......
......@@ -491,8 +491,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
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);
......
......@@ -2142,7 +2142,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
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);
}
}
......
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