11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
26
27 #include "gc/shared/markBitMap.inline.hpp"
28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
30 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
31 #include "gc/shenandoah/shenandoahStringDedup.hpp"
32 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
33 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
34 #include "memory/iterator.inline.hpp"
35 #include "oops/oop.inline.hpp"
36
37 template <class T, bool STRING_DEDUP, bool DEGEN>
38 void ShenandoahTraversalGC::process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, ShenandoahStrDedupQueue* dq) {
39 T o = RawAccess<>::oop_load(p);
40 if (!CompressedOops::is_null(o)) {
41 oop obj = CompressedOops::decode_not_null(o);
42 if (DEGEN) {
43 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
44 if (!oopDesc::unsafe_equals(obj, forw)) {
45 // Update reference.
46 RawAccess<OOP_NOT_NULL>::oop_store(p, forw);
47 }
48 obj = forw;
49 } else if (_heap->in_collection_set(obj)) {
50 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
51 if (oopDesc::unsafe_equals(obj, forw)) {
52 bool evacuated = false;
53 forw = _heap->evacuate_object(obj, thread, evacuated);
54 }
55 assert(! oopDesc::unsafe_equals(obj, forw) || _heap->cancelled_concgc() || _heap->is_degenerated_gc_in_progress(), "must be evacuated");
56 // Update reference.
57 _heap->atomic_compare_exchange_oop(forw, p, obj);
58 obj = forw;
59 }
60
61 if (!_heap->is_marked_next(obj) && _heap->mark_next(obj)) {
62 bool succeeded = queue->push(ShenandoahMarkTask(obj));
63 assert(succeeded, "must succeed to push to task queue");
64
65 if (STRING_DEDUP && ShenandoahStringDedup::is_candidate(obj) && !_heap->cancelled_concgc()) {
66 assert(ShenandoahStringDedup::is_enabled(), "Must be enabled");
67 assert(dq != NULL, "Dedup queue not set");
68 // Only dealing with to-space string, so that we can avoid evac-oom protocol, which is costly here.
69 assert(!_heap->in_collection_set(obj), "Must be in to-space");
70 ShenandoahStringDedup::enqueue_candidate(obj, dq);
71 }
72 }
73 }
74 }
75
76 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
|
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
26
27 #include "gc/shared/markBitMap.inline.hpp"
28 #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp"
29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
30 #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
31 #include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"
32 #include "gc/shenandoah/shenandoahStringDedup.hpp"
33 #include "gc/shenandoah/shenandoahTraversalGC.hpp"
34 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
35 #include "memory/iterator.inline.hpp"
36 #include "oops/oop.inline.hpp"
37
38 template <class T, bool STRING_DEDUP, bool DEGEN, bool UPDATE_MATRIX>
39 void ShenandoahTraversalGC::process_oop(T* p, Thread* thread, ShenandoahObjToScanQueue* queue, oop base_obj, ShenandoahStrDedupQueue* dq) {
40 T o = RawAccess<>::oop_load(p);
41 if (!CompressedOops::is_null(o)) {
42 oop obj = CompressedOops::decode_not_null(o);
43 bool update_matrix = true;
44 if (DEGEN) {
45 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
46 if (!oopDesc::unsafe_equals(obj, forw)) {
47 // Update reference.
48 RawAccess<OOP_NOT_NULL>::oop_store(p, forw);
49 }
50 obj = forw;
51 } else if (_heap->in_collection_set(obj)) {
52 oop forw = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
53 if (oopDesc::unsafe_equals(obj, forw)) {
54 forw = _heap->evacuate_object(obj, thread);
55 }
56 // tty->print_cr("NORMAL visit: "PTR_FORMAT", obj: "PTR_FORMAT" to "PTR_FORMAT, p2i(p), p2i(obj), p2i(forw));
57 assert(! oopDesc::unsafe_equals(obj, forw) || _heap->cancelled_concgc(), "must be evacuated");
58 // Update reference.
59 oop previous = _heap->atomic_compare_exchange_oop(forw, p, obj);
60 if (UPDATE_MATRIX && !oopDesc::unsafe_equals(previous, obj)) {
61 update_matrix = false;
62 }
63 obj = forw;
64 }
65
66 if (UPDATE_MATRIX && update_matrix) {
67 shenandoah_assert_not_forwarded_except(p, obj, _heap->cancelled_concgc());
68 const void* src;
69 if (!_heap->is_in_reserved(p)) {
70 src = (const void*)(HeapWord*) obj;
71 } else {
72 src = p;
73 }
74 if (src != NULL) {
75 _matrix->set_connected(src, obj);
76 }
77 }
78
79 if (_traversal_set->is_in((HeapWord*) obj) && !_heap->is_marked_next(obj) && _heap->mark_next(obj)) {
80 bool succeeded = queue->push(ShenandoahMarkTask(obj));
81 assert(succeeded, "must succeed to push to task queue");
82
83 if (STRING_DEDUP && ShenandoahStringDedup::is_candidate(obj) && !_heap->cancelled_concgc()) {
84 assert(ShenandoahStringDedup::is_enabled(), "Must be enabled");
85 assert(dq != NULL, "Dedup queue not set");
86 // Only dealing with to-space string, so that we can avoid evac-oom protocol, which is costly here.
87 assert(!_heap->in_collection_set(obj), "Must be in to-space");
88 ShenandoahStringDedup::enqueue_candidate(obj, dq);
89 }
90 }
91 }
92 }
93
94 #endif // SHARE_VM_GC_SHENANDOAH_SHENANDOAHTRAVERSALGC_INLINE_HPP
|