couple questions on method handle combinators

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 12 17:21:55 UTC 2017


Hi Roland,

The GWT forms contain some special profiling logic for the boolean branch and AFAICT counting forms for target invocation (of either branch) are created to block the JIT inlining until they have been called enough times. I believe for this logic to work correctly it requires execution in the interpreter, otherwise the LF update may not be visible, since final fields are trusted to be stable, once C2 gets hold if it it will think it constant. Vladimir will know much more than I.

This might all be getting in the way of what you want to achieve. It may be better for you to generate explicit byte code for that which you want to test (similar to that of recent tests David added).

Paul.


> On 12 Jun 2017, at 09:45, Roland Westrelin <rwestrel at redhat.com> wrote:
> 
> 
>> (I'll happily leave your other inlining questions to people more
>> knowledgeable in that area).
> 
> I could have phrased that question better. Let me try to give some
> context. For:
> 
> MethodHandles.guardWithTest(test77_mh_test, test77_mh1, test77_mh2);
> 
> AFAICT, the logic implemented by the lambda forms is:
> 
> MethodHandle mh = selectAlternative(test77_mh_test, test77_mh1, test77_mh2);
> mh.invoke(...);
> 
> So mh can't be a constant at the invoke if test77_mh_test returns either
> true and false.
> 
> I suppose I expected something like:
> 
> if (test77_mh_test.invoke()) {
>  test77_mh1.invoke();
> } else {
>  test77_mh2.invoke();
> }
> 
> in which case, at the invoke sites the method handles could be known.
> 
> The reason I'm experimenting with guardWithTest is that I'd like the
> lambda forms to follow a particular shape (to check if c2 can optimize
> the handling of the method handle call return properly):
> 
> if ( ) {
>  value_type_result = m1.invoke();
> } else {
>  value_type_result = m2.invoke();
> }
> // value type result merged here
> return value_type_result;
> 
> The merge of 2 return values is what I'm interested in. With a loop I
> expect I would get a similar pattern:
> 
> value_type_result = init_mh.invoke();
> for(;;) {
>  value_type_result = body_mh.invoke(); // value type result merged here
> }
> return value_type_result;
> 
> So I guess my question is: Is there no way to get guardWithTest to do
> what I want? Other than with loops and guardWithTest, is there another
> way to get a merge point with returned values from invokes?
> 
> Roland.



More information about the valhalla-dev mailing list