1 /*
2 * Copyright (c) 2016, 2024, Oracle and/or its affiliates. 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
26 #ifndef SHARE_GC_PARALLEL_PSPARALLELCOMPACTNEW_INLINE_HPP
27 #define SHARE_GC_PARALLEL_PSPARALLELCOMPACTNEW_INLINE_HPP
28
29 #include "gc/parallel/psParallelCompactNew.hpp"
30
31 #include "gc/parallel/parallelScavengeHeap.hpp"
32 #include "gc/parallel/parMarkBitMap.inline.hpp"
33 #include "gc/shared/collectedHeap.hpp"
34 #include "gc/shared/continuationGCSupport.inline.hpp"
35 #include "gc/shared/fullGCForwarding.inline.hpp"
36 #include "oops/access.inline.hpp"
37 #include "oops/compressedOops.inline.hpp"
38 #include "oops/klass.hpp"
39 #include "oops/oop.inline.hpp"
40
41 inline bool PSParallelCompactNew::is_marked(oop obj) {
42 return mark_bitmap()->is_marked(obj);
43 }
44
45 inline MutableSpace* PSParallelCompactNew::space(SpaceId id) {
46 assert(id < last_space_id, "id out of range");
47 return _space_info[id].space();
48 }
49
50 inline ObjectStartArray* PSParallelCompactNew::start_array(SpaceId id) {
51 assert(id < last_space_id, "id out of range");
52 return _space_info[id].start_array();
53 }
54
55 template <class T>
56 inline void PSParallelCompactNew::adjust_pointer(T* p) {
57 T heap_oop = RawAccess<>::oop_load(p);
58 if (!CompressedOops::is_null(heap_oop)) {
59 oop obj = CompressedOops::decode_not_null(heap_oop);
60 assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap");
61 assert(is_marked(obj), "must be marked");
62 if (!FullGCForwarding::is_forwarded(obj)) {
63 return;
64 }
65 oop new_obj = FullGCForwarding::forwardee(obj);
66 assert(new_obj != nullptr, "non-null address for live objects");
67 assert(new_obj != obj, "inv");
68 assert(ParallelScavengeHeap::heap()->is_in_reserved(new_obj),
69 "should be in object space");
70 RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
71 }
72 }
73
74 #endif // SHARE_GC_PARALLEL_PSPARALLELCOMPACTNEW_INLINE_HPP