< prev index next >

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

Print this page

 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/serial/serialStringDedup.hpp"
 33 #include "memory/universe.hpp"
 34 #include "oops/markWord.hpp"
 35 #include "oops/access.inline.hpp"
 36 #include "oops/compressedOops.inline.hpp"
 37 #include "oops/oop.inline.hpp"
 38 #include "utilities/align.hpp"
 39 #include "utilities/stack.inline.hpp"
 40 
 41 inline void MarkSweep::mark_object(oop obj) {
 42   if (StringDedup::is_enabled() &&
 43       java_lang_String::is_instance(obj) &&
 44       SerialStringDedup::is_candidate_from_mark(obj)) {
 45     _string_dedup_requests->add(obj);
 46   }
 47 
 48   // some marks may contain information we need to preserve so we store them away
 49   // and overwrite the mark.  We'll restore it at the end of markSweep.
 50   markWord mark = obj->mark();
 51   obj->set_mark(markWord::prototype().set_marked());
 52 
 53   if (obj->mark_must_be_preserved(mark)) {
 54     preserve_mark(obj, mark);
 55   }
 56 }
 57 
 58 template <class T> inline void MarkSweep::mark_and_push(T* p) {
 59   T heap_oop = RawAccess<>::oop_load(p);
 60   if (!CompressedOops::is_null(heap_oop)) {
 61     oop obj = CompressedOops::decode_not_null(heap_oop);
 62     if (!obj->mark().is_marked()) {
 63       mark_object(obj);
 64       _marking_stack.push(obj);
 65     }
 66   }
 67 }
 68 
 69 inline void MarkSweep::follow_klass(Klass* klass) {
 70   oop op = klass->class_loader_data()->holder_no_keepalive();
 71   MarkSweep::mark_and_push(&op);
 72 }
 73 
 74 inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
 75   MarkSweep::follow_cld_closure.do_cld(cld);
 76 }
 77 
 78 template <typename T>
 79 inline void MarkAndPushClosure::do_oop_work(T* p)            { MarkSweep::mark_and_push(p); }
 80 inline void MarkAndPushClosure::do_oop(oop* p)               { do_oop_work(p); }
 81 inline void MarkAndPushClosure::do_oop(narrowOop* p)         { do_oop_work(p); }
 82 inline void MarkAndPushClosure::do_klass(Klass* k)           { MarkSweep::follow_klass(k); }
 83 inline void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
 84 
 85 template <class T> inline void MarkSweep::adjust_pointer(T* p) {
 86   T heap_oop = RawAccess<>::oop_load(p);
 87   if (!CompressedOops::is_null(heap_oop)) {
 88     oop obj = CompressedOops::decode_not_null(heap_oop);
 89     assert(Universe::heap()->is_in(obj), "should be in heap");
 90 
 91     if (obj->is_forwarded()) {
 92       oop new_obj = obj->forwardee();


 93       assert(is_object_aligned(new_obj), "oop must be aligned");
 94       RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 95     }
 96   }
 97 }
 98 
 99 template <typename T>
100 void AdjustPointerClosure::do_oop_work(T* p)           { MarkSweep::adjust_pointer(p); }
101 inline void AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
102 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
103 
104 
105 inline size_t MarkSweep::adjust_pointers(oop obj) {
106   return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);

107 }
108 
109 #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 "classfile/javaClasses.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 inline void MarkSweep::mark_object(oop obj) {
 43   if (StringDedup::is_enabled() &&
 44       java_lang_String::is_instance(obj) &&
 45       SerialStringDedup::is_candidate_from_mark(obj)) {
 46     _string_dedup_requests->add(obj);
 47   }
 48 
 49   // some marks may contain information we need to preserve so we store them away
 50   // and overwrite the mark.  We'll restore it at the end of markSweep.
 51   markWord mark = obj->mark();
 52   obj->set_mark(obj->klass()->prototype_header().set_marked());
 53 
 54   if (obj->mark_must_be_preserved(mark)) {
 55     preserve_mark(obj, mark);
 56   }
 57 }
 58 
 59 template <class T> inline void MarkSweep::mark_and_push(T* p) {
 60   T heap_oop = RawAccess<>::oop_load(p);
 61   if (!CompressedOops::is_null(heap_oop)) {
 62     oop obj = CompressedOops::decode_not_null(heap_oop);
 63     if (!obj->mark().is_marked()) {
 64       mark_object(obj);
 65       _marking_stack.push(obj);
 66     }
 67   }
 68 }
 69 
 70 inline void MarkSweep::follow_klass(Klass* klass) {
 71   oop op = klass->class_loader_data()->holder_no_keepalive();
 72   MarkSweep::mark_and_push(&op);
 73 }
 74 
 75 inline void MarkSweep::follow_cld(ClassLoaderData* cld) {
 76   MarkSweep::follow_cld_closure.do_cld(cld);
 77 }
 78 
 79 template <typename T>
 80 inline void MarkAndPushClosure::do_oop_work(T* p)            { MarkSweep::mark_and_push(p); }
 81 inline void MarkAndPushClosure::do_oop(oop* p)               { do_oop_work(p); }
 82 inline void MarkAndPushClosure::do_oop(narrowOop* p)         { do_oop_work(p); }
 83 inline void MarkAndPushClosure::do_klass(Klass* k)           { MarkSweep::follow_klass(k); }
 84 inline void MarkAndPushClosure::do_cld(ClassLoaderData* cld) { MarkSweep::follow_cld(cld); }
 85 
 86 template <class T> inline void MarkSweep::adjust_pointer(const SlidingForwarding* const forwarding, T* p) {
 87   T heap_oop = RawAccess<>::oop_load(p);
 88   if (!CompressedOops::is_null(heap_oop)) {
 89     oop obj = CompressedOops::decode_not_null(heap_oop);
 90     assert(Universe::heap()->is_in(obj), "should be in heap");
 91 
 92     markWord header = obj->mark();
 93     if (header.is_marked()) {
 94       oop new_obj = forwarding->forwardee(obj);
 95       assert(new_obj != NULL, "must be forwarded");
 96       assert(is_object_aligned(new_obj), "oop must be aligned");
 97       RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 98     }
 99   }
100 }
101 
102 template <typename T>
103 void AdjustPointerClosure::do_oop_work(T* p)           { MarkSweep::adjust_pointer(_forwarding, p); }
104 inline void AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
105 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
106 
107 
108 inline size_t MarkSweep::adjust_pointers(const SlidingForwarding* const forwarding, oop obj) {
109   AdjustPointerClosure cl(forwarding);
110   return obj->oop_iterate_size(&cl);
111 }
112 
113 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP
< prev index next >