Revision: 9447
Author:   [email protected]
Date:     Tue Sep 27 03:53:22 2011
Log:      Tighten up assertions checking GC-safety of stub calls.

Ensure that stubs are properly pregenerated on all platforms.

[email protected]
BUG=v8:1729

Review URL: http://codereview.chromium.org/8041035
http://code.google.com/p/v8/source/detail?r=9447

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/code-stubs-arm.h
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/code-stubs.h
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.h
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/mips/code-stubs-mips.cc
 /branches/bleeding_edge/src/mips/macro-assembler-mips.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc
 /branches/bleeding_edge/src/x64/code-stubs-x64.h
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Sep 21 07:46:54 2011 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Tue Sep 27 03:53:22 2011
@@ -859,7 +859,7 @@
 }


-bool WriteInt32ToHeapNumberStub::CompilingCallsToThisStubIsGCSafe() {
+bool WriteInt32ToHeapNumberStub::IsPregenerated() {
   // These variants are compiled ahead of time.  See next method.
   if (the_int_.is(r1) && the_heap_number_.is(r0) && scratch_.is(r2)) {
     return true;
@@ -2094,6 +2094,10 @@


 void BinaryOpStub::Generate(MacroAssembler* masm) {
+  // Explicitly allow generation of nested stubs. It is safe here because
+  // generation code does not use any raw pointers.
+  AllowStubCallsScope allow_stub_calls(masm, true);
+
   switch (operands_type_) {
     case BinaryOpIC::UNINITIALIZED:
       GenerateTypeTransition(masm);
@@ -3394,7 +3398,7 @@
 }


-bool CEntryStub::CompilingCallsToThisStubIsGCSafe() {
+bool CEntryStub::IsPregenerated() {
   return (!save_doubles_ || ISOLATE->fp_stubs_generated()) &&
           result_size_ == 1;
 }
@@ -3402,6 +3406,8 @@

 void CodeStub::GenerateStubsAheadOfTime() {
   WriteInt32ToHeapNumberStub::GenerateFixedRegStubsAheadOfTime();
+  StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime();
+  RecordWriteStub::GenerateFixedRegStubsAheadOfTime();
 }


@@ -6837,7 +6843,7 @@
 };


-bool RecordWriteStub::CompilingCallsToThisStubIsGCSafe() {
+bool RecordWriteStub::IsPregenerated() {
   for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
        !entry->object.is(no_reg);
        entry++) {
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.h Mon Sep 19 11:36:47 2011 +++ /branches/bleeding_edge/src/arm/code-stubs-arm.h Tue Sep 27 03:53:22 2011
@@ -65,7 +65,7 @@

   void Generate(MacroAssembler* masm);

-  virtual bool CompilingCallsToThisStubIsGCSafe() { return true; }
+  virtual bool IsPregenerated() { return true; }
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

@@ -342,7 +342,7 @@
         the_heap_number_(the_heap_number),
         scratch_(scratch) { }

-  bool CompilingCallsToThisStubIsGCSafe();
+  bool IsPregenerated();
   static void GenerateFixedRegStubsAheadOfTime();

  private:
@@ -416,7 +416,7 @@
     INCREMENTAL_COMPACTION
   };

-  virtual bool CompilingCallsToThisStubIsGCSafe();
+  virtual bool IsPregenerated();
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Fri Sep 23 02:31:20 2011 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Tue Sep 27 03:53:22 2011
@@ -2003,7 +2003,7 @@


 void MacroAssembler::TailCallStub(CodeStub* stub, Condition cond) {
-  ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_);
+  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
   Jump(stub->GetCode(), RelocInfo::CODE_TARGET, cond);
 }

@@ -2113,7 +2113,7 @@

 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_;
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
 }


=======================================
--- /branches/bleeding_edge/src/code-stubs.h    Mon Sep 19 11:36:47 2011
+++ /branches/bleeding_edge/src/code-stubs.h    Tue Sep 27 03:53:22 2011
@@ -143,9 +143,18 @@
   static const char* MajorName(Major major_key, bool allow_unknown_keys);

   virtual ~CodeStub() {}
+
+  bool CompilingCallsToThisStubIsGCSafe() {
+    bool is_pregenerated = IsPregenerated();
+#ifdef DEBUG
+    Code* code = NULL;
+    ASSERT(!is_pregenerated || FindCodeInCache(&code));
+#endif
+    return is_pregenerated;
+  }

   // See comment above, where Instanceof is defined.
-  virtual bool CompilingCallsToThisStubIsGCSafe() {
+  virtual bool IsPregenerated() {
     return MajorKey() <= Instanceof;
   }

@@ -564,7 +573,7 @@
// time, so it's OK to call it from other stubs that can't cope with GC during // their code generation. On machines that always have gp registers (x64) we
   // can generate both variants ahead of time.
-  virtual bool CompilingCallsToThisStubIsGCSafe();
+  virtual bool IsPregenerated();

  private:
   void GenerateCore(MacroAssembler* masm,
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Sep 20 06:32:27 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Tue Sep 27 03:53:22 2011
@@ -986,6 +986,10 @@


 void BinaryOpStub::Generate(MacroAssembler* masm) {
+  // Explicitly allow generation of nested stubs. It is safe here because
+  // generation code does not use any raw pointers.
+  AllowStubCallsScope allow_stub_calls(masm, true);
+
   switch (operands_type_) {
     case BinaryOpIC::UNINITIALIZED:
       GenerateTypeTransition(masm);
@@ -4333,13 +4337,16 @@
 }


-bool CEntryStub::CompilingCallsToThisStubIsGCSafe() {
+bool CEntryStub::IsPregenerated() {
   return (!save_doubles_ || ISOLATE->fp_stubs_generated()) &&
           result_size_ == 1;
 }


 void CodeStub::GenerateStubsAheadOfTime() {
+  StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime();
+ // It is important that the store buffer overflow stubs are generated first.
+  RecordWriteStub::GenerateFixedRegStubsAheadOfTime();
 }


@@ -6597,7 +6604,7 @@
   // GenerateStoreField calls the stub with two different permutations of
   // registers.  This is the second.
   { ebx, ecx, edx, EMIT_REMEMBERED_SET },
-  // StoreIC::GenerateNormal via GenerateDictionaryStore.
+ // StoreIC::GenerateNormal via GenerateDictionaryStore, CompileArrayPushCall
   { ebx, edi, edx, EMIT_REMEMBERED_SET },
   // KeyedStoreIC::GenerateGeneric.
   { ebx, edx, ecx, EMIT_REMEMBERED_SET},
@@ -6608,7 +6615,7 @@
 };


-bool RecordWriteStub::CompilingCallsToThisStubIsGCSafe() {
+bool RecordWriteStub::IsPregenerated() {
   for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
        !entry->object.is(no_reg);
        entry++) {
@@ -6627,8 +6634,12 @@
 void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime() {
   StoreBufferOverflowStub stub1(kDontSaveFPRegs);
   stub1.GetCode();
-  StoreBufferOverflowStub stub2(kSaveFPRegs);
-  stub2.GetCode();
+
+  CpuFeatures::TryForceFeatureScope scope(SSE2);
+  if (CpuFeatures::IsSupported(SSE2)) {
+    StoreBufferOverflowStub stub2(kSaveFPRegs);
+    stub2.GetCode();
+  }
 }


=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Mon Sep 19 11:36:47 2011 +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.h Tue Sep 27 03:53:22 2011
@@ -67,7 +67,7 @@

   void Generate(MacroAssembler* masm);

-  virtual bool CompilingCallsToThisStubIsGCSafe() { return true; }
+  virtual bool IsPregenerated() { return true; }
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

@@ -495,7 +495,7 @@
     INCREMENTAL_COMPACTION
   };

-  virtual bool CompilingCallsToThisStubIsGCSafe();
+  virtual bool IsPregenerated();
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Thu Sep 22 04:30:04 2011 +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Tue Sep 27 03:53:22 2011
@@ -1510,7 +1510,7 @@


 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_);
+  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
   jmp(stub->GetCode(), RelocInfo::CODE_TARGET);
 }

@@ -1533,7 +1533,7 @@

 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_;
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
 }


=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Tue Sep 20 09:33:03 2011 +++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Tue Sep 27 03:53:22 2011
@@ -3477,7 +3477,7 @@
 }


-bool CEntryStub::CompilingCallsToThisStubIsGCSafe() {
+bool CEntryStub::IsPregenerated() {
   return (!save_doubles_ || ISOLATE->fp_stubs_generated()) &&
           result_size_ == 1;
 }
=======================================
--- /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Thu Sep 22 04:30:04 2011 +++ /branches/bleeding_edge/src/mips/macro-assembler-mips.cc Tue Sep 27 03:53:22 2011
@@ -3575,7 +3575,7 @@


 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_);
+  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
   Jump(stub->GetCode(), RelocInfo::CODE_TARGET);
 }

@@ -3694,7 +3694,7 @@

 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_;
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
 }


=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Sep 20 06:32:27 2011 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Tue Sep 27 03:53:22 2011
@@ -773,6 +773,10 @@


 void BinaryOpStub::Generate(MacroAssembler* masm) {
+  // Explicitly allow generation of nested stubs. It is safe here because
+  // generation code does not use any raw pointers.
+  AllowStubCallsScope allow_stub_calls(masm, true);
+
   switch (operands_type_) {
     case BinaryOpIC::UNINITIALIZED:
       GenerateTypeTransition(masm);
@@ -3349,7 +3353,7 @@
 }


-bool CEntryStub::CompilingCallsToThisStubIsGCSafe() {
+bool CEntryStub::IsPregenerated() {
   return result_size_ == 1;
 }

@@ -5578,7 +5582,7 @@
 };


-bool RecordWriteStub::CompilingCallsToThisStubIsGCSafe() {
+bool RecordWriteStub::IsPregenerated() {
   for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
        !entry->object.is(no_reg);
        entry++) {
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.h Mon Sep 19 11:36:47 2011 +++ /branches/bleeding_edge/src/x64/code-stubs-x64.h Tue Sep 27 03:53:22 2011
@@ -66,7 +66,7 @@

   void Generate(MacroAssembler* masm);

-  virtual bool CompilingCallsToThisStubIsGCSafe() { return true; }
+  virtual bool IsPregenerated() { return true; }
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

@@ -497,7 +497,7 @@
     INCREMENTAL_COMPACTION
   };

-  virtual bool CompilingCallsToThisStubIsGCSafe();
+  virtual bool IsPregenerated();
   static void GenerateFixedRegStubsAheadOfTime();
   virtual bool SometimesSetsUpAFrame() { return false; }

=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Fri Sep 23 07:19:04 2011 +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Tue Sep 27 03:53:22 2011
@@ -508,7 +508,7 @@


 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_);
+  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
   Jump(stub->GetCode(), RelocInfo::CODE_TARGET);
 }

@@ -531,7 +531,7 @@

 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return stub->CompilingCallsToThisStubIsGCSafe() || allow_stub_calls_;
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
 }


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

Reply via email to