When discarding Ion code, ensure there is an IonContext around so the autoflusher can function (bug 786004, r=dvander)
authorMarty Rosenberg <mrosenberg@mozilla.com>
Tue, 28 Aug 2012 05:20:22 -0400
changeset 105030 b63bb39ed1c08605128c984987bbf176dfd81999
parent 105024 91493e20a6e518a5b6f16e858abf8e3effb21bdd
child 105031 07d466a718a660c156f195a05c15c7cfe5abd99d
child 105678 6cd206b371761294125cb98fe9d0c11e2383795f
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewersdvander
bugs786004
milestone17.0a1
When discarding Ion code, ensure there is an IonContext around so the autoflusher can function (bug 786004, r=dvander)
js/src/ion/Ion.cpp
js/src/ion/IonCode.h
js/src/jsgc.cpp
--- a/js/src/ion/Ion.cpp
+++ b/js/src/ion/Ion.cpp
@@ -702,18 +702,22 @@ IonScript::toggleBarriers(bool enabled)
         if (enabled)
             Assembler::ToggleToCmp(loc);
         else
             Assembler::ToggleToJmp(loc);
     }
 }
 
 void
-IonScript::purgeCaches()
+IonScript::purgeCaches(JSCompartment *c)
 {
+    // This is necessary because AutoFlushCache::updateTop()
+    // looks up the current flusher in the IonContext.  Without one
+    // it cannot work.
+    js::ion::IonContext ictx(NULL, c, NULL);
     AutoFlushCache afc("purgeCaches");
     for (size_t i = 0; i < numCaches(); i++)
         getCache(i).reset();
 }
 
 void
 ion::ToggleBarriers(JSCompartment *comp, bool needs)
 {
--- a/js/src/ion/IonCode.h
+++ b/js/src/ion/IonCode.h
@@ -352,17 +352,17 @@ struct IonScript
     size_t numCaches() const {
         return cacheEntries_;
     }
     inline CodeOffsetLabel &getPrebarrier(size_t index);
     size_t numPrebarriers() const {
         return prebarrierEntries_;
     }
     void toggleBarriers(bool enabled);
-    void purgeCaches();
+    void purgeCaches(JSCompartment *c);
     void copySnapshots(const SnapshotWriter *writer);
     void copyBailoutTable(const SnapshotOffset *table);
     void copyConstants(const HeapValue *vp);
     void copySafepointIndices(const SafepointIndex *firstSafepointIndex, MacroAssembler &masm);
     void copyOsiIndices(const OsiIndex *firstOsiIndex, MacroAssembler &masm);
     void copyCacheEntries(const IonCache *caches, MacroAssembler &masm);
     void copyPrebarrierEntries(const CodeOffsetLabel *barriers, MacroAssembler &masm);
     void copySafepoints(const SafepointWriter *writer);
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -5702,17 +5702,17 @@ PurgeJITCaches(JSCompartment *c)
                     jit->purgeCaches();
             }
         }
 
 #ifdef JS_ION
 
         /* Discard Ion caches. */ 
         if (script->hasIonScript())
-            script->ion->purgeCaches();
+            script->ion->purgeCaches(c);
 
 #endif
     }
 #endif
 }
 
 } /* namespace js */