1 /* |
1 /* |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
64 CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure); |
64 CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure); |
65 |
65 |
66 inline void MarkSweep::mark_object(oop obj) { |
66 inline void MarkSweep::mark_object(oop obj) { |
67 // some marks may contain information we need to preserve so we store them away |
67 // some marks may contain information we need to preserve so we store them away |
68 // and overwrite the mark. We'll restore it at the end of markSweep. |
68 // and overwrite the mark. We'll restore it at the end of markSweep. |
69 markOop mark = obj->mark(); |
69 markOop mark = obj->mark_raw(); |
70 obj->set_mark(markOopDesc::prototype()->set_marked()); |
70 obj->set_mark_raw(markOopDesc::prototype()->set_marked()); |
71 |
71 |
72 if (mark->must_be_preserved(obj)) { |
72 if (mark->must_be_preserved(obj)) { |
73 preserve_mark(obj, mark); |
73 preserve_mark(obj, mark); |
74 } |
74 } |
75 } |
75 } |
76 |
76 |
77 template <class T> inline void MarkSweep::mark_and_push(T* p) { |
77 template <class T> inline void MarkSweep::mark_and_push(T* p) { |
78 T heap_oop = RawAccess<>::oop_load(p); |
78 T heap_oop = RawAccess<>::oop_load(p); |
79 if (!CompressedOops::is_null(heap_oop)) { |
79 if (!CompressedOops::is_null(heap_oop)) { |
80 oop obj = CompressedOops::decode_not_null(heap_oop); |
80 oop obj = CompressedOops::decode_not_null(heap_oop); |
81 if (!obj->mark()->is_marked()) { |
81 if (!obj->mark_raw()->is_marked()) { |
82 mark_object(obj); |
82 mark_object(obj); |
83 _marking_stack.push(obj); |
83 _marking_stack.push(obj); |
84 } |
84 } |
85 } |
85 } |
86 } |
86 } |
172 assert(!Universe::heap()->is_in_reserved(p), |
172 assert(!Universe::heap()->is_in_reserved(p), |
173 "roots shouldn't be things within the heap"); |
173 "roots shouldn't be things within the heap"); |
174 T heap_oop = RawAccess<>::oop_load(p); |
174 T heap_oop = RawAccess<>::oop_load(p); |
175 if (!CompressedOops::is_null(heap_oop)) { |
175 if (!CompressedOops::is_null(heap_oop)) { |
176 oop obj = CompressedOops::decode_not_null(heap_oop); |
176 oop obj = CompressedOops::decode_not_null(heap_oop); |
177 if (!obj->mark()->is_marked()) { |
177 if (!obj->mark_raw()->is_marked()) { |
178 mark_object(obj); |
178 mark_object(obj); |
179 follow_object(obj); |
179 follow_object(obj); |
180 } |
180 } |
181 } |
181 } |
182 follow_stack(); |
182 follow_stack(); |
188 void PreservedMark::adjust_pointer() { |
188 void PreservedMark::adjust_pointer() { |
189 MarkSweep::adjust_pointer(&_obj); |
189 MarkSweep::adjust_pointer(&_obj); |
190 } |
190 } |
191 |
191 |
192 void PreservedMark::restore() { |
192 void PreservedMark::restore() { |
193 _obj->set_mark(_mark); |
193 _obj->set_mark_raw(_mark); |
194 } |
194 } |
195 |
195 |
196 // We preserve the mark which should be replaced at the end and the location |
196 // We preserve the mark which should be replaced at the end and the location |
197 // that it will go. Note that the object that this markOop belongs to isn't |
197 // that it will go. Note that the object that this markOop belongs to isn't |
198 // currently at that address but it will be after phase4 |
198 // currently at that address but it will be after phase4 |
250 |
250 |
251 // deal with the overflow |
251 // deal with the overflow |
252 while (!_preserved_oop_stack.is_empty()) { |
252 while (!_preserved_oop_stack.is_empty()) { |
253 oop obj = _preserved_oop_stack.pop(); |
253 oop obj = _preserved_oop_stack.pop(); |
254 markOop mark = _preserved_mark_stack.pop(); |
254 markOop mark = _preserved_mark_stack.pop(); |
255 obj->set_mark(mark); |
255 obj->set_mark_raw(mark); |
256 } |
256 } |
257 } |
257 } |
258 |
258 |
259 MarkSweep::IsAliveClosure MarkSweep::is_alive; |
259 MarkSweep::IsAliveClosure MarkSweep::is_alive; |
260 |
260 |