Revision: 9459
Author:   [email protected]
Date:     Wed Sep 28 03:32:12 2011
Log:      Make sure we don't flush the pregenerated stubs, since they need
to be always present, so that we can call them from other stubs
without trying to generate stubs while we are generating stubs.
Review URL: http://codereview.chromium.org/8052029
http://code.google.com/p/v8/source/detail?r=9459

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/stub-cache.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Sep 27 04:42:02 2011 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Sep 28 03:32:12 2011
@@ -877,8 +877,8 @@
 void WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime() {
   WriteInt32ToHeapNumberStub stub1(r1, r0, r2);
   WriteInt32ToHeapNumberStub stub2(r2, r0, r3);
-  Handle<Code> code1 = stub1.GetCode();
-  Handle<Code> code2 = stub2.GetCode();
+  Handle<Code> code1 = stub1.GetCode()->set_is_pregenerated(true);
+  Handle<Code> code2 = stub2.GetCode()->set_is_pregenerated(true);
 }


@@ -3413,7 +3413,7 @@

 void CodeStub::GenerateFPStubs() {
   CEntryStub save_doubles(1, kSaveFPRegs);
-  Handle<Code> code = save_doubles.GetCode();
+  Handle<Code> code = save_doubles.GetCode()->set_is_pregenerated(true);
   code->GetIsolate()->set_fp_stubs_generated(true);
 }

@@ -6877,9 +6877,9 @@

 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime() {
   StoreBufferOverflowStub stub1(kDontSaveFPRegs);
-  stub1.GetCode();
+  stub1.GetCode()->set_is_pregenerated(true);
   StoreBufferOverflowStub stub2(kSaveFPRegs);
-  stub2.GetCode();
+  stub2.GetCode()->set_is_pregenerated(true);
 }


@@ -6892,7 +6892,7 @@
                          entry->address,
                          entry->action,
                          kDontSaveFPRegs);
-    stub.GetCode();
+    stub.GetCode()->set_is_pregenerated(true);
   }
 }

=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Sep 27 06:45:13 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Sep 28 03:32:12 2011
@@ -4424,6 +4424,7 @@
 void CodeStub::GenerateFPStubs() {
   CEntryStub save_doubles(1, kSaveFPRegs);
   Handle<Code> code = save_doubles.GetCode();
+  code->set_is_pregenerated(true);
   code->GetIsolate()->set_fp_stubs_generated(true);
 }

@@ -6667,7 +6668,7 @@
   { ebx, eax, edi, EMIT_REMEMBERED_SET },
   // Used in CompileArrayPushCall.
   { ebx, ecx, edx, EMIT_REMEMBERED_SET },
-  // Used in CompileStoreGlobal.
+  // Used in CompileStoreGlobal and CallFunctionStub.
   { ebx, ecx, edx, OMIT_REMEMBERED_SET },
   // Used in StoreStubCompiler::CompileStoreField and
   // KeyedStoreStubCompiler::CompileStoreField via GenerateStoreField.
@@ -6704,12 +6705,12 @@

 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime() {
   StoreBufferOverflowStub stub1(kDontSaveFPRegs);
-  stub1.GetCode();
+  stub1.GetCode()->set_is_pregenerated(true);

   CpuFeatures::TryForceFeatureScope scope(SSE2);
   if (CpuFeatures::IsSupported(SSE2)) {
     StoreBufferOverflowStub stub2(kSaveFPRegs);
-    stub2.GetCode();
+    stub2.GetCode()->set_is_pregenerated(true);
   }
 }

@@ -6723,7 +6724,7 @@
                          entry->address,
                          entry->action,
                          kDontSaveFPRegs);
-    stub.GetCode();
+    stub.GetCode()->set_is_pregenerated(true);
   }
 }

=======================================
--- /branches/bleeding_edge/src/isolate.cc      Tue Sep 20 03:08:39 2011
+++ /branches/bleeding_edge/src/isolate.cc      Wed Sep 28 03:32:12 2011
@@ -1768,7 +1768,7 @@
   // If we are deserializing, read the state into the now-empty heap.
   if (des != NULL) {
     des->Deserialize();
-    stub_cache_->Clear();
+    stub_cache_->Initialize(true);
   }

   // Deserializing may put strange things in the root array's copy of the
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Tue Sep 27 04:42:02 2011
+++ /branches/bleeding_edge/src/objects-inl.h   Wed Sep 28 03:32:12 2011
@@ -2933,6 +2933,19 @@
   ASSERT(0 <= major && major < 256);
   WRITE_BYTE_FIELD(this, kStubMajorKeyOffset, major);
 }
