hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
author stefank
Fri, 04 Apr 2014 09:46:10 +0200
changeset 23858 dae377f5a7c7
parent 23855 c4574075402c
child 24098 48f07e2c74de
permissions -rw-r--r--
8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code Reviewed-by: brutisso, tschatzl
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
/*
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
     2
 * Copyright (c) 2001, 2013, 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: 5033
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
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: 5033
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: 7385
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    26
#include "gc_implementation/g1/concurrentG1Refine.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    27
#include "gc_implementation/g1/concurrentG1RefineThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    28
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    29
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    30
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
    31
#include "gc_implementation/g1/g1HotCardCache.hpp"
13288
331d5b6725f3 7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents: 11586
diff changeset
    32
#include "gc_implementation/g1/g1GCPhaseTimes.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    33
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    34
#include "gc_implementation/g1/g1RemSet.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    35
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
    36
#include "gc_implementation/g1/heapRegionRemSet.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    37
#include "memory/iterator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    38
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7385
diff changeset
    39
#include "utilities/intHisto.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
#define CARD_REPEAT_HISTO 0
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
#if CARD_REPEAT_HISTO
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
static size_t ct_freq_sz;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
static jbyte* ct_freq = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
void init_ct_freq_table(size_t heap_sz_bytes) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
  if (ct_freq == NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
    ct_freq_sz = heap_sz_bytes/CardTableModRefBS::card_size;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    50
    ct_freq = new jbyte[ct_freq_sz];
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
    for (size_t j = 0; j < ct_freq_sz; j++) ct_freq[j] = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
void ct_freq_note_card(size_t index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
  assert(0 <= index && index < ct_freq_sz, "Bounds error.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
  if (ct_freq[index] < 100) { ct_freq[index]++; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
static IntHistogram card_repeat_count(10, 10);
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
void ct_freq_update_histo_and_reset() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
  for (size_t j = 0; j < ct_freq_sz; j++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
    card_repeat_count.add_entry(ct_freq[j]);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
    ct_freq[j] = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
    71
G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs)
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
    72
  : _g1(g1), _conc_refine_cards(0),
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
    73
    _ct_bs(ct_bs), _g1p(_g1->g1_policy()),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
    _cg1r(g1->concurrent_g1_refine()),
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
    75
    _cset_rs_update_cl(NULL),
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
    76
    _cards_scanned(NULL), _total_cards_scanned(0),
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
    77
    _prev_period_summary()
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
  _seq_task = new SubTasksDone(NumSeqTasks);
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
    80
  guarantee(n_workers() > 0, "There should be some workers");
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11586
diff changeset
    81
  _cset_rs_update_cl = NEW_C_HEAP_ARRAY(OopsInHeapRegionClosure*, n_workers(), mtGC);
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
    82
  for (uint i = 0; i < n_workers(); i++) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
    83
    _cset_rs_update_cl[i] = NULL;
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
    84
  }
20310
903b398490d9 8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
tschatzl
parents: 20309
diff changeset
    85
  if (G1SummarizeRSetStats) {
903b398490d9 8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
tschatzl
parents: 20309
diff changeset
    86
    _prev_period_summary.initialize(this);
903b398490d9 8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
tschatzl
parents: 20309
diff changeset
    87
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
    90
G1RemSet::~G1RemSet() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
  delete _seq_task;
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
    92
  for (uint i = 0; i < n_workers(); i++) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
    93
    assert(_cset_rs_update_cl[i] == NULL, "it should be");
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
    94
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11586
diff changeset
    95
  FREE_C_HEAP_ARRAY(OopsInHeapRegionClosure*, _cset_rs_update_cl, mtGC);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
}
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
void CountNonCleanMemRegionClosure::do_MemRegion(MemRegion mr) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
  if (_g1->is_in_g1_reserved(mr.start())) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
    _n += (int) ((mr.byte_size() / CardTableModRefBS::card_size));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
    if (_start_first == NULL) _start_first = mr.start();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
class ScanRSClosure : public HeapRegionClosure {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
  size_t _cards_done, _cards;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
  G1CollectedHeap* _g1h;
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   108
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
  OopsInHeapRegionClosure* _oc;
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   110
  CodeBlobToOopClosure* _code_root_cl;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   111
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   112
  G1BlockOffsetSharedArray* _bot_shared;
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 20305
diff changeset
   113
  G1SATBCardTableModRefBS *_ct_bs;
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   114
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   115
  double _strong_code_root_scan_time_sec;
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   116
  uint   _worker_i;
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   117
  int    _block_size;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   118
  bool   _try_claimed;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   119
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
public:
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   121
  ScanRSClosure(OopsInHeapRegionClosure* oc,
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   122
                CodeBlobToOopClosure* code_root_cl,
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   123
                uint worker_i) :
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   124
    _oc(oc),
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   125
    _code_root_cl(code_root_cl),
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   126
    _strong_code_root_scan_time_sec(0.0),
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
    _cards(0),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
    _cards_done(0),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
    _worker_i(worker_i),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
    _try_claimed(false)
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
    _g1h = G1CollectedHeap::heap();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
    _bot_shared = _g1h->bot_shared();
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 20305
diff changeset
   134
    _ct_bs = _g1h->g1_barrier_set();
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   135
    _block_size = MAX2<int>(G1RSetScanBlockSize, 1);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
  void set_try_claimed() { _try_claimed = true; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  void scanCard(size_t index, HeapRegion *r) {
10770
de4ae3b50648 7096030: G1: PrintGCDetails enhancements
johnc
parents: 10674
diff changeset
   141
    // Stack allocate the DirtyCardToOopClosure instance
de4ae3b50648 7096030: G1: PrintGCDetails enhancements
johnc
parents: 10674
diff changeset
   142
    HeapRegionDCTOC cl(_g1h, r, _oc,
de4ae3b50648 7096030: G1: PrintGCDetails enhancements
johnc
parents: 10674
diff changeset
   143
                       CardTableModRefBS::Precise,
de4ae3b50648 7096030: G1: PrintGCDetails enhancements
johnc
parents: 10674
diff changeset
   144
                       HeapRegionDCTOC::IntoCSFilterKind);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
    // Set the "from" region in the closure.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
    _oc->set_region(r);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
    HeapWord* card_start = _bot_shared->address_for_index(index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
    HeapWord* card_end = card_start + G1BlockOffsetSharedArray::N_words;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
    Space *sp = SharedHeap::heap()->space_containing(card_start);
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   151
    MemRegion sm_region = sp->used_region_at_save_marks();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
    MemRegion mr = sm_region.intersection(MemRegion(card_start,card_end));
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   153
    if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   154
      // We make the card as "claimed" lazily (so races are possible
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   155
      // but they're benign), which reduces the number of duplicate
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   156
      // scans (the rsets of the regions in the cset can intersect).
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   157
      _ct_bs->set_card_claimed(index);
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   158
      _cards_done++;
10770
de4ae3b50648 7096030: G1: PrintGCDetails enhancements
johnc
parents: 10674
diff changeset
   159
      cl.do_MemRegion(mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
  void printCard(HeapRegion* card_region, size_t card_index,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
                 HeapWord* card_start) {
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 23855
diff changeset
   165
    gclog_or_tty->print_cr("T %u Region [" PTR_FORMAT ", " PTR_FORMAT ") "
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
                           "RS names card %p: "
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
                           "[" PTR_FORMAT ", " PTR_FORMAT ")",
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
                           _worker_i,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
                           card_region->bottom(), card_region->end(),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
                           card_index,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
                           card_start, card_start + G1BlockOffsetSharedArray::N_words);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   174
  void scan_strong_code_roots(HeapRegion* r) {
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   175
    double scan_start = os::elapsedTime();
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   176
    r->strong_code_roots_do(_code_root_cl);
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   177
    _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   178
  }
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   179
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
  bool doHeapRegion(HeapRegion* r) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
    assert(r->in_collection_set(), "should only be called on elements of CS.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
    HeapRegionRemSet* hrrs = r->rem_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
    if (hrrs->iter_is_complete()) return false; // All done.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   184
    if (!_try_claimed && !hrrs->claim_iter()) return false;
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   185
    // If we ever free the collection set concurrently, we should also
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   186
    // clear the card table concurrently therefore we won't need to
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   187
    // add regions of the collection set to the dirty cards region.
2883
406d1e6d1aa1 6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents: 2881
diff changeset
   188
    _g1h->push_dirty_cards_region(r);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   189
    // If we didn't return above, then
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   190
    //   _try_claimed || r->claim_iter()
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   191
    // is true: either we're supposed to work on claimed-but-not-complete
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   192
    // regions, or we successfully claimed the region.
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   193
17108
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13728
diff changeset
   194
    HeapRegionRemSetIterator iter(hrrs);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   195
    size_t card_index;
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   196
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 21560
diff changeset
   197
    // We claim cards in block so as to reduce the contention. The block size is determined by
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   198
    // the G1RSetScanBlockSize parameter.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   199
    size_t jump_to_card = hrrs->iter_claimed_next(_block_size);
17108
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13728
diff changeset
   200
    for (size_t current_card = 0; iter.has_next(card_index); current_card++) {
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   201
      if (current_card >= jump_to_card + _block_size) {
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   202
        jump_to_card = hrrs->iter_claimed_next(_block_size);
2737
0c3db8869263 6819098: G1: reduce RSet scanning times
iveresov
parents: 2344
diff changeset
   203
      }
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 3590
diff changeset
   204
      if (current_card < jump_to_card) continue;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   205
      HeapWord* card_start = _g1h->bot_shared()->address_for_index(card_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   206
#if 0
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   207
      gclog_or_tty->print("Rem set iteration yielded card [" PTR_FORMAT ", " PTR_FORMAT ").\n",
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   208
                          card_start, card_start + CardTableModRefBS::card_size_in_words);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   211
      HeapRegion* card_region = _g1h->heap_region_containing(card_start);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
      assert(card_region != NULL, "Yielding cards not in the heap?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
      _cards++;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
2883
406d1e6d1aa1 6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents: 2881
diff changeset
   215
      if (!card_region->is_on_dirty_cards_region_list()) {
406d1e6d1aa1 6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents: 2881
diff changeset
   216
        _g1h->push_dirty_cards_region(card_region);
406d1e6d1aa1 6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents: 2881
diff changeset
   217
      }
406d1e6d1aa1 6819065: G1: eliminate high serial card table clearing time
apetrusenko
parents: 2881
diff changeset
   218
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   219
      // If the card is dirty, then we will scan it during updateRS.
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   220
      if (!card_region->in_collection_set() &&
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   221
          !_ct_bs->is_card_dirty(card_index)) {
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   222
        scanCard(card_index, card_region);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
    }
2737
0c3db8869263 6819098: G1: reduce RSet scanning times
iveresov
parents: 2344
diff changeset
   225
    if (!_try_claimed) {
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   226
      // Scan the strong code root list attached to the current region
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   227
      scan_strong_code_roots(r);
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   228
2737
0c3db8869263 6819098: G1: reduce RSet scanning times
iveresov
parents: 2344
diff changeset
   229
      hrrs->set_iter_complete();
0c3db8869263 6819098: G1: reduce RSet scanning times
iveresov
parents: 2344
diff changeset
   230
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
    return false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
  }
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   233
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   234
  double strong_code_root_scan_time_sec() {
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   235
    return _strong_code_root_scan_time_sec;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   236
  }
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   237
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
  size_t cards_done() { return _cards_done;}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
  size_t cards_looked_up() { return _cards;}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   242
void G1RemSet::scanRS(OopsInHeapRegionClosure* oc,
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   243
                      CodeBlobToOopClosure* code_root_cl,
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   244
                      uint worker_i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
  double rs_time_start = os::elapsedTime();
11176
9bb1ddd8da51 7112743: G1: Reduce overhead of marking closure during evacuation pauses
johnc
parents: 11174
diff changeset
   246
  HeapRegion *startRegion = _g1->start_cset_region_for_worker(worker_i);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   247
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   248
  ScanRSClosure scanRScl(oc, code_root_cl, worker_i);
10670
4ea0e7d2ffbc 6484982: G1: process references during evacuation pauses
johnc
parents: 10000
diff changeset
   249
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
  _g1->collection_set_iterate_from(startRegion, &scanRScl);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   251
  scanRScl.set_try_claimed();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   252
  _g1->collection_set_iterate_from(startRegion, &scanRScl);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   254
  double scan_rs_time_sec = (os::elapsedTime() - rs_time_start)
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   255
                            - scanRScl.strong_code_root_scan_time_sec();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   256
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   257
  assert(_cards_scanned != NULL, "invariant");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   258
  _cards_scanned[worker_i] = scanRScl.cards_done();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   259
13288
331d5b6725f3 7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents: 11586
diff changeset
   260
  _g1p->phase_times()->record_scan_rs_time(worker_i, scan_rs_time_sec * 1000.0);
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   261
  _g1p->phase_times()->record_strong_code_root_scan_time(worker_i,
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   262
                                                         scanRScl.strong_code_root_scan_time_sec() * 1000.0);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   263
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   264
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   265
// Closure used for updating RSets and recording references that
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   266
// point into the collection set. Only called during an
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   267
// evacuation pause.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   268
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   269
class RefineRecordRefsIntoCSCardTableEntryClosure: public CardTableEntryClosure {
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   270
  G1RemSet* _g1rs;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   271
  DirtyCardQueue* _into_cset_dcq;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   272
public:
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   273
  RefineRecordRefsIntoCSCardTableEntryClosure(G1CollectedHeap* g1h,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   274
                                              DirtyCardQueue* into_cset_dcq) :
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   275
    _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq)
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   276
  {}
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   277
  bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   278
    // The only time we care about recording cards that
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   279
    // contain references that point into the collection set
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   280
    // is during RSet updating within an evacuation pause.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   281
    // In this case worker_i should be the id of a GC worker thread.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   282
    assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   283
    assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "should be a GC worker");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   285
    if (_g1rs->refine_card(card_ptr, worker_i, true)) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   286
      // 'card_ptr' contains references that point into the collection
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   287
      // set. We need to record the card in the DCQS
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   288
      // (G1CollectedHeap::into_cset_dirty_card_queue_set())
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   289
      // that's used for that purpose.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   290
      //
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   291
      // Enqueue the card
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   292
      _into_cset_dcq->enqueue(card_ptr);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   293
    }
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   294
    return true;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   295
  }
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   296
};
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   297
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   298
void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   299
  double start = os::elapsedTime();
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   300
  // Apply the given closure to all remaining log entries.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   301
  RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
10670
4ea0e7d2ffbc 6484982: G1: process references during evacuation pauses
johnc
parents: 10000
diff changeset
   302
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   303
  _g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   304
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   305
  // Now there should be no dirty cards.
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   306
  if (G1RSLogCheckCardTable) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   307
    CountNonCleanMemRegionClosure cl(_g1);
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   308
    _ct_bs->mod_card_iterate(&cl);
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   309
    // XXX This isn't true any more: keeping cards of young regions
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   310
    // marked dirty broke it.  Need some reasonable fix.
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   311
    guarantee(cl.n() == 0, "Card table should be clean.");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   312
  }
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   313
13288
331d5b6725f3 7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents: 11586
diff changeset
   314
  _g1p->phase_times()->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   315
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   316
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   317
void G1RemSet::cleanupHRRS() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   318
  HeapRegionRemSet::cleanup();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   319
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   320
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   321
void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc,
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   322
                                           CodeBlobToOopClosure* code_root_cl,
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   323
                                           uint worker_i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   324
#if CARD_REPEAT_HISTO
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   325
  ct_freq_update_histo_and_reset();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   326
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   327
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   328
  // We cache the value of 'oc' closure into the appropriate slot in the
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   329
  // _cset_rs_update_cl for this worker
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   330
  assert(worker_i < n_workers(), "sanity");
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   331
  _cset_rs_update_cl[worker_i] = oc;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   332
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   333
  // A DirtyCardQueue that is used to hold cards containing references
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   334
  // that point into the collection set. This DCQ is associated with a
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   335
  // special DirtyCardQueueSet (see g1CollectedHeap.hpp).  Under normal
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   336
  // circumstances (i.e. the pause successfully completes), these cards
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   337
  // are just discarded (there's no need to update the RSets of regions
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   338
  // that were in the collection set - after the pause these regions
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   339
  // are wholly 'free' of live objects. In the event of an evacuation
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   340
  // failure the cards/buffers in this queue set are:
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   341
  // * passed to the DirtyCardQueueSet that is used to manage deferred
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   342
  //   RSet updates, or
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   343
  // * scanned for references that point into the collection set
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   344
  //   and the RSet of the corresponding region in the collection set
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   345
  //   is updated immediately.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   346
  DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set());
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   347
6250
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   348
  assert((ParallelGCThreads > 0) || worker_i == 0, "invariant");
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   349
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   350
  // The two flags below were introduced temporarily to serialize
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   351
  // the updating and scanning of remembered sets. There are some
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   352
  // race conditions when these two operations are done in parallel
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   353
  // and they are causing failures. When we resolve said race
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   354
  // conditions, we'll revert back to parallel remembered set
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   355
  // updating and scanning. See CRs 6677707 and 6677708.
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   356
  if (G1UseParallelRSetUpdating || (worker_i == 0)) {
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   357
    updateRS(&into_cset_dcq, worker_i);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   358
  } else {
13516
f7adc27fb367 7178363: G1: Remove the serial code for PrintGCDetails and make it a special case of the parallel code
brutisso
parents: 13336
diff changeset
   359
    _g1p->phase_times()->record_update_rs_processed_buffers(worker_i, 0);
13288
331d5b6725f3 7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents: 11586
diff changeset
   360
    _g1p->phase_times()->record_update_rs_time(worker_i, 0.0);
6250
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   361
  }
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   362
  if (G1UseParallelRSetScanning || (worker_i == 0)) {
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 17855
diff changeset
   363
    scanRS(oc, code_root_cl, worker_i);
6250
5680f968c721 6930581: G1: assert(ParallelGCThreads > 1 || n_yielded() == _hrrs->occupied(),"Should have yielded all the ..
johnc
parents: 6247
diff changeset
   364
  } else {
13288
331d5b6725f3 7178361: G1: Make sure that PrintGC and PrintGCDetails use the same timing for the GC pause
brutisso
parents: 11586
diff changeset
   365
    _g1p->phase_times()->record_scan_rs_time(worker_i, 0.0);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   366
  }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   367
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   368
  // We now clear the cached values of _cset_rs_update_cl for this worker
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   369
  _cset_rs_update_cl[worker_i] = NULL;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   370
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   371
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   372
void G1RemSet::prepare_for_oops_into_collection_set_do() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   373
  cleanupHRRS();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   374
  ConcurrentG1Refine* cg1r = _g1->concurrent_g1_refine();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   375
  _g1->set_refine_cte_cl_concurrency(false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   376
  DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   377
  dcqs.concatenate_logs();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   378
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   379
  guarantee( _cards_scanned == NULL, "invariant" );
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11586
diff changeset
   380
  _cards_scanned = NEW_C_HEAP_ARRAY(size_t, n_workers(), mtGC);
2009
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   381
  for (uint i = 0; i < n_workers(); ++i) {
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   382
    _cards_scanned[i] = 0;
4adf43957a1b 6484959: G1: introduce survivor spaces
apetrusenko
parents: 1374
diff changeset
   383
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   384
  _total_cards_scanned = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   385
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   386
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   387
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   388
// This closure, applied to a DirtyCardQueueSet, is used to immediately
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   389
// update the RSets for the regions in the CSet. For each card it iterates
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   390
// through the oops which coincide with that card. It scans the reference
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   391
// fields in each oop; when it finds an oop that points into the collection
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   392
// set, the RSet for the region containing the referenced object is updated.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   393
class UpdateRSetCardTableEntryIntoCSetClosure: public CardTableEntryClosure {
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   394
  G1CollectedHeap* _g1;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   395
  CardTableModRefBS* _ct_bs;
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   396
public:
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   397
  UpdateRSetCardTableEntryIntoCSetClosure(G1CollectedHeap* g1,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   398
                                          CardTableModRefBS* bs):
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   399
    _g1(g1), _ct_bs(bs)
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   400
  { }
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   401
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   402
  bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   403
    // Construct the region representing the card.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   404
    HeapWord* start = _ct_bs->addr_for(card_ptr);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   405
    // And find the region containing it.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   406
    HeapRegion* r = _g1->heap_region_containing(start);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   407
    assert(r != NULL, "unexpected null");
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   408
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   409
    // Scan oops in the card looking for references into the collection set
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   410
    // Don't use addr_for(card_ptr + 1) which can ask for
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   411
    // a card beyond the heap.  This is not safe without a perm
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   412
    // gen.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   413
    HeapWord* end   = start + CardTableModRefBS::card_size_in_words;
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   414
    MemRegion scanRegion(start, end);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   415
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   416
    UpdateRSetImmediate update_rs_cl(_g1->g1_rem_set());
10674
09e6f8d20337 7097053: G1: assert(da ? referent->is_oop() : referent->is_oop_or_null()) failed: referenceProcessor.cpp:1054
johnc
parents: 10670
diff changeset
   417
    FilterIntoCSClosure update_rs_cset_oop_cl(NULL, _g1, &update_rs_cl);
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   418
    FilterOutOfRegionClosure filter_then_update_rs_cset_oop_cl(r, &update_rs_cset_oop_cl);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   419
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   420
    // We can pass false as the "filter_young" parameter here as:
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   421
    // * we should be in a STW pause,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   422
    // * the DCQS to which this closure is applied is used to hold
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   423
    //   references that point into the collection set from the prior
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   424
    //   RSet updating,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   425
    // * the post-write barrier shouldn't be logging updates to young
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   426
    //   regions (but there is a situation where this can happen - see
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   427
    //   the comment in G1RemSet::refine_card() below -
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   428
    //   that should not be applicable here), and
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   429
    // * during actual RSet updating, the filtering of cards in young
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   430
    //   regions in HeapRegion::oops_on_card_seq_iterate_careful is
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   431
    //   employed.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   432
    // As a result, when this closure is applied to "refs into cset"
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   433
    // DCQS, we shouldn't see any cards in young regions.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   434
    update_rs_cl.set_region(r);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   435
    HeapWord* stop_point =
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   436
      r->oops_on_card_seq_iterate_careful(scanRegion,
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   437
                                          &filter_then_update_rs_cset_oop_cl,
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   438
                                          false /* filter_young */,
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   439
                                          NULL  /* card_ptr */);
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   440
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   441
    // Since this is performed in the event of an evacuation failure, we
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   442
    // we shouldn't see a non-null stop point
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   443
    assert(stop_point == NULL, "saw an unallocated region");
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   444
    return true;
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   445
  }
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   446
};
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   447
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   448
void G1RemSet::cleanup_after_oops_into_collection_set_do() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   449
  guarantee( _cards_scanned != NULL, "invariant" );
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   450
  _total_cards_scanned = 0;
