ysr@777: /* trims@1907: * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. ysr@777: * ysr@777: */ ysr@777: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP stefank@2314: stefank@2314: #include "utilities/numberSeq.hpp" stefank@2314: ysr@777: class G1CollectorPolicy; ysr@777: zgu@3900: class SurvRateGroup : public CHeapObj { ysr@777: private: ysr@777: G1CollectorPolicy* _g1p; ysr@777: const char* _name; ysr@777: apetrusenko@980: size_t _stats_arrays_length; ysr@777: double* _surv_rate; ysr@777: double* _accum_surv_rate_pred; ysr@777: double _last_pred; ysr@777: double _accum_surv_rate; ysr@777: TruncatedSeq** _surv_rate_pred; ysr@777: NumberSeq** _summary_surv_rates; ysr@777: size_t _summary_surv_rates_len; ysr@777: size_t _summary_surv_rates_max_len; ysr@777: ysr@777: int _all_regions_allocated; apetrusenko@980: size_t _region_num; ysr@777: size_t _setup_seq_num; ysr@777: ysr@777: public: ysr@777: SurvRateGroup(G1CollectorPolicy* g1p, ysr@777: const char* name, ysr@777: size_t summary_surv_rates_len); apetrusenko@980: void reset(); ysr@777: void start_adding_regions(); ysr@777: void stop_adding_regions(); ysr@777: void record_surviving_words(int age_in_group, size_t surv_words); ysr@777: void all_surviving_words_recorded(bool propagate); ysr@777: const char* name() { return _name; } ysr@777: apetrusenko@980: size_t region_num() { return _region_num; } ysr@777: double accum_surv_rate_pred(int age) { ysr@777: assert(age >= 0, "must be"); apetrusenko@980: if ((size_t)age < _stats_arrays_length) ysr@777: return _accum_surv_rate_pred[age]; ysr@777: else { apetrusenko@980: double diff = (double) (age - _stats_arrays_length + 1); apetrusenko@980: return _accum_surv_rate_pred[_stats_arrays_length-1] + diff * _last_pred; ysr@777: } ysr@777: } ysr@777: ysr@777: double accum_surv_rate(size_t adjustment); ysr@777: ysr@777: TruncatedSeq* get_seq(size_t age) { ysr@777: if (age >= _setup_seq_num) { ysr@777: guarantee( _setup_seq_num > 0, "invariant" ); ysr@777: age = _setup_seq_num-1; ysr@777: } ysr@777: TruncatedSeq* seq = _surv_rate_pred[age]; ysr@777: guarantee( seq != NULL, "invariant" ); ysr@777: return seq; ysr@777: } ysr@777: ysr@777: int next_age_index(); ysr@777: int age_in_group(int age_index) { johnc@1829: int ret = (int) (_all_regions_allocated - age_index); ysr@777: assert( ret >= 0, "invariant" ); ysr@777: return ret; ysr@777: } ysr@777: void finished_recalculating_age_indexes() { johnc@1829: _all_regions_allocated = 0; ysr@777: } ysr@777: ysr@777: #ifndef PRODUCT ysr@777: void print(); ysr@777: void print_surv_rate_summary(); ysr@777: #endif // PRODUCT ysr@777: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP