Wed, 02 Nov 2011 08:04:23 +0100
7106751: G1: gc/gctests/nativeGC03 crashes VM with SIGSEGV
Summary: _cset_rs_update_cl[] was indexed with values beyond what it is set up to handle.
Reviewed-by: ysr, jmasa, johnc
ysr@777 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP |
stefank@2314 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "utilities/numberSeq.hpp" |
stefank@2314 | 29 | |
ysr@777 | 30 | class G1CollectorPolicy; |
ysr@777 | 31 | |
ysr@777 | 32 | class SurvRateGroup : public CHeapObj { |
ysr@777 | 33 | private: |
ysr@777 | 34 | G1CollectorPolicy* _g1p; |
ysr@777 | 35 | const char* _name; |
ysr@777 | 36 | |
apetrusenko@980 | 37 | size_t _stats_arrays_length; |
ysr@777 | 38 | double* _surv_rate; |
ysr@777 | 39 | double* _accum_surv_rate_pred; |
ysr@777 | 40 | double _last_pred; |
ysr@777 | 41 | double _accum_surv_rate; |
ysr@777 | 42 | TruncatedSeq** _surv_rate_pred; |
ysr@777 | 43 | NumberSeq** _summary_surv_rates; |
ysr@777 | 44 | size_t _summary_surv_rates_len; |
ysr@777 | 45 | size_t _summary_surv_rates_max_len; |
ysr@777 | 46 | |
ysr@777 | 47 | int _all_regions_allocated; |
apetrusenko@980 | 48 | size_t _region_num; |
ysr@777 | 49 | size_t _setup_seq_num; |
ysr@777 | 50 | |
ysr@777 | 51 | public: |
ysr@777 | 52 | SurvRateGroup(G1CollectorPolicy* g1p, |
ysr@777 | 53 | const char* name, |
ysr@777 | 54 | size_t summary_surv_rates_len); |
apetrusenko@980 | 55 | void reset(); |
ysr@777 | 56 | void start_adding_regions(); |
ysr@777 | 57 | void stop_adding_regions(); |
ysr@777 | 58 | void record_surviving_words(int age_in_group, size_t surv_words); |
ysr@777 | 59 | void all_surviving_words_recorded(bool propagate); |
ysr@777 | 60 | const char* name() { return _name; } |
ysr@777 | 61 | |
apetrusenko@980 | 62 | size_t region_num() { return _region_num; } |
ysr@777 | 63 | double accum_surv_rate_pred(int age) { |
ysr@777 | 64 | assert(age >= 0, "must be"); |
apetrusenko@980 | 65 | if ((size_t)age < _stats_arrays_length) |
ysr@777 | 66 | return _accum_surv_rate_pred[age]; |
ysr@777 | 67 | else { |
apetrusenko@980 | 68 | double diff = (double) (age - _stats_arrays_length + 1); |
apetrusenko@980 | 69 | return _accum_surv_rate_pred[_stats_arrays_length-1] + diff * _last_pred; |
ysr@777 | 70 | } |
ysr@777 | 71 | } |
ysr@777 | 72 | |
ysr@777 | 73 | double accum_surv_rate(size_t adjustment); |
ysr@777 | 74 | |
ysr@777 | 75 | TruncatedSeq* get_seq(size_t age) { |
ysr@777 | 76 | if (age >= _setup_seq_num) { |
ysr@777 | 77 | guarantee( _setup_seq_num > 0, "invariant" ); |
ysr@777 | 78 | age = _setup_seq_num-1; |
ysr@777 | 79 | } |
ysr@777 | 80 | TruncatedSeq* seq = _surv_rate_pred[age]; |
ysr@777 | 81 | guarantee( seq != NULL, "invariant" ); |
ysr@777 | 82 | return seq; |
ysr@777 | 83 | } |
ysr@777 | 84 | |
ysr@777 | 85 | int next_age_index(); |
ysr@777 | 86 | int age_in_group(int age_index) { |
johnc@1829 | 87 | int ret = (int) (_all_regions_allocated - age_index); |
ysr@777 | 88 | assert( ret >= 0, "invariant" ); |
ysr@777 | 89 | return ret; |
ysr@777 | 90 | } |
ysr@777 | 91 | void finished_recalculating_age_indexes() { |
johnc@1829 | 92 | _all_regions_allocated = 0; |
ysr@777 | 93 | } |
ysr@777 | 94 | |
ysr@777 | 95 | #ifndef PRODUCT |
ysr@777 | 96 | void print(); |
ysr@777 | 97 | void print_surv_rate_summary(); |
ysr@777 | 98 | #endif // PRODUCT |
ysr@777 | 99 | }; |
stefank@2314 | 100 | |
stefank@2314 | 101 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_SURVRATEGROUP_HPP |