--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Mon Mar 02 16:37:04 2009 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp Fri Mar 06 13:50:14 2009 -0800
@@ -31,24 +31,7 @@
}
inline void HRInto_G1RemSet::write_ref_nv(HeapRegion* from, oop* p) {
- oop obj = *p;
- assert(from != NULL && from->is_in_reserved(p),
- "p is not in a from");
- HeapRegion* to = _g1->heap_region_containing(obj);
- if (from != to && to != NULL) {
- if (!to->popular() && !from->is_survivor()) {
-#if G1_REM_SET_LOGGING
- gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS"
- " for region [" PTR_FORMAT ", " PTR_FORMAT ")",
- p, obj,
- to->bottom(), to->end());
-#endif
- assert(to->rem_set() != NULL, "Need per-region 'into' remsets.");
- if (to->rem_set()->add_reference(p)) {
- _g1->schedule_popular_region_evac(to);
- }
- }
- }
+ par_write_ref(from, p, 0);
}
inline void HRInto_G1RemSet::write_ref(HeapRegion* from, oop* p) {
@@ -82,7 +65,22 @@
HeapRegion* to = _g1->heap_region_containing(obj);
// The test below could be optimized by applying a bit op to to and from.
if (to != NULL && from != NULL && from != to) {
- if (!to->popular() && !from->is_survivor()) {
+ bool update_delayed = false;
+ // There is a tricky infinite loop if we keep pushing
+ // self forwarding pointers onto our _new_refs list.
+ // The _par_traversal_in_progress flag is true during the collection pause,
+ // false during the evacuation failure handing.
+ if (_par_traversal_in_progress &&
+ to->in_collection_set() && !self_forwarded(obj)) {
+ _new_refs[tid]->push(p);
+ // Deferred updates to the Cset are either discarded (in the normal case),
+ // or processed (if an evacuation failure occurs) at the end
+ // of the collection.
+ // See HRInto_G1RemSet::cleanup_after_oops_into_collection_set_do().
+ update_delayed = true;
+ }
+
+ if (!to->popular() && !update_delayed) {
#if G1_REM_SET_LOGGING
gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS"
" for region [" PTR_FORMAT ", " PTR_FORMAT ")",
@@ -94,11 +92,5 @@
_g1->schedule_popular_region_evac(to);
}
}
- // There is a tricky infinite loop if we keep pushing
- // self forwarding pointers onto our _new_refs list.
- if (_par_traversal_in_progress &&
- to->in_collection_set() && !self_forwarded(obj)) {
- _new_refs[tid]->push(p);
- }
}
}