RFR: 8231895: Avoid String allocations in JVM_FindLoadedClass
Ioi Lam
ioi.lam at oracle.com
Sun Oct 6 03:33:11 UTC 2019
Looks good.
We have a few places that convert from . to /. I am wondering if we
should consolidate them to a single place:
open/src/hotspot/share$ find . -name \*.cpp -print -o -name \*.hpp
-print | xargs grep "'/'" | grep '[^=!]=[^=]'
./prims/unsafe.cpp: if (utfName[i] == '.') utfName[i] = '/';
./compiler/compilerOracle.cpp: if (name[i] == '.') name[i] = '/';
// package prefix uses '/'
./compiler/methodMatcher.cpp: if (*lp == '.') *lp = '/'; // dots
build the package prefix
./classfile/javaAssertions.cpp: if (name_copy[i] == '.') name_copy[i]
= '/';
Thanks
- Ioi
On 10/5/19 3:50 PM, 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
>
> Testing: tier1-3
>
> Thanks!
>
> /Claes
More information about the hotspot-runtime-dev
mailing list