Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-07-11 Thread Chen Liang
On Thu, 29 Jun 2023 01:55:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-07-11 Thread Mandy Chung
On Thu, 29 Jun 2023 01:55:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-07-11 Thread Chen Liang
On Thu, 29 Jun 2023 01:55:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-07-11 Thread Mandy Chung
On Thu, 29 Jun 2023 01:55:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-07-11 Thread Chen Liang
On Thu, 29 Jun 2023 01:55:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-28 Thread Chen Liang
On Wed, 28 Jun 2023 19:15:02 GMT, Paul Sandoz wrote: >> I use this block to remove the overhead around MethodHandle and VarHandle >> infrastructure initialization (such as LF spinning) that is not related to >> any particular class; so that I measure only the impact of encountering a >> new cl

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v17]

2023-06-28 Thread Chen Liang
On Wed, 28 Jun 2023 23:08:28 GMT, Mandy Chung wrote: > I suggest to create a CSR to document the behavioral change to match the > specification. CSR filed for this behavior change; no spec updates but there's minor class-loading compatibility risk. I would be grateful if you can review the CSR

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v19]

2023-06-28 Thread Chen Liang
> 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 > Method

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v18]

2023-06-28 Thread Chen Liang
> 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 > Method

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v17]

2023-06-28 Thread Mandy Chung
On Wed, 28 Jun 2023 01:34:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-28 Thread Paul Sandoz
On Tue, 27 Jun 2023 23:33:25 GMT, Chen Liang wrote: >> test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java line >> 92: >> >>> 90: }); >>> 91: >>> 92: static { >> >> Is this static block required? > > I use this block to remove the overhead around Met

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-28 Thread Paul Sandoz
On Wed, 28 Jun 2023 00:08:35 GMT, Chen Liang wrote: >> The MH on VH case is worth considering; the indirect VH cases are already >> covered by `-Djava.lang.invoke.VarHandle.VAR_HANDLE_IDENTITY_ADAPT=true`. > > Done; added a test case to test initialization on toMethodHandle use in > latest push

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v17]

2023-06-28 Thread Paul Sandoz
On Wed, 28 Jun 2023 01:34:30 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v17]

2023-06-27 Thread Chen Liang
> 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 > Method

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Mandy Chung
On Tue, 27 Jun 2023 13:57:31 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v16]

2023-06-27 Thread Mandy Chung
On Wed, 28 Jun 2023 00:13:48 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Chen Liang
On Tue, 27 Jun 2023 23:33:57 GMT, Chen Liang wrote: >> 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

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v16]

2023-06-27 Thread Chen Liang
> 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 > Method

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Chen Liang
On Tue, 27 Jun 2023 21:14:23 GMT, Paul Sandoz wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Rollback VHG changes > > test/jdk/java/lang/invoke/VarHandles/LazyInitializingTest.java line 85: > >> 83: >> 84: @Te

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v15]

2023-06-27 Thread Chen Liang
> 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 > Method

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Paul Sandoz
On Tue, 27 Jun 2023 13:57:31 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Paul Sandoz
On Tue, 27 Jun 2023 13:57:31 GMT, Chen Liang 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 c

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-27 Thread Paul Sandoz
On Fri, 9 Jun 2023 18:59:41 GMT, Paul Sandoz wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove meaningless target calls and clear outdated cache as needed > > Something was bothering me about the current complex

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-27 Thread Chen Liang
On Fri, 9 Jun 2023 18:59:41 GMT, Paul Sandoz wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove meaningless target calls and clear outdated cache as needed > > Something was bothering me about the current complex

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v14]

2023-06-27 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v13]

2023-06-27 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v12]

2023-06-26 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-14 Thread Chen Liang
On Fri, 9 Jun 2023 18:59:41 GMT, Paul Sandoz wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove meaningless target calls and clear outdated cache as needed > > Something was bothering me about the current complex

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-11 Thread Chen Liang
On Thu, 8 Jun 2023 01:32:20 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-09 Thread Paul Sandoz
On Thu, 8 Jun 2023 01:32:20 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v11]

2023-06-07 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-07 Thread Chen Liang
On Thu, 8 Jun 2023 00:12:39 GMT, Paul Sandoz wrote: > Ok, yes, it's less likely now but possible a MH has been explicitly obtained > before the defining class has been intialized. In this case I still think we > can clear the table out after processing any existing entries, since > subsequent

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-07 Thread Paul Sandoz
On Wed, 7 Jun 2023 22:38:29 GMT, Chen Liang wrote: > > Change only the static field var handle implementations to call `target()`, > > since it is unnecessary on the others. > > Unfortunately, I don't think there is a convenient way for VH implementations > to easily unwrap the correct VH; a `

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v10]

