RFR: 8339317: Optimize ClassFile writeBuffer

Shaojin Wen swen at openjdk.org
Fri Aug 30 12:20:31 UTC 2024


On Thu, 29 Aug 2024 21:49:58 GMT, Shaojin Wen <swen at openjdk.org> wrote:

> A small optimization, optimize the BufferWriter implementation and use of ClassFile, provide faster patchInt and skip

I debugged the code and watched the compile log, patchInt calls are frequent. For example, the following call stack:


patchInt:164, BufWriterImpl (jdk.internal.classfile.impl)
writeTo:856, UnboundAttribute$AdHocAttribute (jdk.internal.classfile.impl)
writeAttribute:233, Util (jdk.internal.classfile.impl)
writeAttributes:240, Util (jdk.internal.classfile.impl)
writeTo:53, AttributeHolder (jdk.internal.classfile.impl)
writeTo:153, DirectMethodBuilder (jdk.internal.classfile.impl)
writeList:247, Util (jdk.internal.classfile.impl)
build:187, DirectClassBuilder (jdk.internal.classfile.impl)
build:125, ClassFileImpl (jdk.internal.classfile.impl)
build:332, ClassFile (java.lang.classfile)
classFileSetup:261, InvokerBytecodeGenerator (java.lang.invoke)
generateCustomizedCodeBytes:540, InvokerBytecodeGenerator (java.lang.invoke)
generateCustomizedCode:518, InvokerBytecodeGenerator (java.lang.invoke)
compileToBytecode:845, LambdaForm (java.lang.invoke)
makePreparedLambdaForm:302, DirectMethodHandle (java.lang.invoke)
preparedLambdaForm:230, DirectMethodHandle (java.lang.invoke)
preparedLambdaForm:215, DirectMethodHandle (java.lang.invoke)
preparedLambdaForm:224, DirectMethodHandle (java.lang.invoke)
make:106, DirectMethodHandle (java.lang.invoke)
make:127, DirectMethodHandle (java.lang.invoke)
make:132, DirectMethodHandle (java.lang.invoke)
basicInvoker:96, Invokers (java.lang.invoke)
<init>:1102, LambdaForm$NamedFunction (java.lang.invoke)
<init>:1354, LambdaForm$Name (java.lang.invoke)
makeReinvokerForm:160, DelegatingMethodHandle (java.lang.invoke)
makeReinvokerForm:120, DelegatingMethodHandle (java.lang.invoke)
chooseDelegatingForm:112, DelegatingMethodHandle (java.lang.invoke)
<init>:50, DelegatingMethodHandle (java.lang.invoke)
<init>:465, MethodHandleImpl$AsVarargsCollector (java.lang.invoke)
<init>:462, MethodHandleImpl$AsVarargsCollector (java.lang.invoke)
makeVarargsCollector:453, MethodHandleImpl (java.lang.invoke)
asVarargsCollector:1516, MethodHandle (java.lang.invoke)
withVarargs:1201, MethodHandle (java.lang.invoke)
setVarargs:1720, MethodHandle (java.lang.invoke)
getDirectMethodCommon:4122, MethodHandles$Lookup (java.lang.invoke)
getDirectMethodNoSecurityManager:4065, MethodHandles$Lookup (java.lang.invoke)
getDirectMethodForConstant:4314, MethodHandles$Lookup (java.lang.invoke)
linkMethodHandleConstant:4262, MethodHandles$Lookup (java.lang.invoke)
linkMethodHandleConstant:628, MethodHandleNatives (java.lang.invoke)
concat6String:167, StringConcat (jmh)
concat6String:174, StringConcatTest (jmh)
main:239, StringConcatTest (jmh)

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

PR Comment: https://git.openjdk.org/jdk/pull/20780#issuecomment-2319149595


More information about the core-libs-dev mailing list