Re: RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
On Mon, 17 Oct 2022 21:48:42 GMT, Ioi Lam wrote: >> Please review this small optimization. As shown in the JBS issue, most of >> the generated LambdaForm classes have a single ClassData, so we can get a >> small footprint/speed improvement. > > Ioi Lam has updated the pull request with a new target base due to a merge or > a rebase. The incremental webrev excludes the unrelated changes brought in by > the merge/rebase. The pull request contains four additional commits since the > last revision: > > - Merge branch 'master' into > 8295302-no-arraylist-for-single-classdata-for-lambdaform > - @mlchung comments > - @iwanowww comments > - 8295302: Do not use ArrayList when LambdaForm has a single ClassData src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 352: > 350: private Object classDataValues() { > 351: final List cd = classData; > 352: return switch(cd.size()) { Suggestion: return switch (cd.size()) { - PR: https://git.openjdk.org/jdk/pull/10706
Re: RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
On Tue, 18 Oct 2022 05:21:47 GMT, Ioi Lam wrote: >> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java >> line 346: >> >>> 344: >>> 345: /** >>> 346: * Returns an object to pass this.classData to the method >>> of the >> >> What about: >> >> Suggestion: >> >> * Returns the class data object that will be passed to >> `Lookup.defineHiddenClass`. >> * The classData is loaded in the method of the generated class. >> * If the class data contains only one single object, this method >> returns that single object. >> * If the class data contains more than one objects, this method returns >> a List. >> * >> * This method returns null if no class data. > > Actually, the classData is passed here: > > > private MemberName loadMethod(byte[] classFile) { > Class invokerClass = LOOKUP.makeHiddenClassDefiner(className, > classFile, Set.of()) > .defineClass(true, classDataValues()); > return resolveInvokerMember(invokerClass, invokerName, invokerType); > } > > > So it doesn't go through `Lookup.defineHiddenClass`. yes, it's an internal version that defines a hidden class, equivalent to calling `Lookup::defineHiddenClassWithClassData` (typo in my suggested wording), but it will bypass the security permission check and also returns the Class instead of Lookup (saving not to allocate a Lookup object). - PR: https://git.openjdk.org/jdk/pull/10706
Re: RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
On Tue, 18 Oct 2022 02:03:06 GMT, Mandy Chung wrote: >> Ioi Lam has updated the pull request with a new target base due to a merge >> or a rebase. The incremental webrev excludes the unrelated changes brought >> in by the merge/rebase. The pull request contains four additional commits >> since the last revision: >> >> - Merge branch 'master' into >> 8295302-no-arraylist-for-single-classdata-for-lambdaform >> - @mlchung comments >> - @iwanowww comments >> - 8295302: Do not use ArrayList when LambdaForm has a single ClassData > > src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java > line 346: > >> 344: >> 345: /** >> 346: * Returns an object to pass this.classData to the method >> of the > > What about: > > Suggestion: > > * Returns the class data object that will be passed to > `Lookup.defineHiddenClass`. > * The classData is loaded in the method of the generated class. > * If the class data contains only one single object, this method returns > that single object. > * If the class data contains more than one objects, this method returns > a List. > * > * This method returns null if no class data. Actually, the classData is passed here: private MemberName loadMethod(byte[] classFile) { Class invokerClass = LOOKUP.makeHiddenClassDefiner(className, classFile, Set.of()) .defineClass(true, classDataValues()); return resolveInvokerMember(invokerClass, invokerName, invokerType); } So it doesn't go through `Lookup.defineHiddenClass`. - PR: https://git.openjdk.org/jdk/pull/10706
Re: RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
On Mon, 17 Oct 2022 21:48:42 GMT, Ioi Lam wrote: >> Please review this small optimization. As shown in the JBS issue, most of >> the generated LambdaForm classes have a single ClassData, so we can get a >> small footprint/speed improvement. > > Ioi Lam has updated the pull request with a new target base due to a merge or > a rebase. The incremental webrev excludes the unrelated changes brought in by > the merge/rebase. The pull request contains four additional commits since the > last revision: > > - Merge branch 'master' into > 8295302-no-arraylist-for-single-classdata-for-lambdaform > - @mlchung comments > - @iwanowww comments > - 8295302: Do not use ArrayList when LambdaForm has a single ClassData Thanks for the update.I made the suggested wording. You can push once it's updated. src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java line 346: > 344: > 345: /** > 346: * Returns an object to pass this.classData to the method > of the What about: Suggestion: * Returns the class data object that will be passed to `Lookup.defineHiddenClass`. * The classData is loaded in the method of the generated class. * If the class data contains only one single object, this method returns that single object. * If the class data contains more than one objects, this method returns a List. * * This method returns null if no class data. - Marked as reviewed by mchung (Reviewer). PR: https://git.openjdk.org/jdk/pull/10706
Re: RFR: 8295302: Do not use ArrayList when LambdaForm has a single ClassData [v3]
> Please review this small optimization. As shown in the JBS issue, most of the > generated LambdaForm classes have a single ClassData, so we can get a small > footprint/speed improvement. Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision: - Merge branch 'master' into 8295302-no-arraylist-for-single-classdata-for-lambdaform - @mlchung comments - @iwanowww comments - 8295302: Do not use ArrayList when LambdaForm has a single ClassData - Changes: - all: https://git.openjdk.org/jdk/pull/10706/files - new: https://git.openjdk.org/jdk/pull/10706/files/5a800f0d..eb05b9ef Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk=10706=02 - incr: https://webrevs.openjdk.org/?repo=jdk=10706=01-02 Stats: 4613 lines in 133 files changed: 2969 ins; 1034 del; 610 mod Patch: https://git.openjdk.org/jdk/pull/10706.diff Fetch: git fetch https://git.openjdk.org/jdk pull/10706/head:pull/10706 PR: https://git.openjdk.org/jdk/pull/10706