208
209 // The active MT'ness degree of the queues below
210 uint _num_q;
211 // The maximum MT'ness degree of the queues below
212 uint _max_num_q;
213
214 // Master array of discovered oops
215 DiscoveredList* _discovered_refs;
216
217 // Arrays of lists of oops, one per thread (pointers into master array above)
218 DiscoveredList* _discoveredSoftRefs;
219 DiscoveredList* _discoveredWeakRefs;
220 DiscoveredList* _discoveredFinalRefs;
221 DiscoveredList* _discoveredPhantomRefs;
222
223 public:
224 static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
225
226 uint num_q() { return _num_q; }
227 uint max_num_q() { return _max_num_q; }
228 void set_active_mt_degree(uint v) { _num_q = v; }
229
230 DiscoveredList* discovered_refs() { return _discovered_refs; }
231
232 ReferencePolicy* setup_policy(bool always_clear) {
233 _current_soft_ref_policy = always_clear ?
234 _always_clear_soft_ref_policy : _default_soft_ref_policy;
235 _current_soft_ref_policy->setup(); // snapshot the policy threshold
236 return _current_soft_ref_policy;
237 }
238
239 // Process references with a certain reachability level.
240 void process_discovered_reflist(DiscoveredList refs_lists[],
241 ReferencePolicy* policy,
242 bool clear_referent,
243 BoolObjectClosure* is_alive,
244 OopClosure* keep_alive,
245 VoidClosure* complete_gc,
246 AbstractRefProcTaskExecutor* task_executor);
247
248 void process_phaseJNI(BoolObjectClosure* is_alive,
309
310 // Returns the name of the discovered reference list
311 // occupying the i / _num_q slot.
312 const char* list_name(uint i);
313
314 void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
315
316 protected:
317 // "Preclean" the given discovered reference list
318 // by removing references with strongly reachable referents.
319 // Currently used in support of CMS only.
320 void preclean_discovered_reflist(DiscoveredList& refs_list,
321 BoolObjectClosure* is_alive,
322 OopClosure* keep_alive,
323 VoidClosure* complete_gc,
324 YieldClosure* yield);
325
326 // round-robin mod _num_q (not: _not_ mode _max_num_q)
327 uint next_id() {
328 uint id = _next_id;
329 if (++_next_id == _num_q) {
330 _next_id = 0;
331 }
332 return id;
333 }
334 DiscoveredList* get_discovered_list(ReferenceType rt);
335 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
336 HeapWord* discovered_addr);
337
338 void clear_discovered_references(DiscoveredList& refs_list);
339
340 // Calculate the number of jni handles.
341 size_t count_jni_refs();
342
343 void log_reflist_counts(DiscoveredList ref_lists[], size_t total_count) PRODUCT_RETURN;
344
345 // Balances reference queues.
346 void balance_queues(DiscoveredList ref_lists[]);
347
348 // Update (advance) the soft ref master clock field.
349 void update_soft_ref_master_clock();
350
351 public:
352 // Default parameters give you a vanilla reference processor.
353 ReferenceProcessor(MemRegion span,
354 bool mt_processing = false, uint mt_processing_degree = 1,
355 bool mt_discovery = false, uint mt_discovery_degree = 1,
356 bool atomic_discovery = true,
357 BoolObjectClosure* is_alive_non_header = NULL);
358
359 // RefDiscoveryPolicy values
360 enum DiscoveryPolicy {
361 ReferenceBasedDiscovery = 0,
362 ReferentBasedDiscovery = 1,
363 DiscoveryPolicyMin = ReferenceBasedDiscovery,
|
208
209 // The active MT'ness degree of the queues below
210 uint _num_q;
211 // The maximum MT'ness degree of the queues below
212 uint _max_num_q;
213
214 // Master array of discovered oops
215 DiscoveredList* _discovered_refs;
216
217 // Arrays of lists of oops, one per thread (pointers into master array above)
218 DiscoveredList* _discoveredSoftRefs;
219 DiscoveredList* _discoveredWeakRefs;
220 DiscoveredList* _discoveredFinalRefs;
221 DiscoveredList* _discoveredPhantomRefs;
222
223 public:
224 static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
225
226 uint num_q() { return _num_q; }
227 uint max_num_q() { return _max_num_q; }
228 void set_active_mt_degree(uint v);
229
230 DiscoveredList* discovered_refs() { return _discovered_refs; }
231
232 ReferencePolicy* setup_policy(bool always_clear) {
233 _current_soft_ref_policy = always_clear ?
234 _always_clear_soft_ref_policy : _default_soft_ref_policy;
235 _current_soft_ref_policy->setup(); // snapshot the policy threshold
236 return _current_soft_ref_policy;
237 }
238
239 // Process references with a certain reachability level.
240 void process_discovered_reflist(DiscoveredList refs_lists[],
241 ReferencePolicy* policy,
242 bool clear_referent,
243 BoolObjectClosure* is_alive,
244 OopClosure* keep_alive,
245 VoidClosure* complete_gc,
246 AbstractRefProcTaskExecutor* task_executor);
247
248 void process_phaseJNI(BoolObjectClosure* is_alive,
309
310 // Returns the name of the discovered reference list
311 // occupying the i / _num_q slot.
312 const char* list_name(uint i);
313
314 void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
315
316 protected:
317 // "Preclean" the given discovered reference list
318 // by removing references with strongly reachable referents.
319 // Currently used in support of CMS only.
320 void preclean_discovered_reflist(DiscoveredList& refs_list,
321 BoolObjectClosure* is_alive,
322 OopClosure* keep_alive,
323 VoidClosure* complete_gc,
324 YieldClosure* yield);
325
326 // round-robin mod _num_q (not: _not_ mode _max_num_q)
327 uint next_id() {
328 uint id = _next_id;
329 assert(!_discovery_is_mt, "Round robin should only be used in serial discovery");
330 if (++_next_id == _num_q) {
331 _next_id = 0;
332 }
333 assert(_next_id < _num_q, "_next_id %u _num_q %u _max_num_q %u", _next_id, _num_q, _max_num_q);
334 return id;
335 }
336 DiscoveredList* get_discovered_list(ReferenceType rt);
337 inline void add_to_discovered_list_mt(DiscoveredList& refs_list, oop obj,
338 HeapWord* discovered_addr);
339
340 void clear_discovered_references(DiscoveredList& refs_list);
341
342 // Calculate the number of jni handles.
343 size_t count_jni_refs();
344
345 void log_reflist_counts(DiscoveredList ref_lists[], uint active_length, size_t total_count) PRODUCT_RETURN;
346
347 // Balances reference queues.
348 void balance_queues(DiscoveredList ref_lists[]);
349
350 // Update (advance) the soft ref master clock field.
351 void update_soft_ref_master_clock();
352
353 public:
354 // Default parameters give you a vanilla reference processor.
355 ReferenceProcessor(MemRegion span,
356 bool mt_processing = false, uint mt_processing_degree = 1,
357 bool mt_discovery = false, uint mt_discovery_degree = 1,
358 bool atomic_discovery = true,
359 BoolObjectClosure* is_alive_non_header = NULL);
360
361 // RefDiscoveryPolicy values
362 enum DiscoveryPolicy {
363 ReferenceBasedDiscovery = 0,
364 ReferentBasedDiscovery = 1,
365 DiscoveryPolicyMin = ReferenceBasedDiscovery,
|