hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp
author ysr
Sun, 16 Mar 2008 21:57:25 -0700
changeset 341 6578aad59716
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction Summary: The option CMSInitiatingPermOccupancyFraction now controls perm triggering threshold. Even though the actual value of the threshold has not yet been changed, so there is no change in policy, we now have the infrastructure in place for dynamically deciding when to collect the perm gen, an issue that will be addressed in the near future. Reviewed-by: jmasa
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 2001-2007 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 void CMSBitMap::clear_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
  // CMS bitmaps are usually cover large memory regions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
  _bm.clear_large();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
  return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
inline size_t CMSBitMap::heapWordToOffset(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  return (pointer_delta(addr, _bmStartWord)) >> _shifter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
inline HeapWord* CMSBitMap::offsetToHeapWord(size_t offset) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  return _bmStartWord + (offset << _shifter);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
inline size_t CMSBitMap::heapWordDiffToOffsetDiff(size_t diff) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  assert((diff & ((1 << _shifter) - 1)) == 0, "argument check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  return diff >> _shifter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
inline void CMSBitMap::mark(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  _bm.set_bit(heapWordToOffset(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
inline bool CMSBitMap::par_mark(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  return _bm.par_at_put(heapWordToOffset(addr), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
inline void CMSBitMap::par_clear(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _bm.par_at_put(heapWordToOffset(addr), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
inline void CMSBitMap::mark_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Range size is usually just 1 bit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  _bm.set_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                BitMap::small_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
inline void CMSBitMap::clear_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Range size is usually just 1 bit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  _bm.clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
                  BitMap::small_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
inline void CMSBitMap::par_mark_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Range size is usually just 1 bit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _bm.par_set_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                    BitMap::small_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
inline void CMSBitMap::par_clear_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Range size is usually just 1 bit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  _bm.par_clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                      BitMap::small_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
inline void CMSBitMap::mark_large_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Range size must be greater than 32 bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  _bm.set_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                BitMap::large_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
inline void CMSBitMap::clear_large_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Range size must be greater than 32 bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  _bm.clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                  BitMap::large_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
inline void CMSBitMap::par_mark_large_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Range size must be greater than 32 bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  _bm.par_set_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
                    BitMap::large_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
inline void CMSBitMap::par_clear_large_range(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  NOT_PRODUCT(region_invariant(mr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Range size must be greater than 32 bytes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  _bm.par_clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
                      BitMap::large_range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
// Starting at "addr" (inclusive) return a memory region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
// corresponding to the first maximally contiguous marked ("1") region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
inline MemRegion CMSBitMap::getAndClearMarkedRegion(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  return getAndClearMarkedRegion(addr, endWord());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// Starting at "start_addr" (inclusive) return a memory region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// corresponding to the first maximal contiguous marked ("1") region
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
// strictly less than end_addr.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
inline MemRegion CMSBitMap::getAndClearMarkedRegion(HeapWord* start_addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
                                                    HeapWord* end_addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  HeapWord *start, *end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  start = getNextMarkedWordAddress  (start_addr, end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  end   = getNextUnmarkedWordAddress(start,      end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  assert(start <= end, "Consistency check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  MemRegion mr(start, end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  if (!mr.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    clear_range(mr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  return mr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
inline bool CMSBitMap::isMarked(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  return _bm.at(heapWordToOffset(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
// The same as isMarked() but without a lock check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
inline bool CMSBitMap::par_isMarked(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  return _bm.at(heapWordToOffset(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
inline bool CMSBitMap::isUnmarked(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
         "outside underlying space?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  return !_bm.at(heapWordToOffset(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
// Return the HeapWord address corresponding to next "1" bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
// (inclusive).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
inline HeapWord* CMSBitMap::getNextMarkedWordAddress(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  return getNextMarkedWordAddress(addr, endWord());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
// Return the least HeapWord address corresponding to next "1" bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
// starting at start_addr (inclusive) but strictly less than end_addr.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
inline HeapWord* CMSBitMap::getNextMarkedWordAddress(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  HeapWord* start_addr, HeapWord* end_addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  size_t nextOffset = _bm.get_next_one_offset(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
                        heapWordToOffset(start_addr),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
                        heapWordToOffset(end_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  HeapWord* nextAddr = offsetToHeapWord(nextOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  assert(nextAddr >= start_addr &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
         nextAddr <= end_addr, "get_next_one postcondition");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  assert((nextAddr == end_addr) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
         isMarked(nextAddr), "get_next_one postcondition");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  return nextAddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
// Return the HeapWord address corrsponding to the next "0" bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// (inclusive).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
inline HeapWord* CMSBitMap::getNextUnmarkedWordAddress(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  return getNextUnmarkedWordAddress(addr, endWord());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
// Return the HeapWord address corrsponding to the next "0" bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
// (inclusive).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
inline HeapWord* CMSBitMap::getNextUnmarkedWordAddress(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  HeapWord* start_addr, HeapWord* end_addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  size_t nextOffset = _bm.get_next_zero_offset(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
                        heapWordToOffset(start_addr),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
                        heapWordToOffset(end_addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  HeapWord* nextAddr = offsetToHeapWord(nextOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  assert(nextAddr >= start_addr &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
         nextAddr <= end_addr, "get_next_zero postcondition");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  assert((nextAddr == end_addr) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
          isUnmarked(nextAddr), "get_next_zero postcondition");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  return nextAddr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
inline bool CMSBitMap::isAllClear() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  return getNextMarkedWordAddress(startWord()) >= endWord();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
inline void CMSBitMap::iterate(BitMapClosure* cl, HeapWord* left,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
                            HeapWord* right) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  assert_locked();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  left = MAX2(_bmStartWord, left);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  right = MIN2(_bmStartWord + _bmWordSize, right);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  if (right > left) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    _bm.iterate(cl, heapWordToOffset(left), heapWordToOffset(right));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
inline void CMSCollector::start_icms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  if (CMSIncrementalMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    ConcurrentMarkSweepThread::start_icms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
inline void CMSCollector::stop_icms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  if (CMSIncrementalMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    ConcurrentMarkSweepThread::stop_icms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
inline void CMSCollector::disable_icms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  if (CMSIncrementalMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    ConcurrentMarkSweepThread::disable_icms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
inline void CMSCollector::enable_icms() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  if (CMSIncrementalMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    ConcurrentMarkSweepThread::enable_icms();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
inline void CMSCollector::icms_wait() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  if (CMSIncrementalMode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    cmsThread()->icms_wait();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
inline void CMSCollector::save_sweep_limits() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  _cmsGen->save_sweep_limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  _permGen->save_sweep_limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
inline bool CMSCollector::is_dead_obj(oop obj) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  HeapWord* addr = (HeapWord*)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  assert((_cmsGen->cmsSpace()->is_in_reserved(addr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
          && _cmsGen->cmsSpace()->block_is_obj(addr))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
         ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
         (_permGen->cmsSpace()->is_in_reserved(addr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
          && _permGen->cmsSpace()->block_is_obj(addr)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
         "must be object");
341
6578aad59716 6634032: CMS: Need CMSInitiatingPermOccupancyFraction for perm, divorcing from CMSInitiatingOccupancyFraction
ysr
parents: 1
diff changeset
   270
  return  should_unload_classes() &&
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
          _collectorState == Sweeping &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
         !_markBitMap.isMarked(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
inline bool CMSCollector::should_abort_preclean() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // We are in the midst of an "abortable preclean" and either
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // scavenge is done or foreground GC wants to take over collection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  return _collectorState == AbortablePreclean &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
         (_abort_preclean || _foregroundGCIsActive ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
          GenCollectedHeap::heap()->incremental_collection_will_fail());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
inline size_t CMSCollector::get_eden_used() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  return _young_gen->as_DefNewGeneration()->eden()->used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
inline size_t CMSCollector::get_eden_capacity() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  return _young_gen->as_DefNewGeneration()->eden()->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
inline bool CMSStats::valid() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  return _valid_bits == _ALL_VALID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
inline void CMSStats::record_gc0_begin() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  if (_gc0_begin_time.is_updated()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    float last_gc0_period = _gc0_begin_time.seconds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    _gc0_period = AdaptiveWeightedAverage::exp_avg(_gc0_period,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
      last_gc0_period, _gc0_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    _gc0_alpha = _saved_alpha;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    _valid_bits |= _GC0_VALID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  _cms_used_at_gc0_begin = _cms_gen->cmsSpace()->used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  _gc0_begin_time.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
inline void CMSStats::record_gc0_end(size_t cms_gen_bytes_used) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  float last_gc0_duration = _gc0_begin_time.seconds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  _gc0_duration = AdaptiveWeightedAverage::exp_avg(_gc0_duration,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    last_gc0_duration, _gc0_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // Amount promoted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  _cms_used_at_gc0_end = cms_gen_bytes_used;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  size_t promoted_bytes = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  if (_cms_used_at_gc0_end >= _cms_used_at_gc0_begin) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    promoted_bytes = _cms_used_at_gc0_end - _cms_used_at_gc0_begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // If the younger gen collections were skipped, then the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  // number of promoted bytes will be 0 and adding it to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  // average will incorrectly lessen the average.  It is, however,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  // also possible that no promotion was needed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // _gc0_promoted used to be calculated as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  // _gc0_promoted = AdaptiveWeightedAverage::exp_avg(_gc0_promoted,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  //  promoted_bytes, _gc0_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  _cms_gen->gc_stats()->avg_promoted()->sample(promoted_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  _gc0_promoted = (size_t) _cms_gen->gc_stats()->avg_promoted()->average();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  // Amount directly allocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  size_t allocated_bytes = _cms_gen->direct_allocated_words() * HeapWordSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  _cms_gen->reset_direct_allocated_words();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  _cms_allocated = AdaptiveWeightedAverage::exp_avg(_cms_allocated,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    allocated_bytes, _gc0_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
inline void CMSStats::record_cms_begin() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  _cms_timer.stop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // This is just an approximate value, but is good enough.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  _cms_used_at_cms_begin = _cms_used_at_gc0_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  _cms_period = AdaptiveWeightedAverage::exp_avg((float)_cms_period,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    (float) _cms_timer.seconds(), _cms_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  _cms_begin_time.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  _cms_timer.reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  _cms_timer.start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
inline void CMSStats::record_cms_end() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  _cms_timer.stop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  float cur_duration = _cms_timer.seconds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  _cms_duration = AdaptiveWeightedAverage::exp_avg(_cms_duration,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    cur_duration, _cms_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  // Avoid division by 0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  const size_t cms_used_mb = MAX2(_cms_used_at_cms_begin / M, (size_t)1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  _cms_duration_per_mb = AdaptiveWeightedAverage::exp_avg(_cms_duration_per_mb,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
                                 cur_duration / cms_used_mb,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
                                 _cms_alpha);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  _cms_end_time.update();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  _cms_alpha = _saved_alpha;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  _allow_duty_cycle_reduction = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  _valid_bits |= _CMS_VALID;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  _cms_timer.start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
inline double CMSStats::cms_time_since_begin() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  return _cms_begin_time.seconds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
inline double CMSStats::cms_time_since_end() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  return _cms_end_time.seconds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
inline double CMSStats::promotion_rate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  assert(valid(), "statistics not valid yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  return gc0_promoted() / gc0_period();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
inline double CMSStats::cms_allocation_rate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  assert(valid(), "statistics not valid yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  return cms_allocated() / gc0_period();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
inline double CMSStats::cms_consumption_rate() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  assert(valid(), "statistics not valid yet");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  return (gc0_promoted() + cms_allocated()) / gc0_period();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
inline unsigned int CMSStats::icms_update_duty_cycle() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // Update the duty cycle only if pacing is enabled and the stats are valid
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // (after at least one young gen gc and one cms cycle have completed).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  if (CMSIncrementalPacing && valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    return icms_update_duty_cycle_impl();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  return _icms_duty_cycle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
inline void ConcurrentMarkSweepGeneration::save_sweep_limit() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  cmsSpace()->save_sweep_limit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
inline size_t ConcurrentMarkSweepGeneration::capacity() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  return _cmsSpace->capacity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
inline size_t ConcurrentMarkSweepGeneration::used() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  return _cmsSpace->used();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
inline size_t ConcurrentMarkSweepGeneration::free() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  return _cmsSpace->free();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
inline MemRegion ConcurrentMarkSweepGeneration::used_region() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  return _cmsSpace->used_region();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
inline MemRegion ConcurrentMarkSweepGeneration::used_region_at_save_marks() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  return _cmsSpace->used_region_at_save_marks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
inline void MarkFromRootsClosure::do_yield_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  if (ConcurrentMarkSweepThread::should_yield() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      _yield) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
inline void Par_MarkFromRootsClosure::do_yield_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  if (ConcurrentMarkSweepThread::should_yield() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      _yield) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
// Return value of "true" indicates that the on-going preclean
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
// should be aborted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
inline bool ScanMarkedObjectsAgainCarefullyClosure::do_yield_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  if (ConcurrentMarkSweepThread::should_yield() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      _yield) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    // Sample young gen size before and after yield
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    _collector->sample_eden();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    _collector->sample_eden();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    return _collector->should_abort_preclean();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
inline void SurvivorSpacePrecleanClosure::do_yield_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  if (ConcurrentMarkSweepThread::should_yield() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
      _yield) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    // Sample young gen size before and after yield
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    _collector->sample_eden();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    _collector->sample_eden();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
inline void SweepClosure::do_yield_check(HeapWord* addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  if (ConcurrentMarkSweepThread::should_yield() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      _yield) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    do_yield_work(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
inline void MarkRefsIntoAndScanClosure::do_yield_check() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  // The conditions are ordered for the remarking phase
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  // when _yield is false.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  if (_yield &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
      !_collector->foregroundGCIsActive() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
      ConcurrentMarkSweepThread::should_yield()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    do_yield_work();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
inline void ModUnionClosure::do_MemRegion(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // Align the end of mr so it's at a card boundary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // This is superfluous except at the end of the space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  // we should do better than this XXX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  MemRegion mr2(mr.start(), (HeapWord*)round_to((intptr_t)mr.end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
                 CardTableModRefBS::card_size /* bytes */));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  _t->mark_range(mr2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
inline void ModUnionClosurePar::do_MemRegion(MemRegion mr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  // Align the end of mr so it's at a card boundary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  // This is superfluous except at the end of the space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  // we should do better than this XXX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  MemRegion mr2(mr.start(), (HeapWord*)round_to((intptr_t)mr.end(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
                 CardTableModRefBS::card_size /* bytes */));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  _t->par_mark_range(mr2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
}