2023-06-07 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-07 Thread Chen Liang
On Wed, 7 Jun 2023 20:26:47 GMT, Paul Sandoz wrote: > Change only the static field var handle implementations to call `target()`, > since it is unnecessary on the others. Unfortunately, I don't think there is a convenient way for VH implementations to easily unwrap the correct VH; a `target()`

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-07 Thread Paul Sandoz
On Wed, 7 Jun 2023 00:10:59 GMT, Paul Sandoz wrote: >>> I believe instead of changing the guards we can change the implementation >>> of the static methods on the concrete static VHs to call `asDirect()` (lets >>> also add `@ForceInline` on `asDirect`), since `linkToStatic` will pass the >>> a

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-06 Thread Chen Liang
On Wed, 7 Jun 2023 00:10:59 GMT, Paul Sandoz wrote: >>> I believe instead of changing the guards we can change the implementation >>> of the static methods on the concrete static VHs to call `asDirect()` (lets >>> also add `@ForceInline` on `asDirect`), since `linkToStatic` will pass the >>> a

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v9]

2023-06-06 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-06 Thread Paul Sandoz
On Tue, 6 Jun 2023 22:34:57 GMT, Chen Liang wrote: > Is this aimed at decreasing long-term invocation cost or the initial > invocation cost? FYI long-term invocation is already efficient enough; if > this is for initial invocation, which can potentially bypass costly MH > construction, I recom

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-06 Thread Chen Liang
On Tue, 6 Jun 2023 21:29:49 GMT, Paul Sandoz wrote: > I believe instead of changing the guards we can change the implementation of > the static methods on the concrete static VHs to call `asDirect()` (lets also > add `@ForceInline` on `asDirect`), since `linkToStatic` will pass the args to > t

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-06 Thread Paul Sandoz
On Fri, 2 Jun 2023 19:09:49 GMT, Mandy Chung wrote: > > I wonder if it is possible to transition from an lazy (indirect) VH to a > > direct VH once initialized i.e., `checkAccessModeThenIsDirect` returns the > > value of `initialized`. > > Sounds a good idea. Once the class is initialized, the

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v8]

2023-06-04 Thread Chen Liang
On Sun, 4 Jun 2023 16:12:46 GMT, ExE Boss wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Improve subsequent VH call performance, thanks exeboss > > src/java.base/share/classes/java/lang/invoke/LazyInitializingVarHan

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v8]

2023-06-04 Thread ExE Boss
On Sun, 4 Jun 2023 13:23:46 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v8]

2023-06-04 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v7]

2023-06-04 Thread Chen Liang
On Sat, 3 Jun 2023 03:47:40 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/lang/invoke/LazyInitializingVarHandle.java >> line 106: >> >>> 104: UNSAFE.ensureClassInitialized(refc); >>> 105: this.initialized = true; >>> 106: } >> >> This should probably have a fas

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v7]

2023-06-02 Thread Chen Liang
On Sat, 3 Jun 2023 02:25:59 GMT, ExE Boss wrote: >> Chen Liang has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove lazy init of MH, for all invocation of the Lazy VH needs this MH > > src/java.base/share/classes/java/lang/invoke/LazyI

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v7]

2023-06-02 Thread ExE Boss
On Sat, 3 Jun 2023 00:16:23 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v7]

2023-06-02 Thread Chen Liang
On Sat, 3 Jun 2023 00:16:23 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v7]

2023-06-02 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 02:37:13 GMT, Chen Liang wrote: > I've also updated the benchmark for the latest patch. Unfortunately the > regular invocations and lazy var handle initial call performance saw a > decrease. Maybe I misunderstood what you meant about "a decrease in performance". > The indir

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v6]

2023-06-02 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Chen Liang
On Fri, 2 Jun 2023 22:50:21 GMT, Mandy Chung wrote: > what performance results do you see with this change? The indirect VH invocation already has a performance similar to the direct invocation in JMH. Do you mean that I should add `asDirect` to the direct paths in VH and check the benchmark r

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 02:12:30 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Chen Liang
On Fri, 2 Jun 2023 16:29:13 GMT, Paul Sandoz wrote: > I wonder if it is possible to transition from an lazy (indirect) VH to a > direct VH once initialized i.e., `checkAccessModeThenIsDirect` returns the > value of `initialized`. Thereby we reduce the potential footprint cost of > inflating fu

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 02:12:30 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 02:12:30 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 16:29:13 GMT, Paul Sandoz wrote: > I wonder if it is possible to transition from an lazy (indirect) VH to a > direct VH once initialized i.e., `checkAccessModeThenIsDirect` returns the > value of `initialized`. Sounds a good idea. Once the class is initialized, the lazy VH

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Paul Sandoz
On Fri, 2 Jun 2023 17:16:09 GMT, Mandy Chung wrote: > > I think we only need to initialize Parent without initializing Child in > > this case. > > The bytecode behavior to access the field via > `lookup.findStaticVarHandle(Child.class, "value", int[].class)` is > `Child.value;`. The class or

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Mandy Chung
On Fri, 2 Jun 2023 02:37:13 GMT, Chen Liang wrote: > I think we only need to initialize Parent without initializing Child in this > case. The bytecode behavior to access the field via `lookup.findStaticVarHandle(Child.class, "value", int[].class)` is `Child.value;`. The class or interface t

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-02 Thread Paul Sandoz
On Fri, 2 Jun 2023 02:12:30 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-01 Thread Chen Liang
On Fri, 2 Jun 2023 02:12:30 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v4]

