Browse Prior Art Database

Garbage Collection of C++ Exception Objects During Stack Unwinding

IP.com Disclosure Number: IPCOM000014049D
Original Publication Date: 2001-Jul-29
Included in the Prior Art Database: 2003-Jun-19
Document File: 4 page(s) / 58K

Publishing Venue

IBM

Abstract

IBM VisualAge C++ line of compilers use an exception handling design that can be conceptually broken into two distinct parts. Compiler generated code creates an object on the stack that describes an exception and calls the C++ runtime (libC.a for AIX/PowerPC and libC.so for AIX/IA64) to unwind the stack looking for a catch block region associated with the exception. When the runtime finds a catch region it returns control to conventional compiler generated code. The compiler generated code (catch region) performs error handling and then calls a routine entitled __CleanupCatch to restore the program’s hardware registers and remove the exception object(s) generated earlier.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 100% of the total text.

Page 1 of 4

Garbage Collection of C++ Exception Objects During Stack Unwinding

   IBM VisualAge C++ line of compilers use an exception handling design that can be conceptually broken into two distinct parts.

Compiler generated code creates an object on the stack that describes an exception and calls the

C++ runtime (libC.a for AIX/PowerPC and libC.so for AIX/IA64) to unwind the stack looking for a catch block region associated with the exception. When the runtime finds a catch region it returns control to conventional compiler generated code. The compiler generated code (catch region) performs error handling and then calls a routine entitled

__CleanupCatch to restore the program's hardware registers and remove the exception object(s) generated earlier.

This design relies on the program code communicating all necessary exception information to the C++ runtime library so that it can alter the program state correctly. However, when an exception is thrown from a catch block there is no mechanism to communicate to the runtime that an exception object is no longer valid and should be discarded.

A minimal example (in pseudo-code) is:


1.


2.

Page 2 of 4

The algorithm is diagrammed as follows:

2

Page 3 of 4

3

[This page contains 1 picture or other non-text object]

Page 4 of 4

This approach can be 'patched' into the current design with no loss of binary compatibility between program libraries.

4