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
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Fri Oct 14 11:12:24 2011 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Oct 17 09:57:41 2011 -0700
@@ -5068,7 +5068,7 @@
// Select discovered lists [i, i+stride, i+2*stride,...,limit)
for (int idx = i; idx < limit; idx += stride) {
- DiscoveredList& ref_list = rp->discovered_soft_refs()[idx];
+ DiscoveredList& ref_list = rp->discovered_refs()[idx];
DiscoveredListIterator iter(ref_list, &keep_alive, &always_alive);
while (iter.has_next()) {
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp Fri Oct 14 11:12:24 2011 -0400
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp Mon Oct 17 09:57:41 2011 -0700
@@ -105,19 +105,22 @@
_discovery_is_mt = mt_discovery;
_num_q = MAX2(1, mt_processing_degree);
_max_num_q = MAX2(_num_q, mt_discovery_degree);
- _discoveredSoftRefs = NEW_C_HEAP_ARRAY(DiscoveredList,
+ _discovered_refs = NEW_C_HEAP_ARRAY(DiscoveredList,
_max_num_q * number_of_subclasses_of_ref());
- if (_discoveredSoftRefs == NULL) {
+ if (_discovered_refs == NULL) {
vm_exit_during_initialization("Could not allocated RefProc Array");
}
+ _discoveredSoftRefs = &_discovered_refs[0];
_discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q];
_discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q];
_discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
- // Initialized all entries to NULL
+
+ // Initialize all entries to NULL
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
- _discoveredSoftRefs[i].set_head(NULL);
- _discoveredSoftRefs[i].set_length(0);
+ _discovered_refs[i].set_head(NULL);
+ _discovered_refs[i].set_length(0);
}
+
// If we do barriers, cache a copy of the barrier set.
if (discovered_list_needs_barrier) {
_bs = Universe::heap()->barrier_set();
@@ -129,7 +132,7 @@
void ReferenceProcessor::verify_no_references_recorded() {
guarantee(!_discovering_refs, "Discovering refs?");
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
- guarantee(_discoveredSoftRefs[i].is_empty(),
+ guarantee(_discovered_refs[i].is_empty(),
"Found non-empty discovered list");
}
}
@@ -138,9 +141,9 @@
void ReferenceProcessor::weak_oops_do(OopClosure* f) {
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
if (UseCompressedOops) {
- f->do_oop((narrowOop*)_discoveredSoftRefs[i].adr_head());
+ f->do_oop((narrowOop*)_discovered_refs[i].adr_head());
} else {
- f->do_oop((oop*)_discoveredSoftRefs[i].adr_head());
+ f->do_oop((oop*)_discovered_refs[i].adr_head());
}
}
}
@@ -423,15 +426,15 @@
AbstractRefProcTaskExecutor* task_executor) {
if (_processing_is_mt && task_executor != NULL) {
// Parallel code
- RefProcEnqueueTask tsk(*this, _discoveredSoftRefs,
+ RefProcEnqueueTask tsk(*this, _discovered_refs,
pending_list_addr, _max_num_q);
task_executor->execute(tsk);
} else {
// Serial code: call the parent class's implementation
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
- enqueue_discovered_reflist(_discoveredSoftRefs[i], pending_list_addr);
- _discoveredSoftRefs[i].set_head(NULL);
- _discoveredSoftRefs[i].set_length(0);
+ enqueue_discovered_reflist(_discovered_refs[i], pending_list_addr);
+ _discovered_refs[i].set_head(NULL);
+ _discovered_refs[i].set_length(0);
}
}
}
@@ -691,7 +694,7 @@
if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
gclog_or_tty->print_cr("\nAbandoning %s discovered list", list_name(i));
}
- abandon_partial_discovered_list(_discoveredSoftRefs[i]);
+ abandon_partial_discovered_list(_discovered_refs[i]);
}
}
@@ -952,7 +955,7 @@
"\nScrubbing %s discovered list of Null referents",
list_name(i));
}
- clean_up_discovered_reflist(_discoveredSoftRefs[i]);
+ clean_up_discovered_reflist(_discovered_refs[i]);
}
}
@@ -1402,7 +1405,7 @@
void ReferenceProcessor::clear_discovered_references() {
guarantee(!_discovering_refs, "Discovering refs?");
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
- clear_discovered_references(_discoveredSoftRefs[i]);
+ clear_discovered_references(_discovered_refs[i]);
}
}
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp Fri Oct 14 11:12:24 2011 -0400
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp Mon Oct 17 09:57:41 2011 -0700
@@ -255,7 +255,11 @@
int _num_q;
// The maximum MT'ness degree of the queues below
int _max_num_q;
- // Arrays of lists of oops, one per thread
+
+ // Master array of discovered oops
+ DiscoveredList* _discovered_refs;
+
+ // Arrays of lists of oops, one per thread (pointers into master array above)
DiscoveredList* _discoveredSoftRefs;
DiscoveredList* _discoveredWeakRefs;
DiscoveredList* _discoveredFinalRefs;
@@ -267,7 +271,8 @@
int num_q() { return _num_q; }
int max_num_q() { return _max_num_q; }
void set_active_mt_degree(int v) { _num_q = v; }
- DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
+
+ DiscoveredList* discovered_refs() { return _discovered_refs; }
ReferencePolicy* setup_policy(bool always_clear) {
_current_soft_ref_policy = always_clear ?
@@ -411,6 +416,7 @@
// constructor
ReferenceProcessor():
_span((HeapWord*)NULL, (HeapWord*)NULL),
+ _discovered_refs(NULL),
_discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL),
_discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
_discovering_refs(false),