diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index e0c1c8a197a2..aa428eb18581 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -181,8 +181,7 @@ struct GCSizes { #define FOR_EACH_SIZE(macro) \ macro(_, _, marker) \ - macro(_, _, nurseryCommitted) \ - macro(_, _, nurseryDecommitted) \ + macro(_, _, nursery) \ macro(_, _, storeBufferVals) \ macro(_, _, storeBufferCells) \ macro(_, _, storeBufferSlots) \ diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index da955a0a7f6f..c17603a0600c 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -70,14 +70,14 @@ js::Nursery::init() JSRuntime *rt = runtime(); rt->gcNurseryStart_ = uintptr_t(heap); - currentStart_ = start(); rt->gcNurseryEnd_ = chunk(LastNurseryChunk).end(); numActiveChunks_ = 1; + setCurrentChunk(0); #ifdef JS_GC_ZEAL JS_POISON(heap, FreshNursery, NurserySize); #endif - setCurrentChunk(0); - updateDecommittedRegion(); + for (int i = 0; i < NumNurseryChunks; ++i) + chunk(i).trailer.runtime = rt; #ifdef PROFILE_NURSERY char *env = getenv("JS_MINORGC_TIME"); @@ -117,7 +117,6 @@ js::Nursery::disable() JS_ASSERT(isEmpty()); numActiveChunks_ = 0; currentEnd_ = 0; - updateDecommittedRegion(); } bool @@ -869,14 +868,15 @@ js::Nursery::sweep(JSRuntime *rt) /* Only reset the alloc point when we are close to the end. */ if (currentChunk_ + 1 == NumNurseryChunks) setCurrentChunk(0); - } else -#endif - { - setCurrentChunk(0); - } - /* Set current start position for isEmpty checks. */ - currentStart_ = position(); + /* Set current start position for isEmpty checks. */ + currentStart_ = position(); + + return; + } +#endif + + setCurrentChunk(0); } void @@ -889,7 +889,6 @@ void js::Nursery::shrinkAllocableSpace() { numActiveChunks_ = Max(numActiveChunks_ - 1, 1); - updateDecommittedRegion(); } #endif /* JSGC_GENERATIONAL */ diff --git a/js/src/gc/Nursery.h b/js/src/gc/Nursery.h index 7b248cb01b67..7b6536022298 100644 --- a/js/src/gc/Nursery.h +++ b/js/src/gc/Nursery.h @@ -15,7 +15,6 @@ #include "ds/BitArray.h" #include "gc/Heap.h" -#include "gc/Memory.h" #include "js/GCAPI.h" #include "js/HashTable.h" #include "js/HeapAPI.h" @@ -30,7 +29,6 @@ namespace js { class ObjectElements; class HeapSlot; -void SetGCZeal(JSRuntime *, uint8_t, uint32_t); namespace gc { class Cell; @@ -125,8 +123,27 @@ class Nursery /* Forward a slots/elements pointer stored in an Ion frame. */ void forwardBufferPointer(HeapSlot **pSlotsElems); - size_t sizeOfHeapCommitted() { return numActiveChunks_ * gc::ChunkSize; } - size_t sizeOfHeapDecommitted() { return (NumNurseryChunks - numActiveChunks_) * gc::ChunkSize; } + size_t sizeOfHeap() { return start() ? NurserySize : 0; } + +#ifdef JS_GC_ZEAL + /* + * In debug and zeal builds, these bytes indicate the state of an unused + * segment of nursery-allocated memory. + */ + static const uint8_t FreshNursery = 0x2a; + static const uint8_t SweptNursery = 0x2b; + static const uint8_t AllocatedThing = 0x2c; + void enterZealMode() { + if (isEnabled()) + numActiveChunks_ = NumNurseryChunks; + } + void leaveZealMode() { + if (isEnabled()) { + JS_ASSERT(isEmpty()); + setCurrentChunk(0); + } + } +#endif private: /* @@ -139,7 +156,7 @@ class Nursery /* Pointer to the first unallocated byte in the nursery. */ uintptr_t position_; - /* Pointer to the logical start of the Nursery. */ + /* Pointer to the logic start of the Nursery. */ uintptr_t currentStart_; /* Pointer to the last byte of space in the current chunk. */ @@ -194,18 +211,8 @@ class Nursery JS_ASSERT(chunkno < numActiveChunks_); currentChunk_ = chunkno; position_ = chunk(chunkno).start(); + currentStart_ = chunk(0).start(); currentEnd_ = chunk(chunkno).end(); - chunk(chunkno).trailer.runtime = runtime(); - } - - void updateDecommittedRegion() { -#ifndef JS_GC_ZEAL - if (numActiveChunks_ < NumNurseryChunks) { - uintptr_t decommitStart = chunk(numActiveChunks_).start(); - JS_ASSERT(decommitStart == AlignBytes(decommitStart, 1 << 20)); - gc::MarkPagesUnused(runtime(), (void *)decommitStart, heapEnd() - decommitStart); - } -#endif } MOZ_ALWAYS_INLINE uintptr_t allocationEnd() const { @@ -277,36 +284,11 @@ class Nursery static void MinorGCCallback(JSTracer *trc, void **thingp, JSGCTraceKind kind); -#ifdef JS_GC_ZEAL - /* - * In debug and zeal builds, these bytes indicate the state of an unused - * segment of nursery-allocated memory. - */ - static const uint8_t FreshNursery = 0x2a; - static const uint8_t SweptNursery = 0x2b; - static const uint8_t AllocatedThing = 0x2c; - void enterZealMode() { - if (isEnabled()) - numActiveChunks_ = NumNurseryChunks; - } - void leaveZealMode() { - if (isEnabled()) { - JS_ASSERT(isEmpty()); - setCurrentChunk(0); - currentStart_ = start(); - } - } -#else - void enterZealMode() {} - void leaveZealMode() {} -#endif - friend class gc::MinorCollectionTracer; friend class jit::CodeGenerator; friend class jit::MacroAssembler; friend class jit::ICStubCompiler; friend class jit::BaselineCompiler; - friend void SetGCZeal(JSRuntime *, uint8_t, uint32_t); }; } /* namespace js */ diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index e22a2f0d9b7a..4aea953122f0 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -628,8 +628,7 @@ JSRuntime::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, JS::Runtim rtSizes->gc.marker += gcMarker.sizeOfExcludingThis(mallocSizeOf); #ifdef JSGC_GENERATIONAL - rtSizes->gc.nurseryCommitted += gcNursery.sizeOfHeapCommitted(); - rtSizes->gc.nurseryDecommitted += gcNursery.sizeOfHeapDecommitted(); + rtSizes->gc.nursery += gcNursery.sizeOfHeap(); gcStoreBuffer.addSizeOfExcludingThis(mallocSizeOf, &rtSizes->gc); #endif } diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 6f57bdef8b8b..75f2319e66a8 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -2347,9 +2347,9 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, KIND_HEAP, rtStats.runtime.gc.marker, "The GC mark stack and gray roots."); - RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/gc/nursery-committed"), - KIND_NONHEAP, rtStats.runtime.gc.nurseryCommitted, - "Memory being used by the GC's nursery."); + RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/gc/nursery"), + KIND_NONHEAP, rtStats.runtime.gc.nursery, + "The GC nursery."); RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/gc/store-buffer/vals"), KIND_HEAP, rtStats.runtime.gc.storeBufferVals, @@ -2393,11 +2393,6 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, "GC arenas in non-empty chunks that is decommitted, i.e. it takes up " "address space but no physical memory or swap space."); - REPORT_GC_BYTES(rtPath2 + NS_LITERAL_CSTRING("runtime/gc/nursery-decommitted"), - rtStats.runtime.gc.nurseryDecommitted, - "Memory allocated to the GC's nursery this is decommitted, i.e. it takes up " - "address space but no physical memory or swap space."); - REPORT_GC_BYTES(rtPath + NS_LITERAL_CSTRING("gc-heap/unused-chunks"), rtStats.gcHeapUnusedChunks, "Empty GC chunks which will soon be released unless claimed for new "