Exceptions and Exception Handling - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Exceptions and Exception Handling

Description:

Exceptions and Exception Handling. Yaodong Bi. Requirements for Exception Handling ... Forced branch mostly done at assembly level. Jsr pc, PRINT_CHAR. Jmp ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 6
Provided by: BI86
Category:

less

Transcript and Presenter's Notes

Title: Exceptions and Exception Handling


1
Exceptions and Exception Handling
  • Yaodong Bi

2
Requirements for Exception Handling
  • Simple to understand and use
  • The code for exception handling should not
    obscure understanding of normal operations
  • Run-time overheads are incurred only when
    handling an exception
  • Uniform treatment of exceptions
  • Recovery actions can be programmed

3
Exception handling in old languages
  • Use unused return value
  • If (function() ERROR)
  • // error handling
  • else
  • // normal operation
  • Forced branch mostly done at assembly level
  • Jsr pc, PRINT_CHAR
  • Jmp IO_ERROR // error handling
  • Jmp DEVICE_NOT_READY // error handling
  • //normal processing
  • Subroutine PRINT_CHAR would return to a different
    location by manipulating returning address.

4
Modern Exception Handling
  • Domain of an exception handler
  • The region of computation with which, if an
    exception occurs, the handler will be invoked
  • Exception propagation
  • Regard the absence of a handler as a programmer
    error, or the function must specify what
    exceptions it may raise handled by compiler
  • When no local handler can be found, the system
    looks for handlers up the chain of invokers at
    run-time propagation employed in Ada, C, and
    Java

5
Modern Exception Handling
  • Resumption and termination
  • Resumption
  • A handler is invoked as an implicit procedure
  • Figure 6.1
  • Termination
  • Control does not return to the point where the
    exception occurred.
  • The block/procedure containing the handler is
    terminated, and control returned back to the
    calling block/procedure
  • Figure 6.2
Write a Comment
User Comments (0)
About PowerShow.com