src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp

changeset 435
a61af66fc99e
child 548
ba764ed4b6f2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,117 @@
     1.4 +/*
     1.5 + * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +inline PSPromotionManager* PSPromotionManager::manager_array(int index) {
    1.29 +  assert(_manager_array != NULL, "access of NULL manager_array");
    1.30 +  assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access");
    1.31 +  return _manager_array[index];
    1.32 +}
    1.33 +
    1.34 +inline void PSPromotionManager::claim_or_forward_internal_depth(oop* p) {
    1.35 +  if (p != NULL) {
    1.36 +    oop o = *p;
    1.37 +    if (o->is_forwarded()) {
    1.38 +      o = o->forwardee();
    1.39 +
    1.40 +      // Card mark
    1.41 +      if (PSScavenge::is_obj_in_young((HeapWord*) o)) {
    1.42 +        PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
    1.43 +      }
    1.44 +      *p = o;
    1.45 +    } else {
    1.46 +      push_depth(p);
    1.47 +    }
    1.48 +  }
    1.49 +}
    1.50 +
    1.51 +inline void PSPromotionManager::claim_or_forward_internal_breadth(oop* p) {
    1.52 +  if (p != NULL) {
    1.53 +    oop o = *p;
    1.54 +    if (o->is_forwarded()) {
    1.55 +      o = o->forwardee();
    1.56 +    } else {
    1.57 +      o = copy_to_survivor_space(o, false);
    1.58 +    }
    1.59 +
    1.60 +    // Card mark
    1.61 +    if (PSScavenge::is_obj_in_young((HeapWord*) o)) {
    1.62 +      PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
    1.63 +    }
    1.64 +    *p = o;
    1.65 +  }
    1.66 +}
    1.67 +
    1.68 +inline void PSPromotionManager::flush_prefetch_queue() {
    1.69 +  assert(!depth_first(), "invariant");
    1.70 +  for (int i=0; i<_prefetch_queue.length(); i++) {
    1.71 +    claim_or_forward_internal_breadth(_prefetch_queue.pop());
    1.72 +  }
    1.73 +}
    1.74 +
    1.75 +inline void PSPromotionManager::claim_or_forward_depth(oop* p) {
    1.76 +  assert(depth_first(), "invariant");
    1.77 +  assert(PSScavenge::should_scavenge(*p, true), "revisiting object?");
    1.78 +  assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
    1.79 +  assert(Universe::heap()->is_in(p), "pointer outside heap");
    1.80 +
    1.81 +  claim_or_forward_internal_depth(p);
    1.82 +}
    1.83 +
    1.84 +inline void PSPromotionManager::claim_or_forward_breadth(oop* p) {
    1.85 +  assert(!depth_first(), "invariant");
    1.86 +  assert(PSScavenge::should_scavenge(*p, true), "revisiting object?");
    1.87 +  assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
    1.88 +  assert(Universe::heap()->is_in(p), "pointer outside heap");
    1.89 +
    1.90 +  if (UsePrefetchQueue) {
    1.91 +    claim_or_forward_internal_breadth(_prefetch_queue.push_and_pop(p));
    1.92 +  } else {
    1.93 +    // This option is used for testing.  The use of the prefetch
    1.94 +    // queue can delay the processing of the objects and thus
    1.95 +    // change the order of object scans.  For example, remembered
    1.96 +    // set updates are typically the clearing of the remembered
    1.97 +    // set (the cards) followed by updates of the remembered set
    1.98 +    // for young-to-old pointers.  In a situation where there
    1.99 +    // is an error in the sequence of clearing and updating
   1.100 +    // (e.g. clear card A, update card A, erroneously clear
   1.101 +    // card A again) the error can be obscured by a delay
   1.102 +    // in the update due to the use of the prefetch queue
   1.103 +    // (e.g., clear card A, erroneously clear card A again,
   1.104 +    // update card A that was pushed into the prefetch queue
   1.105 +    // and thus delayed until after the erronous clear).  The
   1.106 +    // length of the delay is random depending on the objects
   1.107 +    // in the queue and the delay can be zero.
   1.108 +    claim_or_forward_internal_breadth(p);
   1.109 +  }
   1.110 +}
   1.111 +
   1.112 +inline void PSPromotionManager::process_popped_location_depth(oop* p) {
   1.113 +  if (is_oop_masked(p)) {
   1.114 +    assert(PSChunkLargeArrays, "invariant");
   1.115 +    oop const old = unmask_chunked_array_oop(p);
   1.116 +    process_array_chunk(old);
   1.117 +  } else {
   1.118 +    PSScavenge::copy_and_push_safe_barrier(this, p);
   1.119 +  }
   1.120 +}

mercurial