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 }