hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp
author jwilhelm
Thu, 03 Oct 2013 21:36:29 +0200
changeset 20398 b206c580c45f
parent 17854 d65bc1546091
child 22220 eb467dfb9585
permissions -rw-r--r--
8025852: Remove unnecessary setters in collector policy classes Summary: Use instance variables directly within the collector policy classes and remove unused setters. Reviewed-by: tschatzl, jcoomes
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: 13289
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: 6247
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    26
#include "gc_implementation/g1/concurrentG1Refine.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    27
#include "gc_implementation/g1/concurrentG1RefineThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    28
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    29
#include "gc_implementation/g1/g1HotCardCache.hpp"
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 8683
diff changeset
    30
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    31
ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) :
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    32
  _threads(NULL), _n_threads(0),
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    33
  _hot_card_cache(g1h)
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
{
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    35
  // Ergomonically select initial concurrent refinement parameters
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    36
  if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) {
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    37
    FLAG_SET_DEFAULT(G1ConcRefinementGreenZone, MAX2<int>(ParallelGCThreads, 1));
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    38
  }
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    39
  set_green_zone(G1ConcRefinementGreenZone);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    40
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    41
  if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) {
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    42
    FLAG_SET_DEFAULT(G1ConcRefinementYellowZone, green_zone() * 3);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    43
  }
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    44
  set_yellow_zone(MAX2<int>(G1ConcRefinementYellowZone, green_zone()));
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    45
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    46
  if (FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) {
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    47
    FLAG_SET_DEFAULT(G1ConcRefinementRedZone, yellow_zone() * 2);
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    48
  }
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    49
  set_red_zone(MAX2<int>(G1ConcRefinementRedZone, yellow_zone()));
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    50
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    51
  _n_worker_threads = thread_num();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    52
  // We need one extra thread to do the young gen rset size sampling.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    53
  _n_threads = _n_worker_threads + 1;
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    54
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    55
  reset_threshold_step();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    56
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8929
diff changeset
    57
  _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    58
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    59
  int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    60
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    61
  ConcurrentG1RefineThread *next = NULL;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    62
  for (int i = _n_threads - 1; i >= 0; i--) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    63
    ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    64
    assert(t != NULL, "Conc refine should have been created");
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    65
    assert(t->cg1r() == this, "Conc refine thread should refer to this");
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    66
    _threads[i] = t;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    67
    next = t;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    71
void ConcurrentG1Refine::reset_threshold_step() {
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    72
  if (FLAG_IS_DEFAULT(G1ConcRefinementThresholdStep)) {
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    73
    _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1);
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    74
  } else {
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4887
diff changeset
    75
    _thread_threshold_step = G1ConcRefinementThresholdStep;
2882
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
    76
  }
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    77
}
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    78
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
void ConcurrentG1Refine::init() {
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
    80
  _hot_card_cache.initialize();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    83
void ConcurrentG1Refine::stop() {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    84
  if (_threads != NULL) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    85
    for (int i = 0; i < _n_threads; i++) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    86
      _threads[i]->stop();
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    87
    }
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    88
  }
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    89
}
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
    90
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    91
void ConcurrentG1Refine::reinitialize_threads() {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    92
  reset_threshold_step();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    93
  if (_threads != NULL) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    94
    for (int i = 0; i < _n_threads; i++) {
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    95
      _threads[i]->initialize();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    96
    }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    97
  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    98
}
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    99
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
ConcurrentG1Refine::~ConcurrentG1Refine() {
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   101
  if (_threads != NULL) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   102
    for (int i = 0; i < _n_threads; i++) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   103
      delete _threads[i];
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   104
    }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8929
diff changeset
   105
    FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   109
void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   110
  if (_threads != NULL) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   111
    for (int i = 0; i < _n_threads; i++) {
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   112
      tc->do_thread(_threads[i]);
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2249
diff changeset
   113
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   117
void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   118
  if (_threads != NULL) {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   119
    for (int i = 0; i < worker_thread_num(); i++) {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   120
      tc->do_thread(_threads[i]);
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   121
    }
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   122
  }
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   123
}
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   124
17327
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
   125
int ConcurrentG1Refine::thread_num() {
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
   126
  int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
   127
                                                : ParallelGCThreads;
4bd0581aa231 7176479: G1: JVM crashes on T5-8 system with 1.5 TB heap
johnc
parents: 13289
diff changeset
   128
  return MAX2<int>(n_threads, 1);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
}
4022
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   130
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   131
void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   132
  for (int i = 0; i < _n_threads; ++i) {
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   133
    _threads[i]->print_on(st);
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   134
    st->cr();
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   135
  }
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   136
}
17854
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   137
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   138
ConcurrentG1RefineThread * ConcurrentG1Refine::sampling_thread() const {
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   139
  return _threads[worker_thread_num()];
d65bc1546091 8013895: G1: G1SummarizeRSetStats output on Linux needs improvemen
tschatzl
parents: 17327
diff changeset
   140
}