RFR: 8254104: MethodCounters must exist before nmethod is installed

Igor Veresov iveresov at openjdk.java.net
Wed Oct 7 16:01:14 UTC 2020


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

>> Would be great if you explain in what cases you don't have MethodCounters  *AFTER* compilation?
>> Should you do that at the beginning of compilation?
>> We do check for presence of MDO during start of compilation (C2 example):
>> https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/compile.cpp#L599
>
> 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.

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

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


More information about the hotspot-compiler-dev mailing list