Mercurial > hg > truffle
diff src/share/vm/gc_implementation/g1/concurrentMark.hpp @ 7397:442f942757c0
8000244: G1: Ergonomically set MarkStackSize and use virtual space for global marking stack
Summary: Set the value of MarkStackSize to a value based on the number of parallel marking threads with a reasonable minimum. Expand the marking stack if we have to restart marking due to an overflow up to a reasonable maximum. Allocate the underlying space for the marking stack from virtual memory.
Reviewed-by: jmasa, brutisso
author | johnc |
---|---|
date | Mon, 01 Oct 2012 09:28:13 -0700 |
parents | 8a5ea0a9ccc4 |
children | d275c3dc73e6 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Thu Nov 29 10:09:04 2012 -0800 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Oct 01 09:28:13 2012 -0700 @@ -63,7 +63,7 @@ public: // constructor - CMBitMapRO(ReservedSpace rs, int shifter); + CMBitMapRO(int shifter); enum { do_yield = true }; @@ -117,8 +117,11 @@ public: // constructor - CMBitMap(ReservedSpace rs, int shifter) : - CMBitMapRO(rs, shifter) {} + CMBitMap(int shifter) : + CMBitMapRO(shifter) {} + + // Allocates the back store for the marking bitmap + bool allocate(ReservedSpace heap_rs); // write marks void mark(HeapWord* addr) { @@ -155,17 +158,18 @@ MemRegion getAndClearMarkedRegion(HeapWord* addr, HeapWord* end_addr); }; -// Represents a marking stack used by the CM collector. -// Ideally this should be GrowableArray<> just like MSC's marking stack(s). +// Represents a marking stack used by ConcurrentMarking in the G1 collector. class CMMarkStack VALUE_OBJ_CLASS_SPEC { + VirtualSpace _virtual_space; // Underlying backing store for actual stack ConcurrentMark* _cm; oop* _base; // bottom of stack - jint _index; // one more than last occupied index - jint _capacity; // max #elements - jint _saved_index; // value of _index saved at start of GC - NOT_PRODUCT(jint _max_depth;) // max depth plumbed during run + jint _index; // one more than last occupied index + jint _capacity; // max #elements + jint _saved_index; // value of _index saved at start of GC + NOT_PRODUCT(jint _max_depth;) // max depth plumbed during run - bool _overflow; + bool _overflow; + bool _should_expand; DEBUG_ONLY(bool _drain_in_progress;) DEBUG_ONLY(bool _drain_in_progress_yields;) @@ -173,7 +177,13 @@ CMMarkStack(ConcurrentMark* cm); ~CMMarkStack(); - void allocate(size_t size); +#ifndef PRODUCT + jint max_depth() const { + return _max_depth; + } +#endif + + bool allocate(size_t capacity); oop pop() { if (!isEmpty()) { @@ -231,11 +241,17 @@ bool isEmpty() { return _index == 0; } bool isFull() { return _index == _capacity; } - int maxElems() { return _capacity; } + int maxElems() { return _capacity; } bool overflow() { return _overflow; } void clear_overflow() { _overflow = false; } + bool should_expand() const { return _should_expand; } + void set_should_expand(); + + // Expand the stack, typically in response to an overflow condition + void expand(); + int size() { return _index; } void setEmpty() { _index = 0; clear_overflow(); } @@ -344,6 +360,7 @@ class ConcurrentMarkThread; class ConcurrentMark: public CHeapObj<mtGC> { + friend class CMMarkStack; friend class ConcurrentMarkThread; friend class CMTask; friend class CMBitMapClosure; @@ -577,6 +594,9 @@ // the card bitmaps. intptr_t _heap_bottom_card_num; + // Set to true when initialization is complete + bool _completed_initialization; + public: // Manipulation of the global mark stack. // Notice that the first mark_stack_push is CAS-based, whereas the @@ -636,7 +656,7 @@ return _task_queues->steal(worker_id, hash_seed, obj); } - ConcurrentMark(ReservedSpace rs, uint max_regions); + ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs); ~ConcurrentMark(); ConcurrentMarkThread* cmThread() { return _cmThread; } @@ -907,6 +927,11 @@ // Should *not* be called from parallel code. inline bool mark_and_count(oop obj); + // Returns true if initialization was successfully completed. + bool completed_initialization() const { + return _completed_initialization; + } + protected: // Clear all the per-task bitmaps and arrays used to store the // counting data.