An apparatus and method are provided for detecting and handling exceptions. Instructions
that are executed only when there is an exception pending are qualified by a first
predicate register in a predicate register pair. Instructions that are executed
only when there is no exception pending are qualified based on a second predicate
register in the predicate register pair. When an exception is thrown, a determination
is made as to whether or not the instruction that threw the exception is in a try
block, or range, of the method that threw the exception. If not, the first predicate
register predicated instruction to branch to a return stub for the method is generated.
If the instruction that threw the exception is in a try block of the method, the
first predicate register predicated instruction to branch to a snippet associated
with the method is generated.