diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp index 87ca3afc4a3e7d6b06c233ffb81434a717e82def..3115b6b112777368c52438006c10b5664d06f492 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp @@ -329,7 +329,7 @@ class Par_PushOrMarkClosure: public OopClosure { class CMSKeepAliveClosure: public OopClosure { private: CMSCollector* _collector; - MemRegion _span; + const MemRegion _span; CMSMarkStack* _mark_stack; CMSBitMap* _bit_map; protected: @@ -340,7 +340,9 @@ class CMSKeepAliveClosure: public OopClosure { _collector(collector), _span(span), _bit_map(bit_map), - _mark_stack(mark_stack) { } + _mark_stack(mark_stack) { + assert(!_span.is_empty(), "Empty span could spell trouble"); + } virtual void do_oop(oop* p); virtual void do_oop(narrowOop* p); inline void do_oop_nv(oop* p) { CMSKeepAliveClosure::do_oop_work(p); } diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 689ede0ea057b5bb0c5b5454b459d8d9a69429e5..8ab7bdd1b58c4ba334f94dd249cf3f2f2e8e8be0 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -520,7 +520,10 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, -1 /* lock-free */, "No_lock" /* dummy */), _modUnionClosure(&_modUnionTable), _modUnionClosurePar(&_modUnionTable), - _is_alive_closure(&_markBitMap), + // Adjust my span to cover old (cms) gen and perm gen + _span(cmsGen->reserved()._union(permGen->reserved())), + // Construct the is_alive_closure with _span & markBitMap + _is_alive_closure(_span, &_markBitMap), _restart_addr(NULL), _overflow_list(NULL), _preserved_oop_stack(NULL), @@ -572,11 +575,6 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen, _cmsGen->cmsSpace()->set_collector(this); _permGen->cmsSpace()->set_collector(this); - // Adjust my span to cover old (cms) gen and perm gen - _span = _cmsGen->reserved()._union(_permGen->reserved()); - // Initialize the span of is_alive_closure - _is_alive_closure.set_span(_span); - // Allocate MUT and marking bit map { MutexLockerEx x(_markBitMap.lock(), Mutex::_no_safepoint_check_flag); @@ -5496,7 +5494,7 @@ class CMSRefProcTaskProxy: public AbstractGangTask { typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask; CMSCollector* _collector; CMSBitMap* _mark_bit_map; - MemRegion _span; + const MemRegion _span; OopTaskQueueSet* _task_queues; ParallelTaskTerminator _term; ProcessTask& _task; @@ -5513,7 +5511,10 @@ public: _collector(collector), _span(span), _mark_bit_map(mark_bit_map), _task_queues(task_queues), _term(total_workers, task_queues) - { } + { + assert(_collector->_span.equals(_span) && !_span.is_empty(), + "Inconsistency in _span"); + } OopTaskQueueSet* task_queues() { return _task_queues; } @@ -5530,11 +5531,12 @@ public: }; void CMSRefProcTaskProxy::work(int i) { + assert(_collector->_span.equals(_span), "Inconsistency in _span"); CMSParKeepAliveClosure par_keep_alive(_collector, _span, _mark_bit_map, work_queue(i)); CMSParDrainMarkingStackClosure par_drain_stack(_collector, _span, _mark_bit_map, work_queue(i)); - CMSIsAliveClosure is_alive_closure(_mark_bit_map); + CMSIsAliveClosure is_alive_closure(_span, _mark_bit_map); _task.work(i, is_alive_closure, par_keep_alive, par_drain_stack); if (_task.marks_oops_alive()) { do_work_steal(i, &par_drain_stack, &par_keep_alive, diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index ea44e417b833d2a39facf69569106c3631eb10c0..6d5546eeb9533705d42c835408810d2881524fd4 100644 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -435,23 +435,22 @@ class CMSStats VALUE_OBJ_CLASS_SPEC { // if the object is "live" (reachable). Used in weak // reference processing. class CMSIsAliveClosure: public BoolObjectClosure { - MemRegion _span; + const MemRegion _span; const CMSBitMap* _bit_map; friend class CMSCollector; - protected: - void set_span(MemRegion span) { _span = span; } public: - CMSIsAliveClosure(CMSBitMap* bit_map): - _bit_map(bit_map) { } - CMSIsAliveClosure(MemRegion span, CMSBitMap* bit_map): _span(span), - _bit_map(bit_map) { } + _bit_map(bit_map) { + assert(!span.is_empty(), "Empty span could spell trouble"); + } + void do_object(oop obj) { assert(false, "not to be invoked"); } + bool do_object_b(oop obj); }; @@ -600,7 +599,7 @@ class CMSCollector: public CHeapObj { // ("Weak") Reference processing support ReferenceProcessor* _ref_processor; CMSIsAliveClosure _is_alive_closure; - // keep this textually after _markBitMap; c'tor dependency + // keep this textually after _markBitMap and _span; c'tor dependency ConcurrentMarkSweepThread* _cmsThread; // the thread doing the work ModUnionClosure _modUnionClosure;