hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp
author never
Sun, 25 Sep 2011 16:03:29 -0700
changeset 10565 dc90c239f4ec
parent 7397 5b173b4ca846
child 13195 be27e1b6a4b9
permissions -rw-r--r--
7089790: integrate bsd-port changes Reviewed-by: kvn, twisti, jrose Contributed-by: Kurt Miller <kurt@intricatesoftware.com>, Greg Lewis <glewis@eyesbeyond.com>, Jung-uk Kim <jkim@freebsd.org>, Christos Zoulas <christos@zoulas.com>, Landon Fuller <landonf@plausible.coop>, The FreeBSD Foundation <board@freebsdfoundation.org>, Michael Franz <mvfranz@gmail.com>, Roger Hoover <rhoover@apple.com>, Alexander Strange <astrange@apple.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
1
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 823
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 823
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: 823
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "gc_implementation/parallelScavenge/parMarkBitMap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "runtime/os.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "utilities/bitMap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#ifdef TARGET_OS_FAMILY_linux
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
# include "os_linux.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#ifdef TARGET_OS_FAMILY_solaris
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
# include "os_solaris.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#ifdef TARGET_OS_FAMILY_windows
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
# include "os_windows.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#endif
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    41
#ifdef TARGET_OS_FAMILY_bsd
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    42
# include "os_bsd.inline.hpp"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents: 7397
diff changeset
    43
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
bool
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
ParMarkBitMap::initialize(MemRegion covered_region)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  const idx_t bits = bits_required(covered_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // The bits will be divided evenly between two bitmaps; each of them should be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // an integral number of words.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  assert(bits % (BitsPerWord * 2) == 0, "region size unaligned");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  const size_t words = bits / BitsPerWord;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  const size_t raw_bytes = words * sizeof(idx_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  const size_t granularity = os::vm_allocation_granularity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  const size_t bytes = align_size_up(raw_bytes, MAX2(page_sz, granularity));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  const size_t rs_align = page_sz == (size_t) os::vm_page_size() ? 0 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    MAX2(page_sz, granularity);
252
050143a0dbfb 6642862: Code cache allocation fails with large pages after 6588638
jcoomes
parents: 1
diff changeset
    61
  ReservedSpace rs(bytes, rs_align, rs_align > 0);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  os::trace_page_sizes("par bitmap", raw_bytes, raw_bytes, page_sz,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
                       rs.base(), rs.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  _virtual_space = new PSVirtualSpace(rs, page_sz);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  if (_virtual_space != NULL && _virtual_space->expand_by(bytes)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    _region_start = covered_region.start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    _region_size = covered_region.word_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    idx_t* map = (idx_t*)_virtual_space->reserved_low_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    _beg_bits.set_map(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    _beg_bits.set_size(bits / 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    _end_bits.set_map(map + words / 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    _end_bits.set_size(bits / 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  _region_start = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  _region_size = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  if (_virtual_space != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    delete _virtual_space;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    _virtual_space = NULL;
823
9a5271881bc0 6716785: implicit null checks not triggering with CompressedOops
coleenp
parents: 670
diff changeset
    81
    // Release memory reserved in the space.
9a5271881bc0 6716785: implicit null checks not triggering with CompressedOops
coleenp
parents: 670
diff changeset
    82
    rs.release();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
extern size_t mark_bitmap_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
extern size_t mark_bitmap_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#endif  // #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
bool
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
ParMarkBitMap::mark_obj(HeapWord* addr, size_t size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  const idx_t beg_bit = addr_to_bit(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  if (_beg_bits.par_set_bit(beg_bit)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    const idx_t end_bit = addr_to_bit(addr + size - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    bool end_bit_ok = _end_bits.par_set_bit(end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    assert(end_bit_ok, "concurrency problem");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    DEBUG_ONLY(Atomic::inc_ptr(&mark_bitmap_count));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    DEBUG_ONLY(Atomic::add_ptr(size, &mark_bitmap_size));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  assert(beg_addr <= end_addr, "bad range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  idx_t live_bits = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  // The bitmap routines require the right boundary to be word-aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  const idx_t end_bit = addr_to_bit(end_addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  const idx_t range_end = BitMap::word_align_up(end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  while (beg_bit < end_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    idx_t tmp_end = find_obj_end(beg_bit, range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    if (tmp_end < end_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
      live_bits += tmp_end - beg_bit + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      beg_bit = find_obj_beg(tmp_end + 1, range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
      live_bits += end_bit - beg_bit;  // No + 1 here; end_bit is not counted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
      return bits_to_words(live_bits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  return bits_to_words(live_bits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  assert(beg_addr <= (HeapWord*)end_obj, "bad range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  assert(is_marked(end_obj), "end_obj must be live");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  idx_t live_bits = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // The bitmap routines require the right boundary to be word-aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  const idx_t end_bit = addr_to_bit((HeapWord*)end_obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  const idx_t range_end = BitMap::word_align_up(end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  while (beg_bit < end_bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    idx_t tmp_end = find_obj_end(beg_bit, range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    assert(tmp_end < end_bit, "missing end bit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    live_bits += tmp_end - beg_bit + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    beg_bit = find_obj_beg(tmp_end + 1, range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  return bits_to_words(live_bits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
ParMarkBitMap::IterationStatus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                       idx_t range_beg, idx_t range_end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  DEBUG_ONLY(verify_bit(range_beg);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  DEBUG_ONLY(verify_bit(range_end);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  assert(range_beg <= range_end, "live range invalid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // The bitmap routines require the right boundary to be word-aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  const idx_t search_end = BitMap::word_align_up(range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  idx_t cur_beg = find_obj_beg(range_beg, search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  while (cur_beg < range_end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    const idx_t cur_end = find_obj_end(cur_beg, search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    if (cur_end >= range_end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
      // The obj ends outside the range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      live_closure->set_source(bit_to_addr(cur_beg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      return incomplete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    const size_t size = obj_size(cur_beg, cur_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    if (status != incomplete) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      assert(status == would_overflow || status == full, "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      return status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    // Successfully processed the object; look for the next object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    cur_beg = find_obj_beg(cur_end + 1, search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  live_closure->set_source(bit_to_addr(range_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  return complete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
ParMarkBitMap::IterationStatus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
                       ParMarkBitMapClosure* dead_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
                       idx_t range_beg, idx_t range_end,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
                       idx_t dead_range_end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  DEBUG_ONLY(verify_bit(range_beg);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  DEBUG_ONLY(verify_bit(range_end);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  DEBUG_ONLY(verify_bit(dead_range_end);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  assert(range_beg <= range_end, "live range invalid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  assert(range_end <= dead_range_end, "dead range invalid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  // The bitmap routines require the right boundary to be word-aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  const idx_t live_search_end = BitMap::word_align_up(range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  const idx_t dead_search_end = BitMap::word_align_up(dead_range_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  idx_t cur_beg = range_beg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  if (range_beg < range_end && is_unmarked(range_beg)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    // The range starts with dead space.  Look for the next object, then fill.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    cur_beg = find_obj_beg(range_beg + 1, dead_search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    const size_t size = obj_size(range_beg, dead_space_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    dead_closure->do_addr(bit_to_addr(range_beg), size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  while (cur_beg < range_end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    const idx_t cur_end = find_obj_end(cur_beg, live_search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    if (cur_end >= range_end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      // The obj ends outside the range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      live_closure->set_source(bit_to_addr(cur_beg));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      return incomplete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    const size_t size = obj_size(cur_beg, cur_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    IterationStatus status = live_closure->do_addr(bit_to_addr(cur_beg), size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    if (status != incomplete) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
      assert(status == would_overflow || status == full, "sanity");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      return status;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    // Look for the start of the next object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    const idx_t dead_space_beg = cur_end + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    cur_beg = find_obj_beg(dead_space_beg, dead_search_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    if (cur_beg > dead_space_beg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      // Found dead space; compute the size and invoke the dead closure.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      const idx_t dead_space_end = MIN2(cur_beg - 1, dead_range_end - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      const size_t size = obj_size(dead_space_beg, dead_space_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      dead_closure->do_addr(bit_to_addr(dead_space_beg), size);
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
  live_closure->set_source(bit_to_addr(range_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  return complete;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
void ParMarkBitMap::reset_counters()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  _cas_tries = _cas_retries = _cas_by_another = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
#endif  // #ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
void ParMarkBitMap::verify_clear() const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  const idx_t* const beg = (const idx_t*)_virtual_space->committed_low_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  const idx_t* const end = (const idx_t*)_virtual_space->committed_high_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  for (const idx_t* p = beg; p < end; ++p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    assert(*p == 0, "bitmap not clear");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
#endif  // #ifdef ASSERT