When discarding Ion code, ensure there is an IonContext around so the autoflusher can function (
bug 786004, r=dvander)
--- 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 */