deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:backend_arm:exceptions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
dev:crosscompiler:backend_arm:exceptions [2019/08/05 09:32] – [ARM Exceptions] ursgrafdev:crosscompiler:backend_arm:exceptions [2019/08/05 17:49] – [Java Exceptions] ursgraf
Line 21: Line 21:
 ===== Java Exceptions ===== ===== Java Exceptions =====
 ==== Program Exception ==== ==== Program Exception ====
 +Each Java exception causes a ARM program exception. The 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 SRR0.
 +  * Read instruction at this address
 +  * Determine from type of instruction which kind of exception was thrown
 +  * If unchecked instruction: create exception such as //ClassCastException//, //ArrayIndexOutOfBoundsException//, etc.
 +  * copy parameter //exception// into register R2
 +  * copy parameter //addr// into register R3
 +  * branch to compiler specific subroutine //handleException//.
  
 +==== Subroutine handleException ====
 +The following steps have to be taken:
 +  * 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.
 +  * If exception is found → put handler address into SRR0, //rfi//.
 +  * If not found → 
 +     - get address of call to this method (LR) from stack frame, copy into variable //addr// (in R3).
 +     - replace LR in the stack frame with address of //handleException// subroutine.
 +     - get address of epilog from exception table and branch to this address, this causes the unwinding of this method.
 +
 +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.
 +[{{ .:exceptionoverview.png?700 | //Example for handling of exceptions//}}] 
dev/crosscompiler/backend_arm/exceptions.txt · Last modified: 2019/11/17 18:24 by ursgraf