Actually for the exception handler generated code, I can place it anywhere which would remove a check at the start of a method. If I follow the controlled exception route (where there are no asynchronous exceptions, note that I do not have Thread.stop which is a good thing here). If I place it at the end of the method then I would not need a check at the start. However, for stuff such as array access where bounds checks need to be performed, if there is an exception then it will have to be thrown by the generated code.


However, for asynchronous exceptions if one does occur then it will just appear in the current method being called. If it propogates upwards then how exceptions are normally handled would be used instead.


To locate jump targets, I can have jump indexes which are associated with a program.


For programs I will need a kind of index so a class which can provide indices as required.


For simplicity and some speed, I do not need to strictly follow SSA. The compiler will just perform basic cached optimizations.


I know how I can implement branching without requiring knowing the exact IDs of future basic blocks.


This also means I would not need an index factory which would be a bit ugly. Jumps can only be made to the start of basic blocks anyway.


I just need to figure out the potential jump targets for all operations then setup jump targets for all of them. Then once that is done, I can have a multiple of lists which define the operations to be placed within basic blocks. Then at program generation the lists can be turned into basic blocks and then sent to the program as required.


Also some operations such as getting and setting of fields would be terminal operations potentially (provided they are not final or have a known value).


So the first thing to do then would be to go through all operations and determine the jump targets that the operations jump to then exception handlers. The mapping of logical instructions to block builders will be setup. The block handlers can also have the register states such as which ones are active and which ones are temporary for example.


Actually with this new code route, I do not need to have a mutable NRProgram.