RFR: 8261447: MethodInvocationCounters frequently run into overflow [v2]

Lutz Schmidt lucy at openjdk.java.net
Tue Mar 2 20:50:43 UTC 2021


On Thu, 25 Feb 2021 16:31:58 GMT, Igor Veresov <iveresov at openjdk.org> wrote:

>> src/hotspot/share/oops/method.cpp line 516:
>> 
>>> 514:   // This is ok because counters are unsigned by nature, and it gives us
>>> 515:   // another factor of 2 before the counter values become meaningless.
>>> 516:   // Print a "overflow" notification to create awareness.
>> 
>> What ```invocation_count()``` returns (which is currently equivalent to ```interpreter_invocation_count()``` btw) comes from the ```InvocationCounter::count()``` which cannot grow beyond 2^31, so all these counts are always positive. What exactly do these casts to unsigned do?
>
> So, why do we need the casts to unsigned in this method?

When you increment (2^31-1), you get 2^31 which is 0x80000000. When interpreted as signed int, it is MIN_INT. I don't want that. I want to treat the value as positive number - what it actually is. There is no negative count!

-------------

PR: https://git.openjdk.java.net/jdk/pull/2511


More information about the hotspot-dev mailing list