comparison src/share/vm/gc_implementation/g1/survRateGroup.hpp @ 342:37f87013dfd8

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