[lworld+vector] RFR: 8319972: [lworld+vector] Enable intrinsification of Unsafe.finishPrivateBuffer.
Xiaohong Gong
xgong at openjdk.org
Thu Nov 16 08:28:52 UTC 2023
On Thu, 16 Nov 2023 07:29:46 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:
>> src/hotspot/share/opto/inlinetypenode.cpp line 1039:
>>
>>> 1037: kit->insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out_or_null(AllocateNode::RawAddress));
>>> 1038:
>>> 1039: return InlineTypeNode::make_from_oop(kit, obj, vk->inline_klass(), !vk->maybe_null());
>>
>> I think this is the root cause of incorrectness in https://bugs.openjdk.org/browse/JDK-8317659. The field values of the `InlineTypeNode` are not updated from the changed oop buffer.
>>
>> So can we just make `Unsafe.finishPrivateBuffer()` accept `InlineTypeNode` like before, checking its oop is in larval state, and return `make_from_oop()` here?
>
> Following is the API sequence to modify a vector lane.
>
>
> obj = Unsafe.makePrivateBuffer(Value.default);
> Unsafe.putDouble(obj, OFFSET, value);
> obj = Unsafe.finishPrivateBuffer(obj);
>
>
> In case putDouble is not in-line expanded, compiler makes a call to Unsafe_MakePrivateBuffer native implimentation. There is no way for compiler to detect any JVM state changes since put* returns a void. Thus finishPrivateBuffer will directly use default value and this will cause incorrectness, preventing scalarization ie. creating an InlineTypeNode b/w make and finish private buffer will fix this problem.
Per my personal understanding, I see that we may miss the memory dependency for above case with the original `fnishPrivateBuffer()` intrinsifaction. But with above changes, it can add the memory dependency to `Unsafe.putDouble`, as `make_from_oop()` can generate the load operations from the private buffer. So the issue is fixing. Right?
I still cannot undersand the relationship with `scalarization` happened between them, as the memory dependence is added (the buffer has def-use) between them, how the scalarization is happened? Please correct me if any misunderstanding!
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/952#discussion_r1395317585
More information about the valhalla-dev
mailing list