On Tue, 27 Jun 2023 13:57:31 GMT, Chen Liang <li...@openjdk.org> wrote:
>> This patch implements lazy initialization for VarHandle working on static >> fields. It has a good initial call performance. >> >> We introduce a new internal API, `target()` to unpack a lazy VarHandle in VH >> implementation methods. If called via MethodHandle, a barrier is added in >> the MethodHandle instead. >> >> The new test ensures the correctness of Lazy VH for both direct and indirect >> invocation; the performance of MethodHandle version of lazy VH is not yet >> tested. >> >> >> Benchmark Mode Cnt Score >> Error Units >> LazyStaticColdStart.methodHandleCreateEager ss 10 41.490 ± >> 12.331 us/op >> LazyStaticColdStart.methodHandleCreateLazy ss 10 21.810 ± >> 16.964 us/op >> LazyStaticColdStart.methodHandleInitializeCallEager ss 10 57.860 ± >> 13.738 us/op >> LazyStaticColdStart.methodHandleInitializeCallLazy ss 10 93.300 ± >> 18.858 us/op >> LazyStaticColdStart.varHandleCreateEager ss 10 39.860 ± >> 9.362 us/op >> LazyStaticColdStart.varHandleCreateLazy ss 10 17.630 ± >> 1.111 us/op >> LazyStaticColdStart.varHandleInitializeCallEager ss 10 123.170 ± >> 62.468 us/op >> LazyStaticColdStart.varHandleInitializeCallLazy ss 10 105.390 ± >> 41.815 us/op > > Chen Liang has updated the pull request incrementally with one additional > commit since the last revision: > > Rollback VHG changes src/java.base/share/classes/java/lang/invoke/LazyInitializingVarHandle.java line 63: > 61: } > 62: > 63: @ForceInline Suggestion: @Override @ForceInline src/java.base/share/classes/java/lang/invoke/VarHandle.java line 2210: > 2208: > 2209: /** > 2210: * Computes a method handle that can be passed the {@linkplain > #target() direct} Suggestion: * Computes a method handle that can be passed the {@linkplain #asDirect() direct} ? test/jdk/java/lang/invoke/VarHandles/LazyInitializingTest.java line 85: > 83: > 84: @Test > 85: public void testInitializationOnVarHandleUse() { I think we will need to expand this to also test operating on a MH to a VH, an indirect VH, and on a MH to indirect VH. We could do this separately. test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java line 92: > 90: }); > 91: > 92: static { Is this static block required? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1244336226 PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1244362027 PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1244367651 PR Review Comment: https://git.openjdk.org/jdk/pull/13821#discussion_r1244367889