RFR: 8183137: [MVT] C2 doesn't eliminate redundant value type allocations inside loops

Roland Westrelin rwestrel at redhat.com
Thu Jul 13 15:54:58 UTC 2017


Thanks for looking at this, Tobias.

>> http://cr.openjdk.java.net/~roland/8183137/webrev.01/
>
> This looks good to me!
>
> Just some minor things:
> - little typo in valuetypenode.hpp:134  ValueTypeNode -> ValueTypePtrNode
> - for better readability, you could merge test95_mt/test95_mt3/test96_mt/test96_mt3 in ValueTypeTestBench.java because they are identical

Ok.

>> There are tests such as test95/test96 for which the allocation is still
>> not eliminated but could be by improving this further.
>
> Is this because C2 does not inline the non-static method handle calls?
> You've mentioned off-thread that you are working on fixing
> this. What's your plan there?

Yes. Actually, I found after I posted the webrev that test95/test96
don't behave as intended. I'll push a fixed version. Also, since I
posted the webrev, I changed the condition cfgnode.cpp line 1636 to:

if (req() > 2 && in(1) != NULL && in(1)->is_ValueTypeBase() && (can_reshape || in(1)->is_ValueType())) {

It's only safe to apply that transformation once we know all inputs to
the ValueTypePtr node.

My plan for the non constant method handle case is to transform:

(Phi ValueTypePtr#1 Node#2) to (Phi ValueTypePtr#1 CheckCast#2)

with a CheckCast to the type of the ValueTypePtr then push the CheckCast
through phi up until a call to a method handle linker. Modify the call
so it now returns the type of the CheckCast instead of __Value, add
projections to the call for all return values, allocate a new value type
right after the call and populate it with the values from the
projections, create a ValueTypePtr with the projection as field and the
new allocation as oop edge. Then let the current machinery push it down
through the Phis. I have it working on test95/test96.

Roland.


More information about the valhalla-dev mailing list