Bug 1018568 - Make AutoAssertOnGC a nop in opt builds. r=terrence

This commit is contained in:
Jan de Mooij 2014-06-03 09:27:18 +02:00
parent 943fc38329
commit f3da5b23d3
4 changed files with 16 additions and 0 deletions

View File

@ -374,6 +374,7 @@ ShrinkGCBuffers(JSRuntime *rt);
*/
class JS_PUBLIC_API(AutoAssertOnGC)
{
#ifdef DEBUG
JSRuntime *runtime;
size_t gcNumber;
@ -383,6 +384,14 @@ class JS_PUBLIC_API(AutoAssertOnGC)
~AutoAssertOnGC();
static void VerifyIsSafeToGC(JSRuntime *rt);
#else
public:
AutoAssertOnGC() {}
explicit AutoAssertOnGC(JSRuntime *rt) {}
~AutoAssertOnGC() {}
static void VerifyIsSafeToGC(JSRuntime *rt) {}
#endif
};
/*

View File

@ -537,6 +537,7 @@ class GCRuntime
/* Strong references on scripts held for PCCount profiling API. */
js::ScriptAndCountsVector *scriptAndCountsVector;
#ifdef DEBUG
/*
* Some regions of code are hard for the static rooting hazard analysis to
* understand. In those cases, we trade the static analysis for a dynamic
@ -544,6 +545,7 @@ class GCRuntime
* might trigger, a GC.
*/
int inUnsafeRegion;
#endif
private:
/* Always preserve JIT code during GCs, for testing. */

View File

@ -1115,7 +1115,9 @@ GCRuntime::GCRuntime(JSRuntime *rt) :
mallocBytes(0),
mallocGCTriggered(false),
scriptAndCountsVector(nullptr),
#ifdef DEBUG
inUnsafeRegion(0),
#endif
alwaysPreserveCode(false),
#ifdef DEBUG
noGCOrAllocationCheck(0),
@ -5614,6 +5616,7 @@ JS::GetGCNumber()
}
#endif
#ifdef DEBUG
JS::AutoAssertOnGC::AutoAssertOnGC()
: runtime(nullptr), gcNumber(0)
{
@ -5659,3 +5662,4 @@ JS::AutoAssertOnGC::VerifyIsSafeToGC(JSRuntime *rt)
if (rt->gc.inUnsafeRegion > 0)
MOZ_CRASH("[AutoAssertOnGC] possible GC in GC-unsafe region");
}
#endif

View File

@ -638,6 +638,7 @@ class JSLinearString : public JSString
return JS::TwoByteChars(chars(), length());
}
MOZ_ALWAYS_INLINE
jschar latin1OrTwoByteChar(size_t index) const {
MOZ_ASSERT(JSString::isLinear());
MOZ_ASSERT(index < length());