+
+
+bool Code::is_pregenerated() {
+  return kind() == STUB && IsPregeneratedField::decode(flags());
+}
+
+
+void Code::set_is_pregenerated(bool value) {
+  ASSERT(kind() == STUB);
+  Flags f = flags();
+  f = static_cast<Flags>(IsPregeneratedField::update(f, value));
+  set_flags(f);
+}


 bool Code::optimizable() {
=======================================
--- /branches/bleeding_edge/src/objects.h       Tue Sep 27 04:42:02 2011
+++ /branches/bleeding_edge/src/objects.h       Wed Sep 28 03:32:12 2011
@@ -3657,6 +3657,11 @@
   inline int major_key();
   inline void set_major_key(int value);

+  // For stubs, tells whether they should always exist, so that they can be
+  // called from other stubs.
+  inline bool is_pregenerated();
+  inline void set_is_pregenerated(bool value);
+
   // [optimizable]: For FUNCTION kind, tells if it is optimizable.
   inline bool optimizable();
   inline void set_optimizable(bool value);
@@ -3880,6 +3885,7 @@
   class KindField: public BitField<Kind, 7, 4> {};
   class CacheHolderField: public BitField<InlineCacheHolderFlag, 11, 1> {};
   class ExtraICStateField: public BitField<ExtraICState, 12, 2> {};
+  class IsPregeneratedField: public BitField<bool, 14, 1> {};

   // Signed field cannot be encoded using the BitField class.
   static const int kArgumentsCountShift = 14;
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc   Tue Sep 13 05:53:28 2011
+++ /branches/bleeding_edge/src/stub-cache.cc   Wed Sep 28 03:32:12 2011
@@ -55,7 +55,15 @@
   ASSERT(IsPowerOf2(kSecondaryTableSize));
   if (create_heap_objects) {
     HandleScope scope;
-    Clear();
+    Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal);
+    for (int i = 0; i < kPrimaryTableSize; i++) {
+      primary_[i].key = heap()->empty_string();
+      primary_[i].value = empty;
+    }
+    for (int j = 0; j < kSecondaryTableSize; j++) {
+      secondary_[j].key = heap()->empty_string();
+      secondary_[j].value = empty;
+    }
   }
 }

@@ -1099,15 +1107,20 @@


 void StubCache::Clear() {
+  Code* empty = isolate_->builtins()->builtin(Builtins::kIllegal);
   for (int i = 0; i < kPrimaryTableSize; i++) {
-    primary_[i].key = heap()->empty_string();
-    primary_[i].value = isolate_->builtins()->builtin(
-        Builtins::kIllegal);
+    Code* code = primary_[i].value;
+    if (code != empty && !code->is_pregenerated()) {
+      primary_[i].key = heap()->empty_string();
+      primary_[i].value = empty;
+    }
   }
   for (int j = 0; j < kSecondaryTableSize; j++) {
-    secondary_[j].key = heap()->empty_string();
-    secondary_[j].value = isolate_->builtins()->builtin(
-        Builtins::kIllegal);
+    Code* code = secondary_[j].value;
+    if (code != empty && !code->is_pregenerated()) {
+      secondary_[j].key = heap()->empty_string();
+      secondary_[j].value = empty;
+    }
   }
 }

=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Sep 27 04:42:02 2011 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Sep 28 03:32:12 2011
@@ -3376,7 +3376,7 @@

 void CodeStub::GenerateStubsAheadOfTime() {
   CEntryStub save_doubles(1, kSaveFPRegs);
-  save_doubles.GetCode();
+  save_doubles.GetCode()->set_is_pregenerated(true);
   StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime();
// It is important that the store buffer overflow stubs are generated first.
   RecordWriteStub::GenerateFixedRegStubsAheadOfTime();
@@ -5616,9 +5616,9 @@

 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime() {
   StoreBufferOverflowStub stub1(kDontSaveFPRegs);
-  stub1.GetCode();
+  stub1.GetCode()->set_is_pregenerated(true);
   StoreBufferOverflowStub stub2(kSaveFPRegs);
-  stub2.GetCode();
+  stub2.GetCode()->set_is_pregenerated(true);
 }


@@ -5631,7 +5631,7 @@
                          entry->address,
                          entry->action,
                          kDontSaveFPRegs);
-    stub.GetCode();
+    stub.GetCode()->set_is_pregenerated(true);
   }
 }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to