Delayed Exception Handling for Code Motion Optimization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Optimizing compilers face limitations in moving code that may raise exceptions, as this can alter program semantics and result in different execution outcomes, particularly in environments where many instructions may raise exceptions, leading to inhibited code motion.
Innovation Solution
Implementing a system to selectively delay exceptions raised by relocated instructions, using data structures to track relocation information and managing exceptions at runtime to ensure they are handled at the original intended location, allowing for more flexible code optimization while preserving exception order and results.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Speed
If code is moved to optimize performance, then execution speed is improved, but program semantics may change due to exception ordering
Solution Approach 1:
The compiler performs preliminary analysis to identify exceptions that would be raised by relocated code and pre-generates delayed exception handling mechanisms. This allows code to be safely relocated while maintaining exception ordering through runtime delay of exception handling until the original location is reached.
Solution Approach 2:
A delayed exception handling mechanism acts as an intermediary between the relocated code and the exception handling system. This intermediary delays the actual exception handling until the appropriate time (when the original location is executed), thereby preserving program semantics while allowing code relocation for optimization.
2Reliability
If code motion is restricted to preserve exception order, then program semantics are maintained, but code optimization capability is reduced
Solution Approach 1:
The compiler performs preliminary analysis to identify exceptions that would be raised by relocated code and pre-generates delayed exception handling mechanisms. This allows code to be safely relocated while maintaining exception ordering through runtime delay of exception handling until the original location is reached.
Solution Approach 2:
The exception handling mechanism transitions from a static approach (where code cannot be relocated) to a dynamic approach where exceptions are delayed until the appropriate time. This dynamic delay mechanism allows flexible code motion while preserving semantic correctness at runtime.
3Device complexity
If exceptions are handled immediately at relocation point, then exception handling is simple, but computation results may be lost due to out-of-order handling
Solution Approach 1:
The compiler performs preliminary analysis to identify exceptions that would be raised by relocated code and pre-generates delayed exception handling mechanisms. This allows code to be safely relocated while maintaining exception ordering through runtime delay of exception handling until the original location is reached.
Solution Approach 2:
The delayed exception handling mechanism ensures continuous preservation of computation results by maintaining the logical sequence of exception handling. Even though code is relocated, the exception handling continues in the correct order by delaying until the original location is executed, preventing loss of computation results.
Data Source
AI summary
Systems, methods, media, and other embodiments associated with optimizing code motion with delayed exception handling are described. One exemplary system embodiment includes a data store to store information about a relocated instruction, a relocation logic to relocate instructions, and a run-time logic to detect exceptions raised by executed instructions. The run-time logic may selectively delay handling exceptions based on whether an executed instruction is a relocated instruction.


