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

Thu, 12 Oct 2017 21:27:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 21:27:07 +0800
changeset 7535
7ae4e26cb1e0
parent 7051
1f1d373cd044
parent 6876
710a3c8b516e
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
aoqi@0 27
aoqi@0 28 #include "gc_implementation/g1/g1HotCardCache.hpp"
aoqi@0 29 #include "memory/allocation.hpp"
aoqi@0 30 #include "runtime/thread.hpp"
aoqi@0 31 #include "utilities/globalDefinitions.hpp"
aoqi@0 32
aoqi@0 33 // Forward decl
aoqi@0 34 class ConcurrentG1RefineThread;
aoqi@0 35 class G1CollectedHeap;
aoqi@0 36 class G1HotCardCache;
tschatzl@7051 37 class G1RegionToSpaceMapper;
aoqi@0 38 class G1RemSet;
aoqi@0 39 class DirtyCardQueue;
aoqi@0 40
aoqi@0 41 class ConcurrentG1Refine: public CHeapObj<mtGC> {
aoqi@0 42 ConcurrentG1RefineThread** _threads;
aoqi@0 43 uint _n_threads;
aoqi@0 44 uint _n_worker_threads;
aoqi@0 45 /*
aoqi@0 46 * The value of the update buffer queue length falls into one of 3 zones:
aoqi@0 47 * green, yellow, red. If the value is in [0, green) nothing is
aoqi@0 48 * done, the buffers are left unprocessed to enable the caching effect of the
aoqi@0 49 * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
aoqi@0 50 * threads are gradually activated. In [yellow, red) all threads are
aoqi@0 51 * running. If the length becomes red (max queue length) the mutators start
aoqi@0 52 * processing the buffers.
aoqi@0 53 *
aoqi@0 54 * There are some interesting cases (when G1UseAdaptiveConcRefinement
aoqi@0 55 * is turned off):
aoqi@0 56 * 1) green = yellow = red = 0. In this case the mutator will process all
aoqi@0 57 * buffers. Except for those that are created by the deferred updates
aoqi@0 58 * machinery during a collection.
aoqi@0 59 * 2) green = 0. Means no caching. Can be a good way to minimize the
aoqi@0 60 * amount of time spent updating rsets during a collection.
aoqi@0 61 */
aoqi@0 62 int _green_zone;
aoqi@0 63 int _yellow_zone;
aoqi@0 64 int _red_zone;
aoqi@0 65
aoqi@0 66 int _thread_threshold_step;
aoqi@0 67
aoqi@0 68 // We delay the refinement of 'hot' cards using the hot card cache.
aoqi@0 69 G1HotCardCache _hot_card_cache;
aoqi@0 70
aoqi@0 71 // Reset the threshold step value based of the current zone boundaries.
aoqi@0 72 void reset_threshold_step();
aoqi@0 73
aoqi@0 74 public:
tschatzl@6930 75 ConcurrentG1Refine(G1CollectedHeap* g1h, CardTableEntryClosure* refine_closure);
aoqi@0 76 ~ConcurrentG1Refine();
aoqi@0 77
tschatzl@7051 78 void init(G1RegionToSpaceMapper* card_counts_storage);
aoqi@0 79 void stop();
aoqi@0 80
aoqi@0 81 void reinitialize_threads();
aoqi@0 82
aoqi@0 83 // Iterate over all concurrent refinement threads
aoqi@0 84 void threads_do(ThreadClosure *tc);
aoqi@0 85
aoqi@0 86 // Iterate over all worker refinement threads
aoqi@0 87 void worker_threads_do(ThreadClosure * tc);
aoqi@0 88
aoqi@0 89 // The RS sampling thread
aoqi@0 90 ConcurrentG1RefineThread * sampling_thread() const;
aoqi@0 91
aoqi@0 92 static uint thread_num();
aoqi@0 93
aoqi@0 94 void print_worker_threads_on(outputStream* st) const;
aoqi@0 95
aoqi@0 96 void set_green_zone(int x) { _green_zone = x; }
aoqi@0 97 void set_yellow_zone(int x) { _yellow_zone = x; }
aoqi@0 98 void set_red_zone(int x) { _red_zone = x; }
aoqi@0 99
aoqi@0 100 int green_zone() const { return _green_zone; }
aoqi@0 101 int yellow_zone() const { return _yellow_zone; }
aoqi@0 102 int red_zone() const { return _red_zone; }
aoqi@0 103
aoqi@0 104 uint total_thread_num() const { return _n_threads; }
aoqi@0 105 uint worker_thread_num() const { return _n_worker_threads; }
aoqi@0 106
aoqi@0 107 int thread_threshold_step() const { return _thread_threshold_step; }
aoqi@0 108
aoqi@0 109 G1HotCardCache* hot_card_cache() { return &_hot_card_cache; }
aoqi@0 110 };
aoqi@0 111
aoqi@0 112 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP

mercurial