Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-06-10 Thread Per Minborg
On Fri, 17 May 2024 09:31:33 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-21 Thread Chen Liang
On Fri, 17 May 2024 09:31:33 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-21 Thread Per Minborg
On Fri, 17 May 2024 09:31:33 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-20 Thread Chen Liang
On Mon, 20 May 2024 09:50:17 GMT, Jens Lidestrom wrote: >> Per Minborg has updated the pull request incrementally with two additional >> commits since the last revision: >> >> - Add benchmarks for memoized IntFunction and Function >> - Add benchmark for memoized supplier > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-20 Thread Jens Lidestrom
On Fri, 17 May 2024 09:31:33 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> > src="https://github.com/openjdk/jdk/assets/7457876/db4b22a1-af87-4914-adac-b05a87e7cb42; >> width=20% height=20%> >> >> ## Summary >> This PR proposes to introduce an internal _Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-17 Thread Per Minborg
On Fri, 17 May 2024 09:31:33 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v20]

2024-05-17 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v19]

2024-05-17 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v18]

2024-05-17 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v17]

2024-05-17 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v16]

2024-05-17 Thread Per Minborg
On Thu, 16 May 2024 12:48:24 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v16]

2024-05-16 Thread Olexandr Rotan
Is it possible to make stable values and collections Serializable? I see various applications for this feature in entity classes as a way to preserve immutability of entity fields and at the same time not break current JPA specifications. It is a *very* common task in commercial development.

Re: RFR: 8330465: Stable Values and Collections (Internal) [v16]

2024-05-16 Thread Per Minborg
On Thu, 16 May 2024 12:48:24 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v16]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v15]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v14]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v13]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Thu, 16 May 2024 11:14:16 GMT, Chen Liang wrote: >> The idea here is to have the most likely value in the middle... Not sure if >> that motivates the added complexity though. > > Is there any refernce on how/why the middle entry in a tableswitch > instruction is the fastest? It is only in

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Thu, 16 May 2024 11:13:24 GMT, Chen Liang wrote: >> It seems reasonable to assume `null` values are not constant-folded. For >> straight-out-of-the-box usage, there is no apparent significant difference >> as indicated by a new benchmark I just added: >> >> >> Benchmark

Re: RFR: 8330465: Stable Values and Collections (Internal) [v6]

2024-05-16 Thread Chen Liang
On Thu, 16 May 2024 07:29:21 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v12]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Chen Liang
On Thu, 16 May 2024 07:11:20 GMT, Per Minborg wrote: >> src/java.base/share/classes/jdk/internal/lang/stable/StableValueImpl.java >> line 139: >> >>> 137: case NON_NULL: { return valueVolatile(); } >>> 138: case ERROR:{ throw StableUtil.error(this); } >>> 139:

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Chen Liang
On Thu, 16 May 2024 06:54:26 GMT, Per Minborg wrote: >> Maybe the `state == NULL` check should be moved before `v != null`, as the  >> **JIT** doesn’t constant‑fold `null` [`@Stable`] values: >>

Re: RFR: 8330465: Stable Values and Collections (Internal) [v11]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v10]

2024-05-16 Thread ExE Boss
On Thu, 16 May 2024 09:01:22 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v10]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:26:57 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 15:49:22 GMT, Chen Liang wrote: >> Maybe there is a better home for this? > > I don't think we should publish this API; this will soon be phased out by > strict final fields (written only before super constructor calls) introduced > by Valhalla, as strict final fields are

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:29:08 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v9]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:31:15 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v8]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 19:07:26 GMT, Chen Liang wrote: >> Yes, according to the `@Stable` annotation’s JavaDoc, this is UB: >> https://github.com/openjdk/jdk/blob/8a4315f833f3700075d65fae6bc566011c837c07/src/java.base/share/classes/jdk/internal/vm/annotation/Stable.java#L74-L80 > > Fyi what usually

Re: RFR: 8330465: Stable Values and Collections (Internal) [v7]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v6]

