< prev index next >

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

Print this page




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

  91       RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
  92     }
  93   }
  94 }
  95 
  96 template <typename T>
  97 void AdjustPointerClosure::do_oop_work(T* p)           { MarkSweep::adjust_pointer(p); }
  98 inline void AdjustPointerClosure::do_oop(oop* p)       { do_oop_work(p); }
  99 inline void AdjustPointerClosure::do_oop(narrowOop* p) { do_oop_work(p); }
 100 
 101 
 102 inline int MarkSweep::adjust_pointers(oop obj) {
 103   return obj->oop_iterate_size(&MarkSweep::adjust_pointer_closure);
 104 }
 105 
 106 #endif // SHARE_GC_SERIAL_MARKSWEEP_INLINE_HPP


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