From: danno@chromium.org Date: Wed, 5 Dec 2012 16:16:32 +0000 (+0000) Subject: Fix isolate bug introduced by generated code stubs X-Git-Tag: upstream/4.7.83~15492 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84f2454eac88f3e98600bcc2723a7054820b48ae;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 800c0f132..a571f9f7c 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -37,20 +37,14 @@ namespace v8 { namespace internal { -CodeStubInterfaceDescriptor* - KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { - static CodeStubInterfaceDescriptor* result = NULL; - if (result == NULL) { - Handle 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(); } diff --git a/src/arm/deoptimizer-arm.cc b/src/arm/deoptimizer-arm.cc index 8db156d03..84acba287 100644 --- a/src/arm/deoptimizer-arm.cc +++ b/src/arm/deoptimizer-arm.cc @@ -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 miss_ic(descriptor->deoptimization_handler); + isolate_->code_stub_interface_descriptor(major_key); + Handle miss_ic(descriptor->deoptimization_handler_); output_frame->SetPc(reinterpret_cast(miss_ic->instruction_start())); unsigned input_frame_size = input_->GetFrameSize(); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 921489e7c..f44ca98aa 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -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); } } diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index da9ec6a14..74bd93f88 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -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); diff --git a/src/code-stubs.h b/src/code-stubs.h index c6e328c43..527abde95 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -242,9 +242,12 @@ class PlatformCodeStub : public CodeStub { struct CodeStubInterfaceDescriptor { - int number_of_register_params; - Register* register_params; - Handle deoptimization_handler; + CodeStubInterfaceDescriptor() + : register_param_count_(-1), + register_params_(NULL) { } + int register_param_count_; + Register* register_params_; + Handle 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 CodeFromGraph(HGraph* graph); @@ -1084,8 +1092,9 @@ class KeyedLoadFastElementStub : public HydrogenCodeStub { virtual Handle GenerateCode(); - virtual CodeStubInterfaceDescriptor* GetInterfaceDescriptor( - Isolate* isolate); + virtual void InitializeInterfaceDescriptor( + Isolate* isolate, + CodeStubInterfaceDescriptor* descriptor); private: class IsJSArrayBits: public BitField {}; diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 8ddc9343f..23dfc24b6 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -41,20 +41,14 @@ namespace v8 { namespace internal { -CodeStubInterfaceDescriptor* - KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { - static CodeStubInterfaceDescriptor* result = NULL; - if (result == NULL) { - Handle 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(); } diff --git a/src/ia32/deoptimizer-ia32.cc b/src/ia32/deoptimizer-ia32.cc index bdbaec1f1..1fbdbfd9a 100644 --- a/src/ia32/deoptimizer-ia32.cc +++ b/src/ia32/deoptimizer-ia32.cc @@ -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 miss_ic(descriptor->deoptimization_handler); + isolate_->code_stub_interface_descriptor(major_key); + Handle miss_ic(descriptor->deoptimization_handler_); output_frame->SetPc(reinterpret_cast(miss_ic->instruction_start())); unsigned input_frame_size = input_->GetFrameSize(); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 63afef6c1..fd9cc9472 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -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); } } diff --git a/src/isolate.cc b/src/isolate.cc index 2d6bc47b3..d09625c40 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -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##_); diff --git a/src/isolate.h b/src/isolate.h index e617179fb..6bbe5eb52 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -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 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. diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 2c39a0c80..f95036840 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -37,20 +37,14 @@ namespace v8 { namespace internal { -CodeStubInterfaceDescriptor* - KeyedLoadFastElementStub::GetInterfaceDescriptor(Isolate* isolate) { - static CodeStubInterfaceDescriptor* result = NULL; - if (result == NULL) { - Handle 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(); } diff --git a/src/x64/deoptimizer-x64.cc b/src/x64/deoptimizer-x64.cc index 2cdd3f0d2..20f507bdf 100644 --- a/src/x64/deoptimizer-x64.cc +++ b/src/x64/deoptimizer-x64.cc @@ -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 miss_ic(descriptor->deoptimization_handler); + isolate_->code_stub_interface_descriptor(major_key); + Handle miss_ic(descriptor->deoptimization_handler_); output_frame->SetPc(reinterpret_cast(miss_ic->instruction_start())); unsigned input_frame_size = input_->GetFrameSize(); intptr_t value = input_->GetFrameSlot(input_frame_size - kPointerSize); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 919d0747e..c9c99de12 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -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); } }