Each PPC exception is caused by a synchronous or asynchronous event and causes the processor to switch to supervisor mode and jump to the proper exception vector.
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 and must conclude the method with the instruction rfi.
The reset exception must not have a prolog, as there is no stack yet. This poses a special problem if the space in the exception table is not sufficient to hold the code of the reset exception. In such a case simply calling a method is not allowed but must be handled by setting up a temporary stack pointer first.
In order to save processing time, floating point registers are not saved when entering exception handling. If desired, however, all volatile FPR's will be saved by a call to US.ENABLE_FLOATS() and the FP-Enable bit in the MSR will also be set. Nonvolatile FPR'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.
Each Java exception causes a PPC program exception. The handler receives the thrown exception as a parameter in the first parameter register R2. The code generator has to make sure that this parameter is copied into R2 during the prolog of the program exception handler. The handler does the following:
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.