Status

defect
RESOLVED WONTFIX
7 years ago
9 months ago

People

(Reporter: throdrig, Assigned: throdrig)

Tracking

Details

Attachments

(3 attachments)

halfmoon needs a basic implementation of exception handling mirroring how it's done in CodegenLIR.cpp.
Assignee: nobody → throdrig
Status: NEW → ASSIGNED
This is a relatively large change as it includes both the exception handling machinery plus fixes that are required to pass the acceptance tests once exception handling is implemented.  Enabling exception handling exposed some unfinished corners as well.  I've broken the overall patch into a couple parts.

The first part corrects the formatting specs at the beginning of several of the files.  The halfmoon code uses an indent of 2 but the formatting says 4 which makes emacs annoying.  At some point in V12 we should unify all our formatting since we're changing most of the source anyway.

The second patch is the changes to ast.py and hrdefs.py which are the descriptions of the instructions in the IR and automatically generate the files in halfmoon/generated.  The patch includes the autogenerated file updates which are quite large but not particularly interesting.  The IR changes were:

* a catchblock instruction to be the head of a catch
* changed setlocal to store in Atom form so that it can be read by catch as Atom instead of more precise type
* loadenv_env and callstatic changes to support static calls
* changes to the shape of the findprop routines required for proper handling of "with"
* added missing atom2ns
* debugline and debugfile instructions.  these aren't really wired up other than to support TRACE=1 for debugging of execution.

The third patch are the real changes.  The original intent was for every block to have a link to the exception handlers that covered some instruction in the block.  In practice this interacted badly with the setjmp/longjmp style exception handling since the actual edge went from the start block to the catch handler.  I changed the exception edges to maintain that relationship directly but left in the rest of the code required for the more precise tracking.

To ensure that the state of locals was properly maintained in the generated code I reused the safepoint and setlocal instructions.  I have plans for merge of the safepoint and deopt_safepoint machinery to make this a bit cleaner and more efficient but I decided to hold off on the rewrite of all that till we start tearing things up for V12.  The code in the presence of exception handling doesn't do any optimization of the storing of locals so it's less efficient than it should be.  The merge of safepoint and deopt_safepoint should fix that.

There are a bunch of changes having to do with traversing the added exception edges in various algorithms.  They all point to the need to unify the representation of the block ends instead of having the unique subclasses with their own representations.  I decided not to tackle that here.

In hm-liremitter.cpp I basically replicated the code from the CodegenLIR.cpp that does the exception dispatch.  I had to change the order that it was emitted because hm-liremitter.cpp has some logic that tries to validate the usage of LIR_live and it was unhappy with the backedges created by emitting the exception catch blocks after all the other blocks.  Currently they are emitted in the computed reverse post order usage for all other blocks so they are mixed in a bit.  This won't matter for LLVM since it will presumably do it's own block layout.  Hopefully most of the rest of the changes are relatively obvious.
Posted patch IR changesSplinter Review
Blocks: halfmoon
Tamarin is a dead project now. Mass WONTFIX.
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → WONTFIX
Tamarin isn't maintained anymore. WONTFIX remaining bugs.
You need to log in before you can comment on or make changes to this bug.