src/hotspot/share/gc/shared/cardTable.cpp
author tschatzl
Wed, 08 Aug 2018 15:31:06 +0200
changeset 51332 c25572739e7c
parent 49194 ece10494786c
child 54110 f4f0dce5d0bb
permissions -rw-r--r--
8208669: GC changes to allow enabling -Wreorder Reviewed-by: kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48961
120b61d50f85 8195103: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47998
diff changeset
     2
 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4461
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4461
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: 4461
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5892
diff changeset
    25
#include "precompiled.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    26
#include "gc/shared/cardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    27
#include "gc/shared/collectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    28
#include "gc/shared/space.inline.hpp"
47998
fb0275c320a0 8189871: Refactor GC barriers to use declarative semantics
eosterlund
parents: 47216
diff changeset
    29
#include "logging/log.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 30154
diff changeset
    30
#include "memory/virtualspace.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    31
#include "runtime/java.hpp"
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    32
#include "runtime/os.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
    33
#include "services/memTracker.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    34
#include "utilities/align.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5892
diff changeset
    35
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    36
size_t CardTable::compute_byte_map_size() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  assert(_guard_index == cards_required(_whole_heap.word_size()) - 1,
22775
52bc5222f5f1 8026849: Fix typos in the GC code, part 2
jwilhelm
parents: 22551
diff changeset
    38
                                        "uninitialized, check declaration order");
52bc5222f5f1 8026849: Fix typos in the GC code, part 2
jwilhelm
parents: 22551
diff changeset
    39
  assert(_page_size != 0, "uninitialized, check declaration order");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  const size_t granularity = os::vm_allocation_granularity();
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
    41
  return align_up(_guard_index + 1, MAX2(_page_size, granularity));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    44
CardTable::CardTable(MemRegion whole_heap, bool conc_scan) :
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    45
  _scanned_concurrently(conc_scan),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  _whole_heap(whole_heap),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    47
  _guard_index(0),
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    48
  _last_valid_index(0),
194
8cdd3d9a4c99 6635560: segv in reference processor on t1000
jcoomes
parents: 1
diff changeset
    49
  _page_size(os::vm_page_size()),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    50
  _byte_map_size(0),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49194
diff changeset
    51
  _byte_map(NULL),
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49194
diff changeset
    52
  _byte_map_base(NULL),
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49194
diff changeset
    53
  _cur_covered_regions(0),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    54
  _covered(NULL),
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    55
  _committed(NULL),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49194
diff changeset
    56
  _guard_region()
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
{
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    58
  assert((uintptr_t(_whole_heap.start())  & (card_size - 1))  == 0, "heap must start at card boundary");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    59
  assert((uintptr_t(_whole_heap.end()) & (card_size - 1))  == 0, "heap must end at card boundary");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    60
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    61
  assert(card_size <= 512, "card_size must be less than 512"); // why?
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    62
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    63
  _covered   = new MemRegion[_max_covered_regions];
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    64
  if (_covered == NULL) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    65
    vm_exit_during_initialization("Could not allocate card table covered region set.");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    66
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    67
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    68
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    69
CardTable::~CardTable() {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    70
  if (_covered) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    71
    delete[] _covered;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    72
    _covered = NULL;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    73
  }
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    74
  if (_committed) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    75
    delete[] _committed;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    76
    _committed = NULL;
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    77
  }
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    78
}
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    79
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
    80
void CardTable::initialize() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    81
  _guard_index = cards_required(_whole_heap.word_size()) - 1;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    82
  _last_valid_index = _guard_index - 1;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    83
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    84
  _byte_map_size = compute_byte_map_size();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    85
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  HeapWord* low_bound  = _whole_heap.start();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  HeapWord* high_bound = _whole_heap.end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    89
  _cur_covered_regions = 0;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    90
  _committed = new MemRegion[_max_covered_regions];
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    91
  if (_committed == NULL) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
    92
    vm_exit_during_initialization("Could not allocate card table committed region set.");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
