hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/promotionInfo.cpp
author stefank
Thu, 02 Apr 2015 10:04:27 +0200
changeset 30150 d9c940aa42ef
parent 29797 4d360e3ddebf
permissions -rw-r--r--
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution Reviewed-by: brutisso, coleenp, kbarrett, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 24092
diff changeset
     2
 * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     4
 *
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     8
 *
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    13
 * accompanied this code).
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    14
 *
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5541
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5541
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5541
diff changeset
    21
 * questions.
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    22
 *
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    23
 */
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6447
diff changeset
    25
#include "precompiled.hpp"
30150
d9c940aa42ef 8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents: 29797
diff changeset
    26
#include "memory/genOopClosures.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6447
diff changeset
    27
#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6447
diff changeset
    28
#include "gc_implementation/concurrentMarkSweep/promotionInfo.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6447
diff changeset
    29
#include "oops/markOop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6447
diff changeset
    30
#include "oops/oop.inline.hpp"
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    31
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    32
/////////////////////////////////////////////////////////////////////////
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    33
//// PromotionInfo
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    34
/////////////////////////////////////////////////////////////////////////
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    35
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    36
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    37
//////////////////////////////////////////////////////////////////////////////
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    38
// We go over the list of promoted objects, removing each from the list,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    39
// and applying the closure (this may, in turn, add more elements to
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    40
// the tail of the promoted list, and these newly added objects will
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    41
// also be processed) until the list is empty.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    42
// To aid verification and debugging, in the non-product builds
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    43
// we actually forward _promoHead each time we process a promoted oop.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    44
// Note that this is not necessary in general (i.e. when we don't need to
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    45
// call PromotionInfo::verify()) because oop_iterate can only add to the
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    46
// end of _promoTail, and never needs to look at _promoHead.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    47
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    48
#define PROMOTED_OOPS_ITERATE_DEFN(OopClosureType, nv_suffix)               \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    49
                                                                            \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    50
