RFR: 8306647: Implementation of Structured Concurrency (Preview)

Andrew Haley aph at openjdk.org
Tue May 23 15:31:42 UTC 2023


On Mon, 22 May 2023 18:42:02 GMT, Alan Bateman <alanb at 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


More information about the hotspot-dev mailing list