2024-05-16 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Thu, 16 May 2024 07:19:54 GMT, Per Minborg wrote: >> src/java.base/share/classes/jdk/internal/lang/StableValue.java line 384: >> >>> 382: * @param the memoized type >>> 383: */ >>> 384: static Supplier ofSupplier(Supplier original) { >> >> `ofSupplier` sounds like this

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:25:04 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > > src/java.base/share/classes/jdk/internal/lang/StableValue.java

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:19:05 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 16:11:56 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-16 Thread Per Minborg
On Wed, 15 May 2024 18:45:16 GMT, ExE Boss wrote: >> src/java.base/share/classes/jdk/internal/lang/stable/StableValueImpl.java >> line 104: >> >>> 102: // Optimistically try plain semantics first >>> 103: final V v = value; >>> 104: if (v != null) { >> >> If `value ==

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Chen Liang
On Wed, 15 May 2024 18:49:49 GMT, ExE Boss wrote: >> src/java.base/share/classes/jdk/internal/lang/stable/StableValueImpl.java >> line 240: >> >>> 238: } >>> 239: } finally { >>> 240: supplying = false; >> >> Resetting a stable field is a bad idea.

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread ExE Boss
On Wed, 15 May 2024 16:10:06 GMT, Chen Liang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Switch to monomorphic StableValue and use lazy arrays > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread ExE Boss
On Wed, 15 May 2024 15:27:34 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Chen Liang
On Wed, 15 May 2024 15:27:34 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Chen Liang
On Mon, 6 May 2024 19:31:43 GMT, Per Minborg wrote: >> src/java.base/share/classes/jdk/internal/lang/StableArray.java line 25: >> >>> 23: * @since 23 >>> 24: */ >>> 25: public sealed interface StableArray >> >> Do we have a use case for StableArray beyond those of StableList? > > I am trying

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Chen Liang
On Wed, 15 May 2024 15:20:58 GMT, Per Minborg wrote: >> At some point in the future, 'jdk.unsupported' will be removed > > Maybe there is a better home for this? I don't think we should publish this API; this will soon be phased out by strict final fields (written only before super constructor

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Chen Liang
On Tue, 14 May 2024 11:12:39 GMT, Per Minborg wrote: >> src/hotspot/share/ci/ciField.cpp line 262: >> >>> 260: const char* stable_array3d_klass_name = >>> "jdk/internal/lang/StableArray3D"; >>> 261: >>> 262: static bool trust_final_non_static_fields_of_type(Symbol* signature) { >> >> Is

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Per Minborg
On Wed, 15 May 2024 15:27:34 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Per Minborg
On Wed, 15 May 2024 08:53:32 GMT, ExE Boss wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Revise docs for ofBackground() > > src/java.base/share/classes/jdk/internal/lang/StableValue.java line 1: > >> 1: /* > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v5]

2024-05-15 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Per Minborg
On Wed, 15 May 2024 12:26:34 GMT, Rémi Forax wrote: >> Given that `TrustedFieldType` is more generic than stable values, it could >> be moved to `jdk.internal.misc` or `jdk.internal.reflect`, then  >> `jdk.unsupported` could use it without exporting new packages to  >> `jdk.unsupported`. > > At

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Rémi Forax
On Wed, 15 May 2024 11:27:04 GMT, ExE Boss wrote: >>> Maybe export this interface to `jdk.unsupported`? >> >> I don't we should do that. In general, we need jdk.unsupported to go away in >> the long term. Also integrity of the platform depends on java.base being >> very stingy and not

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread ExE Boss
On Wed, 15 May 2024 10:43:52 GMT, Alan Bateman wrote: >> src/java.base/share/classes/jdk/internal/lang/stable/TrustedFieldType.java >> line 14: >> >>> 12: * operations. >>> 13: */ >>> 14: public sealed interface TrustedFieldType >> >> Maybe export this interface to `jdk.unsupported`? > >>

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Alan Bateman
On Wed, 15 May 2024 08:49:46 GMT, ExE Boss wrote: > Maybe export this interface to `jdk.unsupported`? I don't we should do that. In general, we need jdk.unsupported to go away in the long term. Also integrity of the platform depends on java.base being very stingy and not exporting internal

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread ExE Boss
On Wed, 15 May 2024 07:48:42 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v4]

2024-05-15 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v3]

2024-05-15 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v2]

2024-05-15 Thread Per Minborg
On Tue, 14 May 2024 16:02:41 GMT, Viktor Klang wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove text in public class that references an internal class > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v2]

2024-05-14 Thread Viktor Klang
On Tue, 14 May 2024 14:51:20 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v2]

2024-05-14 Thread Viktor Klang
On Tue, 14 May 2024 14:51:20 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal) [v2]

2024-05-14 Thread Per Minborg
On Tue, 14 May 2024 14:19:44 GMT, Alan Bateman wrote: >> Per Minborg has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Remove text in public class that references an internal class > >

Re: RFR: 8330465: Stable Values and Collections (Internal) [v2]

