On Mon, 22 May 2023 18:42:02 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/ScopedValue.java line 399:
>> 
>>> 397:             var prevSnapshot = scopedValueBindings();
>>> 398:             var newSnapshot = new Snapshot(this, prevSnapshot);
>>> 399:             return runWith(newSnapshot, new CallableAdapter<R>(op));
>> 
>> Can we just do this instead?
>> Suggestion:
>> 
>>             return runWith(newSnapshot, op::get);
>> 
>> IIUC the current approach is to avoid the dynamic creation of a class via 
>> the invoke dynamic? I don't fully understand the comment about release 
>> fencing.
>
> @theRealAph will want to comment on this as it is very performance sensitive. 
> I think CallableAdapter.s is non-final to avoid the release fence.

That's right. The problem is that we can never get rid of the release fence, 
apparently even when the instance of the adapter is scalar replaced. I imagine 
that'll get fixed one day, but this is internal JDK code.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13932#discussion_r1202492523

Reply via email to