17376
4ee999c3c007 8012902: remove use of global operator new - take 2
minqi
parents: 17087
diff changeset
    94
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  const size_t rs_align = _page_size == (size_t) os::vm_page_size() ? 0 :
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    MAX2(_page_size, (size_t) os::vm_allocation_granularity());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ReservedSpace heap_rs(_byte_map_size, rs_align, false);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
    98
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
    99
  MemTracker::record_virtual_memory_type((address)heap_rs.base(), mtGC);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 12268
diff changeset
   100
37462
58bb9394a98b 8152491: Convert TracePageSizes to use UL
stefank
parents: 37226
diff changeset
   101
  os::trace_page_sizes("Card Table", _guard_index + 1, _guard_index + 1,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                       _page_size, heap_rs.base(), heap_rs.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  if (!heap_rs.is_reserved()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    vm_exit_during_initialization("Could not reserve enough space for the "
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                                  "card marking array");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 20309
diff changeset
   108
  // The assembler store_check code will do an unsigned shift of the oop,
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   109
  // then add it to _byte_map_base, i.e.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  //
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   111
  //   _byte_map = _byte_map_base + (uintptr_t(low_bound) >> card_shift)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  _byte_map = (jbyte*) heap_rs.base();
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   113
  _byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  jbyte* guard_card = &_byte_map[_guard_index];
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   118
  HeapWord* guard_page = align_down((HeapWord*)guard_card, _page_size);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   119
  _guard_region = MemRegion(guard_page, _page_size);
18069
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17376
diff changeset
   120
  os::commit_memory_or_exit((char*)guard_page, _page_size, _page_size,
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17376
diff changeset
   121
                            !ExecMem, "card table last card");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  *guard_card = last_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   124
  log_trace(gc, barrier)("CardTable::CardTable: ");
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   125
  log_trace(gc, barrier)("    &_byte_map[0]: " INTPTR_FORMAT "  &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   126
                  p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index]));
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   127
  log_trace(gc, barrier)("    _byte_map_base: " INTPTR_FORMAT, p2i(_byte_map_base));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   130
