1 /*
 2  * Copyright (c) 2017, 2023, Oracle and/or its affiliates. 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 
25 #ifndef SHARE_GC_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
26 #define SHARE_GC_G1_G1FULLGCOOPCLOSURES_INLINE_HPP
27 
28 #include "gc/g1/g1FullGCOopClosures.hpp"
29 
30 #include "gc/g1/g1Allocator.inline.hpp"
31 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
32 #include "gc/g1/g1FullCollector.inline.hpp"
33 #include "gc/g1/g1FullGCMarker.inline.hpp"
34 #include "gc/shared/slidingForwarding.inline.hpp"
35 #include "gc/g1/g1HeapRegionRemSet.inline.hpp"
36 #include "memory/iterator.inline.hpp"
37 #include "memory/universe.hpp"
38 #include "oops/access.inline.hpp"
39 #include "oops/compressedOops.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 
42 template <typename T>
43 inline void G1MarkAndPushClosure::do_oop_work(T* p) {
44   _marker->mark_and_push(p);
45 }
46 
47 inline void G1MarkAndPushClosure::do_oop(oop* p) {
48   do_oop_work(p);
49 }
50 
51 inline void G1MarkAndPushClosure::do_oop(narrowOop* p) {
52   do_oop_work(p);
53 }
54 
55 template <bool ALT_FWD>
56 template <class T> inline void G1AdjustClosure<ALT_FWD>::adjust_pointer(T* p) {
57   T heap_oop = RawAccess<>::oop_load(p);
58   if (CompressedOops::is_null(heap_oop)) {
59     return;
60   }
61 
62   oop obj = CompressedOops::decode_not_null(heap_oop);
63   assert(Universe::heap()->is_in(obj), "should be in heap");
64   if (!_collector->is_compacting(obj)) {
65     // We never forward objects in non-compacting regions so there is no need to
66     // process them further.
67     return;
68   }
69 
70   if (SlidingForwarding::is_forwarded(obj)) {
71     oop forwardee = SlidingForwarding::forwardee<ALT_FWD>(obj);
72     // Forwarded, just update.
73     assert(G1CollectedHeap::heap()->is_in_reserved(forwardee), "should be in object space");
74     RawAccess<IS_NOT_NULL>::oop_store(p, forwardee);
75   }
76 
77 }
78 
79 template <bool ALT_FWD>
80 inline void G1AdjustClosure<ALT_FWD>::do_oop(oop* p)       { do_oop_work(p); }
81 template <bool ALT_FWD>
82 inline void G1AdjustClosure<ALT_FWD>::do_oop(narrowOop* p) { do_oop_work(p); }
83 
84 inline bool G1IsAliveClosure::do_object_b(oop p) {
85   return _bitmap->is_marked(p);
86 }
87 
88 template<typename T>
89 inline void G1FullKeepAliveClosure::do_oop_work(T* p) {
90   _marker->mark_and_push(p);
91 }
92 
93 #endif // SHARE_GC_G1_G1FULLGCOOPCLOSURES_INLINE_HPP