Fix isolate bug introduced by generated code stubs
authordanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 5 Dec 2012 16:16:32 +0000 (16:16 +0000)
committerdanno@chromium.org <danno@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 5 Dec 2012 16:16:32 +0000 (16:16 +0000)
Review URL: https://codereview.chromium.org/11441013

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13145 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

13 files changed:
src/arm/code-stubs-arm.cc
src/arm/deoptimizer-arm.cc
src/arm/lithium-arm.cc
src/code-stubs-hydrogen.cc
src/code-stubs.h
src/ia32/code-stubs-ia32.cc
src/ia32/deoptimizer-ia32.cc
src/ia32/lithium-ia32.cc
src/isolate.cc
src/isolate.h
src/x64/code-stubs-x64.cc
src/x64/deoptimizer-x64.cc
src/x64/lithium-x64.cc

index 800c0f132dab246a27ca5541101c427d12eb1c10..a571f9f7cd1068d1c5989b091b2169af9e7a3533 100644 (file)
@@ -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();
 }
 
 
index 8db156d033fcc3e56ae316764b0687914c426ff4..84acba287340bcb1b79b8f555939251099fbb518 100644 (file)
@@ -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);
index 921489e7cd2607d3016dc97dbc366823b289665d..f44ca98aad059da26ffb7bfeb6aa320d9247e5ca 100644 (file)
@@ -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);
   }
 }
index da9ec6a141138688a1d08193910359f72c34b98e..74bd93f8805b768fbcb9806d2da04f754c80dfff 100644 (file)
@@ -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);
index c6e328c43da9edec8be2492dfec1889da951cb3c..527abde958843aa2bbaa255949b43c0a4316efb8 100644 (file)
@@ -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> {};
index 8ddc9343fc59261c1e1d07e3056c83a91444a237..23dfc24b6e9d3f12897b23ad33fe11751896b7ff 100644 (file)
@@ -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();
 }
 
 
index bdbaec1f10e6d711d981d77a7de225de9381b751..1fbdbfd9a94c882e0e42f81c2be4b476fece7d40 100644 (file)
@@ -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);
index 63afef6c1ee4ff4d26d59032f2266a3a4dc55318..fd9cc947284bf31823cff9f998e3bf5c3642785f 100644 (file)
@@ -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);
   }
 }
index 2d6bc47b38c7caf2fbd9f42a5d2feb03f3f4feef..d09625c401a4a8ad0d27f5faae6cc54616c85b13 100644 (file)
@@ -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##_);
index e617179fbe5ebef87537c397043c0993d860ee4a..6bbe5eb527744e46a64bb791ee8c194e3683253b 100644 (file)
@@ -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.
index 2c39a0c80776e04ca4d7b8e273a7daa624723b5d..f950368404804ada7d78da991bc0b6ca2464a288 100644 (file)
@@ -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();
 }
 
 
index 2cdd3f0d27afb499bd9e8bc34969d5103474cec5..20f507bdfbf65e75bbfec19b5e8fb3939967d0e7 100644 (file)
@@ -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);
index 919d0747ea78f69043231fa2c22df832573b2529..c9c99de1254fa12909cf2b234ef15345e307708c 100644 (file)
@@ -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);
   }
 }