提交 57f866e9 编写于 作者: J johnc

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
上级 a299c2e7
......@@ -5068,7 +5068,7 @@ public:
// 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()) {
......
......@@ -105,19 +105,22 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
_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 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
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::verify_no_references_recorded() {
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 @@ void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr
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 @@ void ReferenceProcessor::abandon_partial_discovery() {
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 @@ void ReferenceProcessor::clean_up_discovered_references() {
"\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::verify_ok_to_handle_reflists() {
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]);
}
}
......
......@@ -255,7 +255,11 @@ class ReferenceProcessor : public CHeapObj {
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 @@ class ReferenceProcessor : public CHeapObj {
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 @@ class ReferenceProcessor : public CHeapObj {
// constructor
ReferenceProcessor():
_span((HeapWord*)NULL, (HeapWord*)NULL),
_discovered_refs(NULL),
_discoveredSoftRefs(NULL), _discoveredWeakRefs(NULL),
_discoveredFinalRefs(NULL), _discoveredPhantomRefs(NULL),
_discovering_refs(false),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册