src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp

Fri, 17 May 2013 11:57:05 +0200

author
ehelin
date
Fri, 17 May 2013 11:57:05 +0200
changeset 5159
001ec9515f84
parent 5078
194f52aa2f23
child 5204
e72f7eecc96d
permissions
-rw-r--r--

8014277: Remove ObjectClosure as base class for BoolObjectClosure
Reviewed-by: brutisso, tschatzl

ysr@777 1 /*
johnc@5078 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/g1/concurrentG1Refine.hpp"
stefank@2314 27 #include "gc_implementation/g1/concurrentG1RefineThread.hpp"
stefank@2314 28 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
johnc@5078 29 #include "gc_implementation/g1/g1HotCardCache.hpp"
ysr@777 30
johnc@5078 31 ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h) :
johnc@5078 32 _threads(NULL), _n_threads(0),
johnc@5078 33 _hot_card_cache(g1h)
ysr@777 34 {
iveresov@1546 35 // Ergomonically select initial concurrent refinement parameters
tonyp@1717 36 if (FLAG_IS_DEFAULT(G1ConcRefinementGreenZone)) {
tonyp@1717 37 FLAG_SET_DEFAULT(G1ConcRefinementGreenZone, MAX2<int>(ParallelGCThreads, 1));
iveresov@1546 38 }
tonyp@1717 39 set_green_zone(G1ConcRefinementGreenZone);
iveresov@1546 40
tonyp@1717 41 if (FLAG_IS_DEFAULT(G1ConcRefinementYellowZone)) {
tonyp@1717 42 FLAG_SET_DEFAULT(G1ConcRefinementYellowZone, green_zone() * 3);
iveresov@1546 43 }
tonyp@1717 44 set_yellow_zone(MAX2<int>(G1ConcRefinementYellowZone, green_zone()));
iveresov@1546 45
tonyp@1717 46 if (FLAG_IS_DEFAULT(G1ConcRefinementRedZone)) {
tonyp@1717 47 FLAG_SET_DEFAULT(G1ConcRefinementRedZone, yellow_zone() * 2);
iveresov@1546 48 }
tonyp@1717 49 set_red_zone(MAX2<int>(G1ConcRefinementRedZone, yellow_zone()));
johnc@5078 50
iveresov@1546 51 _n_worker_threads = thread_num();
iveresov@1546 52 // We need one extra thread to do the young gen rset size sampling.
iveresov@1546 53 _n_threads = _n_worker_threads + 1;
johnc@5078 54
iveresov@1546 55 reset_threshold_step();
iveresov@1546 56
zgu@3900 57 _threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
johnc@5078 58
iveresov@1546 59 int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
johnc@5078 60
iveresov@1546 61 ConcurrentG1RefineThread *next = NULL;
iveresov@1546 62 for (int i = _n_threads - 1; i >= 0; i--) {
iveresov@1546 63 ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
iveresov@1546 64 assert(t != NULL, "Conc refine should have been created");
iveresov@1546 65 assert(t->cg1r() == this, "Conc refine thread should refer to this");
iveresov@1546 66 _threads[i] = t;
iveresov@1546 67 next = t;
ysr@777 68 }
ysr@777 69 }
ysr@777 70
iveresov@1546 71 void ConcurrentG1Refine::reset_threshold_step() {
tonyp@1717 72 if (FLAG_IS_DEFAULT(G1ConcRefinementThresholdStep)) {
iveresov@1546 73 _thread_threshold_step = (yellow_zone() - green_zone()) / (worker_thread_num() + 1);
iveresov@1546 74 } else {
tonyp@1717 75 _thread_threshold_step = G1ConcRefinementThresholdStep;
iveresov@1230 76 }
iveresov@1546 77 }
iveresov@1546 78
ysr@777 79 void ConcurrentG1Refine::init() {
johnc@5078 80 _hot_card_cache.initialize();
ysr@777 81 }
ysr@777 82
iveresov@1229 83 void ConcurrentG1Refine::stop() {
iveresov@1229 84 if (_threads != NULL) {
iveresov@1229 85 for (int i = 0; i < _n_threads; i++) {
iveresov@1229 86 _threads[i]->stop();
iveresov@1229 87 }
iveresov@1229 88 }
iveresov@1229 89 }
iveresov@1229 90
iveresov@1546 91 void ConcurrentG1Refine::reinitialize_threads() {
iveresov@1546 92 reset_threshold_step();
iveresov@1546 93 if (_threads != NULL) {
iveresov@1546 94 for (int i = 0; i < _n_threads; i++) {
iveresov@1546 95 _threads[i]->initialize();
iveresov@1546 96 }
iveresov@1546 97 }
iveresov@1546 98 }
iveresov@1546 99
ysr@777 100 ConcurrentG1Refine::~ConcurrentG1Refine() {
iveresov@1229 101 if (_threads != NULL) {
iveresov@1229 102 for (int i = 0; i < _n_threads; i++) {
iveresov@1229 103 delete _threads[i];
iveresov@1229 104 }
zgu@3900 105 FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
ysr@777 106 }
ysr@777 107 }
ysr@777 108
iveresov@1229 109 void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
iveresov@1229 110 if (_threads != NULL) {
iveresov@1229 111 for (int i = 0; i < _n_threads; i++) {
iveresov@1229 112 tc->do_thread(_threads[i]);
iveresov@1229 113 }
ysr@777 114 }
ysr@777 115 }
ysr@777 116
johnc@5078 117 int ConcurrentG1Refine::thread_num() {
johnc@5078 118 int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
johnc@5078 119 : ParallelGCThreads;
johnc@5078 120 return MAX2<int>(n_threads, 1);
ysr@777 121 }
tonyp@1454 122
tonyp@1454 123 void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
tonyp@1454 124 for (int i = 0; i < _n_threads; ++i) {
tonyp@1454 125 _threads[i]->print_on(st);
tonyp@1454 126 st->cr();
tonyp@1454 127 }
tonyp@1454 128 }

mercurial