Implement jump fallthrough optimization in JIT - #20
Conversation
- Restructure JIT compilation into sessions that chain related blocks. - Elide trailing jumps to uncompiled blocks within a session to allow fallthrough. - Use a shared epilogue (pops and ret) via a session-wide exit label. - Maintain lazy entry point exposure, only updating `jit_info.entry` for the session's primary block. - Correctly handle internal jumps and multi-incoming edges using session-local labels. Co-authored-by: chc4 <1669003+chc4@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
| let exit_label = ops.new_dynamic_label(); | ||
| let mut session_labels = HashMap::new(); | ||
|
|
||
| let mut current_id = Some(id); |
There was a problem hiding this comment.
this logic seems complex and slow, and im not sure why its necessary? if you're already checking that the block doesn't already exist when we jit a block in order for it to be returned as a fallthrough why do you need this session_labels.contains_key stuff again. in general its hard to understand whats even going on here and feels much more complicated than it needs to be
There was a problem hiding this comment.
I've simplified the compilation loop as requested. The new logic directly follows fallthrough chains and drains the pending queue in a more straightforward manner. I also removed the greedy entry point assignment and stub generation, ensuring we strictly follow the lazy compilation strategy and only expose the entry point for the session's primary block.
- Restructure JIT compilation into sessions that chain related blocks. - Elide trailing jumps to uncompiled blocks within a session to allow fallthrough. - Use a shared epilogue (pops and ret) via a session-wide exit label. - Maintain lazy entry point exposure, only updating `jit_info.entry` for the session's primary block. - Correctly handle internal jumps and multi-incoming edges using session-local labels. - Simplified compilation loop to follow fallthrough chains directly and drain the pending queue efficiently. Co-authored-by: chc4 <1669003+chc4@users.noreply.github.com>
This change implements jump elision (fallthrough) optimization in the JIT. When a block ends in an unconditional jump to a target that hasn't been compiled yet, the JIT now places that target immediately after the current block and removes the jump instruction. Compilation sessions are now used to chain these blocks together, and they all share a single epilogue at the end of the session. Jumps between blocks within the same session use relative labels, while jumps to previously compiled sessions use absolute pointers. This implementation adheres to the project's lazy compilation strategy by only exposing the entry point for the block that triggered the JIT session.
PR created automatically by Jules for task 4900888967778220104 started by @chc4