hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp
author drchase
Fri, 09 May 2014 16:50:54 -0400
changeset 24424 2658d7834c6e
parent 23858 dae377f5a7c7
child 25361 5146d1e12a2f
permissions -rw-r--r--
8037816: Fix for 8036122 breaks build with Xcode5/clang Summary: Repaired or selectively disabled offending formats; future-proofed with additional checking Reviewed-by: kvn, jrose, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23858
diff changeset
     2
 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
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: 5402
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    26
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    27
#include "memory/space.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    28
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    29
#include "runtime/java.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    30
#include "services/memTracker.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    31
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23858
diff changeset
    32
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23858
diff changeset
    33
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
// G1BlockOffsetSharedArray
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion reserved,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
                                                   size_t init_word_size) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
  _reserved(reserved), _end(NULL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
  size_t size = compute_size(reserved.word_size());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
  ReservedSpace rs(ReservedSpace::allocation_align_size_up(size));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
  if (!rs.is_reserved()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
    vm_exit_during_initialization("Could not reserve enough space for heap offset array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  if (!_vs.initialize(rs, 0)) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
    vm_exit_during_initialization("Could not reserve enough space for heap offset array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    50
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    51
  MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    52
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
  _offset_array = (u_char*)_vs.low_boundary();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
  resize(init_word_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
  if (TraceBlockOffsetTable) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
    gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
    gclog_or_tty->print_cr("  "
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
                  "  rs.base(): " INTPTR_FORMAT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
                  "  rs.size(): " INTPTR_FORMAT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
                  "  rs end(): " INTPTR_FORMAT,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
                  rs.base(), rs.size(), rs.base() + rs.size());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    62
    gclog_or_tty->print_cr("  "
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
                  "  _vs.low_boundary(): " INTPTR_FORMAT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
                  "  _vs.high_boundary(): " INTPTR_FORMAT,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
                  _vs.low_boundary(),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
                  _vs.high_boundary());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
void G1BlockOffsetSharedArray::resize(size_t new_word_size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
  assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
  size_t new_size = compute_size(new_word_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
  size_t old_size = _vs.committed_size();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
  size_t delta;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
  char* high = _vs.high();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
  _end = _reserved.start() + new_word_size;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
  if (new_size > old_size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
    delta = ReservedSpace::page_align_size_up(new_size - old_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
    assert(delta > 0, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
    if (!_vs.expand_by(delta)) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
      // Do better than this for Merlin
17087
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 14584
diff changeset
    82
      vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
    assert(_vs.high() == high + delta, "invalid expansion");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
    // Initialization of the contents is left to the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
    // G1BlockOffsetArray that uses it.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
    delta = ReservedSpace::page_align_size_down(old_size - new_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
    if (delta == 0) return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
    _vs.shrink_by(delta);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
    assert(_vs.high() == high - delta, "invalid expansion");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    93
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    94
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
  assert(p >= _reserved.start(), "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
  size_t delta = pointer_delta(p, _reserved.start());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
  return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
// G1BlockOffsetArray
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
                                       MemRegion mr, bool init_to_zero) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
  G1BlockOffsetTable(mr.start(), mr.end()),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
  _unallocated_block(_bottom),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   110
  _array(array), _csp(NULL),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
  _init_to_zero(init_to_zero) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   112
  assert(_bottom <= _end, "arguments out of order");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   113
  if (!_init_to_zero) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
    // initialize cards to point back to mr.start()
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
    set_remainder_to_point_to_start(mr.start() + N_words, mr.end());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
    _array->set_offset_array(0, 0);  // set first card to 0
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   117
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   118
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   119
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
void G1BlockOffsetArray::set_space(Space* sp) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
  _sp = sp;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   122
  _csp = sp->toContiguousSpace();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   123
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   124
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
// The arguments follow the normal convention of denoting
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
// a right-open interval: [start, end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  if (start >= end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
    // The start address is equal to the end address (or to
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
    // the right of the end address) so there are not cards
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
    // that need to be updated..
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
  // Write the backskip value for each region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
  //    offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  //    card             2nd                       3rd
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
  //     | +- 1st        |                         |
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
  //     v v             v                         v
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   143
  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+-+-+-
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   144
  //    |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ...
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+-+-+-
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
  //    11              19                        75
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
  //      12
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
  //    offset card is the card that points to the start of an object
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
  //      x - offset value of offset card
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
  //    1st - start of first logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
  //      0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  //    2nd - start of second logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
  //      1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   155
  //    3rd - start of third logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   156
  //      2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   158
  //    integer below the block offset entry is an example of
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
  //    the index of the entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  //    Given an address,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
  //      Find the index for the address
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
  //      Find the block offset table entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
  //      Convert the entry to a back slide
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
  //        (e.g., with today's, offset = 0x81 =>
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
  //          back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
  //      Move back N (e.g., 8) entries and repeat with the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
  //        value of the new entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  size_t start_card = _array->index_for(start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
  size_t end_card = _array->index_for(end-1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
  assert(start ==_array->address_for_index(start_card), "Precondition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
  assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
  set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
// Unlike the normal convention in this code, the argument here denotes
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
// a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
// above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
  if (start_card > end_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   184
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   185
  assert(start_card > _array->index_for(_bottom), "Cannot be first card");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   186
  assert(_array->offset_array(start_card-1) <= N_words,
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   187
         "Offset card has an unexpected value");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   188
  size_t start_card_for_region = start_card;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   189
  u_char offset = max_jubyte;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   190
  for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   191
    // -1 so that the the card with the actual offset is counted.  Another -1
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   192
    // so that the reach ends in this region and not at the start
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
    // of the next.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   194
    size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   195
    offset = N_words + i;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
    if (reach >= end_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
      _array->set_offset_array(start_card_for_region, end_card, offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
      start_card_for_region = reach + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
      break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   200
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
    _array->set_offset_array(start_card_for_region, reach, offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   202
    start_card_for_region = reach + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   204
  assert(start_card_for_region > end_card, "Sanity check");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   205
  DEBUG_ONLY(check_all_cards(start_card, end_card);)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   206
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   207
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   208
// The block [blk_start, blk_end) has been allocated;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
// adjust the block offset table to represent this information;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
// right-open interval: [blk_start, blk_end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   211
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
G1BlockOffsetArray::alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
  mark_block(blk_start, blk_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
  allocated(blk_start, blk_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   215
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   216
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   217
// Adjust BOT to show that a previously whole block has been split
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
// into two.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
void G1BlockOffsetArray::split_block(HeapWord* blk, size_t blk_size,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
                                     size_t left_blk_size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   221
  // Verify that the BOT shows [blk, blk + blk_size) to be one block.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
  verify_single_block(blk, blk_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
  // Update the BOT to indicate that [blk + left_blk_size, blk + blk_size)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
  // is one single block.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
  mark_block(blk + left_blk_size, blk + blk_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
// Action_mark - update the BOT for the block [blk_start, blk_end).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
//               Current typical use is for splitting a block.
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   231
// Action_single - update the BOT for an allocation.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
// Action_verify - BOT verification.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
void G1BlockOffsetArray::do_block_internal(HeapWord* blk_start,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   234
                                           HeapWord* blk_end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
                                           Action action) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
  assert(Universe::heap()->is_in_reserved(blk_start),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   237
         "reference must be into the heap");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
  assert(Universe::heap()->is_in_reserved(blk_end-1),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
         "limit must be within the heap");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
  // This is optimized to make the test fast, assuming we only rarely
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
  // cross boundaries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   242
  uintptr_t end_ui = (uintptr_t)(blk_end - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   243
  uintptr_t start_ui = (uintptr_t)blk_start;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   244
  // Calculate the last card boundary preceding end of blk
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
  intptr_t boundary_before_end = (intptr_t)end_ui;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   246
  clear_bits(boundary_before_end, right_n_bits(LogN));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   247
  if (start_ui <= (uintptr_t)boundary_before_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   248
    // blk starts at or crosses a boundary
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   249
    // Calculate index of card on which blk begins
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
    size_t    start_index = _array->index_for(blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   251
    // Index of card on which blk ends
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   252
    size_t    end_index   = _array->index_for(blk_end - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
    // Start address of card on which blk begins
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   254
    HeapWord* boundary    = _array->address_for_index(start_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   255
    assert(boundary <= blk_start, "blk should start at or after boundary");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   256
    if (blk_start != boundary) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   257
      // blk starts strictly after boundary
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   258
      // adjust card boundary and start_index forward to next card
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   259
      boundary += N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   260
      start_index++;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   261
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   262
    assert(start_index <= end_index, "monotonicity of index_for()");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   263
    assert(boundary <= (HeapWord*)boundary_before_end, "tautology");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   264
    switch (action) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   265
      case Action_mark: {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   266
        if (init_to_zero()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   267
          _array->set_offset_array(start_index, boundary, blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   268
          break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   269
        } // Else fall through to the next case
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   270
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   271
      case Action_single: {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   272
        _array->set_offset_array(start_index, boundary, blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   273
        // We have finished marking the "offset card". We need to now
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   274
        // mark the subsequent cards that this blk spans.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   275
        if (start_index < end_index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   276
          HeapWord* rem_st = _array->address_for_index(start_index) + N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   277
          HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   278
          set_remainder_to_point_to_start(rem_st, rem_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   279
        }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   280
        break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   281
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   282
      case Action_check: {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   283
        _array->check_offset_array(start_index, boundary, blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
        // We have finished checking the "offset card". We need to now
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   285
        // check the subsequent cards that this blk spans.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   286
        check_all_cards(start_index + 1, end_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   287
        break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   288
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   289
      default:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   290
        ShouldNotReachHere();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   291
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   292
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   293
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   294
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   295
// The card-interval [start_card, end_card] is a closed interval; this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   296
// is an expensive check -- use with care and only under protection of
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   297
// suitable flag.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   298
void G1BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   299
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   300
  if (end_card < start_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   301
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   302
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   303
  guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   304
  for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   305
    u_char entry = _array->offset_array(c);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   306
    if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   307
      guarantee(entry > N_words,
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   308
                err_msg("Should be in logarithmic region - "
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   309
                        "entry: %u, "
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   310
                        "_array->offset_array(c): %u, "
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   311
                        "N_words: %u",
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   312
                        (uint)entry, (uint)_array->offset_array(c), (uint)N_words));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   313
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   314
    size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   315
    size_t landing_card = c - backskip;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   316
    guarantee(landing_card >= (start_card - 1), "Inv");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   317
    if (landing_card >= start_card) {
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   318
      guarantee(_array->offset_array(landing_card) <= entry,
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   319
                err_msg("Monotonicity - landing_card offset: %u, "
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   320
                        "entry: %u",
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   321
                        (uint)_array->offset_array(landing_card), (uint)entry));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   322
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   323
      guarantee(landing_card == start_card - 1, "Tautology");
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   324
      // Note that N_words is the maximum offset value
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   325
      guarantee(_array->offset_array(landing_card) <= N_words,
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   326
                err_msg("landing card offset: %u, "
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   327
                        "N_words: %u",
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   328
                        (uint)_array->offset_array(landing_card), (uint)N_words));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   329
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   330
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   331
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   332
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   333
// The range [blk_start, blk_end) represents a single contiguous block
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   334
// of storage; modify the block offset table to represent this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   335
// information; Right-open interval: [blk_start, blk_end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   336
// NOTE: this method does _not_ adjust _unallocated_block.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   337
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   338
G1BlockOffsetArray::single_block(HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   339
  do_block_internal(blk_start, blk_end, Action_single);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   340
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   341
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   342
// Mark the BOT such that if [blk_start, blk_end) straddles a card
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   343
// boundary, the card following the first such boundary is marked
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   344
// with the appropriate offset.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   345
// NOTE: this method does _not_ adjust _unallocated_block or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   346
// any cards subsequent to the first one.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   347
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   348
G1BlockOffsetArray::mark_block(HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   349
  do_block_internal(blk_start, blk_end, Action_mark);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   350
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   351
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   352
HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   353
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   354
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   355
  // Must read this exactly once because it can be modified by parallel
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   356
  // allocation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   357
  HeapWord* ub = _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   358
  if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   359
    assert(ub < _end, "tautology (see above)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   360
    return ub;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   361
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   362
  // Otherwise, find the block start using the table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   363
  HeapWord* q = block_at_or_preceding(addr, false, 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   364
  return forward_to_block_containing_addr(q, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   365
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   366
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   367
// This duplicates a little code from the above: unavoidable.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   368
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   369
G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   370
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   371
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   372
  // Must read this exactly once because it can be modified by parallel
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   373
  // allocation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   374
  HeapWord* ub = _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   375
  if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   376
    assert(ub < _end, "tautology (see above)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   377
    return ub;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   378
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   379
  // Otherwise, find the block start using the table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   380
  HeapWord* q = block_at_or_preceding(addr, false, 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   381
  HeapWord* n = q + _sp->block_size(q);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   382
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   383
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   384
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   385
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   386
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   387
G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   388
                                                          HeapWord* n,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   389
                                                          const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   390
  // We're not in the normal case.  We need to handle an important subcase
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   391
  // here: LAB allocation.  An allocation previously recorded in the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   392
  // offset table was actually a lab allocation, and was divided into
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   393
  // several objects subsequently.  Fix this situation as we answer the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   394
  // query, by updating entries as we cross them.
1384
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   395
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   396
  // If the fist object's end q is at the card boundary. Start refining
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   397
  // with the corresponding card (the value of the entry will be basically
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   398
  // set to 0). If the object crosses the boundary -- start from the next card.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   399
  size_t n_index = _array->index_for(n);
1384
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   400
  size_t next_index = _array->index_for(n) + !_array->is_card_boundary(n);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   401
  // Calculate a consistent next boundary.  If "n" is not at the boundary
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   402
  // already, step to the boundary.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   403
  HeapWord* next_boundary = _array->address_for_index(n_index) +
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   404
                            (n_index == next_index ? 0 : N_words);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   405
  assert(next_boundary <= _array->_end,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   406
         err_msg("next_boundary is beyond the end of the covered region "
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   407
                 " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   408
                 next_boundary, _array->_end));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   409
  if (csp() != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   410
    if (addr >= csp()->top()) return csp()->top();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   411
    while (next_boundary < addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   412
      while (n <= next_boundary) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   413
        q = n;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   414
        oop obj = oop(q);
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1623
diff changeset
   415
        if (obj->klass_or_null() == NULL) return q;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   416
        n += obj->size();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   417
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   418
      assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   419
      // [q, n) is the block that crosses the boundary.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   420
      alloc_block_work2(&next_boundary, &next_index, q, n);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   421
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   422
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   423
    while (next_boundary < addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   424
      while (n <= next_boundary) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   425
        q = n;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   426
        oop obj = oop(q);
3262
30d1c247fc25 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 1623
diff changeset
   427
        if (obj->klass_or_null() == NULL) return q;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   428
        n += _sp->block_size(q);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   429
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   430
      assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   431
      // [q, n) is the block that crosses the boundary.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   432
      alloc_block_work2(&next_boundary, &next_index, q, n);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   433
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   434
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   435
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   436
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   437
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   438
HeapWord* G1BlockOffsetArray::block_start_careful(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   439
  assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   440
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   441
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   442
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   443
  // Must read this exactly once because it can be modified by parallel
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   444
  // allocation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   445
  HeapWord* ub = _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   446
  if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   447
    assert(ub < _end, "tautology (see above)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   448
    return ub;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   449
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   450
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   451
  // Otherwise, find the block start using the table, but taking
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   452
  // care (cf block_start_unsafe() above) not to parse any objects/blocks
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   453
  // on the cards themselves.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   454
  size_t index = _array->index_for(addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   455
  assert(_array->address_for_index(index) == addr,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   456
         "arg should be start of card");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   457
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   458
  HeapWord* q = (HeapWord*)addr;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   459
  uint offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   460
  do {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   461
    offset = _array->offset_array(index--);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   462
    q -= offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   463
  } while (offset == N_words);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   464
  assert(q <= addr, "block start should be to left of arg");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   465
  return q;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   466
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   467
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   468
// Note that the committed size of the covered space may have changed,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   469
// so the table size might also wish to change.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   470
void G1BlockOffsetArray::resize(size_t new_word_size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   471
  HeapWord* new_end = _bottom + new_word_size;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   472
  if (_end < new_end && !init_to_zero()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   473
    // verify that the old and new boundaries are also card boundaries
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   474
    assert(_array->is_card_boundary(_end),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   475
           "_end not a card boundary");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   476
    assert(_array->is_card_boundary(new_end),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   477
           "new _end would not be a card boundary");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   478
    // set all the newly added cards
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   479
    _array->set_offset_array(_end, new_end, N_words);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   480
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   481
  _end = new_end;  // update _end
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   482
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   483
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   484
void G1BlockOffsetArray::set_region(MemRegion mr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   485
  _bottom = mr.start();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   486
  _end = mr.end();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   487
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   488
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   489
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   490
//              threshold_
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   491
//              |   _index_
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   492
//              v   v
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   493
//      +-------+-------+-------+-------+-------+
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   494
//      | i-1   |   i   | i+1   | i+2   | i+3   |
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   495
//      +-------+-------+-------+-------+-------+
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   496
//       ( ^    ]
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   497
//         block-start
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   498
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   499
void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   500
                                           HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   501
  // For efficiency, do copy-in/copy-out.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   502
  HeapWord* threshold = *threshold_;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   503
  size_t    index = *index_;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   504
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   505
  assert(blk_start != NULL && blk_end > blk_start,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   506
         "phantom block");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   507
  assert(blk_end > threshold, "should be past threshold");
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 3262
diff changeset
   508
  assert(blk_start <= threshold, "blk_start should be at or before threshold");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   509
  assert(pointer_delta(threshold, blk_start) <= N_words,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   510
         "offset should be <= BlockOffsetSharedArray::N");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   511
  assert(Universe::heap()->is_in_reserved(blk_start),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   512
         "reference must be into the heap");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   513
  assert(Universe::heap()->is_in_reserved(blk_end-1),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   514
         "limit must be within the heap");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   515
  assert(threshold == _array->_reserved.start() + index*N_words,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   516
         "index must agree with threshold");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   517
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   518
  DEBUG_ONLY(size_t orig_index = index;)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   519
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   520
  // Mark the card that holds the offset into the block.  Note
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   521
  // that _next_offset_index and _next_offset_threshold are not
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   522
  // updated until the end of this method.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   523
  _array->set_offset_array(index, threshold, blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   524
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   525
  // We need to now mark the subsequent cards that this blk spans.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   526
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   527
  // Index of card on which blk ends.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   528
  size_t end_index   = _array->index_for(blk_end - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   529
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   530
  // Are there more cards left to be updated?
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   531
  if (index + 1 <= end_index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   532
    HeapWord* rem_st  = _array->address_for_index(index + 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   533
    // Calculate rem_end this way because end_index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   534
    // may be the last valid index in the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   535
    HeapWord* rem_end = _array->address_for_index(end_index) +  N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   536
    set_remainder_to_point_to_start(rem_st, rem_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   537
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   538
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   539
  index = end_index + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   540
  // Calculate threshold_ this way because end_index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   541
  // may be the last valid index in the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   542
  threshold = _array->address_for_index(end_index) + N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   543
  assert(threshold >= blk_end, "Incorrect offset threshold");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   544
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   545
  // index_ and threshold_ updated here.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   546
  *threshold_ = threshold;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   547
  *index_ = index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   548
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   549
#ifdef ASSERT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   550
  // The offset can be 0 if the block starts on a boundary.  That
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   551
  // is checked by an assertion above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   552
  size_t start_index = _array->index_for(blk_start);
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   553
  HeapWord* boundary = _array->address_for_index(start_index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   554
  assert((_array->offset_array(orig_index) == 0 &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   555
          blk_start == boundary) ||
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   556
          (_array->offset_array(orig_index) > 0 &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   557
         _array->offset_array(orig_index) <= N_words),
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   558
         err_msg("offset array should have been set - "
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   559
                  "orig_index offset: %u, "
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   560
                  "blk_start: " PTR_FORMAT ", "
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   561
                  "boundary: " PTR_FORMAT,
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   562
                  (uint)_array->offset_array(orig_index),
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   563
                  blk_start, boundary));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   564
  for (size_t j = orig_index + 1; j <= end_index; j++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   565
    assert(_array->offset_array(j) > 0 &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   566
           _array->offset_array(j) <=
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   567
             (u_char) (N_words+BlockOffsetArray::N_powers-1),
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   568
           err_msg("offset array should have been set - "
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   569
                   "%u not > 0 OR %u not <= %u",
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   570
                   (uint) _array->offset_array(j),
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   571
                   (uint) _array->offset_array(j),
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 22551
diff changeset
   572
                   (uint) (N_words+BlockOffsetArray::N_powers-1)));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   573
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   574
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   575
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   576
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   577
bool
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   578
G1BlockOffsetArray::verify_for_object(HeapWord* obj_start,
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   579
                                      size_t word_size) const {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   580
  size_t first_card = _array->index_for(obj_start);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   581
  size_t last_card = _array->index_for(obj_start + word_size - 1);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   582
  if (!_array->is_card_boundary(obj_start)) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   583
    // If the object is not on a card boundary the BOT entry of the
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   584
    // first card should point to another object so we should not
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   585
    // check that one.
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   586
    first_card += 1;
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   587
  }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   588
  for (size_t card = first_card; card <= last_card; card += 1) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   589
    HeapWord* card_addr = _array->address_for_index(card);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   590
    HeapWord* block_start = block_start_const(card_addr);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   591
    if (block_start != obj_start) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   592
      gclog_or_tty->print_cr("block start: "PTR_FORMAT" is incorrect - "
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   593
                             "card index: "SIZE_FORMAT" "
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   594
                             "card addr: "PTR_FORMAT" BOT entry: %u "
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   595
                             "obj: "PTR_FORMAT" word size: "SIZE_FORMAT" "
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   596
                             "cards: ["SIZE_FORMAT","SIZE_FORMAT"]",
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   597
                             block_start, card, card_addr,
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   598
                             _array->offset_array(card),
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   599
                             obj_start, word_size, first_card, last_card);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   600
      return false;
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   601
    }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   602
  }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   603
  return true;
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   604
}
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   605
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   606
#ifndef PRODUCT
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   607
void
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   608
G1BlockOffsetArray::print_on(outputStream* out) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   609
  size_t from_index = _array->index_for(_bottom);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   610
  size_t to_index = _array->index_for(_end);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   611
  out->print_cr(">> BOT for area ["PTR_FORMAT","PTR_FORMAT") "
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   612
                "cards ["SIZE_FORMAT","SIZE_FORMAT")",
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   613
                _bottom, _end, from_index, to_index);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   614
  for (size_t i = from_index; i < to_index; ++i) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   615
    out->print_cr("  entry "SIZE_FORMAT_W(8)" | "PTR_FORMAT" : %3u",
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   616
                  i, _array->address_for_index(i),
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   617
                  (uint) _array->offset_array(i));
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   618
  }
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   619
}
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   620
#endif // !PRODUCT
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   621
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   622
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   623
// G1BlockOffsetArrayContigSpace
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   624
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   625
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   626
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   627
G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   628
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   629
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   630
  HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   631
  return forward_to_block_containing_addr(q, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   632
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   633
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   634
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   635
G1BlockOffsetArrayContigSpace::
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   636
block_start_unsafe_const(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   637
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   638
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   639
  HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   640
  HeapWord* n = q + _sp->block_size(q);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   641
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   642
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   643
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   644
G1BlockOffsetArrayContigSpace::
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   645
G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   646
                              MemRegion mr) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   647
  G1BlockOffsetArray(array, mr, true)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   648
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   649
  _next_offset_threshold = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   650
  _next_offset_index = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   651
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   652
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   653
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   654
  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   655
         "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   656
  _next_offset_index = _array->index_for(_bottom);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   657
  _next_offset_index++;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   658
  _next_offset_threshold =
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   659
    _array->address_for_index(_next_offset_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   660
  return _next_offset_threshold;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   661
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   662
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   663
void G1BlockOffsetArrayContigSpace::zero_bottom_entry() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   664
  assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   665
         "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   666
  size_t bottom_index = _array->index_for(_bottom);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   667
  assert(_array->address_for_index(bottom_index) == _bottom,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   668
         "Precondition of call");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   669
  _array->set_offset_array(bottom_index, 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   670
}
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   671
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   672
void
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   673
G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   674
  assert(new_top <= _end, "_end should have already been updated");
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   675
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   676
  // The first BOT entry should have offset 0.
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   677
  zero_bottom_entry();
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   678
  initialize_threshold();
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   679
  alloc_block(_bottom, new_top);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   680
 }
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   681
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   682
#ifndef PRODUCT
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   683
void
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   684
G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   685
  G1BlockOffsetArray::print_on(out);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   686
  out->print_cr("  next offset threshold: "PTR_FORMAT, _next_offset_threshold);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   687
  out->print_cr("  next offset index:     "SIZE_FORMAT, _next_offset_index);
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   688
}
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   689
#endif // !PRODUCT