Bug 817812 - Fix --enable-root-analysis compile. r=terrence
authorSteve Fink <sfink@mozilla.com>
Fri, 30 Nov 2012 16:04:42 -0800
changeset 115573 72859dc0fefdcd23ca58fd1362b8e0155f4f5266
parent 115572 51b160a3672e90174d8f70894963d20048ec268d
child 115574 f5e76b86f70c4a7b1b366a93008592de250b6c1c
push id19426
push usersfink@mozilla.com
push dateTue, 11 Dec 2012 01:05:11 +0000
treeherdermozilla-inbound@72859dc0fefd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs817812
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 817812 - Fix --enable-root-analysis compile. r=terrence The recent jsgc.cpp splitup removed some functions that my rooting analysis optimization depended on. This patch exposes a simplified IsAddressableGCThing overload and uses it.
js/src/gc/GCInternals.h
js/src/gc/RootMarking.cpp
js/src/gc/Verifier.cpp
--- a/js/src/gc/GCInternals.h
+++ b/js/src/gc/GCInternals.h
@@ -78,16 +78,21 @@ class IncrementalSafety
         JS_ASSERT(reason_);
         return reason_;
     }
 };
 
 IncrementalSafety
 IsIncrementalGCSafe(JSRuntime *rt);
 
+#ifdef JSGC_ROOT_ANALYSIS
+bool
+IsAddressableGCThing(JSRuntime *rt, uintptr_t w);
+#endif
+
 #ifdef JS_GC_ZEAL
 void
 StartVerifyPreBarriers(JSRuntime *rt);
 
 void
 EndVerifyPreBarriers(JSRuntime *rt);
 
 void
--- a/js/src/gc/RootMarking.cpp
+++ b/js/src/gc/RootMarking.cpp
@@ -200,16 +200,29 @@ IsAddressableGCThing(JSRuntime *rt, uint
         *thing = reinterpret_cast<void *>(addr);
     if (arenaHeader)
         *arenaHeader = aheader;
     if (thingKindPtr)
         *thingKindPtr = thingKind;
     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.
  */
 static inline ConservativeGCTest
 MarkIfGCThingWord(JSTracer *trc, uintptr_t w)
 {
     void *thing;
--- a/js/src/gc/Verifier.cpp
+++ b/js/src/gc/Verifier.cpp
@@ -6,27 +6,30 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsapi.h"
 #include "jscntxt.h"
 #include "jsgc.h"
 #include "jsprf.h"
 #include "jsutil.h"
 
+#include "mozilla/Util.h"
+
 #include "js/HashTable.h"
 #include "gc/GCInternals.h"
 
 #include "jsgcinlines.h"
 
 #ifdef MOZ_VALGRIND
 # include <valgrind/memcheck.h>
 #endif
 
 using namespace js;
 using namespace js::gc;
+using namespace mozilla;
 
 #if defined(DEBUG) && defined(JS_GC_ZEAL) && defined(JSGC_ROOT_ANALYSIS) && !defined(JS_THREADSAFE)
 
 JS_ALWAYS_INLINE bool
 CheckStackRootThing(uintptr_t *w, void *address, ThingRootKind kind)
 {
     if (kind != THING_ROOT_BINDINGS)
         return address == static_cast<void*>(w);
@@ -43,22 +46,17 @@ struct Rooter {
 static void
 CheckStackRoot(JSRuntime *rt, uintptr_t *w, Rooter *begin, Rooter *end)
 {
     /* Mark memory as defined for valgrind, as in MarkWordConservatively. */
 #ifdef MOZ_VALGRIND
     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)),
      * but we can skip that check because poisoning the pointer can't hurt; the
      * pointer still cannot be used for a non-gcthing.
      */
 
     for (Rooter *p = begin; p != end; p++) {
@@ -156,19 +154,19 @@ SuppressCheckRoots(Vector<Rooter, 0, Sys
     // partitioning pass, perhaps.
     qsort(rooters.begin(), rooters.length(), sizeof(Rooter), CompareRooters);
 
     // Forward-declare a variable so its address can be used to mark the
     // current top of the stack
     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++) {
         if (stacks[pos] == hash) {
             // Skip this check. Technically, it is incorrect to not update the
             // LRU queue position, but it'll cost us at most one extra check
             // for every time a hot stack falls out of the window.
             return true;
@@ -286,17 +284,18 @@ JS::CheckStackRoots(JSContext *cx)
             Swap(*firstToScan, *p);
             ++firstToScan;
         }
     }
 
     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++)
         p->rooter->scanned = true;
 }
 
 #endif /* DEBUG && JS_GC_ZEAL && JSGC_ROOT_ANALYSIS && !JS_THREADSAFE */