From f3da5b23d3d0dd37b474f24530b50ae65022e6a1 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 3 Jun 2014 09:27:18 +0200 Subject: [PATCH] Bug 1018568 - Make AutoAssertOnGC a nop in opt builds. r=terrence --- js/public/GCAPI.h | 9 +++++++++ js/src/gc/GCRuntime.h | 2 ++ js/src/jsgc.cpp | 4 ++++ js/src/vm/String.h | 1 + 4 files changed, 16 insertions(+) diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index 966ca2cd9ff..05ac8948fb3 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -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 }; /* diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h index 0b6e918a908..a8cca6249d0 100644 --- a/js/src/gc/GCRuntime.h +++ b/js/src/gc/GCRuntime.h @@ -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. */ diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 509d5456f5f..e83c8fb7bf7 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -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 diff --git a/js/src/vm/String.h b/js/src/vm/String.h index ce95c4a590b..b1cee73a6c4 100644 --- a/js/src/vm/String.h +++ b/js/src/vm/String.h @@ -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());