Bug 650161 - Fix misc build errors with compacting GC enabled r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 16 Jan 2015 14:34:16 +0000
changeset 224202 5b0f5677578a96c8a836433773e0ae6e9ca5e6ac
parent 224201 ac6623427298e49638a13b5902a16a0f5ce3a685
child 224203 ae2eec4a74ea1f8d323f6e09b56f7c07a2c94112
push id54151
push userjcoppeard@mozilla.com
push dateFri, 16 Jan 2015 14:36:07 +0000
treeherdermozilla-inbound@ae2eec4a74ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs650161
milestone38.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 650161 - Fix misc build errors with compacting GC enabled r=terrence
js/src/gc/GCInternals.h
js/src/gc/Marking.cpp
js/src/jsapi-tests/testWeakMap.cpp
js/src/jsgc.cpp
--- a/js/src/gc/GCInternals.h
+++ b/js/src/gc/GCInternals.h
@@ -140,17 +140,17 @@ struct AutoStopVerifyingBarriers
 
 #ifdef JSGC_HASH_TABLE_CHECKS
 void
 CheckHashTablesAfterMovingGC(JSRuntime *rt);
 #endif
 
 #ifdef JSGC_COMPACTING
 struct MovingTracer : JSTracer {
-    MovingTracer(JSRuntime *rt) : JSTracer(rt, Visit, TraceWeakMapKeysValues) {}
+    explicit MovingTracer(JSRuntime *rt) : JSTracer(rt, Visit, TraceWeakMapKeysValues) {}
 
     static void Visit(JSTracer *jstrc, void **thingp, JSGCTraceKind kind);
     static bool IsMovingTracer(JSTracer *trc) {
         return trc->callback == Visit;
     }
 };
 #endif
 
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "gc/Marking.h"
 
 #include "mozilla/DebugOnly.h"
 
 #include "jsprf.h"
 
+#include "gc/GCInternals.h"
 #include "jit/IonCode.h"
 #include "js/SliceBudget.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/ArrayObject.h"
 #include "vm/ScopeObject.h"
 #include "vm/Shape.h"
 #include "vm/Symbol.h"
 #include "vm/TypedArrayObject.h"
--- a/js/src/jsapi-tests/testWeakMap.cpp
+++ b/js/src/jsapi-tests/testWeakMap.cpp
@@ -124,16 +124,19 @@ BEGIN_TEST(testWeakMap_keyDelegates)
     JS_GC(rt);
     CHECK(checkSize(map, 0));
 
     return true;
 }
 
 static void DelegateObjectMoved(JSObject *obj, const JSObject *old)
 {
+    if (!keyDelegate)
+        return;  // Object got moved before we set keyDelegate to point to it.
+
     MOZ_RELEASE_ASSERT(keyDelegate == old);
     keyDelegate = obj;
 }
 
 static JSObject *GetKeyDelegate(JSObject *obj)
 {
     return keyDelegate;
 }
@@ -229,22 +232,16 @@ JSObject *newDelegate()
     /* Create the global object. */
     JS::CompartmentOptions options;
     options.setVersion(JSVERSION_LATEST);
     JS::RootedObject global(cx);
     global = JS_NewGlobalObject(cx, Jsvalify(&delegateClass), nullptr, JS::FireOnNewGlobalHook,
                                 options);
     JS_SetReservedSlot(global, 0, JS::Int32Value(42));
 
-    /*
-     * Ensure the delegate is not in the nursery because for the purpose of this
-     * test we're going to put it in a private slot where it won't get updated.
-     */
-    JS_GC(rt);
-
     return global;
 }
 
 bool
 checkSize(JS::HandleObject map, uint32_t expected)
 {
     JS::RootedObject keys(cx);
     CHECK(JS_NondeterministicGetWeakMapKeys(cx, map, &keys));
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -2093,16 +2093,18 @@ PtrIsInRange(const void *ptr, const void
 {
     return uintptr_t(ptr) - uintptr_t(start) < length;
 }
 #endif
 
 static bool
 RelocateCell(Zone *zone, TenuredCell *src, AllocKind thingKind, size_t thingSize)
 {
+    JS::AutoSuppressGCAnalysis nogc(zone->runtimeFromMainThread());
+
     // Allocate a new cell.
     MOZ_ASSERT(zone == src->zone());
     void *dstAlloc = zone->arenas.allocateFromFreeList(thingKind, thingSize);
     if (!dstAlloc)
         dstAlloc = GCRuntime::refillFreeListInGC(zone, thingKind);
     if (!dstAlloc)
         return false;
     TenuredCell *dst = TenuredCell::fromPointer(dstAlloc);
@@ -2368,33 +2370,33 @@ UpdateCellPointers(MovingTracer *trc, Ar
     }
 }
 
 namespace js {
 namespace gc {
 
 struct ArenasToUpdate
 {
-    ArenasToUpdate(JSRuntime *rt);
+    explicit ArenasToUpdate(JSRuntime *rt);
     bool done() { return initialized && arena == nullptr; }
     ArenaHeader* next();
     ArenaHeader *getArenasToUpdate(AutoLockHelperThreadState& lock, unsigned max);
 
   private:
     bool initialized;
     GCZonesIter zone;    // Current zone to process, unless zone.done()
     unsigned kind;       // Current alloc kind to process
     ArenaHeader *arena;  // Next arena to process
 
     bool shouldProcessKind(unsigned kind);
 };
 
 bool ArenasToUpdate::shouldProcessKind(unsigned kind)
 {
-    MOZ_ASSERT(kind >= 0 && kind < FINALIZE_LIMIT);
+    MOZ_ASSERT(kind < FINALIZE_LIMIT);
     return
         kind != FINALIZE_FAT_INLINE_STRING &&
         kind != FINALIZE_STRING &&
         kind != FINALIZE_EXTERNAL_STRING &&
         kind != FINALIZE_SYMBOL;
 }
 
 ArenasToUpdate::ArenasToUpdate(JSRuntime *rt)