2024-05-14 Thread Per Minborg
> # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values & Collections offer the performance and safety >

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Alan Bateman
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Mon, 22 Apr 2024 09:34:39 GMT, Per Minborg wrote: >> src/java.base/share/classes/jdk/internal/lang/stable/StableValueElement.java >> line 116: >> >>> 114: public V computeIfUnset(Supplier supplier) { >>> 115: // Todo: This creates a lambda >>> 116: return

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Fri, 19 Apr 2024 09:32:56 GMT, ExE Boss wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Chen Liang
On Wed, 17 Apr 2024 13:23:53 GMT, Maurizio Cimadamore wrote: >> I see what you mean. Initially, I thought it would be easy to create >> memorized functions but it turned out, that was not the case if one wants to >> retain easy debugability etc. So, I have added a couple of factory methods

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Maurizio Cimadamore
On Wed, 17 Apr 2024 11:12:37 GMT, Per Minborg wrote: >> Yes, consider the 3 capture scenarios: >> | API | Capture frequency | Capture Impact | Code Convenience | Flexibility | >> |-|---||--|-| >> | `StableValue.ofMap(map, k -> ...)`

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Mon, 22 Apr 2024 17:09:39 GMT, Chen Liang wrote: >> src/java.base/share/classes/jdk/internal/lang/StableValue.java line 130: >> >>> 128: * } else { >>> 129: * V newValue = supplier.get(); >>> 130: * stable.setOrThrow(newValue); >> >> If ::computeIfUnset allows racy

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Chen Liang
On Mon, 22 Apr 2024 16:16:39 GMT, Dan Heidinga wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Wed, 17 Apr 2024 14:24:59 GMT, Maurizio Cimadamore wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Chen Liang
On Tue, 23 Apr 2024 12:18:53 GMT, Per Minborg wrote: >> Good idea. > > Ahh. I thought you meant pattern matching in another place (which actually > turned out to be a really good idea). Here, however, we also need to get the > type parameters correct: > >

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Maurizio Cimadamore
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Dan Heidinga
On Tue, 23 Apr 2024 12:22:25 GMT, Per Minborg wrote: >> src/java.base/share/classes/java/lang/reflect/AccessibleObject.java line 193: >> >>> 191: * final fields declared in a {@linkplain Class#isHidden() >>> hidden class} >>> 192: * final fields declared in a {@linkplain

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Mon, 13 May 2024 12:18:28 GMT, Chen Liang wrote: >> As we need the array in both cases, how would such a solution look like >> without duplicating code? > > I was thinking about changing the StableEnumMap factory to directly take an > EnumSet/BitSet indicating the indices without

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Tue, 23 Apr 2024 09:17:29 GMT, Per Minborg wrote: >> src/java.base/share/classes/java/util/ImmutableCollections.java line 183: >> >>> 181:K key, >>> 182:Function>> extends V> mapper) { >>> 183:

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Tue, 14 May 2024 11:07:00 GMT, Per Minborg wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Mon, 22 Apr 2024 16:31:15 GMT, Dan Heidinga wrote: >> # Stable Values & Collections (Internal) >> >> ## Summary >> This PR proposes to introduce an internal _Stable Values & Collections_ API, >> which provides immutable value holders where elements are initialized _at >> most once_. Stable

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Dan Heidinga
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values

RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
# Stable Values & Collections (Internal) ## Summary This PR proposes to introduce an internal _Stable Values & Collections_ API, which provides immutable value holders where elements are initialized _at most once_. Stable Values & Collections offer the performance and safety benefits of final

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Wed, 17 Apr 2024 15:17:52 GMT, Per Minborg wrote: >> Also, I want to mention a few important differences between `@Stable` and >> Stable Values: >> >> Patterns: >> 1. Benign race (does not exist in StableValue API): multiple threads can >> create an instance and upload, any non-null

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Per Minborg
On Wed, 17 Apr 2024 14:07:05 GMT, Chen Liang wrote: > Question: > > 1. Will we ever try to expose the stable benign race model to users? > 2. Will we ever try to inline the stable values in object layout like a > stable field? 1. I think there is little or no upside in exposing the benign

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread ExE Boss
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Chen Liang
On Wed, 17 Apr 2024 15:17:52 GMT, Per Minborg wrote: >> Also, I want to mention a few important differences between `@Stable` and >> Stable Values: >> >> Patterns: >> 1. Benign race (does not exist in StableValue API): multiple threads can >> create an instance and upload, any non-null

Re: RFR: 8330465: Stable Values and Collections (Internal)

2024-05-14 Thread Chen Liang
On Tue, 16 Apr 2024 11:47:23 GMT, Per Minborg wrote: > # Stable Values & Collections (Internal) > > ## Summary > This PR proposes to introduce an internal _Stable Values & Collections_ API, > which provides immutable value holders where elements are initialized _at > most once_. Stable Values