RFR: 8224162: assert(profile.count() == 0) failed: sanity in InlineTree::is_not_reached
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Wed May 29 12:02:20 UTC 2019
Thanks, Jie.
> http://cr.openjdk.java.net/~jiefu/8224162/webrev.05/
src/hotspot/share/ci/ciMethod.cpp:
if (count >= 0) {
count += receivers_count_total;
+ // Check and handle the overflow condition
+ if (count < 0) {
+ count = max_jint;
+ }
}
There are other places where overflow can occur:
int rcount = call->receiver_count(i) + epsilon;
receivers_count_total += rcount;
Maybe introduce a helper routine for saturating addition?
src/hotspot/share/oops/methodData.hpp:
uint count() const {
- return uint_at(count_off);
+ intptr_t raw_data = intptr_at(count_off);
+ if (raw_data > max_jint) {
+ raw_data = max_jint;
+ } else if (raw_data < min_jint) {
+ raw_data = min_jint;
+ }
+ return uint(raw_data);
}
Should uintptr_t be used here instead? It looks like this version won't
work as expected on 32-bit platforms (since uint => intrptr_t conversion
becomes lossy).
Also, I don't understand why you added comparison against min_jint.
Since counts are unsigned, the following should be enough:
uint count() const {
uintx raw_data = (uintx)intptr_at(count_off);
if (raw_data > max_jint) {
raw_data = max_jint;
}
return uint(raw_data);
}
Best regards,
Vladimir Ivanov
> On 2019/5/23 下午6:21, Vladimir Ivanov wrote:
>> I'm still in favor of fixing the root cause than putting band-aids in
>> otherwise perfectly valid code.
>>
>> I don't consider fixing CounterData::count() and its usages to
>> properly handle overflow as overly complicated. There's a limited
>> number of usages and they don't properly handle overflow as well. So,
>> fixing the bug is highly desireable even though it has been left
>> unnoticed for a long time.
>
More information about the hotspot-compiler-dev
mailing list