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 { ...@@ -37,20 +37,14 @@ namespace v8 {
namespace internal { namespace internal {
CodeStubInterfaceDescriptor* void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { Isolate* isolate,
static CodeStubInterfaceDescriptor* result = NULL; CodeStubInterfaceDescriptor* descriptor) {
if (result == NULL) { static Register registers[] = { r1, r0 };
Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss(); descriptor->register_param_count_ = 2;
static Register registers[] = { r1, r0 }; descriptor->register_params_ = registers;
static CodeStubInterfaceDescriptor info = { descriptor->deoptimization_handler_ =
2, isolate->builtins()->KeyedLoadIC_Miss();
registers,
miss
};
result = &info;
}
return result;
} }
......
...@@ -493,8 +493,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, ...@@ -493,8 +493,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key(); int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptors()[major_key]; isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler); Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start())); output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
......
...@@ -2213,7 +2213,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { ...@@ -2213,7 +2213,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
ASSERT(info()->IsStub()); ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
Register reg = descriptor->register_params[instr->index()]; Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg); return DefineFixed(result, reg);
} }
} }
......
...@@ -78,18 +78,16 @@ bool CodeStubGraphBuilderBase::BuildGraph() { ...@@ -78,18 +78,16 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
set_current_block(next_block); set_current_block(next_block);
int major_key = stub()->MajorKey(); int major_key = stub()->MajorKey();
CodeStubInterfaceDescriptor** descriptors = CodeStubInterfaceDescriptor* descriptor =
info_.isolate()->code_stub_interface_descriptors(); info_.isolate()->code_stub_interface_descriptor(major_key);
if (descriptors[major_key] == NULL) { if (descriptor->register_param_count_ < 0) {
descriptors[major_key] = stub()->GetInterfaceDescriptor(info_.isolate()); stub()->InitializeInterfaceDescriptor(info_.isolate(), descriptor);
} }
parameters_.Reset(new HParameter*[descriptor->register_param_count_]);
CodeStubInterfaceDescriptor* descriptor = descriptors[major_key];
parameters_.Reset(new HParameter*[descriptor->number_of_register_params]);
HGraph* graph = this->graph(); HGraph* graph = this->graph();
Zone* zone = this->zone(); 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); HParameter* param = new(zone) HParameter(i);
AddInstruction(param); AddInstruction(param);
graph->start_environment()->Push(param); graph->start_environment()->Push(param);
......
...@@ -242,9 +242,12 @@ class PlatformCodeStub : public CodeStub { ...@@ -242,9 +242,12 @@ class PlatformCodeStub : public CodeStub {
struct CodeStubInterfaceDescriptor { struct CodeStubInterfaceDescriptor {
int number_of_register_params; CodeStubInterfaceDescriptor()
Register* register_params; : register_param_count_(-1),
Handle<Code> deoptimization_handler; register_params_(NULL) { }
int register_param_count_;
Register* register_params_;
Handle<Code> deoptimization_handler_;
}; };
...@@ -257,8 +260,13 @@ class HydrogenCodeStub : public CodeStub { ...@@ -257,8 +260,13 @@ class HydrogenCodeStub : public CodeStub {
virtual int GetCodeKind() { return Code::COMPILED_STUB; } virtual int GetCodeKind() { return Code::COMPILED_STUB; }
virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor( CodeStubInterfaceDescriptor* GetInterfaceDescriptor(Isolate* isolate) {
Isolate* isolate) = 0; return isolate->code_stub_interface_descriptor(MajorKey());
}
virtual void InitializeInterfaceDescriptor(
Isolate* isolate,
CodeStubInterfaceDescriptor* descriptor) = 0;
protected: protected:
Handle<Code> CodeFromGraph(HGraph* graph); Handle<Code> CodeFromGraph(HGraph* graph);
...@@ -1084,8 +1092,9 @@ class KeyedLoadFastElementStub : public HydrogenCodeStub { ...@@ -1084,8 +1092,9 @@ class KeyedLoadFastElementStub : public HydrogenCodeStub {
virtual Handle<Code> GenerateCode(); virtual Handle<Code> GenerateCode();
virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor( virtual void InitializeInterfaceDescriptor(
Isolate* isolate); Isolate* isolate,
CodeStubInterfaceDescriptor* descriptor);
private: private:
class IsJSArrayBits: public BitField<bool, 8, 1> {}; class IsJSArrayBits: public BitField<bool, 8, 1> {};
......
...@@ -41,20 +41,14 @@ namespace v8 { ...@@ -41,20 +41,14 @@ namespace v8 {
namespace internal { namespace internal {
CodeStubInterfaceDescriptor* void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { Isolate* isolate,
static CodeStubInterfaceDescriptor* result = NULL; CodeStubInterfaceDescriptor* descriptor) {
if (result == NULL) { static Register registers[] = { edx, ecx };
Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss(); descriptor->register_param_count_ = 2;
static Register registers[] = { edx, ecx }; descriptor->register_params_ = registers;
static CodeStubInterfaceDescriptor info = { descriptor->deoptimization_handler_ =
2, isolate->builtins()->KeyedLoadIC_Miss();
registers,
miss
};
result = &info;
}
return result;
} }
......
...@@ -601,8 +601,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, ...@@ -601,8 +601,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key(); int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptors()[major_key]; isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler); Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start())); output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
......
...@@ -2284,7 +2284,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { ...@@ -2284,7 +2284,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
ASSERT(info()->IsStub()); ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
Register reg = descriptor->register_params[instr->index()]; Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg); return DefineFixed(result, reg);
} }
} }
......
...@@ -1965,7 +1965,7 @@ bool Isolate::Init(Deserializer* des) { ...@@ -1965,7 +1965,7 @@ bool Isolate::Init(Deserializer* des) {
regexp_stack_->isolate_ = this; regexp_stack_->isolate_ = this;
date_cache_ = new DateCache(); date_cache_ = new DateCache();
code_stub_interface_descriptors_ = code_stub_interface_descriptors_ =
new CodeStubInterfaceDescriptor*[CodeStub::NUMBER_OF_IDS]; new CodeStubInterfaceDescriptor[CodeStub::NUMBER_OF_IDS];
memset(code_stub_interface_descriptors_, 0, memset(code_stub_interface_descriptors_, 0,
kPointerSize * CodeStub::NUMBER_OF_IDS); kPointerSize * CodeStub::NUMBER_OF_IDS);
...@@ -2194,6 +2194,12 @@ void Isolate::UnlinkDeferredHandles(DeferredHandles* deferred) { ...@@ -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 #ifdef DEBUG
#define ISOLATE_FIELD_OFFSET(type, name, ignored) \ #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
......
...@@ -1060,9 +1060,8 @@ class Isolate { ...@@ -1060,9 +1060,8 @@ class Isolate {
date_cache_ = date_cache; date_cache_ = date_cache;
} }
CodeStubInterfaceDescriptor** code_stub_interface_descriptors() { CodeStubInterfaceDescriptor*
return code_stub_interface_descriptors_; code_stub_interface_descriptor(int index);
}
void IterateDeferredHandles(ObjectVisitor* visitor); void IterateDeferredHandles(ObjectVisitor* visitor);
void LinkDeferredHandles(DeferredHandles* deferred_handles); void LinkDeferredHandles(DeferredHandles* deferred_handles);
...@@ -1246,7 +1245,7 @@ class Isolate { ...@@ -1246,7 +1245,7 @@ class Isolate {
RegExpStack* regexp_stack_; RegExpStack* regexp_stack_;
DateCache* date_cache_; DateCache* date_cache_;
unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_; 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 // The garbage collector should be a little more aggressive when it knows
// that a context was recently exited. // that a context was recently exited.
......
...@@ -37,20 +37,14 @@ namespace v8 { ...@@ -37,20 +37,14 @@ namespace v8 {
namespace internal { namespace internal {
CodeStubInterfaceDescriptor* void KeyedLoadFastElementStub::InitializeInterfaceDescriptor(
KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { Isolate* isolate,
static CodeStubInterfaceDescriptor* result = NULL; CodeStubInterfaceDescriptor* descriptor) {
if (result == NULL) { static Register registers[] = { rdx, rax };
Handle<Code> miss = isolate->builtins()->KeyedLoadIC_Miss(); descriptor->register_param_count_ = 2;
static Register registers[] = { rdx, rax }; descriptor->register_params_ = registers;
static CodeStubInterfaceDescriptor info = { descriptor->deoptimization_handler_ =
2, isolate->builtins()->KeyedLoadIC_Miss();
registers,
miss
};
result = &info;
}
return result;
} }
......
...@@ -491,8 +491,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator, ...@@ -491,8 +491,8 @@ void Deoptimizer::DoCompiledStubFrame(TranslationIterator* iterator,
ASSERT(compiled_code_->kind() == Code::COMPILED_STUB); ASSERT(compiled_code_->kind() == Code::COMPILED_STUB);
int major_key = compiled_code_->major_key(); int major_key = compiled_code_->major_key();
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
isolate_->code_stub_interface_descriptors()[major_key]; isolate_->code_stub_interface_descriptor(major_key);
Handle<Code> miss_ic(descriptor->deoptimization_handler); Handle<Code> miss_ic(descriptor->deoptimization_handler_);
output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start())); output_frame->SetPc(reinterpret_cast<intptr_t>(miss_ic->instruction_start()));
unsigned input_frame_size = input_->GetFrameSize(); unsigned input_frame_size = input_->GetFrameSize();
intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize);
......
...@@ -2142,7 +2142,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { ...@@ -2142,7 +2142,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
ASSERT(info()->IsStub()); ASSERT(info()->IsStub());
CodeStubInterfaceDescriptor* descriptor = CodeStubInterfaceDescriptor* descriptor =
info()->code_stub()->GetInterfaceDescriptor(info()->isolate()); info()->code_stub()->GetInterfaceDescriptor(info()->isolate());
Register reg = descriptor->register_params[instr->index()]; Register reg = descriptor->register_params_[instr->index()];
return DefineFixed(result, reg); 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