Exceptions

Terminology

Types of Java-Exceptions

ARM Exceptions

Each ARM exception is caused by a synchronous or asynchronous event and generally causes the processor to switch its state and jump to its proper exception vector.

ARM Exceptions and Interrupts

Exception classes and their corresponding exception methods have to be specified in the configuration. Instances of these classes are never created and therefore the object constructors are defined as synthetic and will not be translated into code.
The code generator has to create a special exception stack frame.
The ARM architecture reserves 4 bytes of memory at each exception vector. This is just enough to place a branching instruction there which causes the processor to jump to the right exception code.

Floats in Exceptions

In order to save processing time, floating point registers are not saved when entering exception handling. If an exception method calls a another method which uses EXTRs, however, all volatile EXTR's will be saved by a call to US.ENABLE_FLOATS(). Nonvolatile EXTR's, which are used in a method, will be saved on the stack by the prolog of a method in any case. US.ENABLE_FLOATS() has to be called in a exception method or in a method which is called by an exception method.
Important: A decrementer exception calls an action method. The decrementer class could be extended and its action method could be overridden. If this method of the subclass uses floats, you have to insert US.ENABLE_FLOATS() as well. Important: If an exception method or a method called by an exception method uses a method from java/lang/Math, you have to make sure that US.FLOAT_ENABLE() is called.

Java Exceptions

Supervisor Call Exception

Each Java exception causes a ARM supervisor call exception. The supervisor call handler receives the thrown exception as a parameter in the first parameter register R0. The code generator has to make sure that this parameter is copied into R0 during the prolog of the program exception handler. The handler does the following:

The supervisor call handler can use volatile registers freely. It further uses a few nonvolatile registers. However, these must be saved onto the stack at the start of the method and must be restored at the end.

Subroutine handleException

The following steps have to be taken:

When the unwinding of a method is done, the flow of control automatically returns to handleException, because we modified the stack frame accordingly.

The figure below gives an example for the handling of exceptions.

Example for handling of exceptions