10000
5bbb58b0dbb9 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 9988
diff changeset
   451
  for (uint i = 0; i < n_workers(); ++i) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   452
    _total_cards_scanned += _cards_scanned[i];
10000
5bbb58b0dbb9 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 9988
diff changeset
   453
  }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11586
diff changeset
   454
  FREE_C_HEAP_ARRAY(size_t, _cards_scanned, mtGC);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   455
  _cards_scanned = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   456
  // Cleanup after copy
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   457
  _g1->set_refine_cte_cl_concurrency(true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   458
  // Set all cards back to clean.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   459
  _g1->cleanUpCardTable();
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   460
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   461
  DirtyCardQueueSet& into_cset_dcqs = _g1->into_cset_dirty_card_queue_set();
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   462
  int into_cset_n_buffers = into_cset_dcqs.completed_buffers_num();
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   463
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   464
  if (_g1->evacuation_failed()) {
23455
e541bff96524 8035654: Add times for evacuation failure handling in "Other" time
tschatzl
parents: 22772
diff changeset
   465
    double restore_remembered_set_start = os::elapsedTime();
e541bff96524 8035654: Add times for evacuation failure handling in "Other" time
tschatzl
parents: 22772
diff changeset
   466
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   467
    // Restore remembered sets for the regions pointing into the collection set.
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   468
    if (G1DeferredRSUpdate) {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   469
      // If deferred RS updates are enabled then we just need to transfer
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   470
      // the completed buffers from (a) the DirtyCardQueueSet used to hold
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   471
      // cards that contain references that point into the collection set
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   472
      // to (b) the DCQS used to hold the deferred RS updates
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   473
      _g1->dirty_card_queue_set().merge_bufferlists(&into_cset_dcqs);
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   474
    } else {
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   475
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   476
      CardTableModRefBS* bs = (CardTableModRefBS*)_g1->barrier_set();
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   477
      UpdateRSetCardTableEntryIntoCSetClosure update_rs_cset_immediate(_g1, bs);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   478
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   479
      int n_completed_buffers = 0;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   480
      while (into_cset_dcqs.apply_closure_to_completed_buffer(&update_rs_cset_immediate,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   481
                                                    0, 0, true)) {
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   482
        n_completed_buffers++;
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   483
      }
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   484
      assert(n_completed_buffers == into_cset_n_buffers, "missed some buffers");
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   485
    }
23455
e541bff96524 8035654: Add times for evacuation failure handling in "Other" time
tschatzl
parents: 22772
diff changeset
   486
e541bff96524 8035654: Add times for evacuation failure handling in "Other" time
tschatzl
parents: 22772
diff changeset
   487
    _g1->g1_policy()->phase_times()->record_evac_fail_restore_remsets((os::elapsedTime() - restore_remembered_set_start) * 1000.0);
2142
032f4652700c 6720309: G1: don't synchronously update RSet during evacuation pauses
iveresov
parents: 2009
diff changeset
   488
  }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   489
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   490
  // Free any completed buffers in the DirtyCardQueueSet used to hold cards
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   491
  // which contain references that point into the collection.
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   492
  _g1->into_cset_dirty_card_queue_set().clear();
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   493
  assert(_g1->into_cset_dirty_card_queue_set().completed_buffers_num() == 0,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   494
         "all buffers should be freed");
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   495
  _g1->into_cset_dirty_card_queue_set().clear_n_completed_buffers();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   496
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   497
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   498
class ScrubRSClosure: public HeapRegionClosure {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   499
  G1CollectedHeap* _g1h;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   500
  BitMap* _region_bm;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   501
  BitMap* _card_bm;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   502
  CardTableModRefBS* _ctbs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   503
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   504
  ScrubRSClosure(BitMap* region_bm, BitMap* card_bm) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   505
    _g1h(G1CollectedHeap::heap()),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   506
    _region_bm(region_bm), _card_bm(card_bm),
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 20305
diff changeset
   507
    _ctbs(_g1h->g1_barrier_set()) {}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   508
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   509
  bool doHeapRegion(HeapRegion* r) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   510
    if (!r->continuesHumongous()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   511
      r->rem_set()->scrub(_ctbs, _region_bm, _card_bm);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   512
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   513
    return false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   514
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   515
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   516
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   517
void G1RemSet::scrub(BitMap* region_bm, BitMap* card_bm) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   518
  ScrubRSClosure scrub_cl(region_bm, card_bm);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   519
  _g1->heap_region_iterate(&scrub_cl);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   520
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   521
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   522
void G1RemSet::scrub_par(BitMap* region_bm, BitMap* card_bm,
11396
917d8673b5ef 7121618: Change type of number of GC workers to unsigned int.
jmasa
parents: 11176
diff changeset
   523
                                uint worker_num, int claim_val) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   524
  ScrubRSClosure scrub_cl(region_bm, card_bm);
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 11169
diff changeset
   525
  _g1->heap_region_par_iterate_chunked(&scrub_cl,
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 11169
diff changeset
   526
                                       worker_num,
11396
917d8673b5ef 7121618: Change type of number of GC workers to unsigned int.
jmasa
parents: 11176
diff changeset
   527
                                       n_workers(),
11174
fccee5238e70 6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
jmasa
parents: 11169
diff changeset
   528
                                       claim_val);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   529
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   530
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   531
G1TriggerClosure::G1TriggerClosure() :
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   532
  _triggered(false) { }
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   533
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   534
G1InvokeIfNotTriggeredClosure::G1InvokeIfNotTriggeredClosure(G1TriggerClosure* t_cl,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   535
                                                             OopClosure* oop_cl)  :
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   536
  _trigger_cl(t_cl), _oop_cl(oop_cl) { }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   537
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   538
G1Mux2Closure::G1Mux2Closure(OopClosure *c1, OopClosure *c2) :
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   539
  _c1(c1), _c2(c2) { }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   540
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   541
G1UpdateRSOrPushRefOopClosure::
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   542
G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   543
                              G1RemSet* rs,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   544
                              OopsInHeapRegionClosure* push_ref_cl,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   545
                              bool record_refs_into_cset,
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   546
                              uint worker_i) :
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   547
  _g1(g1h), _g1_rem_set(rs), _from(NULL),
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   548
  _record_refs_into_cset(record_refs_into_cset),
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   549
  _push_ref_cl(push_ref_cl), _worker_i(worker_i) { }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   550
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   551
// Returns true if the given card contains references that point
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   552
// into the collection set, if we're checking for such references;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   553
// false otherwise.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   554
23855
c4574075402c 8016302: Change type of the number of GC workers to unsigned int (2)
vkempik
parents: 23455
diff changeset
   555
bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i,
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   556
                           bool check_for_refs_into_cset) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   557
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   558
  // If the card is no longer dirty, nothing to do.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   559
  if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   560
    // No need to return that this card contains refs that point
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   561
    // into the collection set.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   562
    return false;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   563
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   564
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   565
  // Construct the region representing the card.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   566
  HeapWord* start = _ct_bs->addr_for(card_ptr);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   567
  // And find the region containing it.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   568
  HeapRegion* r = _g1->heap_region_containing(start);
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   569
  if (r == NULL) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   570
    // Again no need to return that this card contains refs that
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   571
    // point into the collection set.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   572
    return false;  // Not in the G1 heap (might be in perm, for example.)
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   573
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   574
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   575
  // Why do we have to check here whether a card is on a young region,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   576
  // given that we dirty young regions and, as a result, the
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   577
  // post-barrier is supposed to filter them out and never to enqueue
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   578
  // them? When we allocate a new region as the "allocation region" we
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   579
  // actually dirty its cards after we release the lock, since card
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   580
  // dirtying while holding the lock was a performance bottleneck. So,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   581
  // as a result, it is possible for other threads to actually
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   582
  // allocate objects in the region (after the acquire the lock)
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   583
  // before all the cards on the region are dirtied. This is unlikely,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   584
  // and it doesn't happen often, but it can happen. So, the extra
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   585
  // check below filters out those cards.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   586
  if (r->is_young()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   587
    return false;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   588
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   589
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   590
  // While we are processing RSet buffers during the collection, we
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   591
  // actually don't want to scan any cards on the collection set,
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 21560
diff changeset
   592
  // since we don't want to update remembered sets with entries that
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   593
  // point into the collection set, given that live objects from the
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   594
  // collection set are about to move and such entries will be stale
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   595
  // very soon. This change also deals with a reliability issue which
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   596
  // involves scanning a card in the collection set and coming across
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   597
  // an array that was being chunked and looking malformed. Note,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   598
  // however, that if evacuation fails, we have to scan any objects
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   599
  // that were not moved and create any missing entries.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   600
  if (r->in_collection_set()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   601
    return false;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   602
  }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   603
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   604
  // The result from the hot card cache insert call is either:
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   605
  //   * pointer to the current card
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   606
  //     (implying that the current card is not 'hot'),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   607
  //   * null
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   608
  //     (meaning we had inserted the card ptr into the "hot" card cache,
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   609
  //     which had some headroom),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   610
  //   * a pointer to a "hot" card that was evicted from the "hot" cache.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   611
  //
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   612
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   613
  G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   614
  if (hot_card_cache->use_cache()) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   615
    assert(!check_for_refs_into_cset, "sanity");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   616
    assert(!SafepointSynchronize::is_at_safepoint(), "sanity");
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   617
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   618
    card_ptr = hot_card_cache->insert(card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   619
    if (card_ptr == NULL) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   620
      // There was no eviction. Nothing to do.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   621
      return false;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   622
    }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   623
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   624
    start = _ct_bs->addr_for(card_ptr);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   625
    r = _g1->heap_region_containing(start);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   626
    if (r == NULL) {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   627
      // Not in the G1 heap
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   628
      return false;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   629
    }
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   630
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   631
    // Checking whether the region we got back from the cache
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   632
    // is young here is inappropriate. The region could have been
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   633
    // freed, reallocated and tagged as young while in the cache.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   634
    // Hence we could see its young type change at any time.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   635
  }
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   636
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   637
  // Don't use addr_for(card_ptr + 1) which can ask for
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   638
  // a card beyond the heap.  This is not safe without a perm
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   639
  // gen at the upper end of the heap.
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13516
diff changeset
   640
  HeapWord* end   = start + CardTableModRefBS::card_size_in_words;
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   641
  MemRegion dirtyRegion(start, end);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   642
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   643
#if CARD_REPEAT_HISTO
8103
65eafe3fb3c7 6923430: G1: assert(res != 0,"This should have worked.")
johnc
parents: 7397
diff changeset
   644
  init_ct_freq_table(_g1->max_capacity());
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   645
  ct_freq_note_card(_ct_bs->index_for(start));
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   646
#endif
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   647
10995
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   648
  OopsInHeapRegionClosure* oops_in_heap_closure = NULL;
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   649
  if (check_for_refs_into_cset) {
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   650
    // ConcurrentG1RefineThreads have worker numbers larger than what
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   651
    // _cset_rs_update_cl[] is set up to handle. But those threads should
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   652
    // only be active outside of a collection which means that when they
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   653
    // reach here they should have check_for_refs_into_cset == false.
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   654
    assert((size_t)worker_i < n_workers(), "index of worker larger than _cset_rs_update_cl[].length");
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   655
    oops_in_heap_closure = _cset_rs_update_cl[worker_i];
b3b2d17ff45d 7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
brutisso
parents: 10770
diff changeset
   656
  }
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   657
  G1UpdateRSOrPushRefOopClosure update_rs_oop_cl(_g1,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   658
                                                 _g1->g1_rem_set(),
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   659
                                                 oops_in_heap_closure,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   660
                                                 check_for_refs_into_cset,
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   661
                                                 worker_i);
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   662
  update_rs_oop_cl.set_from(r);
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   663
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   664
  G1TriggerClosure trigger_cl;
10674
09e6f8d20337 7097053: G1: assert(da ? referent->is_oop() : referent->is_oop_or_null()) failed: referenceProcessor.cpp:1054
johnc
parents: 10670
diff changeset
   665
  FilterIntoCSClosure into_cs_cl(NULL, _g1, &trigger_cl);
11586
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   666
  G1InvokeIfNotTriggeredClosure invoke_cl(&trigger_cl, &into_cs_cl);
ccc217c177ee 7133038: G1: Some small profile based optimizations
johnc
parents: 11396
diff changeset
   667
  G1Mux2Closure mux(&invoke_cl, &update_rs_oop_cl);
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   668
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   669
  FilterOutOfRegionClosure filter_then_update_rs_oop_cl(r,
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   670
                        (check_for_refs_into_cset ?
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   671
                                (OopClosure*)&mux :
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   672
                                (OopClosure*)&update_rs_oop_cl));
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   673
6068
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   674
  // The region for the current card may be a young region. The
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   675
  // current card may have been a card that was evicted from the
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   676
  // card cache. When the card was inserted into the cache, we had
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   677
  // determined that its region was non-young. While in the cache,
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   678
  // the region may have been freed during a cleanup pause, reallocated
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   679
  // and tagged as young.
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   680
  //
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   681
  // We wish to filter out cards for such a region but the current
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   682
  // thread, if we're running concurrently, may "see" the young type
6068
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   683
  // change at any time (so an earlier "is_young" check may pass or
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   684
  // fail arbitrarily). We tell the iteration code to perform this
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   685
  // filtering when it has been determined that there has been an actual
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   686
  // allocation in this region and making it safe to check the young type.
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   687
  bool filter_young = true;
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   688
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   689
  HeapWord* stop_point =
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   690
    r->oops_on_card_seq_iterate_careful(dirtyRegion,
6068
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   691
                                        &filter_then_update_rs_oop_cl,
9418
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   692
                                        filter_young,
32a87dd6b746 7035144: G1: nightly failure: Non-dirty cards in region that should be dirty (failures still exist...)
tonyp
parents: 8683
diff changeset
   693
                                        card_ptr);
6068
80ef41e75a2d 6956639: G1: assert(cached_ptr != card_ptr) failed: shouldn't be, concurrentG1Refine.cpp:307
johnc
parents: 5891
diff changeset
   694
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   695
  // If stop_point is non-null, then we encountered an unallocated region
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   696
  // (perhaps the unfilled portion of a TLAB.)  For now, we'll dirty the
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   697
  // card and re-enqueue: if we put off the card until a GC pause, then the
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   698
  // unallocated portion will be filled in.  Alternatively, we might try
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   699
  // the full complexity of the technique used in "regular" precleaning.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   700
  if (stop_point != NULL) {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   701
    // The card might have gotten re-dirtied and re-enqueued while we
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   702
    // worked.  (In fact, it's pretty likely.)
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   703
    if (*card_ptr != CardTableModRefBS::dirty_card_val()) {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   704
      *card_ptr = CardTableModRefBS::dirty_card_val();
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   705
      MutexLockerEx x(Shared_DirtyCardQ_lock,
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   706
                      Mutex::_no_safepoint_check_flag);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   707
      DirtyCardQueue* sdcq =
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   708
        JavaThread::dirty_card_queue_set().shared_dirty_card_queue();
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   709
      sdcq->enqueue(card_ptr);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   710
    }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   711
  } else {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   712
    _conc_refine_cards++;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3262
diff changeset
   713
  }
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   714
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   715
  // This gets set to true if the card being refined has
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   716
  // references that point into the collection set.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   717
  bool has_refs_into_cset = trigger_cl.triggered();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   718
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   719
  // We should only be detecting that the card contains references
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   720
  // that point into the collection set if the current thread is
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   721
  // a GC worker thread.
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   722
  assert(!has_refs_into_cset || SafepointSynchronize::is_at_safepoint(),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   723
           "invalid result at non safepoint");
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   724
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   725
  return has_refs_into_cset;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   726
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   727
20305
af013cf4a5e6 8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents: 19339
diff changeset
   728
void G1RemSet::print_periodic_summary_info(const char* header) {
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   729
  G1RemSetSummary current;
20310
903b398490d9 8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
tschatzl
parents: 20309
diff changeset
   730
  current.initialize(this);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   731
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   732
  _prev_period_summary.subtract_from(&current);
20305
af013cf4a5e6 8014078: G1: improve remembered set summary information by providing per region type information
tschatzl
parents: 19339
diff changeset
   733
  print_summary_info(&_prev_period_summary, header);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   734
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   735
  _prev_period_summary.set(&current);
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   736
}
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2741
diff changeset
   737
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   738
void G1RemSet::print_summary_info() {
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   739
  G1RemSetSummary current;
20310
903b398490d9 8025441: G1: assert "assert(thread < _num_vtimes) failed: just checking" fails when G1ConcRefinementThreads > ParallelGCThreads
tschatzl
parents: 20309
diff changeset
   740
  current.initialize(this);
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   741
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   742
  print_summary_info(&current, " Cumulative RS summary");
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   743
}
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   744
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   745
void G1RemSet::print_summary_info(G1RemSetSummary * summary, const char * header) {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   746
  assert(summary != NULL, "just checking");
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   747
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   748
  if (header != NULL) {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   749
    gclog_or_tty->print_cr("%s", header);
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   750
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   751
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   752
#if CARD_REPEAT_HISTO
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   753
  gclog_or_tty->print_cr("\nG1 card_repeat count histogram: ");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   754
  gclog_or_tty->print_cr("  # of repeats --> # of cards with that number.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   755
  card_repeat_count.print_on(gclog_or_tty);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   756
#endif
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   757
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   758
  summary->print_on(gclog_or_tty);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   759
}
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   760
6958
cfa71cf3564d 6971296: G1: simplify G1RemSet class hierarchy
johnc
parents: 6759
diff changeset
   761
void G1RemSet::prepare_for_verify() {
2249
fb8abed44792 6817419: G1: Enable extensive verification for humongous regions
iveresov
parents: 2152
diff changeset
   762
  if (G1HRRSFlushLogBuffersOnVerify &&
fb8abed44792 6817419: G1: Enable extensive verification for humongous regions
iveresov
parents: 2152
diff changeset
   763
      (VerifyBeforeGC || VerifyAfterGC)
17855
9d0719d7bb85 8015244: G1: Verification after a full GC is incorrectly placed.
johnc
parents: 17854
diff changeset
   764
      &&  (!_g1->full_collection() || G1VerifyRSetsDuringFullGC)) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   765
    cleanupHRRS();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   766
    _g1->set_refine_cte_cl_concurrency(false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   767
    if (SafepointSynchronize::is_at_safepoint()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   768
      DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   769
      dcqs.concatenate_logs();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   770
    }
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   771
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   772
    G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   773
    bool use_hot_card_cache = hot_card_cache->use_cache();
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   774
    hot_card_cache->set_use_cache(false);
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   775
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   776
    DirtyCardQueue into_cset_dcq(&_g1->into_cset_dirty_card_queue_set());
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   777
    updateRS(&into_cset_dcq, 0);
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 6068
diff changeset
   778
    _g1->into_cset_dirty_card_queue_set().clear();
2249
fb8abed44792 6817419: G1: Enable extensive verification for humongous regions
iveresov
parents: 2152
diff changeset
   779
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 17108
diff changeset
   780
    hot_card_cache->set_use_cache(use_hot_card_cache);
2249
fb8abed44792 6817419: G1: Enable extensive verification for humongous regions
iveresov
parents: 2152
diff changeset
   781
    assert(JavaThread::dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   782
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   783
}