Mercurial > hg > graal-compiler
comparison src/share/vm/memory/referenceProcessor.cpp @ 4014:bf2d2b8b1726
7095243: Disambiguate ReferenceProcessor::_discoveredSoftRefs
Summary: Add a new, separate, pointer to the base of the array of discovered reference lists and use this new pointer in places where we iterate over the entire array.
Reviewed-by: ysr, brutisso
author | johnc |
---|---|
date | Mon, 17 Oct 2011 09:57:41 -0700 |
parents | d1bdeef3e3e2 |
children | e7dead7e90af |
comparison
equal
deleted
inserted
replaced
4013:074f0252cc13 | 4014:bf2d2b8b1726 |
---|---|
103 _span = span; | 103 _span = span; |
104 _discovery_is_atomic = atomic_discovery; | 104 _discovery_is_atomic = atomic_discovery; |
105 _discovery_is_mt = mt_discovery; | 105 _discovery_is_mt = mt_discovery; |
106 _num_q = MAX2(1, mt_processing_degree); | 106 _num_q = MAX2(1, mt_processing_degree); |
107 _max_num_q = MAX2(_num_q, mt_discovery_degree); | 107 _max_num_q = MAX2(_num_q, mt_discovery_degree); |
108 _discoveredSoftRefs = NEW_C_HEAP_ARRAY(DiscoveredList, | 108 _discovered_refs = NEW_C_HEAP_ARRAY(DiscoveredList, |
109 _max_num_q * number_of_subclasses_of_ref()); | 109 _max_num_q * number_of_subclasses_of_ref()); |
110 if (_discoveredSoftRefs == NULL) { | 110 if (_discovered_refs == NULL) { |
111 vm_exit_during_initialization("Could not allocated RefProc Array"); | 111 vm_exit_during_initialization("Could not allocated RefProc Array"); |
112 } | 112 } |
113 _discoveredSoftRefs = &_discovered_refs[0]; | |
113 _discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q]; | 114 _discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q]; |
114 _discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q]; | 115 _discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q]; |
115 _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q]; | 116 _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q]; |
116 // Initialized all entries to NULL | 117 |
118 // Initialize all entries to NULL | |
117 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 119 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
118 _discoveredSoftRefs[i].set_head(NULL); | 120 _discovered_refs[i].set_head(NULL); |
119 _discoveredSoftRefs[i].set_length(0); | 121 _discovered_refs[i].set_length(0); |
120 } | 122 } |
123 | |
121 // If we do barriers, cache a copy of the barrier set. | 124 // If we do barriers, cache a copy of the barrier set. |
122 if (discovered_list_needs_barrier) { | 125 if (discovered_list_needs_barrier) { |
123 _bs = Universe::heap()->barrier_set(); | 126 _bs = Universe::heap()->barrier_set(); |
124 } | 127 } |
125 setup_policy(false /* default soft ref policy */); | 128 setup_policy(false /* default soft ref policy */); |
127 | 130 |
128 #ifndef PRODUCT | 131 #ifndef PRODUCT |
129 void ReferenceProcessor::verify_no_references_recorded() { | 132 void ReferenceProcessor::verify_no_references_recorded() { |
130 guarantee(!_discovering_refs, "Discovering refs?"); | 133 guarantee(!_discovering_refs, "Discovering refs?"); |
131 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 134 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
132 guarantee(_discoveredSoftRefs[i].is_empty(), | 135 guarantee(_discovered_refs[i].is_empty(), |
133 "Found non-empty discovered list"); | 136 "Found non-empty discovered list"); |
134 } | 137 } |
135 } | 138 } |
136 #endif | 139 #endif |
137 | 140 |
138 void ReferenceProcessor::weak_oops_do(OopClosure* f) { | 141 void ReferenceProcessor::weak_oops_do(OopClosure* f) { |
139 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 142 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
140 if (UseCompressedOops) { | 143 if (UseCompressedOops) { |
141 f->do_oop((narrowOop*)_discoveredSoftRefs[i].adr_head()); | 144 f->do_oop((narrowOop*)_discovered_refs[i].adr_head()); |
142 } else { | 145 } else { |
143 f->do_oop((oop*)_discoveredSoftRefs[i].adr_head()); | 146 f->do_oop((oop*)_discovered_refs[i].adr_head()); |
144 } | 147 } |
145 } | 148 } |
146 } | 149 } |
147 | 150 |
148 void ReferenceProcessor::update_soft_ref_master_clock() { | 151 void ReferenceProcessor::update_soft_ref_master_clock() { |
421 // Enqueue references that are not made active again | 424 // Enqueue references that are not made active again |
422 void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr, | 425 void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr, |
423 AbstractRefProcTaskExecutor* task_executor) { | 426 AbstractRefProcTaskExecutor* task_executor) { |
424 if (_processing_is_mt && task_executor != NULL) { | 427 if (_processing_is_mt && task_executor != NULL) { |
425 // Parallel code | 428 // Parallel code |
426 RefProcEnqueueTask tsk(*this, _discoveredSoftRefs, | 429 RefProcEnqueueTask tsk(*this, _discovered_refs, |
427 pending_list_addr, _max_num_q); | 430 pending_list_addr, _max_num_q); |
428 task_executor->execute(tsk); | 431 task_executor->execute(tsk); |
429 } else { | 432 } else { |
430 // Serial code: call the parent class's implementation | 433 // Serial code: call the parent class's implementation |
431 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 434 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
432 enqueue_discovered_reflist(_discoveredSoftRefs[i], pending_list_addr); | 435 enqueue_discovered_reflist(_discovered_refs[i], pending_list_addr); |
433 _discoveredSoftRefs[i].set_head(NULL); | 436 _discovered_refs[i].set_head(NULL); |
434 _discoveredSoftRefs[i].set_length(0); | 437 _discovered_refs[i].set_length(0); |
435 } | 438 } |
436 } | 439 } |
437 } | 440 } |
438 | 441 |
439 void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) { | 442 void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) { |
689 // loop over the lists | 692 // loop over the lists |
690 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 693 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
691 if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) { | 694 if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) { |
692 gclog_or_tty->print_cr("\nAbandoning %s discovered list", list_name(i)); | 695 gclog_or_tty->print_cr("\nAbandoning %s discovered list", list_name(i)); |
693 } | 696 } |
694 abandon_partial_discovered_list(_discoveredSoftRefs[i]); | 697 abandon_partial_discovered_list(_discovered_refs[i]); |
695 } | 698 } |
696 } | 699 } |
697 | 700 |
698 class RefProcPhase1Task: public AbstractRefProcTaskExecutor::ProcessTask { | 701 class RefProcPhase1Task: public AbstractRefProcTaskExecutor::ProcessTask { |
699 public: | 702 public: |
950 if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) { | 953 if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) { |
951 gclog_or_tty->print_cr( | 954 gclog_or_tty->print_cr( |
952 "\nScrubbing %s discovered list of Null referents", | 955 "\nScrubbing %s discovered list of Null referents", |
953 list_name(i)); | 956 list_name(i)); |
954 } | 957 } |
955 clean_up_discovered_reflist(_discoveredSoftRefs[i]); | 958 clean_up_discovered_reflist(_discovered_refs[i]); |
956 } | 959 } |
957 } | 960 } |
958 | 961 |
959 void ReferenceProcessor::clean_up_discovered_reflist(DiscoveredList& refs_list) { | 962 void ReferenceProcessor::clean_up_discovered_reflist(DiscoveredList& refs_list) { |
960 assert(!discovery_is_atomic(), "Else why call this method?"); | 963 assert(!discovery_is_atomic(), "Else why call this method?"); |
1400 | 1403 |
1401 #ifndef PRODUCT | 1404 #ifndef PRODUCT |
1402 void ReferenceProcessor::clear_discovered_references() { | 1405 void ReferenceProcessor::clear_discovered_references() { |
1403 guarantee(!_discovering_refs, "Discovering refs?"); | 1406 guarantee(!_discovering_refs, "Discovering refs?"); |
1404 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 1407 for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
1405 clear_discovered_references(_discoveredSoftRefs[i]); | 1408 clear_discovered_references(_discovered_refs[i]); |
1406 } | 1409 } |
1407 } | 1410 } |
1408 | 1411 |
1409 #endif // PRODUCT | 1412 #endif // PRODUCT |