< prev index next >

src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp

Print this page
rev 11970 : [mq]: base_volatiles


3013     _task = task;
3014   }
3015 };
3016 
3017 class CMSConcMarkingTerminatorTerminator: public TerminatorTerminator {
3018   CMSConcMarkingTask* _task;
3019  public:
3020   bool should_exit_termination();
3021   void set_task(CMSConcMarkingTask* task) {
3022     _task = task;
3023   }
3024 };
3025 
3026 // MT Concurrent Marking Task
3027 class CMSConcMarkingTask: public YieldingFlexibleGangTask {
3028   CMSCollector* _collector;
3029   uint          _n_workers;       // requested/desired # workers
3030   bool          _result;
3031   CompactibleFreeListSpace*  _cms_space;
3032   char          _pad_front[64];   // padding to ...
3033   HeapWord*     _global_finger;   // ... avoid sharing cache line
3034   char          _pad_back[64];
3035   HeapWord*     _restart_addr;
3036 
3037   //  Exposed here for yielding support
3038   Mutex* const _bit_map_lock;
3039 
3040   // The per thread work queues, available here for stealing
3041   OopTaskQueueSet*  _task_queues;
3042 
3043   // Termination (and yielding) support
3044   CMSConcMarkingTerminator _term;
3045   CMSConcMarkingTerminatorTerminator _term_term;
3046 
3047  public:
3048   CMSConcMarkingTask(CMSCollector* collector,
3049                  CompactibleFreeListSpace* cms_space,
3050                  YieldingFlexibleWorkGang* workers,
3051                  OopTaskQueueSet* task_queues):
3052     YieldingFlexibleGangTask("Concurrent marking done multi-threaded"),
3053     _collector(collector),
3054     _cms_space(cms_space),
3055     _n_workers(0), _result(true),
3056     _task_queues(task_queues),
3057     _term(_n_workers, task_queues, _collector),
3058     _bit_map_lock(collector->bitMapLock())
3059   {
3060     _requested_size = _n_workers;
3061     _term.set_task(this);
3062     _term_term.set_task(this);
3063     _restart_addr = _global_finger = _cms_space->bottom();
3064   }
3065 
3066 
3067   OopTaskQueueSet* task_queues()  { return _task_queues; }
3068 
3069   OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
3070 
3071   HeapWord** global_finger_addr() { return &_global_finger; }
3072 
3073   CMSConcMarkingTerminator* terminator() { return &_term; }
3074 
3075   virtual void set_for_termination(uint active_workers) {
3076     terminator()->reset_for_reuse(active_workers);
3077   }
3078 
3079   void work(uint worker_id);
3080   bool should_yield() {
3081     return    ConcurrentMarkSweepThread::should_yield()
3082            && !_collector->foregroundGCIsActive();
3083   }
3084 
3085   virtual void coordinator_yield();  // stuff done by coordinator
3086   bool result() { return _result; }
3087 
3088   void reset(HeapWord* ra) {
3089     assert(_global_finger >= _cms_space->end(),  "Postcondition of ::work(i)");
3090     _restart_addr = _global_finger = ra;
3091     _term.reset_for_reuse();


6537     // [_threshold, _finger) represents the interval
6538     // of cards to be cleared  in MUT (or precleaned in card table).
6539     // The set of cards to be cleared is all those that overlap
6540     // with the interval [_threshold, _finger); note that
6541     // _threshold is always kept card-aligned but _finger isn't
6542     // always card-aligned.
6543     HeapWord* old_threshold = _threshold;
6544     assert(old_threshold == (HeapWord*)round_to(
6545             (intptr_t)old_threshold, CardTableModRefBS::card_size),
6546            "_threshold should always be card-aligned");
6547     _threshold = (HeapWord*)round_to(
6548                    (intptr_t)_finger, CardTableModRefBS::card_size);
6549     MemRegion mr(old_threshold, _threshold);
6550     assert(!mr.is_empty(), "Control point invariant");
6551     assert(_span.contains(mr), "Should clear within span"); // _whole_span ??
6552     _mut->clear_range(mr);
6553   }
6554 
6555   // Note: the local finger doesn't advance while we drain
6556   // the stack below, but the global finger sure can and will.
6557   HeapWord** gfa = _task->global_finger_addr();
6558   ParPushOrMarkClosure pushOrMarkClosure(_collector,
6559                                          _span, _bit_map,
6560                                          _work_queue,
6561                                          _overflow_stack,
6562                                          _finger,
6563                                          gfa, this);
6564   bool res = _work_queue->push(obj);   // overflow could occur here
6565   assert(res, "Will hold once we use workqueues");
6566   while (true) {
6567     oop new_oop;
6568     if (!_work_queue->pop_local(new_oop)) {
6569       // We emptied our work_queue; check if there's stuff that can
6570       // be gotten from the overflow stack.
6571       if (CMSConcMarkingTask::get_work_from_overflow_stack(
6572             _overflow_stack, _work_queue)) {
6573         do_yield_check();
6574         continue;
6575       } else {  // done
6576         break;
6577       }


6704 
6705 PushOrMarkClosure::PushOrMarkClosure(CMSCollector* collector,
6706                      MemRegion span,
6707                      CMSBitMap* bitMap, CMSMarkStack*  markStack,
6708                      HeapWord* finger, MarkFromRootsClosure* parent) :
6709   MetadataAwareOopClosure(collector->ref_processor()),
6710   _collector(collector),
6711   _span(span),
6712   _bitMap(bitMap),
6713   _markStack(markStack),
6714   _finger(finger),
6715   _parent(parent)
6716 { }
6717 
6718 ParPushOrMarkClosure::ParPushOrMarkClosure(CMSCollector* collector,
6719                                            MemRegion span,
6720                                            CMSBitMap* bit_map,
6721                                            OopTaskQueue* work_queue,
6722                                            CMSMarkStack*  overflow_stack,
6723                                            HeapWord* finger,
6724                                            HeapWord** global_finger_addr,
6725                                            ParMarkFromRootsClosure* parent) :
6726   MetadataAwareOopClosure(collector->ref_processor()),
6727   _collector(collector),
6728   _whole_span(collector->_span),
6729   _span(span),
6730   _bit_map(bit_map),
6731   _work_queue(work_queue),
6732   _overflow_stack(overflow_stack),
6733   _finger(finger),
6734   _global_finger_addr(global_finger_addr),
6735   _parent(parent)
6736 { }
6737 
6738 // Assumes thread-safe access by callers, who are
6739 // responsible for mutual exclusion.
6740 void CMSCollector::lower_restart_addr(HeapWord* low) {
6741   assert(_span.contains(low), "Out of bounds addr");
6742   if (_restart_addr == NULL) {
6743     _restart_addr = low;
6744   } else {




3013     _task = task;
3014   }
3015 };
3016 
3017 class CMSConcMarkingTerminatorTerminator: public TerminatorTerminator {
3018   CMSConcMarkingTask* _task;
3019  public:
3020   bool should_exit_termination();
3021   void set_task(CMSConcMarkingTask* task) {
3022     _task = task;
3023   }
3024 };
3025 
3026 // MT Concurrent Marking Task
3027 class CMSConcMarkingTask: public YieldingFlexibleGangTask {
3028   CMSCollector*             _collector;
3029   uint                      _n_workers;      // requested/desired # workers
3030   bool                      _result;
3031   CompactibleFreeListSpace* _cms_space;
3032   char                      _pad_front[64];   // padding to ...
3033   HeapWord* volatile        _global_finger;   // ... avoid sharing cache line
3034   char                      _pad_back[64];
3035   HeapWord*                 _restart_addr;
3036 
3037   //  Exposed here for yielding support
3038   Mutex* const _bit_map_lock;
3039 
3040   // The per thread work queues, available here for stealing
3041   OopTaskQueueSet*  _task_queues;
3042 
3043   // Termination (and yielding) support
3044   CMSConcMarkingTerminator _term;
3045   CMSConcMarkingTerminatorTerminator _term_term;
3046 
3047  public:
3048   CMSConcMarkingTask(CMSCollector* collector,
3049                  CompactibleFreeListSpace* cms_space,
3050                  YieldingFlexibleWorkGang* workers,
3051                  OopTaskQueueSet* task_queues):
3052     YieldingFlexibleGangTask("Concurrent marking done multi-threaded"),
3053     _collector(collector),
3054     _cms_space(cms_space),
3055     _n_workers(0), _result(true),
3056     _task_queues(task_queues),
3057     _term(_n_workers, task_queues, _collector),
3058     _bit_map_lock(collector->bitMapLock())
3059   {
3060     _requested_size = _n_workers;
3061     _term.set_task(this);
3062     _term_term.set_task(this);
3063     _restart_addr = _global_finger = _cms_space->bottom();
3064   }
3065 
3066 
3067   OopTaskQueueSet* task_queues()  { return _task_queues; }
3068 
3069   OopTaskQueue* work_queue(int i) { return task_queues()->queue(i); }
3070 
3071   HeapWord* volatile* global_finger_addr() { return &_global_finger; }
3072 
3073   CMSConcMarkingTerminator* terminator() { return &_term; }
3074 
3075   virtual void set_for_termination(uint active_workers) {
3076     terminator()->reset_for_reuse(active_workers);
3077   }
3078 
3079   void work(uint worker_id);
3080   bool should_yield() {
3081     return    ConcurrentMarkSweepThread::should_yield()
3082            && !_collector->foregroundGCIsActive();
3083   }
3084 
3085   virtual void coordinator_yield();  // stuff done by coordinator
3086   bool result() { return _result; }
3087 
3088   void reset(HeapWord* ra) {
3089     assert(_global_finger >= _cms_space->end(),  "Postcondition of ::work(i)");
3090     _restart_addr = _global_finger = ra;
3091     _term.reset_for_reuse();


6537     // [_threshold, _finger) represents the interval
6538     // of cards to be cleared  in MUT (or precleaned in card table).
6539     // The set of cards to be cleared is all those that overlap
6540     // with the interval [_threshold, _finger); note that
6541     // _threshold is always kept card-aligned but _finger isn't
6542     // always card-aligned.
6543     HeapWord* old_threshold = _threshold;
6544     assert(old_threshold == (HeapWord*)round_to(
6545             (intptr_t)old_threshold, CardTableModRefBS::card_size),
6546            "_threshold should always be card-aligned");
6547     _threshold = (HeapWord*)round_to(
6548                    (intptr_t)_finger, CardTableModRefBS::card_size);
6549     MemRegion mr(old_threshold, _threshold);
6550     assert(!mr.is_empty(), "Control point invariant");
6551     assert(_span.contains(mr), "Should clear within span"); // _whole_span ??
6552     _mut->clear_range(mr);
6553   }
6554 
6555   // Note: the local finger doesn't advance while we drain
6556   // the stack below, but the global finger sure can and will.
6557   HeapWord* volatile* gfa = _task->global_finger_addr();
6558   ParPushOrMarkClosure pushOrMarkClosure(_collector,
6559                                          _span, _bit_map,
6560                                          _work_queue,
6561                                          _overflow_stack,
6562                                          _finger,
6563                                          gfa, this);
6564   bool res = _work_queue->push(obj);   // overflow could occur here
6565   assert(res, "Will hold once we use workqueues");
6566   while (true) {
6567     oop new_oop;
6568     if (!_work_queue->pop_local(new_oop)) {
6569       // We emptied our work_queue; check if there's stuff that can
6570       // be gotten from the overflow stack.
6571       if (CMSConcMarkingTask::get_work_from_overflow_stack(
6572             _overflow_stack, _work_queue)) {
6573         do_yield_check();
6574         continue;
6575       } else {  // done
6576         break;
6577       }


6704 
6705 PushOrMarkClosure::PushOrMarkClosure(CMSCollector* collector,
6706                      MemRegion span,
6707                      CMSBitMap* bitMap, CMSMarkStack*  markStack,
6708                      HeapWord* finger, MarkFromRootsClosure* parent) :
6709   MetadataAwareOopClosure(collector->ref_processor()),
6710   _collector(collector),
6711   _span(span),
6712   _bitMap(bitMap),
6713   _markStack(markStack),
6714   _finger(finger),
6715   _parent(parent)
6716 { }
6717 
6718 ParPushOrMarkClosure::ParPushOrMarkClosure(CMSCollector* collector,
6719                                            MemRegion span,
6720                                            CMSBitMap* bit_map,
6721                                            OopTaskQueue* work_queue,
6722                                            CMSMarkStack*  overflow_stack,
6723                                            HeapWord* finger,
6724                                            HeapWord* volatile* global_finger_addr,
6725                                            ParMarkFromRootsClosure* parent) :
6726   MetadataAwareOopClosure(collector->ref_processor()),
6727   _collector(collector),
6728   _whole_span(collector->_span),
6729   _span(span),
6730   _bit_map(bit_map),
6731   _work_queue(work_queue),
6732   _overflow_stack(overflow_stack),
6733   _finger(finger),
6734   _global_finger_addr(global_finger_addr),
6735   _parent(parent)
6736 { }
6737 
6738 // Assumes thread-safe access by callers, who are
6739 // responsible for mutual exclusion.
6740 void CMSCollector::lower_restart_addr(HeapWord* low) {
6741   assert(_span.contains(low), "Out of bounds addr");
6742   if (_restart_addr == NULL) {
6743     _restart_addr = low;
6744   } else {


< prev index next >