JIT Register Allocation via Local Variable Ordering
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Traditional JIT compilers for Java virtual machines are heavyweight and resource-intensive, making it impractical to use global analysis for keeping local variables in registers, which slows down program execution and consumes excessive memory, especially in embedded devices with limited resources.
Innovation Solution
A mechanism that separates methods into code blocks, flows local variables between blocks to maintain continuity, and optimizes register allocation by ordering local variables to minimize register movement, allowing many local variables to remain in registers across multiple blocks without needing to be loaded.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If traditional global analysis is used to allocate registers to local variables, then local variables can be kept in registers, but the JIT compiler becomes heavyweight and execution slows down
Solution Approach 1:
The method is divided into multiple code blocks, and register allocation is performed independently for each code block rather than globally across the entire method. This segmentation allows the JIT compiler to make local optimization decisions without performing expensive global analysis, thus maintaining execution speed while still keeping frequently used local variables in registers.
Solution Approach 2:
Instead of performing complete global analysis on all code, the invention applies partial analysis by focusing only on individual code blocks and their immediate needs. This partial action approach provides sufficient register allocation effectiveness for each block without the overhead of comprehensive global optimization.
2Reliability
If traditional global analysis is used for register allocation, then local variables can be kept in registers, but memory consumption increases
Solution Approach 1:
By segmenting the method into code blocks and performing register allocation locally for each block, the invention reduces the memory overhead associated with global analysis data structures. Each code block's register allocation only requires information about that specific block, rather than maintaining global state information for the entire method.
3Device complexity
If local variables are frequently loaded into registers, then register allocation can be simple, but execution speed decreases due to loading overhead
Solution Approach 1:
The invention performs preliminary analysis within each code block to identify which local variables should be kept in registers before execution. By determining register allocation in advance for each block, the system avoids the need for frequent loading operations during execution, thus maintaining high execution speed without requiring overly complex allocation mechanisms.
Data Source
AI summary
A compilation mechanism is disclosed for facilitating the keeping of local variables in the same hardware registers across multiple code blocks. In one implementation, each code block has a list of local variables associated therewith. This list of local variables represents the local variables that should be loaded into registers prior to entering a code block. For multiple code blocks, the various lists may have local variables in common. In one implementation, the mechanism orders the local variables in the various lists in such a manner that, as much as possible, the same local variables are placed in the same slots of the various lists. By doing so, the mechanism minimizes the movement of local variables from register to register when going from code block to code block.


