193 // Statistics
194 NOT_PRODUCT(
195 inline size_t processed() const { return _processed; }
196 inline size_t removed() const { return _removed; }
197 )
198
199 inline void move_to_next() {
200 if (_ref == _next) {
201 // End of the list.
202 _ref = NULL;
203 } else {
204 _ref = _next;
205 }
206 assert(_ref != _first_seen, "cyclic ref_list found");
207 NOT_PRODUCT(_processed++);
208 }
209 };
210
211 class ReferenceProcessor : public CHeapObj<mtGC> {
212
213 private:
214 size_t total_count(DiscoveredList lists[]);
215
216 protected:
217 // Compatibility with pre-4965777 JDK's
218 static bool _pending_list_uses_discovered_field;
219
220 // The SoftReference master timestamp clock
221 static jlong _soft_ref_timestamp_clock;
222
223 MemRegion _span; // (right-open) interval of heap
224 // subject to wkref discovery
225
226 bool _discovering_refs; // true when discovery enabled
227 bool _discovery_is_atomic; // if discovery is atomic wrt
228 // other collectors in configuration
229 bool _discovery_is_mt; // true if reference discovery is MT.
230
231 bool _enqueuing_is_done; // true if all weak references enqueued
232 bool _processing_is_mt; // true during phases when
233 // reference processing is MT.
650
651 // Abstract reference processing task to execute.
652 class AbstractRefProcTaskExecutor::ProcessTask {
653 protected:
654 ProcessTask(ReferenceProcessor& ref_processor,
655 DiscoveredList refs_lists[],
656 bool marks_oops_alive)
657 : _ref_processor(ref_processor),
658 _refs_lists(refs_lists),
659 _marks_oops_alive(marks_oops_alive)
660 { }
661
662 public:
663 virtual void work(unsigned int work_id, BoolObjectClosure& is_alive,
664 OopClosure& keep_alive,
665 VoidClosure& complete_gc) = 0;
666
667 // Returns true if a task marks some oops as alive.
668 bool marks_oops_alive() const
669 { return _marks_oops_alive; }
670
671 protected:
672 ReferenceProcessor& _ref_processor;
673 DiscoveredList* _refs_lists;
674 const bool _marks_oops_alive;
675 };
676
677 // Abstract reference processing task to execute.
678 class AbstractRefProcTaskExecutor::EnqueueTask {
679 protected:
680 EnqueueTask(ReferenceProcessor& ref_processor,
681 DiscoveredList refs_lists[],
682 HeapWord* pending_list_addr,
683 int n_queues)
684 : _ref_processor(ref_processor),
685 _refs_lists(refs_lists),
686 _pending_list_addr(pending_list_addr),
687 _n_queues(n_queues)
688 { }
689
|
193 // Statistics
194 NOT_PRODUCT(
195 inline size_t processed() const { return _processed; }
196 inline size_t removed() const { return _removed; }
197 )
198
199 inline void move_to_next() {
200 if (_ref == _next) {
201 // End of the list.
202 _ref = NULL;
203 } else {
204 _ref = _next;
205 }
206 assert(_ref != _first_seen, "cyclic ref_list found");
207 NOT_PRODUCT(_processed++);
208 }
209 };
210
211 class ReferenceProcessor : public CHeapObj<mtGC> {
212
213 public:
214 size_t total_count(DiscoveredList lists[]);
215
216 protected:
217 // Compatibility with pre-4965777 JDK's
218 static bool _pending_list_uses_discovered_field;
219
220 // The SoftReference master timestamp clock
221 static jlong _soft_ref_timestamp_clock;
222
223 MemRegion _span; // (right-open) interval of heap
224 // subject to wkref discovery
225
226 bool _discovering_refs; // true when discovery enabled
227 bool _discovery_is_atomic; // if discovery is atomic wrt
228 // other collectors in configuration
229 bool _discovery_is_mt; // true if reference discovery is MT.
230
231 bool _enqueuing_is_done; // true if all weak references enqueued
232 bool _processing_is_mt; // true during phases when
233 // reference processing is MT.
650
651 // Abstract reference processing task to execute.
652 class AbstractRefProcTaskExecutor::ProcessTask {
653 protected:
654 ProcessTask(ReferenceProcessor& ref_processor,
655 DiscoveredList refs_lists[],
656 bool marks_oops_alive)
657 : _ref_processor(ref_processor),
658 _refs_lists(refs_lists),
659 _marks_oops_alive(marks_oops_alive)
660 { }
661
662 public:
663 virtual void work(unsigned int work_id, BoolObjectClosure& is_alive,
664 OopClosure& keep_alive,
665 VoidClosure& complete_gc) = 0;
666
667 // Returns true if a task marks some oops as alive.
668 bool marks_oops_alive() const
669 { return _marks_oops_alive; }
670
671 bool is_empty() const {
672 return _ref_processor.total_count(_refs_lists) == 0;
673 }
674
675 protected:
676 ReferenceProcessor& _ref_processor;
677 DiscoveredList* _refs_lists;
678 const bool _marks_oops_alive;
679 };
680
681 // Abstract reference processing task to execute.
682 class AbstractRefProcTaskExecutor::EnqueueTask {
683 protected:
684 EnqueueTask(ReferenceProcessor& ref_processor,
685 DiscoveredList refs_lists[],
686 HeapWord* pending_list_addr,
687 int n_queues)
688 : _ref_processor(ref_processor),
689 _refs_lists(refs_lists),
690 _pending_list_addr(pending_list_addr),
691 _n_queues(n_queues)
692 { }
693
|