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 "memory/universe.hpp"
32 #include "oops/markWord.inline.hpp"
33 #include "oops/access.inline.hpp"
34 #include "oops/compressedOops.inline.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "utilities/align.hpp"
37 #include "utilities/stack.inline.hpp"
38
39 inline void MarkSweep::mark_object(oop obj) {
40 // some marks may contain information we need to preserve so we store them away
41 // and overwrite the mark. We'll restore it at the end of markSweep.
42 markWord mark = obj->mark();
43 obj->set_mark(markWord::prototype().set_marked());
44
45 if (obj->mark_must_be_preserved(mark)) {
46 preserve_mark(obj, mark);
47 }
48 }
49
50 template <class T> inline void MarkSweep::mark_and_push(T* p) {
51 T heap_oop = RawAccess<>::oop_load(p);
52 if (!CompressedOops::is_null(heap_oop)) {
53 oop obj = CompressedOops::decode_not_null(heap_oop);
54 if (!obj->mark().is_marked()) {
55 mark_object(obj);
56 _marking_stack.push(obj);
57 }
58 }
59 }
60
61 inline void MarkSweep::follow_klass(Klass* klass) {
62 oop op = klass->class_loader_data()->holder_no_keepalive();
63 MarkSweep::mark_and_push(&op);
64 }
65
66 inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
67 MarkSweep::follow_cld_closure.do_cld(cld);
68 }
69
70 template <typename T>
71 inline void MarkAndPushClosure::do_oop_work(T* p) { MarkSweep::mark_and_push(p); }
72 inline void MarkAndPushClosure::do_oop(oop* p) { do_oop_work(p); }
73 inline void MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_work(p); }
74 inline void MarkAndPushClosure::do_klass(Klass* k) { MarkSweep::follow_klass(k); }
75 inline void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
76
77 template <class T> inline void MarkSweep::adjust_pointer(T* p) {
78 T heap_oop = RawAccess<>::oop_load(p);
79 if (!CompressedOops::is_null(heap_oop)) {
80 oop obj = CompressedOops::decode_not_null(heap_oop);
81 assert(Universe::heap()->is_in(obj), "should be in heap");
82
83 oop new_obj = cast_to_oop(obj->mark().decode_pointer());
84
85 assert(new_obj != NULL || // is forwarding ptr?
86 obj->mark() == markWord::prototype() || // not gc marked?
87 (UseBiasedLocking && obj->mark().has_bias_pattern()),
88 // not gc marked?
89 "should be forwarded");
90
91 if (new_obj != NULL) {
92 assert(is_object_aligned(new_obj), "oop must be aligned");
93 RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
94 }
95 }
96 }
97
98 template <typename T>
99 void AdjustPointerClosure::do_oop_work(T* p) { MarkSweep::adjust_pointer(p); }
100 inline void AdjustPointerClosure::do_oop(oop* p) { do_oop_work(p); }
101 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
102
103
104 inline int MarkSweep::adjust_pointers(oop obj) {
105 return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
106 }
107
108 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
|
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 "gc/shared/slidingForwarding.inline.hpp"
31 #include "classfile/classLoaderData.inline.hpp"
32 #include "memory/universe.hpp"
33 #include "oops/markWord.inline.hpp"
34 #include "oops/access.inline.hpp"
35 #include "oops/compressedOops.inline.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "utilities/align.hpp"
38 #include "utilities/stack.inline.hpp"
39
40 inline void MarkSweep::mark_object(oop obj) {
41 // some marks may contain information we need to preserve so we store them away
42 // and overwrite the mark. We'll restore it at the end of markSweep.
43 markWord mark = obj->mark();
44 #ifdef _LP64
45 if (UseCompactObjectHeaders) {
46 markWord real_mark = mark;
47 if (real_mark.has_displaced_mark_helper()) {
48 real_mark = real_mark.displaced_mark_helper();
49 }
50 Klass* klass = real_mark.klass();
51 obj->set_mark(klass->prototype_header().set_marked());
52 } else
53 #endif
54 {
55 obj->set_mark(markWord::prototype().set_marked());
56 }
57
58 if (obj->mark_must_be_preserved(mark)) {
59 preserve_mark(obj, mark);
60 }
61 }
62
63 template <class T> inline void MarkSweep::mark_and_push(T* p) {
64 T heap_oop = RawAccess<>::oop_load(p);
65 if (!CompressedOops::is_null(heap_oop)) {
66 oop obj = CompressedOops::decode_not_null(heap_oop);
67 if (!obj->mark().is_marked()) {
68 mark_object(obj);
69 _marking_stack.push(obj);
70 }
71 }
72 }
73
74 inline void MarkSweep::follow_klass(Klass* klass) {
75 oop op = klass->class_loader_data()->holder_no_keepalive();
76 MarkSweep::mark_and_push(&op);
77 }
78
79 inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
80 MarkSweep::follow_cld_closure.do_cld(cld);
81 }
82
83 template <typename T>
84 inline void MarkAndPushClosure::do_oop_work(T* p) { MarkSweep::mark_and_push(p); }
85 inline void MarkAndPushClosure::do_oop(oop* p) { do_oop_work(p); }
86 inline void MarkAndPushClosure::do_oop(narrowOop* p) { do_oop_work(p); }
87 inline void MarkAndPushClosure::do_klass(Klass* k) { MarkSweep::follow_klass(k); }
88 inline void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
89
90 template <class T> inline void MarkSweep::adjust_pointer(const SlidingForwarding* const forwarding, T* p) {
91 T heap_oop = RawAccess<>::oop_load(p);
92 if (!CompressedOops::is_null(heap_oop)) {
93 oop obj = CompressedOops::decode_not_null(heap_oop);
94 assert(Universe::heap()->is_in(obj), "should be in heap");
95
96 markWord header = obj->mark();
97 if (header.is_marked()) {
98 oop new_obj = forwarding->forwardee(obj);
99 assert(new_obj != NULL, "must be forwarded");
100 assert(is_object_aligned(new_obj), "oop must be aligned");
101 RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
102 }
103 }
104 }
105
106 template <typename T>
107 void AdjustPointerClosure::do_oop_work(T* p) { MarkSweep::adjust_pointer(_forwarding, p); }
108 inline void AdjustPointerClosure::do_oop(oop* p) { do_oop_work(p); }
109 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
110
111
112 inline int MarkSweep::adjust_pointers(const SlidingForwarding* const forwarding, oop obj) {
113 AdjustPointerClosure cl(forwarding);
114 return obj->oop_iterate_size(&cl);
115 }
116
117 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
|