RFR: 8231895: Avoid String allocations in JVM_FindLoadedClass

David Holmes david.holmes at oracle.com
Sun Oct 6 02:32:37 UTC 2019


Hi Claes,

On 6/10/2019 8:50 am, Claes Redestad wrote:
> Hi,
> 
> JVM_FindLoadedClass allocates a java String from JVM code to transform
> class names from external to internal representation (java.lang.Class ->
> java/lang/Class). This is both inefficient and redundant since we'll
> directly transform it to a utf-8 char* and then ignore the newly created
> String.
> 
> Instead we should mutate the C string. There's a small improvement in
> a targeted microbenchmark (order of 100ns/op, see bug for details),
> although effect on most applications is likely to be in the noise.
> 
> Webrev: http://cr.openjdk.java.net/~redestad/8231895/open.00/
> Bug:    https://bugs.openjdk.java.net/browse/JDK-8231895

Looks reasonable. Minor nit:

!   const char* str   = java_lang_String::as_utf8_string(h_name());

You don't need the const (as it isn't what as_utf8_string returns), then 
you won't need to cast it away when you initialize p.

Thanks,
David

> Testing: tier1-3
> 
> Thanks!
> 
> /Claes


More information about the hotspot-runtime-dev mailing list