1 /* 2 * Copyright (c) 2016, 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_PARALLEL_PSPARALLELCOMPACT_INLINE_HPP 26 #define SHARE_GC_PARALLEL_PSPARALLELCOMPACT_INLINE_HPP 27 28 #include "gc/parallel/psParallelCompact.hpp" 29 30 #include "gc/parallel/parallelScavengeHeap.hpp" 31 #include "gc/parallel/parMarkBitMap.inline.hpp" 32 #include "gc/shared/collectedHeap.hpp" 33 #include "gc/shared/continuationGCSupport.inline.hpp" 34 #include "oops/access.inline.hpp" 35 #include "oops/compressedOops.inline.hpp" 36 #include "oops/klass.hpp" 37 #include "oops/oop.inline.hpp" 38 39 inline bool PSParallelCompact::is_marked(oop obj) { 40 return mark_bitmap()->is_marked(obj); 41 } 42 43 inline MutableSpace* PSParallelCompact::space(SpaceId id) { 44 assert(id < last_space_id, "id out of range"); 45 return _space_info[id].space(); 46 } 47 48 inline HeapWord* PSParallelCompact::new_top(SpaceId id) { 49 assert(id < last_space_id, "id out of range"); 50 return _space_info[id].new_top(); 51 } 52 53 inline HeapWord* PSParallelCompact::dense_prefix(SpaceId id) { 54 assert(id < last_space_id, "id out of range"); 55 return _space_info[id].dense_prefix(); 56 } 57 58 inline ObjectStartArray* PSParallelCompact::start_array(SpaceId id) { 59 assert(id < last_space_id, "id out of range"); 60 return _space_info[id].start_array(); 61 } 62 63 #ifdef ASSERT 64 inline void PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) { 65 assert(old_addr >= new_addr || space_id(old_addr) != space_id(new_addr), 66 "must move left or to a different space"); 67 assert(is_object_aligned(old_addr) && is_object_aligned(new_addr), 68 "checking alignment"); 69 } 70 #endif // ASSERT 71 72 template <class T> 73 inline void PSParallelCompact::adjust_pointer(T* p) { 74 T heap_oop = RawAccess<>::oop_load(p); 75 if (!CompressedOops::is_null(heap_oop)) { 76 oop obj = CompressedOops::decode_not_null(heap_oop); 77 assert(ParallelScavengeHeap::heap()->is_in(obj), "should be in heap"); 78 79 if (!obj->is_forwarded()) { 80 return; 81 } 82 oop new_obj = obj->forwardee(); 83 assert(new_obj != nullptr, "non-null address for live objects"); 84 assert(new_obj != obj, "inv"); 85 assert(ParallelScavengeHeap::heap()->is_in_reserved(new_obj), 86 "should be in object space"); 87 RawAccess<IS_NOT_NULL>::oop_store(p, new_obj); 88 } 89 } 90 91 #endif // SHARE_GC_PARALLEL_PSPARALLELCOMPACT_INLINE_HPP