RFR: 8339642: Reduce overheads in InvokerBytecodeGenerator

Shaojin Wen swen at openjdk.org
Fri Sep 6 11:47:50 UTC 2024


On Fri, 6 Sep 2024 10:01:39 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> - A small portion (~5%) of the instrumented overhead when spinning MH/LF classes in `InvokeBytecodeGenerator` comes from creating the exact same `RuntimeVisibleAnnotationsAttribute` for every method. Introducing a couple of constants has a small but measurable impact.
> - `classDesc(MemberName.class)` is called ~8000 times during an OpenJDK build, `classDesc(MethodType.class)` ~900 - special casing looks profitable
> - Class name validation narrowed down, use ReferenceClassDescImpl.ofValidated
> - Various minor optimizations helping reduce bytecode size and speed up interpreter execution

src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 149:

> 147:         localsMap[0] = 0; // localsMap has at least one element
> 148:         for (int i = 1, index = 0; i < localsMap.length; i++) {
> 149:             Class<?> cl = mt.parameterType(i - 1);

Can we use var?

var cl = mt.parameterType(i - 1);

src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 230:

> 228:         // unique static variable name
> 229:         String name;
> 230:         List<ClassData> classData = this.classData;

var classData = this.classData;

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20887#discussion_r1746918308
PR Review Comment: https://git.openjdk.org/jdk/pull/20887#discussion_r1746919127


More information about the core-libs-dev mailing list