1 /*
2 * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
25 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
26
27 #include "gc/shenandoah/shenandoahClosures.hpp"
28
29 #include "gc/shared/barrierSetNMethod.hpp"
30 #include "gc/shenandoah/shenandoahAsserts.hpp"
31 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
32 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
33 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
34 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
35 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
36 #include "memory/iterator.inline.hpp"
37 #include "oops/compressedOops.inline.hpp"
38 #include "runtime/atomic.hpp"
39 #include "runtime/javaThread.hpp"
40
41 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
42 _mark_context(ShenandoahHeap::heap()->marking_context()) {
43 }
44
45 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
46 if (CompressedOops::is_null(obj)) {
47 return false;
48 }
49 obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
50 shenandoah_assert_not_forwarded_if(nullptr, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
51 return _mark_context->is_marked(obj);
52 }
53
54 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
55 _mark_context(ShenandoahHeap::heap()->marking_context()) {
56 }
57
58 bool ShenandoahIsAliveClosure::do_object_b(oop obj) {
59 if (CompressedOops::is_null(obj)) {
60 return false;
61 }
62 shenandoah_assert_not_forwarded(nullptr, obj);
63 return _mark_context->is_marked(obj);
64 }
65
66 BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() {
67 return ShenandoahHeap::heap()->has_forwarded_objects() ?
68 reinterpret_cast<BoolObjectClosure*>(&_fwd_alive_cl) :
69 reinterpret_cast<BoolObjectClosure*>(&_alive_cl);
70 }
71
72 void ShenandoahOopClosureBase::do_nmethod(nmethod* nm) {
73 nm->run_nmethod_entry_barrier();
74 }
75
76 ShenandoahKeepAliveClosure::ShenandoahKeepAliveClosure() :
77 _bs(ShenandoahBarrierSet::barrier_set()) {
78 }
79
80 void ShenandoahKeepAliveClosure::do_oop(oop* p) {
81 do_oop_work(p);
82 }
83
84 void ShenandoahKeepAliveClosure::do_oop(narrowOop* p) {
85 do_oop_work(p);
86 }
87
88 template <typename T>
89 void ShenandoahKeepAliveClosure::do_oop_work(T* p) {
90 assert(ShenandoahHeap::heap()->is_concurrent_mark_in_progress(), "Only for concurrent marking phase");
91 assert(!ShenandoahHeap::heap()->has_forwarded_objects(), "Not expected");
92
93 T o = RawAccess<>::oop_load(p);
94 if (!CompressedOops::is_null(o)) {
95 oop obj = CompressedOops::decode_not_null(o);
96 _bs->enqueue(obj);
97 }
98 }
99
100 ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() :
101 _heap(ShenandoahHeap::heap()) {
102 }
103
104 template <class T>
105 void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {
106 _heap->update_with_forwarded(p);
107 }
108
109 void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }
110 void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
111
|
1 /*
2 * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_INLINE_HPP
27
28 #include "gc/shenandoah/shenandoahClosures.hpp"
29
30 #include "gc/shared/barrierSetNMethod.hpp"
31 #include "gc/shenandoah/shenandoahAsserts.hpp"
32 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
33 #include "gc/shenandoah/shenandoahEvacOOMHandler.inline.hpp"
34 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
35 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
36 #include "gc/shenandoah/shenandoahNMethod.inline.hpp"
37 #include "memory/iterator.inline.hpp"
38 #include "oops/compressedOops.inline.hpp"
39 #include "runtime/atomic.hpp"
40 #include "runtime/javaThread.hpp"
41
42 ShenandoahFlushSATBHandshakeClosure::ShenandoahFlushSATBHandshakeClosure(SATBMarkQueueSet& qset) :
43 HandshakeClosure("Shenandoah Flush SATB"),
44 _qset(qset) {}
45
46 void ShenandoahFlushSATBHandshakeClosure::do_thread(Thread* thread) {
47 _qset.flush_queue(ShenandoahThreadLocalData::satb_mark_queue(thread));
48 }
49
50 ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() :
51 _mark_context(ShenandoahHeap::heap()->marking_context()) {
52 }
53
54 bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) {
55 if (CompressedOops::is_null(obj)) {
56 return false;
57 }
58 obj = ShenandoahBarrierSet::resolve_forwarded_not_null(obj);
59 shenandoah_assert_not_forwarded_if(nullptr, obj, ShenandoahHeap::heap()->is_concurrent_mark_in_progress());
60 return _mark_context->is_marked_or_old(obj);
61 }
62
63 ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() :
64 _mark_context(ShenandoahHeap::heap()->marking_context()) {
65 }
66
67 bool ShenandoahIsAliveClosure::do_object_b(oop obj) {
68 if (CompressedOops::is_null(obj)) {
69 return false;
70 }
71 shenandoah_assert_not_forwarded(nullptr, obj);
72 return _mark_context->is_marked_or_old(obj);
73 }
74
75 BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() {
76 return ShenandoahHeap::heap()->has_forwarded_objects() ?
77 reinterpret_cast<BoolObjectClosure*>(&_fwd_alive_cl) :
78 reinterpret_cast<BoolObjectClosure*>(&_alive_cl);
79 }
80
81 void ShenandoahOopClosureBase::do_nmethod(nmethod* nm) {
82 nm->run_nmethod_entry_barrier();
83 }
84
85 ShenandoahKeepAliveClosure::ShenandoahKeepAliveClosure() :
86 _bs(ShenandoahBarrierSet::barrier_set()) {
87 }
88
89 void ShenandoahKeepAliveClosure::do_oop(oop* p) {
90 do_oop_work(p);
91 }
92
93 void ShenandoahKeepAliveClosure::do_oop(narrowOop* p) {
94 do_oop_work(p);
95 }
96
97 template <typename T>
98 void ShenandoahKeepAliveClosure::do_oop_work(T* p) {
99 assert(ShenandoahHeap::heap()->is_concurrent_mark_in_progress(), "Only for concurrent marking phase");
100 assert(ShenandoahHeap::heap()->is_concurrent_old_mark_in_progress() || !ShenandoahHeap::heap()->has_forwarded_objects(), "Not expected");
101
102 T o = RawAccess<>::oop_load(p);
103 if (!CompressedOops::is_null(o)) {
104 oop obj = CompressedOops::decode_not_null(o);
105 _bs->enqueue(obj);
106 }
107 }
108
109 ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() :
110 _heap(ShenandoahHeap::heap()) {
111 }
112
113 template <class T>
114 void ShenandoahUpdateRefsClosure::do_oop_work(T* p) {
115 _heap->update_with_forwarded(p);
116 }
117
118 void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); }
119 void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); }
120
|