Effect cases in switch

Archie Cobbs archie.cobbs at gmail.com
Tue Dec 12 22:58:59 UTC 2023


On Tue, Dec 12, 2023 at 4:41 PM Remi Forax <forax at univ-mlv.fr> wrote:

> Your proposal is fighting against the physics of the VM, when you enter in
> an exception handler (a catch block), the whole stack disapear so you need
> some compiler magic to store everything which is on stack into locals
> before calling a switch expression so you can restore it inside the
> exception handler. I've implemented a very similar kind of transformation
> 10 years ago, it severly bloats the produced bytecode. Or maybe you are
> suggesting that this new switch will use a new bytecode construct (inline
> exception handler ?), it's more or less what JSR/RET was, but perhaps there
> is a better way.
>

What follows is a somewhat tangential point so don't let this hijack the
core discussion....

In theory the compiler could "synthesize" subroutines, but this runs into
verifier problems. See this thread
<https://mail.openjdk.org/pipermail/compiler-dev/2023-July/023848.html>
which relates to JDK-8308023.

So my tangential point is that perhaps this work, along with JDK-8308023,
might motivate some thinking about how the verifier could be "smartened up"
enough to allow the compiler to safely synthesize true subroutines.

(Personally, something about JDK-8308023 is really offensive .. a 30 line
program produces a 10MB class file.)

-Archie

-- 
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-observers/attachments/20231212/6c86ccd6/attachment.htm>


More information about the amber-spec-observers mailing list