annotate src/share/vm/gc_implementation/g1/survRateGroup.hpp @ 577:58054a18d735

6484959: G1: introduce survivor spaces 6797754: G1: combined bugfix Summary: Implemented a policy to control G1 survivor space parameters. Reviewed-by: tonyp, iveresov
author apetrusenko
date Fri, 06 Feb 2009 01:38:50 +0300
parents 37f87013dfd8
children 0fbdb4381b99
rev   line source
ysr@345 1 /*
ysr@345 2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
ysr@345 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@345 4 *
ysr@345 5 * This code is free software; you can redistribute it and/or modify it
ysr@345 6 * under the terms of the GNU General Public License version 2 only, as
ysr@345 7 * published by the Free Software Foundation.
ysr@345 8 *
ysr@345 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@345 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@345 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@345 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@345 13 * accompanied this code).
ysr@345 14 *
ysr@345 15 * You should have received a copy of the GNU General Public License version
ysr@345 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@345 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@345 18 *
ysr@345 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@345 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@345 21 * have any questions.
ysr@345 22 *
ysr@345 23 */
ysr@345 24
ysr@345 25 class G1CollectorPolicy;
ysr@345 26
ysr@345 27 class SurvRateGroup : public CHeapObj {
ysr@345 28 private:
ysr@345 29 G1CollectorPolicy* _g1p;
ysr@345 30 const char* _name;
ysr@345 31
apetrusenko@577 32 size_t _stats_arrays_length;
ysr@345 33 double* _surv_rate;
ysr@345 34 double* _accum_surv_rate_pred;
ysr@345 35 double _last_pred;
ysr@345 36 double _accum_surv_rate;
ysr@345 37 TruncatedSeq** _surv_rate_pred;
ysr@345 38 NumberSeq** _summary_surv_rates;
ysr@345 39 size_t _summary_surv_rates_len;
ysr@345 40 size_t _summary_surv_rates_max_len;
ysr@345 41
ysr@345 42 int _all_regions_allocated;
apetrusenko@577 43 size_t _region_num;
ysr@345 44 size_t _scan_only_prefix;
ysr@345 45 size_t _setup_seq_num;
ysr@345 46
ysr@345 47 public:
ysr@345 48 SurvRateGroup(G1CollectorPolicy* g1p,
ysr@345 49 const char* name,
ysr@345 50 size_t summary_surv_rates_len);
apetrusenko@577 51 void reset();
ysr@345 52 void start_adding_regions();
ysr@345 53 void stop_adding_regions();
ysr@345 54 void record_scan_only_prefix(size_t scan_only_prefix);
ysr@345 55 void record_surviving_words(int age_in_group, size_t surv_words);
ysr@345 56 void all_surviving_words_recorded(bool propagate);
ysr@345 57 const char* name() { return _name; }
ysr@345 58
apetrusenko@577 59 size_t region_num() { return _region_num; }
ysr@345 60 size_t scan_only_length() { return _scan_only_prefix; }
ysr@345 61 double accum_surv_rate_pred(int age) {
ysr@345 62 assert(age >= 0, "must be");
apetrusenko@577 63 if ((size_t)age < _stats_arrays_length)
ysr@345 64 return _accum_surv_rate_pred[age];
ysr@345 65 else {
apetrusenko@577 66 double diff = (double) (age - _stats_arrays_length + 1);
apetrusenko@577 67 return _accum_surv_rate_pred[_stats_arrays_length-1] + diff * _last_pred;
ysr@345 68 }
ysr@345 69 }
ysr@345 70
ysr@345 71 double accum_surv_rate(size_t adjustment);
ysr@345 72
ysr@345 73 TruncatedSeq* get_seq(size_t age) {
ysr@345 74 if (age >= _setup_seq_num) {
ysr@345 75 guarantee( _setup_seq_num > 0, "invariant" );
ysr@345 76 age = _setup_seq_num-1;
ysr@345 77 }
ysr@345 78 TruncatedSeq* seq = _surv_rate_pred[age];
ysr@345 79 guarantee( seq != NULL, "invariant" );
ysr@345 80 return seq;
ysr@345 81 }
ysr@345 82
ysr@345 83 int next_age_index();
ysr@345 84 int age_in_group(int age_index) {
ysr@345 85 int ret = (int) (_all_regions_allocated - age_index);
ysr@345 86 assert( ret >= 0, "invariant" );
ysr@345 87 return ret;
ysr@345 88 }
ysr@345 89 int recalculate_age_index(int age_index) {
ysr@345 90 int new_age_index = (int) _scan_only_prefix - age_in_group(age_index);
ysr@345 91 guarantee( new_age_index >= 0, "invariant" );
ysr@345 92 return new_age_index;
ysr@345 93 }
ysr@345 94 void finished_recalculating_age_indexes() {
ysr@345 95 _all_regions_allocated = (int) _scan_only_prefix;
ysr@345 96 }
ysr@345 97
ysr@345 98 #ifndef PRODUCT
ysr@345 99 void print();
ysr@345 100 void print_surv_rate_summary();
ysr@345 101 #endif // PRODUCT
ysr@345 102 };