Backed out changeset 738a4b230194 (bug 988326) for assertions
authorEd Morley <emorley@mozilla.com>
Wed, 26 Mar 2014 18:11:11 +0000
changeset 175543 52aaac0d7caeb843ef2ec92c2e747a076720f6f3
parent 175542 70a43999d28d1547d81ee943c38b210ea1af2cd0
child 175544 e6eee5dd8c73fd7f2ca627c6e0bd222a7c4450fd
push id26492
push userryanvm@gmail.com
push dateThu, 27 Mar 2014 00:57:51 +0000
treeherdermozilla-central@441f5fd256e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs988326
milestone31.0a1
backs out738a4b23019461743e0c5bbc89b98bb944bd08ad
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
Backed out changeset 738a4b230194 (bug 988326) for assertions
js/src/gc/Heap.h
js/src/jsgc.cpp
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -13,17 +13,16 @@
 #include <stddef.h>
 #include <stdint.h>
 
 #include "jspubtd.h"
 #include "jstypes.h"
 #include "jsutil.h"
 
 #include "ds/BitArray.h"
-#include "gc/Memory.h"
 #include "js/HeapAPI.h"
 
 struct JSCompartment;
 
 struct JSRuntime;
 
 namespace JS {
 namespace shadow {
@@ -804,26 +803,16 @@ struct Chunk
 
     ArenaHeader *allocateArena(JS::Zone *zone, AllocKind kind);
 
     void releaseArena(ArenaHeader *aheader);
     void recycleArena(ArenaHeader *aheader, ArenaList &dest, AllocKind thingKind);
 
     static Chunk *allocate(JSRuntime *rt);
 
-    void decommitAllArenas(JSRuntime *rt) {
-        JS_ASSERT(info.numArenasFree == ArenasPerChunk);
-
-        decommittedArenas.clear(true);
-        MarkPagesUnused(rt, &arenas[0], ArenasPerChunk * ArenaSize);
-
-        info.freeArenasHead = nullptr;
-        info.numArenasFreeCommitted = 0;
-    }
-
     /* Must be called with the GC lock taken. */
     static inline void release(JSRuntime *rt, Chunk *chunk);
     static inline void releaseList(JSRuntime *rt, Chunk *chunkListHead);
 
     /* Must be called with the GC lock taken. */
     inline void prepareToBeFreed(JSRuntime *rt);
 
     /*
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -662,17 +662,18 @@ ChunkPool::get(JSRuntime *rt)
         JS_ASSERT(emptyCount);
         emptyChunkListHead = chunk->info.next;
         --emptyCount;
     } else {
         JS_ASSERT(!emptyCount);
         chunk = Chunk::allocate(rt);
         if (!chunk)
             return nullptr;
-        JS_ASSERT(chunk->info.numArenasFreeCommitted == 0);
+        JS_ASSERT(chunk->info.numArenasFreeCommitted == ArenasPerChunk);
+        rt->gcNumArenasFreeCommitted += ArenasPerChunk;
     }
     JS_ASSERT(chunk->unused());
     JS_ASSERT(!rt->gcChunkSet.has(chunk));
 
     if (wantBackgroundAllocation(rt))
         rt->gcHelperThread.startBackgroundAllocationIfIdle();
 
     return chunk;
@@ -799,30 +800,35 @@ Chunk::init(JSRuntime *rt)
     JS_POISON(this, JS_FREE_PATTERN, ChunkSize);
 
     /*
      * We clear the bitmap to guard against xpc_IsGrayGCThing being called on
      * uninitialized data, which would happen before the first GC cycle.
      */
     bitmap.clear();
 
-    /*
-     * Decommit the arenas. We do this after poisoning so that if the OS does
-     * not have to recycle the pages, we still get the benefit of poisoning.
-     */
-    decommitAllArenas(rt);
+    /* Initialize the arena tracking bitmap. */
+    decommittedArenas.clear(false);
 
     /* Initialize the chunk info. */
-    info.freeArenasHead = nullptr;
+    info.freeArenasHead = &arenas[0].aheader;
     info.lastDecommittedArenaOffset = 0;
     info.numArenasFree = ArenasPerChunk;
-    info.numArenasFreeCommitted = 0;
+    info.numArenasFreeCommitted = ArenasPerChunk;
     info.age = 0;
     info.trailer.runtime = rt;
 
+    /* Initialize the arena header state. */
+    for (unsigned i = 0; i < ArenasPerChunk; i++) {
+        arenas[i].aheader.setAsNotAllocated();
+        arenas[i].aheader.next = (i + 1 < ArenasPerChunk)
+                                 ? &arenas[i + 1].aheader
+                                 : nullptr;
+    }
+
     /* The rest of info fields are initialized in PickChunk. */
 }
 
 static inline Chunk **
 GetAvailableChunkList(Zone *zone)
 {
     JSRuntime *rt = zone->runtimeFromAnyThread();
     return zone->isSystem
@@ -988,17 +994,16 @@ Chunk::releaseArena(ArenaHeader *aheader
         JS_ASSERT(!info.prevp);
         JS_ASSERT(!info.next);
         addToAvailableList(zone);
     } else if (!unused()) {
         JS_ASSERT(info.prevp);
     } else {
         rt->gcChunkSet.remove(this);
         removeFromAvailableList();
-        decommitAllArenas(rt);
         rt->gcChunkPool.put(this);
     }
 }
 
 /* The caller must hold the GC lock. */
 static Chunk *
 PickChunk(Zone *zone)
 {
@@ -2612,21 +2617,22 @@ GCHelperThread::threadLoop()
                 {
                     AutoUnlockGC unlock(rt);
                     chunk = Chunk::allocate(rt);
                 }
 
                 /* OOM stops the background allocation. */
                 if (!chunk) {
 #if JS_TRACE_LOGGING
-                    logger->log(TraceLogging::GC_ALLOCATING_STOP);
+            logger->log(TraceLogging::GC_ALLOCATING_STOP);
 #endif
                     break;
                 }
-                JS_ASSERT(chunk->info.numArenasFreeCommitted == 0);
+                JS_ASSERT(chunk->info.numArenasFreeCommitted == ArenasPerChunk);
+                rt->gcNumArenasFreeCommitted += ArenasPerChunk;
                 rt->gcChunkPool.put(chunk);
             } while (state == ALLOCATING && rt->gcChunkPool.wantBackgroundAllocation(rt));
             if (state == ALLOCATING)
                 state = IDLE;
 #if JS_TRACE_LOGGING
             logger->log(TraceLogging::GC_ALLOCATING_STOP);
 #endif
             break;