hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)markSweep.inline.hpp 1.17 07/05/29 09:44:12 JVM"
   3 #endif
   4 /*
   5  * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 
  28 inline void MarkSweep::_adjust_pointer(oop* p, bool isroot) {
  29   oop obj = *p;
  30   VALIDATE_MARK_SWEEP_ONLY(oop saved_new_pointer = NULL);
  31   if (obj != NULL) {
  32     oop new_pointer = oop(obj->mark()->decode_pointer());
  33     assert(new_pointer != NULL ||                     // is forwarding ptr?
  34            obj->mark() == markOopDesc::prototype() || // not gc marked?
  35            (UseBiasedLocking && obj->mark()->has_bias_pattern()) || // not gc marked?
  36            obj->is_shared(),                          // never forwarded?
  37            "should contain a forwarding pointer");
  38     if (new_pointer != NULL) {
  39       *p = new_pointer;
  40       assert(Universe::heap()->is_in_reserved(new_pointer),
  41              "should be in object space");
  42       VALIDATE_MARK_SWEEP_ONLY(saved_new_pointer = new_pointer);
  43     }
  44   }
  45   VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, saved_new_pointer, isroot));
  46 }
  47 
  48 inline void MarkSweep::mark_object(oop obj) {
  49 
  50 #ifndef SERIALGC
  51   if (UseParallelOldGC && VerifyParallelOldWithMarkSweep) {
  52     assert(PSParallelCompact::mark_bitmap()->is_marked(obj),
  53       "Should be marked in the marking bitmap");
  54   }
  55 #endif // SERIALGC
  56 
  57   // some marks may contain information we need to preserve so we store them away
  58   // and overwrite the mark.  We'll restore it at the end of markSweep.
  59   markOop mark = obj->mark();
  60   obj->set_mark(markOopDesc::prototype()->set_marked());
  61 
  62   if (mark->must_be_preserved(obj)) {
  63     preserve_mark(obj, mark);
  64   }
  65 }













































































   1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)markSweep.inline.hpp 1.17 07/05/29 09:44:12 JVM"
   3 #endif
   4 /*
   5  * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 




















  28 inline void MarkSweep::mark_object(oop obj) {








  29   // some marks may contain information we need to preserve so we store them away
  30   // and overwrite the mark.  We'll restore it at the end of markSweep.
  31   markOop mark = obj->mark();
  32   obj->set_mark(markOopDesc::prototype()->set_marked());
  33 
  34   if (mark->must_be_preserved(obj)) {
  35     preserve_mark(obj, mark);
  36   }
  37 }
  38 
  39 template <class T> inline void MarkSweep::follow_root(T* p) {
  40   assert(!Universe::heap()->is_in_reserved(p),
  41          "roots shouldn't be things within the heap");
  42 #ifdef VALIDATE_MARK_SWEEP
  43   if (ValidateMarkSweep) {
  44     guarantee(!_root_refs_stack->contains(p), "should only be in here once");
  45     _root_refs_stack->push(p);
  46   }
  47 #endif
  48   T heap_oop = oopDesc::load_heap_oop(p);
  49   if (!oopDesc::is_null(heap_oop)) {
  50     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  51     if (!obj->mark()->is_marked()) {
  52       mark_object(obj);
  53       obj->follow_contents();
  54     }
  55   }
  56   follow_stack();
  57 }
  58 
  59 template <class T> inline void MarkSweep::mark_and_follow(T* p) {
  60 //  assert(Universe::heap()->is_in_reserved(p), "should be in object space");
  61   T heap_oop = oopDesc::load_heap_oop(p);
  62   if (!oopDesc::is_null(heap_oop)) {
  63     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  64     if (!obj->mark()->is_marked()) {
  65       mark_object(obj);
  66       obj->follow_contents();
  67     }
  68   }
  69 }
  70 
  71 template <class T> inline void MarkSweep::mark_and_push(T* p) {
  72 //  assert(Universe::heap()->is_in_reserved(p), "should be in object space");
  73   T heap_oop = oopDesc::load_heap_oop(p);
  74   if (!oopDesc::is_null(heap_oop)) {
  75     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  76     if (!obj->mark()->is_marked()) {
  77       mark_object(obj);
  78       _marking_stack->push(obj);
  79     }
  80   }
  81 }
  82 
  83 template <class T> inline void MarkSweep::adjust_pointer(T* p, bool isroot) {
  84   T heap_oop = oopDesc::load_heap_oop(p);
  85   if (!oopDesc::is_null(heap_oop)) {
  86     oop obj     = oopDesc::decode_heap_oop_not_null(heap_oop);
  87     oop new_obj = oop(obj->mark()->decode_pointer());
  88     assert(new_obj != NULL ||                         // is forwarding ptr?
  89            obj->mark() == markOopDesc::prototype() || // not gc marked?
  90            (UseBiasedLocking && obj->mark()->has_bias_pattern()) ||
  91                                                       // not gc marked?
  92            obj->is_shared(),                          // never forwarded?
  93            "should be forwarded");
  94     if (new_obj != NULL) {
  95       assert(Universe::heap()->is_in_reserved(new_obj),
  96              "should be in object space");
  97       oopDesc::encode_store_heap_oop_not_null(p, new_obj);
  98     }
  99   }
 100   VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, isroot));
 101 }
 102 
 103 template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
 104 #ifdef VALIDATE_MARK_SWEEP
 105   if (ValidateMarkSweep) {
 106     if (!Universe::heap()->is_in_reserved(p)) {
 107       _root_refs_stack->push(p);
 108     } else {
 109       _other_refs_stack->push(p);
 110     }
 111   }
 112 #endif
 113   mark_and_push(p);
 114 }