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

Wed, 02 Jul 2008 12:55:16 -0700

author
xdono
date
Wed, 02 Jul 2008 12:55:16 -0700
changeset 631
d1605aabd0a1
parent 548
ba764ed4b6f2
child 809
a4b729f5b611
permissions
-rw-r--r--

6719955: Update copyright year
Summary: Update copyright year for files that have been modified in 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     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
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 inline void MarkSweep::mark_object(oop obj) {
    26 #ifndef SERIALGC
    27   if (UseParallelOldGC && VerifyParallelOldWithMarkSweep) {
    28     assert(PSParallelCompact::mark_bitmap()->is_marked(obj),
    29            "Should be marked in the marking bitmap");
    30   }
    31 #endif // SERIALGC
    33   // some marks may contain information we need to preserve so we store them away
    34   // and overwrite the mark.  We'll restore it at the end of markSweep.
    35   markOop mark = obj->mark();
    36   obj->set_mark(markOopDesc::prototype()->set_marked());
    38   if (mark->must_be_preserved(obj)) {
    39     preserve_mark(obj, mark);
    40   }
    41 }
    43 template <class T> inline void MarkSweep::follow_root(T* p) {
    44   assert(!Universe::heap()->is_in_reserved(p),
    45          "roots shouldn't be things within the heap");
    46 #ifdef VALIDATE_MARK_SWEEP
    47   if (ValidateMarkSweep) {
    48     guarantee(!_root_refs_stack->contains(p), "should only be in here once");
    49     _root_refs_stack->push(p);
    50   }
    51 #endif
    52   T heap_oop = oopDesc::load_heap_oop(p);
    53   if (!oopDesc::is_null(heap_oop)) {
    54     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
    55     if (!obj->mark()->is_marked()) {
    56       mark_object(obj);
    57       obj->follow_contents();
    58     }
    59   }
    60   follow_stack();
    61 }
    63 template <class T> inline void MarkSweep::mark_and_follow(T* p) {
    64 //  assert(Universe::heap()->is_in_reserved(p), "should be in object space");
    65   T heap_oop = oopDesc::load_heap_oop(p);
    66   if (!oopDesc::is_null(heap_oop)) {
    67     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
    68     if (!obj->mark()->is_marked()) {
    69       mark_object(obj);
    70       obj->follow_contents();
    71     }
    72   }
    73 }
    75 template <class T> inline void MarkSweep::mark_and_push(T* p) {
    76 //  assert(Universe::heap()->is_in_reserved(p), "should be in object space");
    77   T heap_oop = oopDesc::load_heap_oop(p);
    78   if (!oopDesc::is_null(heap_oop)) {
    79     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
    80     if (!obj->mark()->is_marked()) {
    81       mark_object(obj);
    82       _marking_stack->push(obj);
    83     }
    84   }
    85 }
    87 template <class T> inline void MarkSweep::adjust_pointer(T* p, bool isroot) {
    88   T heap_oop = oopDesc::load_heap_oop(p);
    89   if (!oopDesc::is_null(heap_oop)) {
    90     oop obj     = oopDesc::decode_heap_oop_not_null(heap_oop);
    91     oop new_obj = oop(obj->mark()->decode_pointer());
    92     assert(new_obj != NULL ||                         // is forwarding ptr?
    93            obj->mark() == markOopDesc::prototype() || // not gc marked?
    94            (UseBiasedLocking && obj->mark()->has_bias_pattern()) ||
    95                                                       // not gc marked?
    96            obj->is_shared(),                          // never forwarded?
    97            "should be forwarded");
    98     if (new_obj != NULL) {
    99       assert(Universe::heap()->is_in_reserved(new_obj),
   100              "should be in object space");
   101       oopDesc::encode_store_heap_oop_not_null(p, new_obj);
   102     }
   103   }
   104   VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, isroot));
   105 }
   107 template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
   108 #ifdef VALIDATE_MARK_SWEEP
   109   if (ValidateMarkSweep) {
   110     if (!Universe::heap()->is_in_reserved(p)) {
   111       _root_refs_stack->push(p);
   112     } else {
   113       _other_refs_stack->push(p);
   114     }
   115   }
   116 #endif
   117   mark_and_push(p);
   118 }

mercurial