comparison src/share/vm/gc_implementation/g1/g1RemSet.inline.hpp @ 1960:878b57474103

6978187: G1: assert(ParallelGCThreads> 1 || n_yielded() == _hrrs->occupied()) strikes again Summary: An evacuation failure while copying the roots caused an object, A, to be forwarded to itself. During the subsequent RSet updating a reference to A was processed causing the reference to be added to the RSet of A's heap region. As a result of adding to the remembered set we ran into the issue described in 6930581 - the sparse table expanded and the RSet scanning code walked the cards in one instance of RHashTable (_cur) while the occupied() counts the cards in the expanded table (_next). Reviewed-by: tonyp, iveresov
author johnc
date Tue, 16 Nov 2010 14:07:33 -0800
parents c32059ef4dc0
children f95d63e2154a
comparison
equal deleted inserted replaced
1954:e3e1fb85e50a 1960:878b57474103
29 return 1; 29 return 1;
30 } 30 }
31 } 31 }
32 32
33 template <class T> 33 template <class T>
34 inline void G1RemSet::write_ref_nv(HeapRegion* from, T* p) { 34 inline void G1RemSet::write_ref(HeapRegion* from, T* p) {
35 par_write_ref_nv(from, p, 0); 35 par_write_ref(from, p, 0);
36 }
37
38 inline bool G1RemSet::self_forwarded(oop obj) {
39 bool result = (obj->is_forwarded() && (obj->forwardee()== obj));
40 return result;
41 } 36 }
42 37
43 template <class T> 38 template <class T>
44 inline void G1RemSet::par_write_ref_nv(HeapRegion* from, T* p, int tid) { 39 inline void G1RemSet::par_write_ref(HeapRegion* from, T* p, int tid) {
45 oop obj = oopDesc::load_decode_heap_oop(p); 40 oop obj = oopDesc::load_decode_heap_oop(p);
46 #ifdef ASSERT 41 #ifdef ASSERT
47 // can't do because of races 42 // can't do because of races
48 // assert(obj == NULL || obj->is_oop(), "expected an oop"); 43 // assert(obj == NULL || obj->is_oop(), "expected an oop");
49 44
60 #endif // ASSERT 55 #endif // ASSERT
61 56
62 assert(from == NULL || from->is_in_reserved(p), "p is not in from"); 57 assert(from == NULL || from->is_in_reserved(p), "p is not in from");
63 58
64 HeapRegion* to = _g1->heap_region_containing(obj); 59 HeapRegion* to = _g1->heap_region_containing(obj);
65 // The test below could be optimized by applying a bit op to to and from. 60 if (to != NULL && from != to) {
66 if (to != NULL && from != NULL && from != to) {
67 // The _traversal_in_progress flag is true during the collection pause,
68 // false during the evacuation failure handling. This should avoid a
69 // potential loop if we were to add the card containing 'p' to the DCQS
70 // that's used to regenerate the remembered sets for the collection set,
71 // in the event of an evacuation failure, here. The UpdateRSImmediate
72 // closure will eventally call this routine.
73 if (_traversal_in_progress &&
74 to->in_collection_set() && !self_forwarded(obj)) {
75
76 assert(_cset_rs_update_cl[tid] != NULL, "should have been set already");
77 _cset_rs_update_cl[tid]->do_oop(p);
78
79 // Deferred updates to the CSet are either discarded (in the normal case),
80 // or processed (if an evacuation failure occurs) at the end
81 // of the collection.
82 // See G1RemSet::cleanup_after_oops_into_collection_set_do().
83 } else {
84 #if G1_REM_SET_LOGGING 61 #if G1_REM_SET_LOGGING
85 gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS" 62 gclog_or_tty->print_cr("Adding " PTR_FORMAT " (" PTR_FORMAT ") to RS"
86 " for region [" PTR_FORMAT ", " PTR_FORMAT ")", 63 " for region [" PTR_FORMAT ", " PTR_FORMAT ")",
87 p, obj, 64 p, obj,
88 to->bottom(), to->end()); 65 to->bottom(), to->end());
89 #endif 66 #endif
90 assert(to->rem_set() != NULL, "Need per-region 'into' remsets."); 67 assert(to->rem_set() != NULL, "Need per-region 'into' remsets.");
91 to->rem_set()->add_reference(p, tid); 68 to->rem_set()->add_reference(p, tid);
92 }
93 } 69 }
94 } 70 }
95 71
96 template <class T> 72 template <class T>
97 inline void UpdateRSOopClosure::do_oop_work(T* p) { 73 inline void UpdateRSOopClosure::do_oop_work(T* p) {
106 if (!oopDesc::is_null(heap_oop) && !_from->is_survivor()) { 82 if (!oopDesc::is_null(heap_oop) && !_from->is_survivor()) {
107 _g1_rem_set->par_write_ref(_from, p, 0); 83 _g1_rem_set->par_write_ref(_from, p, 0);
108 } 84 }
109 } 85 }
110 86
87 template <class T>
88 inline void UpdateRSOrPushRefOopClosure::do_oop_work(T* p) {
89 oop obj = oopDesc::load_decode_heap_oop(p);
90 #ifdef ASSERT
91 // can't do because of races
92 // assert(obj == NULL || obj->is_oop(), "expected an oop");
93
94 // Do the safe subset of is_oop
95 if (obj != NULL) {
96 #ifdef CHECK_UNHANDLED_OOPS
97 oopDesc* o = obj.obj();
98 #else
99 oopDesc* o = obj;
100 #endif // CHECK_UNHANDLED_OOPS
101 assert((intptr_t)o % MinObjAlignmentInBytes == 0, "not oop aligned");
102 assert(Universe::heap()->is_in_reserved(obj), "must be in heap");
103 }
104 #endif // ASSERT
105
106 assert(_from != NULL, "from region must be non-NULL");
107
108 HeapRegion* to = _g1->heap_region_containing(obj);
109 if (to != NULL && _from != to) {
110 // The _record_refs_into_cset flag is true during the RSet
111 // updating part of an evacuation pause. It is false at all
112 // other times:
113 // * rebuilding the rembered sets after a full GC
114 // * during concurrent refinement.
115 // * updating the remembered sets of regions in the collection
116 // set in the event of an evacuation failure (when deferred
117 // updates are enabled).
118
119 if (_record_refs_into_cset && to->in_collection_set()) {
120 // We are recording references that point into the collection
121 // set and this particular reference does exactly that...
122 // If the referenced object has already been forwarded
123 // to itself, we are handling an evacuation failure and
124 // we have already visited/tried to copy this object
125 // there is no need to retry.
126 if (!self_forwarded(obj)) {
127 assert(_push_ref_cl != NULL, "should not be null");
128 // Push the reference in the refs queue of the G1ParScanThreadState
129 // instance for this worker thread.
130 _push_ref_cl->do_oop(p);
131 }
132
133 // Deferred updates to the CSet are either discarded (in the normal case),
134 // or processed (if an evacuation failure occurs) at the end
135 // of the collection.
136 // See G1RemSet::cleanup_after_oops_into_collection_set_do().
137 } else {
138 // We either don't care about pushing references that point into the
139 // collection set (i.e. we're not during an evacuation pause) _or_
140 // the reference doesn't point into the collection set. Either way
141 // we add the reference directly to the RSet of the region containing
142 // the referenced object.
143 _g1_rem_set->par_write_ref(_from, p, _worker_i);
144 }
145 }
146 }
147