Proposal: Optimizing Efficiency using Read-only Arrays

Brian Goetz brian.goetz at oracle.com
Thu Dec 29 16:42:28 UTC 2022


Freezing addresses nearly all of the concerns you raised, except one: that one might only want to share a part of any array with a callee, but once you share the reference, they can read outside the bounds of what you’ve shared.  

There are known techniques for addressing this as well, but probably best to get the big part of it done first (eliminating the inherent mutability of array references) and then come back for slices/spans.  

> On Dec 29, 2022, at 11:08 AM, Markus Karg <markus at headcrashing.eu> wrote:
> 
> Thank you, Kasper.
> 
> Actually this is not exactly the same but nearly related: Those two JEPs provide just one specific, possible solution ("freezing", i. e. turning previously writable array into read-only one) to the overall problem. There could be other solutions these JEPs explicitly do not aim: For example, another solution for my proposal is directly creating a read-only constant instead of creating a writable array and then "freezing" it afterwards (which, IIUC, will hold two objects in memory, a still writable one, and a read-only view). The aim of my PR is to discuss the final solution we actually want to go, and when.
> 
> -Markus
> 
> -----Ursprüngliche Nachricht-----
> Von: Kasper Nielsen [mailto:kasperni at gmail.com] 
> Gesendet: Donnerstag, 29. Dezember 2022 16:59
> An: Markus Karg
> Cc: amber-dev at openjdk.org
> Betreff: Re: Proposal: Optimizing Efficiency using Read-only Arrays
> 
> On Thu, 29 Dec 2022 at 16:46, Markus Karg <markus at headcrashing.eu> wrote:
>> 
>> Proposal: Optimizing Efficiency using Read-only Arrays
>> 
> 
> There are already two draft JEPs for this:
> 
> https://openjdk.org/jeps/8261099
> https://openjdk.org/jeps/8261007
> 
> /Kasper
> 
> 
> /Kasper
> 



More information about the amber-dev mailing list