diff --git a/js/src/gc/GCInternals.h b/js/src/gc/GCInternals.h index ebe2bde4d78..492a2b0e1ac 100644 --- a/js/src/gc/GCInternals.h +++ b/js/src/gc/GCInternals.h @@ -83,6 +83,11 @@ class IncrementalSafety IncrementalSafety IsIncrementalGCSafe(JSRuntime *rt); +#ifdef JSGC_ROOT_ANALYSIS +bool +IsAddressableGCThing(JSRuntime *rt, uintptr_t w); +#endif + #ifdef JS_GC_ZEAL void StartVerifyPreBarriers(JSRuntime *rt); diff --git a/js/src/gc/RootMarking.cpp b/js/src/gc/RootMarking.cpp index 330063b7893..058dbd65bbf 100644 --- a/js/src/gc/RootMarking.cpp +++ b/js/src/gc/RootMarking.cpp @@ -205,6 +205,19 @@ IsAddressableGCThing(JSRuntime *rt, uintptr_t w, return CGCT_VALID; } +#ifdef JSGC_ROOT_ANALYSIS +bool +js::gc::IsAddressableGCThing(JSRuntime *rt, uintptr_t w) +{ + void *thing; + ArenaHeader *aheader; + AllocKind thingKind; + ConservativeGCTest status = + IsAddressableGCThing(rt, w, false, &thingKind, &aheader, &thing); + return status == CGCT_VALID; +} +#endif + /* * Returns CGCT_VALID and mark it if the w can be a live GC thing and sets * thingKind accordingly. Otherwise returns the reason for rejection. diff --git a/js/src/gc/Verifier.cpp b/js/src/gc/Verifier.cpp index 7d787fd9cae..204a3627f98 100644 --- a/js/src/gc/Verifier.cpp +++ b/js/src/gc/Verifier.cpp @@ -11,6 +11,8 @@ #include "jsprf.h" #include "jsutil.h" +#include "mozilla/Util.h" + #include "js/HashTable.h" #include "gc/GCInternals.h" @@ -22,6 +24,7 @@ using namespace js; using namespace js::gc; +using namespace mozilla; #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE) @@ -48,12 +51,7 @@ CheckStackRoot(JSRuntime *rt, uintptr_t *w, Rooter *begin, Rooter *end) VALGRIND_MAKE_MEM_DEFINED(&w, sizeof(w)); #endif - void *thing; - ArenaHeader *aheader; - AllocKind thingKind; - ConservativeGCTest status = - IsAddressableGCThing(rt, *w, false, &thingKind, &aheader, &thing); - if (status != CGCT_VALID) + if (!IsAddressableGCThing(rt, *w)) return; /* * Note that |thing| may be in a free list (InFreeList(aheader, thing)), @@ -161,9 +159,9 @@ SuppressCheckRoots(Vector &rooters) unsigned int pos; // Compute the hash of the current stack - uint32_t hash = mozilla::HashGeneric(&pos); + uint32_t hash = HashGeneric(&pos); for (unsigned int i = 0; i < Min(StackCheckDepth, rooters.length()); i++) - hash = mozilla::AddToHash(hash, rooters[rooters.length() - i - 1].rooter); + hash = AddToHash(hash, rooters[rooters.length() - i - 1].rooter); // Scan through the remembered stacks to find the current stack for (pos = 0; pos < numMemories; pos++) { @@ -291,7 +289,8 @@ JS::CheckStackRoots(JSContext *cx) JS_ASSERT(stackMin <= stackEnd); CheckStackRootsRangeAndSkipIon(rt, stackMin, stackEnd, firstToScan, rooters.end()); CheckStackRootsRange(rt, cgcd->registerSnapshot.words, - ArrayEnd(cgcd->registerSnapshot.words), firstToScan, rooters.end()); + ArrayEnd(cgcd->registerSnapshot.words), + firstToScan, rooters.end()); // Mark all rooters as scanned for (Rooter *p = rooters.begin(); p != rooters.end(); p++)