hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 360 21d113ecbf6a
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
inline PSPromotionManager* PSPromotionManager::manager_array(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
  assert(_manager_array != NULL, "access of NULL manager_array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
  assert(index >= 0 && index <= (int)ParallelGCThreads, "out of range manager_array access");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  return _manager_array[index];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
inline void PSPromotionManager::claim_or_forward_internal_depth(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  if (p != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    oop o = *p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    if (o->is_forwarded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
      o = o->forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
      // Card mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
      if (PSScavenge::is_obj_in_young((HeapWord*) o)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
        PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
      *p = o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
      push_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
inline void PSPromotionManager::claim_or_forward_internal_breadth(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  if (p != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    oop o = *p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    if (o->is_forwarded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      o = o->forwardee();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      o = copy_to_survivor_space(o, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    // Card mark
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    if (PSScavenge::is_obj_in_young((HeapWord*) o)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    *p = o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
inline void PSPromotionManager::flush_prefetch_queue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  assert(!depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  for (int i=0; i<_prefetch_queue.length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    claim_or_forward_internal_breadth(_prefetch_queue.pop());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
inline void PSPromotionManager::claim_or_forward_depth(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  assert(depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  assert(PSScavenge::should_scavenge(*p, true), "revisiting object?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  assert(Universe::heap()->is_in(p), "pointer outside heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  claim_or_forward_internal_depth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
inline void PSPromotionManager::claim_or_forward_breadth(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  assert(!depth_first(), "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  assert(PSScavenge::should_scavenge(*p, true), "revisiting object?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  assert(Universe::heap()->is_in(p), "pointer outside heap");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  if (UsePrefetchQueue) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    claim_or_forward_internal_breadth(_prefetch_queue.push_and_pop(p));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    // This option is used for testing.  The use of the prefetch
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    // queue can delay the processing of the objects and thus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    // change the order of object scans.  For example, remembered
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    // set updates are typically the clearing of the remembered
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    // set (the cards) followed by updates of the remembered set
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    // for young-to-old pointers.  In a situation where there
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    // is an error in the sequence of clearing and updating
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    // (e.g. clear card A, update card A, erroneously clear
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    // card A again) the error can be obscured by a delay
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    // in the update due to the use of the prefetch queue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    // (e.g., clear card A, erroneously clear card A again,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    // update card A that was pushed into the prefetch queue
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    // and thus delayed until after the erronous clear).  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    // length of the delay is random depending on the objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    // in the queue and the delay can be zero.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    claim_or_forward_internal_breadth(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
inline void PSPromotionManager::process_popped_location_depth(oop* p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  if (is_oop_masked(p)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    assert(PSChunkLargeArrays, "invariant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    oop const old = unmask_chunked_array_oop(p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    process_array_chunk(old);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    PSScavenge::copy_and_push_safe_barrier(this, p);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}