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

Fri, 06 Feb 2009 01:38:50 +0300

author
apetrusenko
date
Fri, 06 Feb 2009 01:38:50 +0300
changeset 980
58054a18d735
parent 777
37f87013dfd8
child 984
fe3d7c11b4b7
permissions
-rw-r--r--

6484959: G1: introduce survivor spaces
6797754: G1: combined bugfix
Summary: Implemented a policy to control G1 survivor space parameters.
Reviewed-by: tonyp, iveresov

ysr@777 1 /*
ysr@777 2 * Copyright 2001-2007 Sun Microsystems, Inc. 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 *
ysr@777 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@777 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@777 21 * have any questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
ysr@777 25 // Forward decl
ysr@777 26 class ConcurrentG1RefineThread;
ysr@777 27 class G1RemSet;
ysr@777 28
ysr@777 29 // What to do after a yield:
ysr@777 30 enum PostYieldAction {
ysr@777 31 PYA_continue, // Continue the traversal
ysr@777 32 PYA_restart, // Restart
ysr@777 33 PYA_cancel // It's been completed by somebody else: cancel.
ysr@777 34 };
ysr@777 35
ysr@777 36 class ConcurrentG1Refine {
ysr@777 37 ConcurrentG1RefineThread* _cg1rThread;
ysr@777 38
ysr@777 39 volatile jint _pya;
ysr@777 40 PostYieldAction _last_pya;
ysr@777 41
ysr@777 42 static bool _enabled; // Protected by G1ConcRefine_mon.
ysr@777 43 unsigned _traversals;
ysr@777 44
ysr@777 45 // Number of cards processed during last refinement traversal.
ysr@777 46 unsigned _first_traversal;
ysr@777 47 unsigned _last_cards_during;
ysr@777 48
ysr@777 49 // The cache for card refinement.
ysr@777 50 bool _use_cache;
ysr@777 51 bool _def_use_cache;
ysr@777 52 size_t _n_periods;
ysr@777 53 size_t _total_cards;
ysr@777 54 size_t _total_travs;
ysr@777 55
ysr@777 56 unsigned char* _card_counts;
ysr@777 57 unsigned _n_card_counts;
ysr@777 58 const jbyte* _ct_bot;
ysr@777 59 unsigned* _cur_card_count_histo;
ysr@777 60 unsigned* _cum_card_count_histo;
ysr@777 61 jbyte** _hot_cache;
ysr@777 62 int _hot_cache_size;
ysr@777 63 int _n_hot;
ysr@777 64 int _hot_cache_idx;
ysr@777 65
ysr@777 66 // Returns the count of this card after incrementing it.
ysr@777 67 int add_card_count(jbyte* card_ptr);
ysr@777 68
ysr@777 69 void print_card_count_histo_range(unsigned* histo, int from, int to,
ysr@777 70 float& cum_card_pct,
ysr@777 71 float& cum_travs_pct);
ysr@777 72 public:
ysr@777 73 ConcurrentG1Refine();
ysr@777 74 ~ConcurrentG1Refine();
ysr@777 75
ysr@777 76 void init(); // Accomplish some initialization that has to wait.
ysr@777 77
ysr@777 78 // Enabled Conc refinement, waking up thread if necessary.
ysr@777 79 void enable();
ysr@777 80
ysr@777 81 // Returns the number of traversals performed since this refiner was enabled.
ysr@777 82 unsigned disable();
ysr@777 83
ysr@777 84 // Requires G1ConcRefine_mon to be held.
ysr@777 85 bool enabled() { return _enabled; }
ysr@777 86
ysr@777 87 // Returns only when G1 concurrent refinement has been enabled.
ysr@777 88 void wait_for_ConcurrentG1Refine_enabled();
ysr@777 89
ysr@777 90 // Do one concurrent refinement pass over the card table. Returns "true"
ysr@777 91 // if heuristics determine that another pass should be done immediately.
ysr@777 92 bool refine();
ysr@777 93
ysr@777 94 // Indicate that an in-progress refinement pass should start over.
ysr@777 95 void set_pya_restart();
ysr@777 96 // Indicate that an in-progress refinement pass should quit.
ysr@777 97 void set_pya_cancel();
ysr@777 98
ysr@777 99 // Get the appropriate post-yield action. Also sets last_pya.
ysr@777 100 PostYieldAction get_pya();
ysr@777 101
ysr@777 102 // The last PYA read by "get_pya".
ysr@777 103 PostYieldAction get_last_pya();
ysr@777 104
ysr@777 105 bool do_traversal();
ysr@777 106
ysr@777 107 ConcurrentG1RefineThread* cg1rThread() { return _cg1rThread; }
ysr@777 108
ysr@777 109 // If this is the first entry for the slot, writes into the cache and
ysr@777 110 // returns NULL. If it causes an eviction, returns the evicted pointer.
ysr@777 111 // Otherwise, its a cache hit, and returns NULL.
ysr@777 112 jbyte* cache_insert(jbyte* card_ptr);
ysr@777 113
ysr@777 114 // Process the cached entries.
ysr@777 115 void clean_up_cache(int worker_i, G1RemSet* g1rs);
ysr@777 116
ysr@777 117 // Discard entries in the hot cache.
ysr@777 118 void clear_hot_cache() {
ysr@777 119 _hot_cache_idx = 0; _n_hot = 0;
ysr@777 120 }
ysr@777 121
ysr@777 122 bool hot_cache_is_empty() { return _n_hot == 0; }
ysr@777 123
ysr@777 124 bool use_cache() { return _use_cache; }
ysr@777 125 void set_use_cache(bool b) {
ysr@777 126 if (b) _use_cache = _def_use_cache;
ysr@777 127 else _use_cache = false;
ysr@777 128 }
ysr@777 129
ysr@777 130 void clear_and_record_card_counts();
ysr@777 131 void print_final_card_counts();
ysr@777 132 };

mercurial