Compiler Assertion Code Removal for Static Compilation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing static compilers struggle to efficiently remove redundant code, particularly for assertions, which can lead to performance issues during static compilation of native images.
Innovation Solution
A computer-implemented method that determines if a compiler option is provided to enable assertions for a reachable class, checks for the presence of an API to enable assertions, and verifies if assertions are executed before class initialization. If not, the method removes assertion-related code from the reachable class.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If static compilation is performed to generate native images before running the service, then compilation time is reduced and runtime performance is improved, but redundant assertion code remains in the compiled output causing increased binary size and unnecessary runtime overhead
Solution Approach 1:
The patent extracts and removes redundant assertion-related code from the native image during static compilation. The compiler identifies assertion statements and their associated metadata, then selectively removes them from the compiled output when assertions are determined to be unnecessary, thereby reducing binary size and runtime overhead while preserving essential functionality.
Solution Approach 2:
The patent performs assertion code removal as a preliminary action during the static compilation phase, before the native image is deployed for runtime execution. By analyzing and removing redundant assertion code during compilation, the system prepares an optimized binary that eliminates unnecessary code paths, reducing both binary size and potential runtime overhead without affecting execution correctness.
2Reliability
If assertion code is retained in the native image, then debugging and verification capabilities are maintained, but binary size increases and runtime performance decreases due to unnecessary code execution
Solution Approach 1:
The patent applies local quality by making the presence of assertion code spatially selective within the binary. Instead of uniformly including or excluding all assertion code, the compiler performs local analysis to identify and remove only those assertion statements that are redundant or unnecessary, while preserving assertion code in locations where it serves a functional purpose. This results in a binary with non-uniform code distribution optimized for both size and reliability.
Solution Approach 2:
The patent discards redundant assertion code during compilation by identifying assertion statements that can be safely removed, while recovering and preserving necessary assertion code that contributes to program correctness. The compiler analyzes assertion semantics and control flow to determine which assertions can be discarded without affecting program behavior, and which must be retained for verification purposes.
3Manufacturing precision
If comprehensive assertion analysis is performed during static compilation, then redundant code removal accuracy is improved, but compilation time increases due to additional analysis overhead
Solution Approach 1:
The patent applies partial action by performing assertion analysis only on the subset of code that is actually reachable and relevant to the native image, rather than analyzing the entire source codebase. The compiler identifies reachable classes and methods through static analysis, then focuses assertion removal efforts only on those portions, reducing the overall analysis overhead while maintaining high accuracy for the critical code paths.
Solution Approach 2:
The patent replaces exhaustive mechanical analysis of all code with a more efficient analysis system that leverages existing compilation infrastructure and metadata. By substituting comprehensive source-level analysis with targeted analysis of already-compiled intermediate representations and runtime metadata, the system achieves high removal accuracy with reduced compilation overhead.
Data Source
AI summary
Embodiments determine that a compiler option is not provided to enable an assertion for a reachable class in a target application, determine that there is no application program interface (API) being used to enable the assertion found in a reachable method in the reachable class, determine that there is no assertion being executed before an initialization of the reachable class, and remove assertion related code from the reachable class.


