< prev index next >

src/hotspot/share/gc/serial/markSweep.inline.hpp

Print this page

 1 /*
 2  * Copyright (c) 2000, 2022, 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_SERIAL_MARKSWEEP_INLINE_HPP
26 #define SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
27 
28 #include "gc/serial/markSweep.hpp"
29 
30 #include "classfile/classLoaderData.inline.hpp"
31 #include "classfile/javaClasses.inline.hpp"
32 #include "gc/shared/continuationGCSupport.inline.hpp"
33 #include "gc/serial/serialStringDedup.hpp"

34 #include "memory/universe.hpp"
35 #include "oops/markWord.hpp"
36 #include "oops/access.inline.hpp"
37 #include "oops/compressedOops.inline.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "utilities/align.hpp"
40 #include "utilities/stack.inline.hpp"
41 
42 template <class T> inline void MarkSweep::adjust_pointer(T* p) {

43   T heap_oop = RawAccess<>::oop_load(p);
44   if (!CompressedOops::is_null(heap_oop)) {
45     oop obj = CompressedOops::decode_not_null(heap_oop);
46     assert(Universe::heap()->is_in(obj), "should be in heap");
47 
48     if (obj->is_forwarded()) {
49       oop new_obj = obj->forwardee();
50       assert(is_object_aligned(new_obj), "oop must be aligned");
51       RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
52     }
53   }
54 }
55 

56 template <typename T>
57 void AdjustPointerClosure::do_oop_work(T* p)           { MarkSweep::adjust_pointer(p); }
58 inline void AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
59 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
60 




61 inline size_t MarkSweep::adjust_pointers(oop obj) {
62   return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);

63 }
64 
65 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP

 1 /*
 2  * Copyright (c) 2000, 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_SERIAL_MARKSWEEP_INLINE_HPP
26 #define SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
27 
28 #include "gc/serial/markSweep.hpp"
29 
30 #include "classfile/classLoaderData.inline.hpp"
31 #include "classfile/javaClasses.inline.hpp"
32 #include "gc/shared/continuationGCSupport.inline.hpp"
33 #include "gc/serial/serialStringDedup.hpp"
34 #include "gc/shared/slidingForwarding.inline.hpp"
35 #include "memory/universe.hpp"
36 #include "oops/markWord.hpp"
37 #include "oops/access.inline.hpp"
38 #include "oops/compressedOops.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "utilities/align.hpp"
41 #include "utilities/stack.inline.hpp"
42 
43 template <bool ALT_FWD, class T>
44 inline void MarkSweep::adjust_pointer(T* p) {
45   T heap_oop = RawAccess<>::oop_load(p);
46   if (!CompressedOops::is_null(heap_oop)) {
47     oop obj = CompressedOops::decode_not_null(heap_oop);
48     assert(Universe::heap()->is_in(obj), "should be in heap");
49 
50     if (SlidingForwarding::is_forwarded(obj)) {
51       oop new_obj = SlidingForwarding::forwardee<ALT_FWD>(obj);
52       assert(is_object_aligned(new_obj), "oop must be aligned");
53       RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
54     }
55   }
56 }
57 
58 template <bool ALT_FWD>
59 template <typename T>
60 void AdjustPointerClosure<ALT_FWD>::do_oop_work(T* p)           { MarkSweep::adjust_pointer<ALT_FWD>(p); }
61 template <bool ALT_FWD>
62 inline void AdjustPointerClosure<ALT_FWD>::do_oop(oop* p)       { do_oop_work(p); }
63 
64 template <bool ALT_FWD>
65 inline void AdjustPointerClosure<ALT_FWD>::do_oop(narrowOop* p) { do_oop_work(p); }
66 
67 template <bool ALT_FWD>
68 inline size_t MarkSweep::adjust_pointers(oop obj) {
69   AdjustPointerClosure<ALT_FWD> adjust_pointer_closure;
70   return obj->oop_iterate_size(&adjust_pointer_closure);
71 }
72 
73 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
< prev index next >