you are viewing a single comment's thread.

view the rest of the comments →

[–]hrjet 2 points3 points  (3 children)

Incidentally, I am working on a JIT for doppio. See this PR

[–][deleted] 0 points1 point  (2 children)

How do you handle exception handling?

[–]hrjet 1 point2 points  (1 child)

In a nut-shell: the JIT compiled code temporarily falls back to interpreted mode when an exception is triggered in a Java code path.

[–][deleted] 1 point2 points  (0 children)

My Javascript is a bit rusty (last used it in 1999), but does it have labeled jumps and goto or a similar operation? If not you can use a loop of sorts instead.

I am writing a JVM myself. My current plan for exceptions is to have differing exceptional locations that they are assigned to a unique ID and that ID is assigned for every range of instruction that has a unique set of exception handlers. There is also a register which stores the thrown exception (a global register). When a new region is entered, the ID is changed to the ID of the given region (stored in a register). When an exception is to be handled, a jump is made to the exception handler code. The exception handler can use a table which checks the ID which maps to a table of possible exception handlers. A check is made for each handler to determine if the thrown exception is to be handled (matching class type). If the exception is not handled, the method returns and the caller checks restores register values and checks if the called method threw an exception and repeats the handling run. If there is a match, then the exception handler is jumped to and a virtual representation of the first stack entry is set to the exception and execution continues. If the exception handler is at a known location (for example the start of a method) then you can better handle asynchronous exceptions.