Bug 1118516 - Remove some dead code and bad abstraction; r=jonco
authorTerrence Cole <terrence@mozilla.com>
Wed, 07 Jan 2015 08:49:47 -0800
changeset 235491 175c011226e3326758cd8728d09f3d199f75b27a
parent 235490 a194a9a118f1fa7b60937cf36e9234bdc9474f22
child 235492 4af240ffb89940b95ee0eaa34b5e2ddc79f1f183
push id366
push usercmanchester@mozilla.com
push dateThu, 08 Jan 2015 16:40:24 +0000
reviewersjonco
bugs1118516
milestone37.0a1
Bug 1118516 - Remove some dead code and bad abstraction; r=jonco
js/src/gc/GCRuntime.h
js/src/jsgc.cpp
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -545,17 +545,16 @@ class GCRuntime
 
     /*
      * Return the list of chunks that can be released outside the GC lock.
      * Must be called either during the GC or with the GC lock taken.
      */
     ChunkPool expireEmptyChunkPool(bool shrinkBuffers, const AutoLockGC &lock);
     void freeEmptyChunks(JSRuntime *rt, const AutoLockGC &lock);
     void prepareToFreeChunk(ChunkInfo &info);
-    void releaseChunk(Chunk *chunk);
 
     friend class BackgroundAllocTask;
     friend class AutoMaybeStartBackgroundAllocation;
     inline bool wantBackgroundAllocation(const AutoLockGC &lock) const;
     void startBackgroundAllocTaskIfIdle();
 
     void requestMajorGC(JS::gcreason::Reason reason);
     void collect(bool incremental, SliceBudget &budget, JSGCInvocationKind gckind,
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -626,28 +626,16 @@ FinalizeArenas(FreeOp *fop,
         return FinalizeTypedArenas<JS::Symbol>(fop, src, dest, thingKind, budget, keepArenas);
       case FINALIZE_JITCODE:
         return FinalizeTypedArenas<jit::JitCode>(fop, src, dest, thingKind, budget, keepArenas);
       default:
         MOZ_CRASH("Invalid alloc kind");
     }
 }
 
-static inline Chunk *
-AllocChunk(JSRuntime *rt)
-{
-    return static_cast<Chunk *>(MapAlignedPages(ChunkSize, ChunkSize));
-}
-
-static inline void
-FreeChunk(JSRuntime *rt, Chunk *p)
-{
-    UnmapPages(static_cast<void *>(p), ChunkSize);
-}
-
 Chunk *
 ChunkPool::pop()
 {
     MOZ_ASSERT(bool(head_) == bool(count_));
     if (!count_)
         return nullptr;
     return remove(head_);
 }
@@ -762,47 +750,38 @@ GCRuntime::expireEmptyChunkPool(bool shr
 static void
 FreeChunkPool(JSRuntime *rt, ChunkPool &pool)
 {
     for (ChunkPool::Iter iter(pool); !iter.done();) {
         Chunk *chunk = iter.get();
         iter.next();
         pool.remove(chunk);
         MOZ_ASSERT(!chunk->info.numArenasFreeCommitted);
-        FreeChunk(rt, chunk);
+        UnmapPages(static_cast<void *>(chunk), ChunkSize);
     }
     MOZ_ASSERT(pool.count() == 0);
 }
 
 void
 GCRuntime::freeEmptyChunks(JSRuntime *rt, const AutoLockGC &lock)
 {
     FreeChunkPool(rt, emptyChunks(lock));
 }
 
 /* static */ Chunk *
 Chunk::allocate(JSRuntime *rt)
 {
-    Chunk *chunk = AllocChunk(rt);
+    Chunk *chunk = static_cast<Chunk *>(MapAlignedPages(ChunkSize, ChunkSize));
     if (!chunk)
         return nullptr;
     chunk->init(rt);
     rt->gc.stats.count(gcstats::STAT_NEW_CHUNK);
     return chunk;
 }
 
-/* Must be called with the GC lock taken. */
-void
-GCRuntime::releaseChunk(Chunk *chunk)
-{
-    MOZ_ASSERT(chunk);
-    prepareToFreeChunk(chunk->info);
-    FreeChunk(rt, chunk);
-}
-
 inline void
 GCRuntime::prepareToFreeChunk(ChunkInfo &info)
 {
     MOZ_ASSERT(numArenasFreeCommitted >= info.numArenasFreeCommitted);
     numArenasFreeCommitted -= info.numArenasFreeCommitted;
     stats.count(gcstats::STAT_DESTROY_CHUNK);
 #ifdef DEBUG
     /*