2023-06-01 Thread Mandy Chung
On Fri, 2 Jun 2023 01:19:26 GMT, Chen Liang wrote: > In addition, should we initialize the ref class or the declaring class only? > I don't think we need to initialize the ref class when declaring class > initialization should be sufficient, but that is a change in behavior. Declaring class wi

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

2023-06-01 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v4]

2023-06-01 Thread Chen Liang
On Thu, 1 Jun 2023 21:26:25 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v4]

2023-06-01 Thread Mandy Chung
On Thu, 1 Jun 2023 21:26:25 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indirec

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v4]

2023-06-01 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-06-01 Thread Chen Liang
On Thu, 1 Jun 2023 19:39:27 GMT, Mandy Chung wrote: > As for the implementation of `LazyStaticVarHandle`, I expect that > `makeFieldHandle` can always create the direct var handle (i.e. > `FieldStaticReadXXX` var handle) and then wrapped by `LazyStaticVarHandle` > similar to how `IndirectVarHa

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-06-01 Thread Mandy Chung
On Wed, 17 May 2023 17:20:37 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indire

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-05-26 Thread ExE Boss
On Wed, 17 May 2023 17:20:37 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indire

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-05-26 Thread Mandy Chung
On Wed, 17 May 2023 17:20:37 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indire

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-05-26 Thread Chen Liang
On Wed, 17 May 2023 17:20:37 GMT, Chen Liang wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >> `Indire

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v3]

2023-05-17 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v2]

2023-05-13 Thread Chen Liang
> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarHandle` to call `asDirect` lazily to accomodate the la

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Maurizio Cimadamore
On Fri, 5 May 2023 13:08:33 GMT, Chen Liang wrote: >> Also, perhaps @PaulSandoz knows more history on this one (I believe this >> code predates FFM). > > Eh? I am not sure what you mean here. This is the essence of the patch, where > the "TODO" above is fixed: lookup.findStaticVarHandle now cre

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Chen Liang
On Fri, 5 May 2023 13:02:05 GMT, Maurizio Cimadamore wrote: >> src/java.base/share/classes/java/lang/invoke/VarHandles.java line 110: >> >>> 108: } >>> 109: else { >>> 110: if (UNSAFE.shouldBeInitialized(refc)) { >> >> This seems unrelated to the issue this PR is re

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Maurizio Cimadamore
On Fri, 5 May 2023 13:03:14 GMT, Chen Liang wrote: >> src/java.base/share/classes/java/lang/invoke/IndirectVarHandle.java line 74: >> >>> 72: @Override >>> 73: public boolean isAccessModeSupported(AccessMode accessMode) { >>> 74: var directTarget = this.directTarget; >> >> Why i

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Chen Liang
On Fri, 5 May 2023 13:00:11 GMT, Maurizio Cimadamore wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Maurizio Cimadamore
On Fri, 5 May 2023 13:01:09 GMT, Maurizio Cimadamore wrote: >> Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. >> >> A few implementation-detail methods in VarHandle are now documented with the >> implied constraints to avoid subtle problems in the future. Changed >

Re: RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-05 Thread Maurizio Cimadamore
On Fri, 5 May 2023 04:48:09 GMT, Chen Liang wrote: > Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. > > A few implementation-detail methods in VarHandle are now documented with the > implied constraints to avoid subtle problems in the future. Changed > `IndirectVarH

RFR: 8291065: Creating a VarHandle for a static field triggers class initialization

2023-05-04 Thread Chen Liang
Also fixed the bug with NPE in `IndirectVarHandle::isAccessModeSupported`. A few implementation-detail methods in VarHandle are now documented with the implied constraints to avoid subtle problems in the future. Changed `IndirectVarHandle` to call `asDirect` lazily to accomodate the lazy VarHand