Transition Stack Frame for Cross-Compiler Exception Handling
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Different compilers for the same programming language use varying exception handling mechanisms, making it difficult for users to switch to a new compiler without recompiling legacy codes, as programs compiled with different mechanisms are hardly compatible.
Innovation Solution
A method that detects a target stack frame from the call stack to handle exceptions, supporting either one-phase or two-phase exception handling mechanisms, allowing for seamless integration and handling of exceptions across different mechanisms.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If different compilers use different exception handling mechanisms, then each compiler can optimize for its own mechanism, but programs compiled by different compilers are incompatible and users cannot switch compilers without recompiling
Solution Approach 1:
The patent introduces a transition stack frame as an intermediary between one-phase and two-phase exception handling mechanisms. This transition stack frame contains both one-phase exception information (exception object pointer, unwind terminator) and two-phase exception information (exception object pointer, unwind terminator, cleanup handler), enabling it to interface with both mechanisms and facilitate compatibility between compilers using different exception handling approaches
Solution Approach 2:
The transition stack frame is designed to serve multiple functions: it can handle exceptions from both one-phase and two-phase mechanisms, store exception information in both formats, and coordinate with different exception handling workflows. This multi-functionality allows a single stack frame structure to bridge the gap between different compiler exception handling implementations
2Productivity
If a user switches to a new compiler with an advanced exception handling mechanism, then they can benefit from improved compilation capabilities, but they must recompile all legacy codes which increases time and effort
Solution Approach 1:
The transition stack frame is prepared in advance during the compilation process with all necessary exception handling information for both one-phase and two-phase mechanisms. By pre-configuring the stack frame with dual-format exception information, the system eliminates the need for recompilation when switching between compilers, as the exception handling compatibility is established beforehand
3Ease of operation
If legacy code is not recompiled with the new compiler, then existing compiled programs can continue to run, but they cannot take advantage of the new compiler's exception handling mechanism
Solution Approach 1:
The transition stack frame acts as a mediator that enables legacy code to interact with the new compiler's exception handling mechanism. By incorporating both one-phase and two-phase exception information structures, the transition stack frame allows legacy code compiled with one mechanism to be handled by a new compiler using a different mechanism, maintaining both portability and reliability
Data Source
AI summary
Embodiments of the present disclosure relate to a method, system, and computer program product for exception handling. In some embodiments, a method is disclosed. According to the method, in response to an application throwing an exception, a target stack frame for handling the exception is detected from a call stack of the application. The call stack comprises a plurality of stack frames. One of the plurality of stack frames corresponds to a function called by the application and supports either a one-phase exception handling mechanism or a two-phase exception handling mechanism. In response to the target stack frame being detected from the call stack, the target stack frame is caused to handle the exception. In other embodiments, a system and a computer program product are disclosed.