void PromotionInfo::promoted_oops_iterate##nv_suffix(OopClosureType* cl) {  \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    51
  NOT_PRODUCT(verify());                                                    \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    52
  PromotedObject *curObj, *nextObj;                                         \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    53
  for (curObj = _promoHead; curObj != NULL; curObj = nextObj) {             \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    54
    if ((nextObj = curObj->next()) == NULL) {                               \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    55
      /* protect ourselves against additions due to closure application     \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    56
         below by resetting the list.  */                                   \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    57
      assert(_promoTail == curObj, "Should have been the tail");            \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    58
      _promoHead = _promoTail = NULL;                                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    59
    }                                                                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    60
    if (curObj->hasDisplacedMark()) {                                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    61
      /* restore displaced header */                                        \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    62
      oop(curObj)->set_mark(nextDisplacedHeader());                         \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    63
    } else {                                                                \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    64
      /* restore prototypical header */                                     \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    65
      oop(curObj)->init_mark();                                             \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    66
    }                                                                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    67
    /* The "promoted_mark" should now not be set */                         \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    68
    assert(!curObj->hasPromotedMark(),                                      \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    69
           "Should have been cleared by restoring displaced mark-word");    \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    70
    NOT_PRODUCT(_promoHead = nextObj);                                      \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    71
    if (cl != NULL) oop(curObj)->oop_iterate(cl);                           \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    72
    if (nextObj == NULL) { /* start at head of list reset above */          \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    73
      nextObj = _promoHead;                                                 \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    74
    }                                                                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    75
  }                                                                         \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    76
  assert(noPromotions(), "post-condition violation");                       \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    77
  assert(_promoHead == NULL && _promoTail == NULL, "emptied promoted list");\
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    78
  assert(_spoolHead == _spoolTail, "emptied spooling buffers");             \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    79
  assert(_firstIndex == _nextIndex, "empty buffer");                        \
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    80
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    81
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    82
// This should have been ALL_SINCE_...() just like the others,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    83
// but, because the body of the method above is somehwat longer,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    84
// the MSVC compiler cannot cope; as a workaround, we split the
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    85
// macro into its 3 constituent parts below (see original macro
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    86
// definition in specializedOopClosures.hpp).
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    87
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(PROMOTED_OOPS_ITERATE_DEFN)
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    88
PROMOTED_OOPS_ITERATE_DEFN(OopsInGenClosure,_v)
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    89
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    90
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    91
// Return the next displaced header, incrementing the pointer and
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    92
// recycling spool area as necessary.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    93
markOop PromotionInfo::nextDisplacedHeader() {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    94
  assert(_spoolHead != NULL, "promotionInfo inconsistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    95
  assert(_spoolHead != _spoolTail || _firstIndex < _nextIndex,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    96
         "Empty spool space: no displaced header can be fetched");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    97
  assert(_spoolHead->bufferSize > _firstIndex, "Off by one error at head?");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    98
  markOop hdr = _spoolHead->displacedHdr[_firstIndex];
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
    99
  // Spool forward
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   100
  if (++_firstIndex == _spoolHead->bufferSize) { // last location in this block
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   101
    // forward to next block, recycling this block into spare spool buffer
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   102
    SpoolBlock* tmp = _spoolHead->nextSpoolBlock;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   103
    assert(_spoolHead != _spoolTail, "Spooling storage mix-up");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   104
    _spoolHead->nextSpoolBlock = _spareSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   105
    _spareSpool = _spoolHead;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   106
    _spoolHead = tmp;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   107
    _firstIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   108
    NOT_PRODUCT(
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   109
      if (_spoolHead == NULL) {  // all buffers fully consumed
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   110
        assert(_spoolTail == NULL && _nextIndex == 1,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   111
               "spool buffers processing inconsistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   112
      }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   113
    )
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   114
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   115
  return hdr;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   116
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   117
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   118
void PromotionInfo::track(PromotedObject* trackOop) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   119
  track(trackOop, oop(trackOop)->klass());
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   120
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   121
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 12509
diff changeset
   122
void PromotionInfo::track(PromotedObject* trackOop, Klass* klassOfOop) {
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   123
  // make a copy of header as it may need to be spooled
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   124
  markOop mark = oop(trackOop)->mark();
12509
6228e2085074 7164144: Fix variable naming style in freeBlockDictionary.* and binaryTreeDictionary*
jmasa
parents: 7397
diff changeset
   125
  trackOop->clear_next();
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   126
  if (mark->must_be_preserved_for_cms_scavenge(klassOfOop)) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   127
    // save non-prototypical header, and mark oop
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   128
    saveDisplacedHeader(mark);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   129
    trackOop->setDisplacedMark();
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   130
  } else {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   131
    // we'd like to assert something like the following:
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   132
    // assert(mark == markOopDesc::prototype(), "consistency check");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   133
    // ... but the above won't work because the age bits have not (yet) been
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   134
    // cleared. The remainder of the check would be identical to the
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   135
    // condition checked in must_be_preserved() above, so we don't really
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   136
    // have anything useful to check here!
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   137
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   138
  if (_promoTail != NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   139
    assert(_promoHead != NULL, "List consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   140
    _promoTail->setNext(trackOop);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   141
    _promoTail = trackOop;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   142
  } else {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   143
    assert(_promoHead == NULL, "List consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   144
    _promoHead = _promoTail = trackOop;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   145
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   146
  // Mask as newly promoted, so we can skip over such objects
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   147
  // when scanning dirty cards
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   148
  assert(!trackOop->hasPromotedMark(), "Should not have been marked");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   149
  trackOop->setPromotedMark();
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   150
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   151
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   152
// Save the given displaced header, incrementing the pointer and
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   153
// obtaining more spool area as necessary.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   154
void PromotionInfo::saveDisplacedHeader(markOop hdr) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   155
  assert(_spoolHead != NULL && _spoolTail != NULL,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   156
         "promotionInfo inconsistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   157
  assert(_spoolTail->bufferSize > _nextIndex, "Off by one error at tail?");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   158
  _spoolTail->displacedHdr[_nextIndex] = hdr;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   159
  // Spool forward
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   160
  if (++_nextIndex == _spoolTail->bufferSize) { // last location in this block
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   161
    // get a new spooling block
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   162
    assert(_spoolTail->nextSpoolBlock == NULL, "tail should terminate spool list");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   163
    _splice_point = _spoolTail;                   // save for splicing
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   164
    _spoolTail->nextSpoolBlock = getSpoolBlock(); // might fail
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   165
    _spoolTail = _spoolTail->nextSpoolBlock;      // might become NULL ...
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   166
    // ... but will attempt filling before next promotion attempt
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   167
    _nextIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   168
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   169
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   170
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   171
// Ensure that spooling space exists. Return false if spooling space
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   172
// could not be obtained.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   173
bool PromotionInfo::ensure_spooling_space_work() {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   174
  assert(!has_spooling_space(), "Only call when there is no spooling space");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   175
  // Try and obtain more spooling space
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   176
  SpoolBlock* newSpool = getSpoolBlock();
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   177
  assert(newSpool == NULL ||
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   178
         (newSpool->bufferSize != 0 && newSpool->nextSpoolBlock == NULL),
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   179
        "getSpoolBlock() sanity check");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   180
  if (newSpool == NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   181
    return false;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   182
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   183
  _nextIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   184
  if (_spoolTail == NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   185
    _spoolTail = newSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   186
    if (_spoolHead == NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   187
      _spoolHead = newSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   188
      _firstIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   189
    } else {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   190
      assert(_splice_point != NULL && _splice_point->nextSpoolBlock == NULL,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   191
             "Splice point invariant");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   192
      // Extra check that _splice_point is connected to list
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   193
      #ifdef ASSERT
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   194
      {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   195
        SpoolBlock* blk = _spoolHead;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   196
        for (; blk->nextSpoolBlock != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   197
             blk = blk->nextSpoolBlock);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   198
        assert(blk != NULL && blk == _splice_point,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   199
               "Splice point incorrect");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   200
      }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   201
      #endif // ASSERT
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   202
      _splice_point->nextSpoolBlock = newSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   203
    }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   204
  } else {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   205
    assert(_spoolHead != NULL, "spool list consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   206
    _spoolTail->nextSpoolBlock = newSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   207
    _spoolTail = newSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   208
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   209
  return true;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   210
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   211
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   212
// Get a free spool buffer from the free pool, getting a new block
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   213
// from the heap if necessary.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   214
SpoolBlock* PromotionInfo::getSpoolBlock() {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   215
  SpoolBlock* res;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   216
  if ((res = _spareSpool) != NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   217
    _spareSpool = _spareSpool->nextSpoolBlock;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   218
    res->nextSpoolBlock = NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   219
  } else {  // spare spool exhausted, get some from heap
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   220
    res = (SpoolBlock*)(space()->allocateScratch(refillSize()));
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   221
    if (res != NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   222
      res->init();
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   223
    }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   224
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   225
  assert(res == NULL || res->nextSpoolBlock == NULL, "postcondition");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   226
  return res;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   227
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   228
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   229
void PromotionInfo::startTrackingPromotions() {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   230
  assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   231
         "spooling inconsistency?");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   232
  _firstIndex = _nextIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   233
  _tracking = true;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   234
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   235
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   236
#define CMSPrintPromoBlockInfo 1
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   237
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   238
void PromotionInfo::stopTrackingPromotions(uint worker_id) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   239
  assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   240
         "spooling inconsistency?");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   241
  _firstIndex = _nextIndex = 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   242
  _tracking = false;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   243
  if (CMSPrintPromoBlockInfo > 1) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   244
    print_statistics(worker_id);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   245
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   246
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   247
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   248
void PromotionInfo::print_statistics(uint worker_id) const {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   249
  assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   250
         "Else will undercount");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   251
  assert(CMSPrintPromoBlockInfo > 0, "Else unnecessary call");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   252
  // Count the number of blocks and slots in the free pool
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   253
  size_t slots  = 0;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   254
  size_t blocks = 0;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   255
  for (SpoolBlock* cur_spool = _spareSpool;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   256
       cur_spool != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   257
       cur_spool = cur_spool->nextSpoolBlock) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   258
    // the first entry is just a self-pointer; indices 1 through
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   259
    // bufferSize - 1 are occupied (thus, bufferSize - 1 slots).
6447
32cc5cad7fa6 6983930: CMS: Various small cleanups ca September 2010
ysr
parents: 6258
diff changeset
   260
    assert((void*)cur_spool->displacedHdr == (void*)&cur_spool->displacedHdr,
32cc5cad7fa6 6983930: CMS: Various small cleanups ca September 2010
ysr
parents: 6258
diff changeset
   261
           "first entry of displacedHdr should be self-referential");
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   262
    slots += cur_spool->bufferSize - 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   263
    blocks++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   264
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   265
  if (_spoolHead != NULL) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   266
    slots += _spoolHead->bufferSize - 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   267
    blocks++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   268
  }
24092
e274d864545a 8039743: Use correct format specifier to print size_t values and pointers in the GC code
stefank
parents: 22551
diff changeset
   269
  gclog_or_tty->print_cr(" [worker %d] promo_blocks = " SIZE_FORMAT ", promo_slots = " SIZE_FORMAT,
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   270
                         worker_id, blocks, slots);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   271
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   272
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   273
// When _spoolTail is not NULL, then the slot <_spoolTail, _nextIndex>
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   274
// points to the next slot available for filling.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   275
// The set of slots holding displaced headers are then all those in the
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   276
// right-open interval denoted by:
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   277
//
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   278
//    [ <_spoolHead, _firstIndex>, <_spoolTail, _nextIndex> )
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   279
//
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   280
// When _spoolTail is NULL, then the set of slots with displaced headers
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   281
// is all those starting at the slot <_spoolHead, _firstIndex> and
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   282
// going up to the last slot of last block in the linked list.
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13728
diff changeset
   283
// In this latter case, _splice_point points to the tail block of
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   284
// this linked list of blocks holding displaced headers.
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   285
void PromotionInfo::verify() const {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   286
  // Verify the following:
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   287
  // 1. the number of displaced headers matches the number of promoted
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   288
  //    objects that have displaced headers
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   289
  // 2. each promoted object lies in this space
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   290
  debug_only(
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   291
    PromotedObject* junk = NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   292
    assert(junk->next_addr() == (void*)(oop(junk)->mark_addr()),
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   293
           "Offset of PromotedObject::_next is expected to align with "
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   294
           "  the OopDesc::_mark within OopDesc");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   295
  )
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   296
  // FIXME: guarantee????
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   297
  guarantee(_spoolHead == NULL || _spoolTail != NULL ||
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   298
            _splice_point != NULL, "list consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   299
  guarantee(_promoHead == NULL || _promoTail != NULL, "list consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   300
  // count the number of objects with displaced headers
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   301
  size_t numObjsWithDisplacedHdrs = 0;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   302
  for (PromotedObject* curObj = _promoHead; curObj != NULL; curObj = curObj->next()) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   303
    guarantee(space()->is_in_reserved((HeapWord*)curObj), "Containment");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   304
    // the last promoted object may fail the mark() != NULL test of is_oop().
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   305
    guarantee(curObj->next() == NULL || oop(curObj)->is_oop(), "must be an oop");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   306
    if (curObj->hasDisplacedMark()) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   307
      numObjsWithDisplacedHdrs++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   308
    }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   309
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   310
  // Count the number of displaced headers
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   311
  size_t numDisplacedHdrs = 0;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   312
  for (SpoolBlock* curSpool = _spoolHead;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   313
       curSpool != _spoolTail && curSpool != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   314
       curSpool = curSpool->nextSpoolBlock) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   315
    // the first entry is just a self-pointer; indices 1 through
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   316
    // bufferSize - 1 are occupied (thus, bufferSize - 1 slots).
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   317
    guarantee((void*)curSpool->displacedHdr == (void*)&curSpool->displacedHdr,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   318
              "first entry of displacedHdr should be self-referential");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   319
    numDisplacedHdrs += curSpool->bufferSize - 1;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   320
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   321
  guarantee((_spoolHead == _spoolTail) == (numDisplacedHdrs == 0),
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   322
            "internal consistency");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   323
  guarantee(_spoolTail != NULL || _nextIndex == 1,
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   324
            "Inconsistency between _spoolTail and _nextIndex");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   325
  // We overcounted (_firstIndex-1) worth of slots in block
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   326
  // _spoolHead and we undercounted (_nextIndex-1) worth of
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   327
  // slots in block _spoolTail. We make an appropriate
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   328
  // adjustment by subtracting the first and adding the
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   329
  // second:  - (_firstIndex - 1) + (_nextIndex - 1)
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   330
  numDisplacedHdrs += (_nextIndex - _firstIndex);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   331
  guarantee(numDisplacedHdrs == numObjsWithDisplacedHdrs, "Displaced hdr count");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   332
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   333
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   334
void PromotionInfo::print_on(outputStream* st) const {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   335
  SpoolBlock* curSpool = NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   336
  size_t i = 0;
6258
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 5547
diff changeset
   337
  st->print_cr(" start & end indices: [" SIZE_FORMAT ", " SIZE_FORMAT ")",
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   338
               _firstIndex, _nextIndex);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   339
  for (curSpool = _spoolHead; curSpool != _spoolTail && curSpool != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   340
       curSpool = curSpool->nextSpoolBlock) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   341
    curSpool->print_on(st);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   342
    st->print_cr(" active ");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   343
    i++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   344
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   345
  for (curSpool = _spoolTail; curSpool != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   346
       curSpool = curSpool->nextSpoolBlock) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   347
    curSpool->print_on(st);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   348
    st->print_cr(" inactive ");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   349
    i++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   350
  }
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   351
  for (curSpool = _spareSpool; curSpool != NULL;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   352
       curSpool = curSpool->nextSpoolBlock) {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   353
    curSpool->print_on(st);
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   354
    st->print_cr(" free ");
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   355
    i++;
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   356
  }
6258
68f252c6e825 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 5547
diff changeset
   357
  st->print_cr("  " SIZE_FORMAT " header spooling blocks", i);
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   358
}
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   359
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   360
void SpoolBlock::print_on(outputStream* st) const {
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   361
  st->print("[" PTR_FORMAT "," PTR_FORMAT "), " SIZE_FORMAT " HeapWords -> " PTR_FORMAT,
29797
4d360e3ddebf 8076055: cms: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
   362
            p2i(this), p2i((HeapWord*)displacedHdr + bufferSize),
4d360e3ddebf 8076055: cms: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents: 24424
diff changeset
   363
            bufferSize, p2i(nextSpoolBlock));
5434
a2e785749780 6951188: CMS: move PromotionInfo into its own file
ysr
parents:
diff changeset
   364
}