This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
dev:crosscompiler:backend_arm:exceptions [2019/08/15 18:42] – [Java Exceptions] ursgraf | dev:crosscompiler:backend_arm:exceptions [2019/11/15 16:32] – [Floats in Exceptions] ursgraf | ||
---|---|---|---|
Line 10: | Line 10: | ||
===== ARM 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. | 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. | ||
- | [{{ .:ppcexception.png? | + | [{{ .:armexception.png? |
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 // | 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 // | ||
The code generator has to create a special exception stack frame.\\ | The code generator has to create a special exception stack frame.\\ | ||
Line 17: | Line 17: | ||
===== Floats in Exceptions ===== | ===== Floats in Exceptions ===== | ||
+ | In order to save processing time, floating point registers are not saved when entering exception handling. If desired, however, all volatile EXTR's will be saved by a call to // | ||
+ | **Important: | ||
+ | **Important: | ||
Line 22: | Line 25: | ||
==== Supervisor Call Exception ==== | ==== 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: | 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: | ||
+ | * Get address of causing instruction into variable //addr// from LR. Must happen first, as the next step uses LR as scratch register. | ||
* increment counter | * increment counter | ||
- | * Get address of causing instruction into variable //addr// from LR. | ||
* Read instruction at this address minus 4, because LR points to next instruction | * Read instruction at this address minus 4, because LR points to next instruction | ||
* Determine from immediate value of instruction which kind of exception was thrown | * Determine from immediate value of instruction which kind of exception was thrown | ||
* If unchecked instruction: | * If unchecked instruction: | ||
- | * copy parameter // | + | * copy parameter // |
- | * copy parameter //addr// into register | + | * copy parameter //addr// into register |
* branch to compiler specific subroutine // | * branch to compiler specific subroutine // | ||
Line 37: | Line 40: | ||
* Search end of method from addr (end at pattern 0x000000yy) | * Search end of method from addr (end at pattern 0x000000yy) | ||
* Search exception in exception table at end of method → start < addr < end && exception instanceof type. | * Search exception in exception table at end of method → start < addr < end && exception instanceof type. | ||
- | * If exception is found → put handler address into SRR0, //rfi//. | + | * If exception is found → put handler address into PC. |
* If not found → | * If not found → | ||
- | - get address of call to this method (LR) from stack frame, copy into variable //addr// (in R3). | + | - get address of call to this method (LR) from stack frame, copy into variable //addr// (in R1). |
- replace LR in the stack frame with address of // | - replace LR in the stack frame with address of // | ||
- get address of epilog from exception table and branch to this address, this causes the unwinding of this method. | - get address of epilog from exception table and branch to this address, this causes the unwinding of this method. | ||
Line 46: | Line 49: | ||
The figure below gives an example for the handling of exceptions. | The figure below gives an example for the handling of exceptions. | ||
- | [{{ .:exceptionoverview.png?700 | //Example for handling of exceptions// | + | [{{ .:exceptionoverviewarm.png?700 | //Example for handling of exceptions// |