RFR: 8254104: MethodCounters must exist before nmethod is installed

Vladimir Kozlov kvn at openjdk.java.net
Wed Oct 7 16:07:06 UTC 2020


On Wed, 7 Oct 2020 15:56:16 GMT, Igor Veresov <iveresov at openjdk.org> wrote:

>> The need for MethodCounters to be present is driven by the tiered compilation policy. It's not needed by a compiler per
>> se. Moreover, you don't need it if you don't install the code. For example when compilation happens for native image
>> it's not needed. Anyways, seemed like an appropriate place to do it.
>
> Oh, and to answer your question about when it happens. In most Graal unit tests it compiles and installs methods that
> have been never executed in the interpreter, which normally lazily allocates the counters. And it doesn't pass through
> the broker, which would've made sure the counters are there.

Okay. MethodCounters are created in Interpreter in all cases regardless TieredCompilation setting:
https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp#L386

So check for TieredCompilation is strange.

I understand that MethodCounters are not created in AOT case. And now I get that it includes Graal unit testing as you
pointed (which similar to AOT) which request compilation through Java and not usual Compilation Broker. In which case
you fix is reasonable.

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

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


More information about the hotspot-compiler-dev mailing list