Download presentation
Presentation is loading. Please wait.
1
Exception Delivery Requirement
After an exception, execution continues in the appropriate catch block with the correct program-visible state Exceptions may be explicitly raised by software (e.g. athrow), generated by the hardware (e.g. *(null)), or be asynchronous Java has precise exceptions constrains updates of both locals and globals
2
Example: NullPointerException (1)
A thread dereferences <null> OS captures hardware state; raises SIGSEGV SIGSEGV delivered to trap handler (C) trap handler identifies as NullPointer trap trap handler modifies stack/registers of Java thread to be as if the faulting instruction had called VM_Runtime.deliverException passing it a trap code and a VM_Registers object (captured hardware state of excepting thread) trap handler has PC, FP, SP, etc. full hardware state Intel look at the instruction and other aspects
3
Example: NullPointerException (2)
deliverException (Java) creates a java.lang.NullPointerException object while matching catch block not found Interpret stackframe to find machine code maps (exception tables) for current method Check for matching exception table entry for given pc and exception type If no match found, update VM_Register object to unwind stackframe (updates pc) GC is enabled when object is created, otherwise it is disabled Intel ORP delays creation of exception object until it is needed, may be useful if performance critical last step, simulates return from method
4
Example: NullPointerException (3)
When a catch block is found, update VM_Registers so catch block can find exception object (compiler-specific) modify VM_Registers to resume execution at first instruction in catch block restore VM_Registers to hardware, and resume execution (Default top-level catch block prints stackdump and terminates thread) 1a) Baseline: push exception object on expression stack 1a) Opt: put it at known static offset 1b) modifies the PC, plus some other stuff last step is to enable GC
5
Exception Delivery Example
Method with handler Throwing method Exception delivery methods
6
Implications for Optimization
Java's precise exceptions constrain order of potentially excepting instructions updates to local variables that are live in catch blocks updates to global memory Some approaches multiple versions of loops [Moreira, Midkiff, Gupta, TOPLAS 99] perform liveness at exception handlers [Gupta, Choi, Hind, ECOOP 00] could be static or dynamic ignore exception dependences, but add compensation code
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.