RFR (S): 8024616: JSR292: lazily initialize core NamedFunctions used for bootstrapping

John Rose john.r.rose at oracle.com
Mon Sep 16 09:17:28 PDT 2013

On Sep 11, 2013, at 4:24 AM, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:

> http://cr.openjdk.java.net/~vlivanov/8024616/webrev.00/
> 75 lines changed: 14 ins; 2 del; 59 mod
> A small set of NamedFunctions is pre-initialized to allow JSR292 bootstrapping. After 8022595, which enabled JSR292 initialization during VM startup, they are instantiated even when JSR292 isn't used.
> It leads to unnecessary work being done and a regression in startup time (~20-25ms for HelloWorld application on my laptop). The major contribution to this time is bytecode compilation of LF's for preinitialized NamedFunctions.
> The fix is to factor NamedFunctions used for bootstrapping into an inner class to delay initialization till the first usage.
> After the fix, JSR292 pre-init duration goes down to 2-3ms (from 25ms) and no anonymous classes are produced, if JSR292 isn't used in the application.
> Testing: concurrent loading & init order tests for java.lang.invoke, JSR292 tests, octane.
> Best regards,
> Vladimir Ivanov

The transformation s/NF_/NF./ is clever and I like it.  The static variable names themselves needs a little prefix, though, just to stay within the naming conventions.  Something like s/NF_/NF.NF_/ or /Lazy.NF_/.

I might as well explain the NF_ naming convention.  Readers of the 292 source code will notice odd-looking hybrid identifier conventions of the form FOO_barBaz, for certain static final variables.  The rule here is that if a MethodHandle or similar type (NamedFunction, MethodType) works like metadata for a "normal" class member "barBaz", then that latter identifier should be part of its name, without transformation to the more canonical "BAR_BAZ" for a static constant.  The prefix "NF_" (or "MH_") marks the variable as a constant, and the verbatim quote of the target class member "barBaz" links it to its target.

I briefly tried expanding the constants to canonical form "MH_BAR_BAZ" and found it very annoying, when reading the code, to switch mentally between the "BAR_BAZ" and "barBaz" forms.  Also, it is very useful, in text editors, to be able to search for the string "barBaz" and come up with hits on both the metadata and the "normal" member at the same time, since it is common to work with both at once.

— John

More information about the hotspot-compiler-dev mailing list