[lworld+vector] RFR: 8319972: [lworld+vector] Enable intrinsification of Unsafe.finishPrivateBuffer.

Jatin Bhateja jbhateja at openjdk.org
Thu Nov 16 07:22:53 UTC 2023


On Wed, 15 Nov 2023 06:22:29 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:

>> Re-enabling intrinsification of Unsafe.finishPrivateBuffer to fix performance degradation seen in Vector API JMH micro benchmarks. It's intrinsifation was disabled to fix incorrectness caused due to missing inductive InlineType Phi node in loops with Unsafe.put* operations. Since Unsafe.put* APIs returns a void hence JVM state is not altered and ciTypeFlow dataflow analysis does not encounter a inductive definition in the loop, due to this C2 parser misses creating an inductive phi node on
>> encountering [loop header block](https://github.com/openjdk/valhalla/blob/lworld%2Bvector/src/hotspot/share/opto/parse1.cpp#L696). 
>> 
>> In order to maintain IR compliance with ciTypeFlow analysis C2 should prevent scalarizing value object b/w make and finish private buffer calls.
>> 
>> New behavior of unsafe inline expanders
>> 1) makePrivate: Receive InlineTypeNode input and return initialized buffer in larval state.
>> 2) finishPrivateBuffer: Receive value object buffer input and return rematerialize InlineTypeNode in non-larval state.
>> 
>> This may result into creation of unbalanced phi node at control flow merges where one of the phi input may InlineTypeNode and other is a buffer of compatible value type, but the IR still remains valid.
>> 
>> In addition compiler is now preventing elimination of allocation in larval state.
>> 
>> Validation Status:-
>>   - All the VectorAPI JTREG tests are now passing at various AVX level with / wo -XX:+DoptimizeALot.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> Jatin
>
> src/hotspot/share/opto/graphKit.cpp line 1968:
> 
>> 1966:         // and transition the allocation into larval state.
>> 1967:         ret = ret->as_InlineType()->make_larval(this);
>> 1968:       }
> 
> As my understanding, the expected behavior is compiler should guarantee the returned `InlineTypeNode` has a larval state buffer after calling `makePrivateBuffer()`, right? Why do we still need this here?

This it to handle larval state propagation if makePrivateBuffer is not inline expanded, in such a case native implementation gets called and at compile time there is not way to detect larval state.

> src/hotspot/share/opto/macro.cpp line 964:
> 
>> 962:   if (alloc->_larval) {
>> 963:     return false;
>> 964:   }
> 
> Does it need to also add such checks in `InlineTypeNode::make_scalar_in_safepoints` ?

With new behavior, a value object in larval state is already allocated over heap and should not be scalarized to InlineTypeNode.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/952#discussion_r1395247961
PR Review Comment: https://git.openjdk.org/valhalla/pull/952#discussion_r1395248178



More information about the valhalla-dev mailing list