hotspot/src/share/vm/gc/g1/g1BlockOffsetTable.cpp
author tschatzl
Wed, 25 Nov 2015 14:43:29 +0100
changeset 34300 6075c1e0e913
parent 34249 a015a11067a2
child 35061 be6025ebffea
permissions -rw-r--r--
8136679: JFR event for adaptive IHOP Reviewed-by: tbenson, mgerdin, sangheki, ehelin
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
/*
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
     2
 * Copyright (c) 2001, 2015, 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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
    26
#include "gc/g1/g1BlockOffsetTable.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
    27
#include "gc/g1/g1CollectedHeap.inline.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
    28
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
    29
#include "gc/shared/space.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    30
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    31
#include "runtime/java.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    32
#include "services/memTracker.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
26313
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
    34
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23858
diff changeset
    35
1374
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
// G1BlockOffsetSharedArray
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    40
G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage) :
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    41
  _reserved(), _end(NULL), _listener(), _offset_array(NULL) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    42
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    43
  _reserved = heap;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    44
  _end = NULL;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    45
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    46
  MemRegion bot_reserved = storage->reserved();
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
    47
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    48
  _offset_array = (u_char*)bot_reserved.start();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    49
  _end = _reserved.end();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    50
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    51
  storage->set_mapping_changed_listener(&_listener);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    52
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
  if (TraceBlockOffsetTable) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
    gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
    gclog_or_tty->print_cr("  "
26313
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
    56
                  "  rs.base(): " PTR_FORMAT
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
    57
                  "  rs.size(): " SIZE_FORMAT
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
    58
                  "  rs end(): " PTR_FORMAT,
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
    59
                  p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    62
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
  assert(p >= _reserved.start(), "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
  size_t delta = pointer_delta(p, _reserved.start());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
  return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
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
30583
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    69
#ifdef ASSERT
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    70
void G1BlockOffsetSharedArray::check_index(size_t index, const char* msg) const {
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    71
  assert((index) < (_reserved.word_size() >> LogN_words),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    72
         "%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    73
         msg, (index), (_reserved.word_size() >> LogN_words));
30583
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    74
  assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    75
         "Index " SIZE_FORMAT " corresponding to " PTR_FORMAT
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    76
         " (%u) is not in committed area.",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    77
         (index),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    78
         p2i(address_for_index_raw(index)),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    79
         G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index)));
30583
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    80
}
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    81
#endif // ASSERT
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30173
diff changeset
    82
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
// G1BlockOffsetArray
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array,
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26313
diff changeset
    88
                                       MemRegion mr) :
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
  G1BlockOffsetTable(mr.start(), mr.end()),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
  _unallocated_block(_bottom),
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26313
diff changeset
    91
  _array(array), _gsp(NULL) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  assert(_bottom <= _end, "arguments out of order");
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
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
    95
void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) {
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
    96
  _gsp = sp;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
// The arguments follow the normal convention of denoting
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
// a right-open interval: [start, end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
  if (start >= end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
    // The start address is equal to the end address (or to
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
    // the right of the end address) so there are not cards
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
    // that need to be updated..
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   110
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
  // Write the backskip value for each region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   112
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   113
  //    offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
  //    card             2nd                       3rd
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
  //     | +- 1st        |                         |
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
  //     v v             v                         v
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
  //    |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
   119
  //    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+     +-+-+-+-+-+-+-+-+-+-+-
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
  //    11              19                        75
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
  //      12
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   122
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   123
  //    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
   124
  //      x - offset value of offset card
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
  //    1st - start of first logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
  //      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
   127
  //    2nd - start of second logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
  //      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
   129
  //    3rd - start of third logarithmic region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  //      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
   131
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
  //    integer below the block offset entry is an example of
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
  //    the index of the entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  //
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  //    Given an address,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  //      Find the index for the address
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
  //      Find the block offset table entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
  //      Convert the entry to a back slide
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
  //        (e.g., with today's, offset = 0x81 =>
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  //          back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
  //      Move back N (e.g., 8) entries and repeat with the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
  //        value of the new entry
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
  size_t start_card = _array->index_for(start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
  size_t end_card = _array->index_for(end-1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
  assert(start ==_array->address_for_index(start_card), "Precondition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
  assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
  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
   149
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
// Unlike the normal convention in this code, the argument here denotes
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
// 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
   153
// above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
void
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   155
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
   156
  if (start_card > end_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   158
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
  assert(start_card > _array->index_for(_bottom), "Cannot be first card");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  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
   161
         "Offset card has an unexpected value");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
  size_t start_card_for_region = start_card;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
  u_char offset = max_jubyte;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
  for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
    // -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
   166
    // 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
   167
    // of the next.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
    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
   169
    offset = N_words + i;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
    if (reach >= end_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
      _array->set_offset_array(start_card_for_region, end_card, offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
      start_card_for_region = reach + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
      break;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
    _array->set_offset_array(start_card_for_region, reach, offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
    start_card_for_region = reach + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  assert(start_card_for_region > end_card, "Sanity check");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
  DEBUG_ONLY(check_all_cards(start_card, end_card);)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
// 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
   183
// 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
   184
// suitable flag.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   185
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
   186
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   187
  if (end_card < start_card) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   188
    return;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   189
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   190
  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
   191
  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
   192
    u_char entry = _array->offset_array(c);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
    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
   194
      guarantee(entry > N_words,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   195
                "Should be in logarithmic region - "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   196
                "entry: %u, "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   197
                "_array->offset_array(c): %u, "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   198
                "N_words: %u",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   199
                (uint)entry, (uint)_array->offset_array(c), (uint)N_words);
1374
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
    size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   202
    size_t landing_card = c - backskip;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
    guarantee(landing_card >= (start_card - 1), "Inv");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   204
    if (landing_card >= start_card) {
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   205
      guarantee(_array->offset_array(landing_card) <= entry,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   206
                "Monotonicity - landing_card offset: %u, "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   207
                "entry: %u",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   208
                (uint)_array->offset_array(landing_card), (uint)entry);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
      guarantee(landing_card == start_card - 1, "Tautology");
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13728
diff changeset
   211
      // 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
   212
      guarantee(_array->offset_array(landing_card) <= N_words,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   213
                "landing card offset: %u, "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   214
                "N_words: %u",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   215
                (uint)_array->offset_array(landing_card), (uint)N_words);
1374
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
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   221
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
  // 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
   224
  // allocation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
  HeapWord* ub = _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
  if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
    assert(ub < _end, "tautology (see above)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
    return ub;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
  // Otherwise, find the block start using the table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
  HeapWord* q = block_at_or_preceding(addr, false, 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
  return forward_to_block_containing_addr(q, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   234
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
// This duplicates a little code from the above: unavoidable.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   237
G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
  // 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
   241
  // allocation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   242
  HeapWord* ub = _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   243
  if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   244
    assert(ub < _end, "tautology (see above)");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
    return ub;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   246
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   247
  // Otherwise, find the block start using the table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   248
  HeapWord* q = block_at_or_preceding(addr, false, 0);
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   249
  HeapWord* n = q + block_size(q);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   251
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   252
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   254
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   255
G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   256
                                                          HeapWord* n,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   257
                                                          const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   258
  // 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
   259
  // here: LAB allocation.  An allocation previously recorded in the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   260
  // offset table was actually a lab allocation, and was divided into
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   261
  // several objects subsequently.  Fix this situation as we answer the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   262
  // 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
   263
163a4d4fa951 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 1374
diff changeset
   264
  // 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
   265
  // 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
   266
  // 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
   267
  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
   268
  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
   269
  // 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
   270
  // already, step to the boundary.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   271
  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
   272
                            (n_index == next_index ? 0 : N_words);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13195
diff changeset
   273
  assert(next_boundary <= _array->_end,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   274
         "next_boundary is beyond the end of the covered region "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   275
         " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   276
         p2i(next_boundary), p2i(_array->_end));
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   277
  if (addr >= gsp()->top()) return gsp()->top();
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   278
  while (next_boundary < addr) {
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   279
    while (n <= next_boundary) {
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   280
      q = n;
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   281
      oop obj = oop(q);
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   282
      if (obj->klass_or_null() == NULL) return q;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   283
      n += block_size(q);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
    }
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   285
    assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   286
    // [q, n) is the block that crosses the boundary.
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   287
    alloc_block_work2(&next_boundary, &next_index, q, n);
1374
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
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   290
}
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
// 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
   293
// so the table size might also wish to change.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   294
void G1BlockOffsetArray::resize(size_t new_word_size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   295
  HeapWord* new_end = _bottom + new_word_size;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   296
  _end = new_end;  // update _end
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   297
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   298
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
//              threshold_
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   301
//              |   _index_
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   302
//              v   v
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   303
//      +-------+-------+-------+-------+-------+
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   304
//      | i-1   |   i   | i+1   | i+2   | i+3   |
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   305
//      +-------+-------+-------+-------+-------+
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   306
//       ( ^    ]
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   307
//         block-start
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   308
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   309
void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   310
                                           HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   311
  // For efficiency, do copy-in/copy-out.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   312
  HeapWord* threshold = *threshold_;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   313
  size_t    index = *index_;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   314
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   315
  assert(blk_start != NULL && blk_end > blk_start,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   316
         "phantom block");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   317
  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
   318
  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
   319
  assert(pointer_delta(threshold, blk_start) <= N_words,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   320
         "offset should be <= BlockOffsetSharedArray::N");
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
   321
  assert(G1CollectedHeap::heap()->is_in_reserved(blk_start),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   322
         "reference must be into the heap");
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
   323
  assert(G1CollectedHeap::heap()->is_in_reserved(blk_end-1),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   324
         "limit must be within the heap");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   325
  assert(threshold == _array->_reserved.start() + index*N_words,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   326
         "index must agree with threshold");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   327
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   328
  DEBUG_ONLY(size_t orig_index = index;)
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
  // Mark the card that holds the offset into the block.  Note
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   331
  // that _next_offset_index and _next_offset_threshold are not
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   332
  // updated until the end of this method.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   333
  _array->set_offset_array(index, threshold, blk_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   334
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   335
  // 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
   336
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   337
  // Index of card on which blk ends.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   338
  size_t end_index   = _array->index_for(blk_end - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   339
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   340
  // Are there more cards left to be updated?
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   341
  if (index + 1 <= end_index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   342
    HeapWord* rem_st  = _array->address_for_index(index + 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   343
    // Calculate rem_end this way because end_index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   344
    // may be the last valid index in the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   345
    HeapWord* rem_end = _array->address_for_index(end_index) +  N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   346
    set_remainder_to_point_to_start(rem_st, rem_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   347
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   348
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   349
  index = end_index + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   350
  // Calculate threshold_ this way because end_index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   351
  // may be the last valid index in the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   352
  threshold = _array->address_for_index(end_index) + N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   353
  assert(threshold >= blk_end, "Incorrect offset threshold");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   354
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   355
  // index_ and threshold_ updated here.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   356
  *threshold_ = threshold;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   357
  *index_ = index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   358
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   359
#ifdef ASSERT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   360
  // 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
   361
  // is checked by an assertion above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   362
  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
   363
  HeapWord* boundary = _array->address_for_index(start_index);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   364
  assert((_array->offset_array(orig_index) == 0 && blk_start == boundary) ||
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   365
         (_array->offset_array(orig_index) > 0 && _array->offset_array(orig_index) <= N_words),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   366
         "offset array should have been set - "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   367
         "orig_index offset: %u, "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   368
         "blk_start: " PTR_FORMAT ", "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   369
         "boundary: " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   370
         (uint)_array->offset_array(orig_index),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   371
         p2i(blk_start), p2i(boundary));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   372
  for (size_t j = orig_index + 1; j <= end_index; j++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   373
    assert(_array->offset_array(j) > 0 &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   374
           _array->offset_array(j) <=
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   375
             (u_char) (N_words+BlockOffsetArray::N_powers-1),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   376
           "offset array should have been set - "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   377
           "%u not > 0 OR %u not <= %u",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   378
           (uint) _array->offset_array(j),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   379
           (uint) _array->offset_array(j),
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   380
           (uint) (N_words+BlockOffsetArray::N_powers-1));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   381
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   382
#endif
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
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   385
void G1BlockOffsetArray::verify() const {
26572
d5e6cac59ba1 8057910: G1: BOT verification should not pass top
brutisso
parents: 26571
diff changeset
   386
  assert(gsp()->bottom() < gsp()->top(), "Only non-empty regions should be verified.");
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   387
  size_t start_card = _array->index_for(gsp()->bottom());
26572
d5e6cac59ba1 8057910: G1: BOT verification should not pass top
brutisso
parents: 26571
diff changeset
   388
  size_t end_card = _array->index_for(gsp()->top() - 1);
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   389
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   390
  for (size_t current_card = start_card; current_card < end_card; current_card++) {
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   391
    u_char entry = _array->offset_array(current_card);
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   392
    if (entry < N_words) {
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   393
      // The entry should point to an object before the current card. Verify that
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   394
      // it is possible to walk from that object in to the current card by just
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   395
      // iterating over the objects following it.
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   396
      HeapWord* card_address = _array->address_for_index(current_card);
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   397
      HeapWord* obj_end = card_address - entry;
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   398
      while (obj_end < card_address) {
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   399
        HeapWord* obj = obj_end;
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   400
        size_t obj_size = block_size(obj);
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   401
        obj_end = obj + obj_size;
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   402
        guarantee(obj_end > obj && obj_end <= gsp()->top(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   403
                  "Invalid object end. obj: " PTR_FORMAT " obj_size: " SIZE_FORMAT " obj_end: " PTR_FORMAT " top: " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   404
                  p2i(obj), obj_size, p2i(obj_end), p2i(gsp()->top()));
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   405
      }
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   406
    } else {
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   407
      // Because we refine the BOT based on which cards are dirty there is not much we can verify here.
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   408
      // We need to make sure that we are going backwards and that we don't pass the start of the
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   409
      // corresponding heap region. But that is about all we can verify.
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   410
      size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   411
      guarantee(backskip >= 1, "Must be going back at least one card.");
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   412
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   413
      size_t max_backskip = current_card - start_card;
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   414
      guarantee(backskip <= max_backskip,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   415
                "Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   416
                start_card, current_card, backskip);
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   417
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   418
      HeapWord* backskip_address = _array->address_for_index(current_card - backskip);
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   419
      guarantee(backskip_address >= gsp()->bottom(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   420
                "Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
   421
                p2i(gsp()->bottom()), p2i(backskip_address));
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   422
    }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   423
  }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   424
}
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   425
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   426
#ifndef PRODUCT
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   427
void
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   428
G1BlockOffsetArray::print_on(outputStream* out) {
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   429
  size_t from_index = _array->index_for(_bottom);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   430
  size_t to_index = _array->index_for(_end);
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   431
  out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") "
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   432
                "cards [" SIZE_FORMAT "," SIZE_FORMAT ")",
26313
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
   433
                p2i(_bottom), p2i(_end), from_index, to_index);
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   434
  for (size_t i = from_index; i < to_index; ++i) {
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   435
    out->print_cr("  entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u",
26313
9baebbfc62dd 8055818: Remove PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC from g1BlockOffsetTable.cpp
brutisso
parents: 26160
diff changeset
   436
                  i, p2i(_array->address_for_index(i)),
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   437
                  (uint) _array->offset_array(i));
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   438
  }
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   439
}
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   440
#endif // !PRODUCT
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   441
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   442
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   443
// G1BlockOffsetArrayContigSpace
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   444
//////////////////////////////////////////////////////////////////////
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   445
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   446
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   447
G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   448
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   449
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   450
  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
   451
  return forward_to_block_containing_addr(q, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   452
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   453
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   454
HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   455
G1BlockOffsetArrayContigSpace::
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   456
block_start_unsafe_const(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   457
  assert(_bottom <= addr && addr < _end,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   458
         "addr must be covered by this Array");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   459
  HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   460
  HeapWord* n = q + block_size(q);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   461
  return forward_to_block_containing_addr_const(q, n, addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   462
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   463
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   464
G1BlockOffsetArrayContigSpace::
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   465
G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   466
                              MemRegion mr) :
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26313
diff changeset
   467
  G1BlockOffsetArray(array, mr)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   468
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   469
  _next_offset_threshold = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   470
  _next_offset_index = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   471
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   472
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   473
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold_raw() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
   474
  assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   475
         "just checking");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   476
  _next_offset_index = _array->index_for_raw(_bottom);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   477
  _next_offset_index++;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   478
  _next_offset_threshold =
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   479
    _array->address_for_index_raw(_next_offset_index);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   480
  return _next_offset_threshold;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   481
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   482
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   483
void G1BlockOffsetArrayContigSpace::zero_bottom_entry_raw() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
   484
  assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   485
         "just checking");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   486
  size_t bottom_index = _array->index_for_raw(_bottom);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   487
  assert(_array->address_for_index_raw(bottom_index) == _bottom,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   488
         "Precondition of call");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   489
  _array->set_offset_array_raw(bottom_index, 0);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   490
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   491
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   492
HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 26572
diff changeset
   493
  assert(!G1CollectedHeap::heap()->is_in_reserved(_array->_offset_array),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   494
         "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   495
  _next_offset_index = _array->index_for(_bottom);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   496
  _next_offset_index++;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   497
  _next_offset_threshold =
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   498
    _array->address_for_index(_next_offset_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   499
  return _next_offset_threshold;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   500
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   501
34249
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   502
void G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* obj_top, size_t fill_size) {
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   503
  // The first BOT entry should have offset 0.
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   504
  reset_bot();
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   505
  alloc_block(_bottom, obj_top);
34249
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   506
  if (fill_size > 0) {
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   507
    alloc_block(obj_top, fill_size);
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   508
  }
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   509
}
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   510
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   511
#ifndef PRODUCT
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   512
void G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   513
  G1BlockOffsetArray::print_on(out);
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   514
  out->print_cr("  next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold));
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   515
  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
   516
}
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   517
#endif // !PRODUCT