--- old/src/hotspot/share/gc/g1/survRateGroup.cpp 2019-06-04 13:17:07.732651051 -0700 +++ new/src/hotspot/share/gc/g1/survRateGroup.cpp 2019-06-04 13:17:07.472651060 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,8 @@ _surv_rate_pred(NULL), _all_regions_allocated(0), _region_num(0), - _setup_seq_num(0) + _setup_seq_num(0), + _retained_region_num(0) { reset(); start_adding_regions(); @@ -49,6 +50,7 @@ _last_pred = 0.0; // the following will set up the arrays with length 1 _region_num = 1; + _retained_region_num = 0; // The call to stop_adding_regions() will use "new" to refill // the _surv_rate_pred array, so we need to make sure to call @@ -72,7 +74,9 @@ void SurvRateGroup::start_adding_regions() { _setup_seq_num = _stats_arrays_length; - _region_num = 0; + // Retained region number should be reflected to address actual reused case. + _region_num = _retained_region_num; + _retained_region_num = 0; } void SurvRateGroup::stop_adding_regions() { @@ -90,7 +94,8 @@ void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) { guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num, - "pre-condition" ); + "Age in group (" PTR_FORMAT ") should be [0, " SIZE_FORMAT "), but it is %d", + p2i(this), _region_num, age_in_group); double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords; _surv_rate_pred[age_in_group]->add(surv_rate);