Switch vs if ?

John Rose john.r.rose at oracle.com
Fri Jan 19 01:03:26 UTC 2018

On Jan 17, 2018, at 2:42 PM, Remi Forax <forax at univ-mlv.fr> wrote:
> next we need a method handle combinator for the integer switch for amber.

With its own profiling, of course.

Also, method handle switch combinators have the potential to
grow dynamically, unlike static switches in bytecode.

This is a trick of PyPy, which "grows" basic blocks as
they are executed; each polymorphic dispatch point works
like an open-ended switch whose cases are all types
*encountered so far* at that point by the program.

So the default branch of a MH switcher could act like
an indy call site, and spin new cases whenever the old
ones don't match.

The underlying storage of the MH switcher should use a
@Stable array of per-case MH's, allowing good inlining.
For a growable switch, the array could either grow or split
out into sub-arrays as appropriate, as a growing HAMT.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20180118/a1468730/attachment.html>

More information about the hotspot-compiler-dev mailing list