int CardTable::find_covering_region_by_base(HeapWord* base) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  for (i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    if (_covered[i].start() == base) return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    if (_covered[i].start() > base) break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // If we didn't find it, create a new one.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  assert(_cur_covered_regions < _max_covered_regions,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
         "too many covered regions");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Move the ones above up, to maintain sorted order.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  for (int j = _cur_covered_regions; j > i; j--) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    _covered[j] = _covered[j-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    _committed[j] = _committed[j-1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  int res = i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  _cur_covered_regions++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  _covered[res].set_start(base);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  _covered[res].set_word_size(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  jbyte* ct_start = byte_for(base);
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   149
  HeapWord* ct_start_aligned = align_down((HeapWord*)ct_start, _page_size);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   150
  _committed[res].set_start(ct_start_aligned);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  _committed[res].set_word_size(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   155
int CardTable::find_covering_region_containing(HeapWord* addr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  for (int i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    if (_covered[i].contains(addr)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      return i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  assert(0, "address outside of heap?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   165
HeapWord* CardTable::largest_prev_committed_end(int ind) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  HeapWord* max_end = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  for (int j = 0; j < ind; j++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    HeapWord* this_end = _committed[j].end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    if (this_end > max_end) max_end = this_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  return max_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   174
MemRegion CardTable::committed_unique_to_self(int self, MemRegion mr) const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  MemRegion result = mr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  for (int r = 0; r < _cur_covered_regions; r += 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    if (r != self) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      result = result.minus(_committed[r]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  // Never include the guard page.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  result = result.minus(_guard_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   186
void CardTable::resize_covered_region(MemRegion new_region) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // We don't change the start of a region, only the end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  assert(_whole_heap.contains(new_region),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
           "attempt to cover area not in reserved area");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  debug_only(verify_guard();)
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   191
  // collided is true if the expansion would push into another committed region
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   192
  debug_only(bool collided = false;)
179
59e3abf83f72 6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents: 1
diff changeset
   193
  int const ind = find_covering_region_by_base(new_region.start());
59e3abf83f72 6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents: 1
diff changeset
   194
  MemRegion const old_region = _covered[ind];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  assert(old_region.start() == new_region.start(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  if (new_region.word_size() != old_region.word_size()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    // Commit new or uncommit old pages, if necessary.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    MemRegion cur_committed = _committed[ind];
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 20309
diff changeset
   199
    // Extend the end of this _committed region
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    // to cover the end of any lower _committed regions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    // This forms overlapping regions, but never interior regions.
179
59e3abf83f72 6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents: 1
diff changeset
   202
    HeapWord* const max_prev_end = largest_prev_committed_end(ind);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    if (max_prev_end > cur_committed.end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      cur_committed.set_end(max_prev_end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    // Align the end up to a page size (starts are already aligned).
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   207
    HeapWord* new_end = (HeapWord*) byte_after(new_region.last());
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   208
    HeapWord* new_end_aligned = align_up(new_end, _page_size);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   209
    assert(new_end_aligned >= new_end, "align up, but less");
2107
338528868274 6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents: 1676
diff changeset
   210
    // Check the other regions (excludes "ind") to ensure that
338528868274 6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents: 1676
diff changeset
   211
    // the new_end_aligned does not intrude onto the committed
338528868274 6786346: intermittent Internal Error (src/share/vm/memory/cardTableModRefBS.cpp:226)
jmasa
parents: 1676
diff changeset
   212
    // space of another region.
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   213
    int ri = 0;
28026
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   214
    for (ri = ind + 1; ri < _cur_covered_regions; ri++) {
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   215
      if (new_end_aligned > _committed[ri].start()) {
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   216
        assert(new_end_aligned <= _committed[ri].end(),
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   217
               "An earlier committed region can't cover a later committed region");
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   218
        // Any region containing the new end
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   219
        // should start at or beyond the region found (ind)
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   220
        // for the new end (committed regions are not expected to
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   221
        // be proper subsets of other committed regions).
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   222
        assert(_committed[ri].start() >= _committed[ind].start(),
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   223
               "New end of committed region is inconsistent");
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   224
        new_end_aligned = _committed[ri].start();
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   225
        // new_end_aligned can be equal to the start of its
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   226
        // committed region (i.e., of "ind") if a second
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   227
        // region following "ind" also start at the same location
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   228
        // as "ind".
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   229
        assert(new_end_aligned >= _committed[ind].start(),
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   230
          "New end of committed region is before start");
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   231
        debug_only(collided = true;)
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   232
        // Should only collide with 1 region
3694b71eef6c 8059066: CardTableModRefBS might commit the same page twice
ehelin
parents: 27904
diff changeset
   233
        break;
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   234
      }
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   235
    }
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   236
#ifdef ASSERT
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   237
    for (++ri; ri < _cur_covered_regions; ri++) {
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   238
      assert(!_committed[ri].contains(new_end_aligned),
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   239
        "New end of committed region is in a second committed region");
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   240
    }
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   241
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    // The guard page is always committed and should not be committed over.
3587
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   243
    // "guarded" is used for assertion checking below and recalls the fact
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   244
    // that the would-be end of the new committed region would have
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   245
    // penetrated the guard page.
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   246
    HeapWord* new_end_for_commit = new_end_aligned;
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   247
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   248
    DEBUG_ONLY(bool guarded = false;)
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   249
    if (new_end_for_commit > _guard_region.start()) {
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   250
      new_end_for_commit = _guard_region.start();
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   251
      DEBUG_ONLY(guarded = true;)
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   252
    }
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   253
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    if (new_end_for_commit > cur_committed.end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      // Must commit new pages.
179
59e3abf83f72 6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents: 1
diff changeset
   256
      MemRegion const new_committed =
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        MemRegion(cur_committed.end(), new_end_for_commit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
      assert(!new_committed.is_empty(), "Region should not be empty here");
18069
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17376
diff changeset
   260
      os::commit_memory_or_exit((char*)new_committed.start(),
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17376
diff changeset
   261
                                new_committed.byte_size(), _page_size,
e6d4971c8650 8013057: assert(_needs_gc || SafepointSynchronize::is_at_safepoint()) failed: only read at safepoint
dcubed
parents: 17376
diff changeset
   262
                                !ExecMem, "card table expansion");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    // Use new_end_aligned (as opposed to new_end_for_commit) because
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    // the cur_committed region may include the guard region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    } else if (new_end_aligned < cur_committed.end()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
      // Must uncommit pages.
179
59e3abf83f72 6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents: 1
diff changeset
   267
      MemRegion const uncommit_region =
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
        committed_unique_to_self(ind, MemRegion(new_end_aligned,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
                                                cur_committed.end()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      if (!uncommit_region.is_empty()) {
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   271
        // It is not safe to uncommit cards if the boundary between
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   272
        // the generations is moving.  A shrink can uncommit cards
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   273
        // owned by generation A but being used by generation B.
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   274
        if (!UseAdaptiveGCBoundary) {
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   275
          if (!os::uncommit_memory((char*)uncommit_region.start(),
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   276
                                   uncommit_region.byte_size())) {
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   277
            assert(false, "Card table contraction failed");
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   278
            // The call failed so don't change the end of the
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   279
            // committed region.  This is better than taking the
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   280
            // VM down.
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   281
            new_end_aligned = _committed[ind].end();
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   282
          }
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   283
        } else {
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   284
          new_end_aligned = _committed[ind].end();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    // In any case, we can reset the end of the current committed entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    _committed[ind].set_end(new_end_aligned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   291
#ifdef ASSERT
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   292
    // Check that the last card in the new region is committed according
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   293
    // to the tables.
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   294
    bool covered = false;
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   295
    for (int cr = 0; cr < _cur_covered_regions; cr++) {
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   296
      if (_committed[cr].contains(new_end - 1)) {
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   297
        covered = true;
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   298
        break;
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   299
      }
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   300
    }
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   301
    assert(covered, "Card for end of new region not committed");
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   302
#endif
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   303
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    // The default of 0 is not necessarily clean cards.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    jbyte* entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    if (old_region.last() < _whole_heap.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
      entry = byte_for(_whole_heap.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      entry = byte_after(old_region.last());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    }
1676
d80e69372634 6653214: MemoryPoolMXBean.setUsageThreshold() does not support large heap sizes.
swamyv
parents: 1388
diff changeset
   311
    assert(index_for(new_region.last()) <  _guard_index,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      "The guard card will be overwritten");
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   313
    // This line commented out cleans the newly expanded region and
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   314
    // not the aligned up expanded region.
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   315
    // jbyte* const end = byte_after(new_region.last());
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   316
    jbyte* const end = (jbyte*) new_end_for_commit;
3587
0140e816d000 6843292: "Expect to be beyond new region unless impacting another region" assertion too strong
jmasa
parents: 2154
diff changeset
   317
    assert((end >= byte_after(new_region.last())) || collided || guarded,
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   318
      "Expect to be beyond new region unless impacting another region");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    // do nothing if we resized downward.
754
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   320
#ifdef ASSERT
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   321
    for (int ri = 0; ri < _cur_covered_regions; ri++) {
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   322
      if (ri != ind) {
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   323
        // The end of the new committed region should not
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   324
        // be in any existing region unless it matches
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   325
        // the start of the next region.
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   326
        assert(!_committed[ri].contains(end) ||
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   327
               (_committed[ri].start() == (HeapWord*) end),
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   328
               "Overlapping committed regions");
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   329
      }
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   330
    }
fb9904179b42 6688799: Second fix for Guarantee failure "Unexpected dirty card found"
jmasa
parents: 360
diff changeset
   331
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    if (entry < end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      memset(entry, clean_card, pointer_delta(end, entry, sizeof(jbyte)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // In any case, the covered size changes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  _covered[ind].set_word_size(new_region.word_size());
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   338
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   339
  log_trace(gc, barrier)("CardTable::resize_covered_region: ");
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   340
  log_trace(gc, barrier)("    _covered[%d].start(): " INTPTR_FORMAT " _covered[%d].last(): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   341
                         ind, p2i(_covered[ind].start()), ind, p2i(_covered[ind].last()));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   342
  log_trace(gc, barrier)("    _committed[%d].start(): " INTPTR_FORMAT "  _committed[%d].last(): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   343
                         ind, p2i(_committed[ind].start()), ind, p2i(_committed[ind].last()));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   344
  log_trace(gc, barrier)("    byte_for(start): " INTPTR_FORMAT "  byte_for(last): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   345
                         p2i(byte_for(_covered[ind].start())),  p2i(byte_for(_covered[ind].last())));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   346
  log_trace(gc, barrier)("    addr_for(start): " INTPTR_FORMAT "  addr_for(last): " INTPTR_FORMAT,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   347
                         p2i(addr_for((jbyte*) _committed[ind].start())),  p2i(addr_for((jbyte*) _committed[ind].last())));
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31964
diff changeset
   348
5892
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   349
  // Touch the last card of the covered region to show that it
477b32b9d021 6952853: SIGSEGV with UseAdaptiveGCBoundary on 64b linux running jvm2008
jmasa
parents: 5547
diff changeset
   350
  // is committed (or SEGV).
18073
f02460441ddc 8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
ccheung
parents: 18069
diff changeset
   351
  debug_only((void) (*byte_for(_covered[ind].last()));)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  debug_only(verify_guard();)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
// Note that these versions are precise!  The scanning code has to handle the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
// fact that the write barrier may be either precise or imprecise.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   357
void CardTable::dirty_MemRegion(MemRegion mr) {
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   358
  assert(align_down(mr.start(), HeapWordSize) == mr.start(), "Unaligned start");
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   359
  assert(align_up  (mr.end(),   HeapWordSize) == mr.end(),   "Unaligned end"  );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  jbyte* cur  = byte_for(mr.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  jbyte* last = byte_after(mr.last());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  while (cur < last) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
    *cur = dirty_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    cur++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   368
void CardTable::clear_MemRegion(MemRegion mr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  // Be conservative: only clean cards entirely contained within the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  // region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  jbyte* cur;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  if (mr.start() == _whole_heap.start()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    cur = byte_for(mr.start());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    assert(mr.start() > _whole_heap.start(), "mr is not covered.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    cur = byte_after(mr.start() - 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  jbyte* last = byte_after(mr.last());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  memset(cur, clean_card, pointer_delta(last, cur, sizeof(jbyte)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   382
void CardTable::clear(MemRegion mr) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  for (int i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    MemRegion mri = mr.intersection(_covered[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    if (!mri.is_empty()) clear_MemRegion(mri);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   389
void CardTable::dirty(MemRegion mr) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   390
  jbyte* first = byte_for(mr.start());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   391
  jbyte* last  = byte_after(mr.last());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   392
  memset(first, dirty_card, last-first);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   393
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   394
9183
3d0e0687fe28 7036482: clear argument is redundant and unused in cardtable methods
ysr
parents: 7397
diff changeset
   395
// Unlike several other card table methods, dirty_card_iterate()
3d0e0687fe28 7036482: clear argument is redundant and unused in cardtable methods
ysr
parents: 7397
diff changeset
   396
// iterates over dirty cards ranges in increasing address order.
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   397
void CardTable::dirty_card_iterate(MemRegion mr, MemRegionClosure* cl) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  for (int i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    MemRegion mri = mr.intersection(_covered[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    if (!mri.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
      jbyte *cur_entry, *next_entry, *limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
      for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
           cur_entry <= limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
           cur_entry  = next_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
        next_entry = cur_entry + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
        if (*cur_entry == dirty_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
          size_t dirty_cards;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
          // Accumulate maximal dirty card range, starting at cur_entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
          for (dirty_cards = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
               next_entry <= limit && *next_entry == dirty_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
               dirty_cards++, next_entry++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
          MemRegion cur_cards(addr_for(cur_entry),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
                              dirty_cards*card_size_in_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
          cl->do_MemRegion(cur_cards);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   421
MemRegion CardTable::dirty_card_range_after_reset(MemRegion mr,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   422
                                                  bool reset,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   423
                                                  int reset_val) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  for (int i = 0; i < _cur_covered_regions; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    MemRegion mri = mr.intersection(_covered[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
    if (!mri.is_empty()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      jbyte* cur_entry, *next_entry, *limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      for (cur_entry = byte_for(mri.start()), limit = byte_for(mri.last());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
           cur_entry <= limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
           cur_entry  = next_entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
        next_entry = cur_entry + 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
        if (*cur_entry == dirty_card) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
          size_t dirty_cards;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
          // Accumulate maximal dirty card range, starting at cur_entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
          for (dirty_cards = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
               next_entry <= limit && *next_entry == dirty_card;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
               dirty_cards++, next_entry++);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
          MemRegion cur_cards(addr_for(cur_entry),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
                              dirty_cards*card_size_in_words);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   440
          if (reset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   441
            for (size_t i = 0; i < dirty_cards; i++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   442
              cur_entry[i] = reset_val;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 360
diff changeset
   443
            }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
          return cur_cards;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  return MemRegion(mr.end(), mr.end());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   453
uintx CardTable::ct_max_alignment_constraint() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  return card_size * os::vm_page_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   457
void CardTable::verify_guard() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  // For product build verification
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  guarantee(_byte_map[_guard_index] == last_card,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
            "card table guard has been modified");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   463
void CardTable::invalidate(MemRegion mr) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   464
  assert(align_down(mr.start(), HeapWordSize) == mr.start(), "Unaligned start");
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   465
  assert(align_up  (mr.end(),   HeapWordSize) == mr.end(),   "Unaligned end"  );
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   466
  for (int i = 0; i < _cur_covered_regions; i++) {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   467
    MemRegion mri = mr.intersection(_covered[i]);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   468
    if (!mri.is_empty()) dirty_MemRegion(mri);
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   469
  }
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   470
}
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   471
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   472
void CardTable::verify() {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  verify_guard();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
#ifndef PRODUCT
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   477
void CardTable::verify_region(MemRegion mr,
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   478
                                      jbyte val, bool val_equals) {
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   479
  jbyte* start    = byte_for(mr.start());
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   480
  jbyte* end      = byte_for(mr.last());
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 25492
diff changeset
   481
  bool failures = false;
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   482
  for (jbyte* curr = start; curr <= end; ++curr) {
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   483
    jbyte curr_val = *curr;
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   484
    bool failed = (val_equals) ? (curr_val != val) : (curr_val == val);
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   485
    if (failed) {
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   486
      if (!failures) {
37226
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   487
        log_error(gc, verify)("== CT verification failed: [" INTPTR_FORMAT "," INTPTR_FORMAT "]", p2i(start), p2i(end));
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   488
        log_error(gc, verify)("==   %sexpecting value: %d", (val_equals) ? "" : "not ", val);
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   489
        failures = true;
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   490
      }
37226
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   491
      log_error(gc, verify)("==   card " PTR_FORMAT " [" PTR_FORMAT "," PTR_FORMAT "], val: %d",
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   492
                            p2i(curr), p2i(addr_for(curr)),
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   493
                            p2i((HeapWord*) (((size_t) addr_for(curr)) + card_size)),
9b0d4b523ce4 8153188: Use log_error(gc, verify) for logging in verification code
brutisso
parents: 35061
diff changeset
   494
                            (int) curr_val);
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   495
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  }
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   497
  guarantee(!failures, "there should not have been any failures");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
}
3695
421cfcc8843c 6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents: 3587
diff changeset
   499
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   500
void CardTable::verify_not_dirty_region(MemRegion mr) {
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   501
  verify_region(mr, dirty_card, false /* val_equals */);
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   502
}
3695
421cfcc8843c 6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents: 3587
diff changeset
   503
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   504
void CardTable::verify_dirty_region(MemRegion mr) {
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 9336
diff changeset
   505
  verify_region(mr, dirty_card, true /* val_equals */);
3695
421cfcc8843c 6841313: G1: dirty cards of survivor regions in parallel
apetrusenko
parents: 3587
diff changeset
   506
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   509
void CardTable::print_on(outputStream* st) const {
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   510
  st->print_cr("Card table byte_map: [" INTPTR_FORMAT "," INTPTR_FORMAT "] _byte_map_base: " INTPTR_FORMAT,
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 49007
diff changeset
   511
               p2i(_byte_map), p2i(_byte_map + _byte_map_size), p2i(_byte_map_base));
12268
f7897aacb9ce 7157141: crash in 64 bit with corrupted oops
never
parents: 11177
diff changeset
   512
}