couple questions on method handle combinators

Roland Westrelin rwestrel at redhat.com
Mon Jun 12 16:45:19 UTC 2017


> (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