218
219 // The SoftReference master timestamp clock
220 static jlong _soft_ref_timestamp_clock;
221
222 MemRegion _span; // (right-open) interval of heap
223 // subject to wkref discovery
224
225 bool _discovering_refs; // true when discovery enabled
226 bool _discovery_is_atomic; // if discovery is atomic wrt
227 // other collectors in configuration
228 bool _discovery_is_mt; // true if reference discovery is MT.
229
230 // If true, setting "next" field of a discovered refs list requires
231 // write barrier(s). (Must be true if used in a collector in which
232 // elements of a discovered list may be moved during discovery: for
233 // example, a collector like Garbage-First that moves objects during a
234 // long-term concurrent marking phase that does weak reference
235 // discovery.)
236 bool _discovered_list_needs_barrier;
237
238 BarrierSet* _bs; // Cached copy of BarrierSet.
239 bool _enqueuing_is_done; // true if all weak references enqueued
240 bool _processing_is_mt; // true during phases when
241 // reference processing is MT.
242 uint _next_id; // round-robin mod _num_q counter in
243 // support of work distribution
244
245 // For collectors that do not keep GC liveness information
246 // in the object header, this field holds a closure that
247 // helps the reference processor determine the reachability
248 // of an oop. It is currently initialized to NULL for all
249 // collectors except for CMS and G1.
250 BoolObjectClosure* _is_alive_non_header;
251
252 // Soft ref clearing policies
253 // . the default policy
254 static ReferencePolicy* _default_soft_ref_policy;
255 // . the "clear all" policy
256 static ReferencePolicy* _always_clear_soft_ref_policy;
257 // . the current policy below is either one of the above
258 ReferencePolicy* _current_soft_ref_policy;
403 return id;
404 }
405 DiscoveredList* get_discovered_list(ReferenceType rt);
406 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
407 HeapWord* discovered_addr);
408 void verify_ok_to_handle_reflists() PRODUCT_RETURN;
409
410 void clear_discovered_references(DiscoveredList& refs_list);
411 void abandon_partial_discovered_list(DiscoveredList& refs_list);
412
413 // Calculate the number of jni handles.
414 unsigned int count_jni_refs();
415
416 // Balances reference queues.
417 void balance_queues(DiscoveredList ref_lists[]);
418
419 // Update (advance) the soft ref master clock field.
420 void update_soft_ref_master_clock();
421
422 public:
423 // constructor
424 ReferenceProcessor():
425 _span((HeapWord*)NULL, (HeapWord*)NULL),
426 _discovered_refs(NULL),
427 _discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL),
428 _discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
429 _discovering_refs(false),
430 _discovery_is_atomic(true),
431 _enqueuing_is_done(false),
432 _discovery_is_mt(false),
433 _discovered_list_needs_barrier(false),
434 _bs(NULL),
435 _is_alive_non_header(NULL),
436 _num_q(0),
437 _max_num_q(0),
438 _processing_is_mt(false),
439 _next_id(0)
440 { }
441
442 // Default parameters give you a vanilla reference processor.
443 ReferenceProcessor(MemRegion span,
444 bool mt_processing = false, uint mt_processing_degree = 1,
445 bool mt_discovery = false, uint mt_discovery_degree = 1,
446 bool atomic_discovery = true,
447 BoolObjectClosure* is_alive_non_header = NULL,
448 bool discovered_list_needs_barrier = false);
449
450 // RefDiscoveryPolicy values
451 enum DiscoveryPolicy {
452 ReferenceBasedDiscovery = 0,
453 ReferentBasedDiscovery = 1,
454 DiscoveryPolicyMin = ReferenceBasedDiscovery,
455 DiscoveryPolicyMax = ReferentBasedDiscovery
456 };
457
458 static void init_statics();
459
460 public:
461 // get and set "is_alive_non_header" field
|
218
219 // The SoftReference master timestamp clock
220 static jlong _soft_ref_timestamp_clock;
221
222 MemRegion _span; // (right-open) interval of heap
223 // subject to wkref discovery
224
225 bool _discovering_refs; // true when discovery enabled
226 bool _discovery_is_atomic; // if discovery is atomic wrt
227 // other collectors in configuration
228 bool _discovery_is_mt; // true if reference discovery is MT.
229
230 // If true, setting "next" field of a discovered refs list requires
231 // write barrier(s). (Must be true if used in a collector in which
232 // elements of a discovered list may be moved during discovery: for
233 // example, a collector like Garbage-First that moves objects during a
234 // long-term concurrent marking phase that does weak reference
235 // discovery.)
236 bool _discovered_list_needs_barrier;
237
238 bool _enqueuing_is_done; // true if all weak references enqueued
239 bool _processing_is_mt; // true during phases when
240 // reference processing is MT.
241 uint _next_id; // round-robin mod _num_q counter in
242 // support of work distribution
243
244 // For collectors that do not keep GC liveness information
245 // in the object header, this field holds a closure that
246 // helps the reference processor determine the reachability
247 // of an oop. It is currently initialized to NULL for all
248 // collectors except for CMS and G1.
249 BoolObjectClosure* _is_alive_non_header;
250
251 // Soft ref clearing policies
252 // . the default policy
253 static ReferencePolicy* _default_soft_ref_policy;
254 // . the "clear all" policy
255 static ReferencePolicy* _always_clear_soft_ref_policy;
256 // . the current policy below is either one of the above
257 ReferencePolicy* _current_soft_ref_policy;
402 return id;
403 }
404 DiscoveredList* get_discovered_list(ReferenceType rt);
405 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
406 HeapWord* discovered_addr);
407 void verify_ok_to_handle_reflists() PRODUCT_RETURN;
408
409 void clear_discovered_references(DiscoveredList& refs_list);
410 void abandon_partial_discovered_list(DiscoveredList& refs_list);
411
412 // Calculate the number of jni handles.
413 unsigned int count_jni_refs();
414
415 // Balances reference queues.
416 void balance_queues(DiscoveredList ref_lists[]);
417
418 // Update (advance) the soft ref master clock field.
419 void update_soft_ref_master_clock();
420
421 public:
422 // Default parameters give you a vanilla reference processor.
423 ReferenceProcessor(MemRegion span,
424 bool mt_processing = false, uint mt_processing_degree = 1,
425 bool mt_discovery = false, uint mt_discovery_degree = 1,
426 bool atomic_discovery = true,
427 BoolObjectClosure* is_alive_non_header = NULL,
428 bool discovered_list_needs_barrier = false);
429
430 // RefDiscoveryPolicy values
431 enum DiscoveryPolicy {
432 ReferenceBasedDiscovery = 0,
433 ReferentBasedDiscovery = 1,
434 DiscoveryPolicyMin = ReferenceBasedDiscovery,
435 DiscoveryPolicyMax = ReferentBasedDiscovery
436 };
437
438 static void init_statics();
439
440 public:
441 // get and set "is_alive_non_header" field
|