cpu: accept an inverted unsigned bound check in the jump-table translator #1164
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1171"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T02:24:20Z.
Change
Refs #317.
tools/cpu_switch_aot.pynow accepts the inverted unsigned bound check in front of a jump-table dispatch:cmp reg, limit; jb/jbe dispatch_block; jmp default. Before, only the fallthrough form (ja/jaeto the default) was recognized, and this shape was refused asunbounded jump-table index.JBandJBEenter the table in this form, withlimitandlimit + 1entries.JMPmust sit directly in front of the dispatch block. The branch must target the first instruction of the block and be the only edge that does.JA/JAEor a signed condition, a missingJMP, a branch past the top of the block, an index that is not the compared value.dispatch()andprove()only. No change to the ABI, frames, calls or data binding.Shared interface: none beyond
cpu_switch_aot.py. No open PR touches that file.Verification
Not run on Windows (no ML64 or MSVC here). The new CTest
cpu_aot_switch_invertedruns in the Windows jobs, including/O2.Linux (LLVM 19
llvm-mcandlld-linkfrom a GNU-syntax copy of the MASM source, mingw-w64 g++-O0and-O2for the translation, Wine 10 for the run):python3 -B tests/cpu/switch_inverted_check.py rejections <dll>: 19 rejection controls passed. Onorigin/mainthe same command fails at the first translation (unbounded jump-table index).-O0and-O2: all match the Python reference on return value and the three output words; the exchanged build changed only its two selectors (1/4, 1/5, 0/5). RBX/RSI are checked only by the Windows register probe.limitentries aborts at selector 4; no single-entry check accepts the two second-entry controls; JA accepted in the inverted form accepts the JA control.switch_check.py rejectionspasses on both (16 + 3 controls).tests/docs_links_check.py,tests/form_coverage_check.py,tests/bidi_controls_check.py: pass.Evidence and follow-up
tests/cpu/switch_inverted.asmis original MASM written for this test. It exportsinv_rva_jbe(MSVC layout, 32-bit JBE, 5 entries),inv_rel_jb(LLVM layout, 64-bit JB, 6 entries, one shared target; the default returns all ones and does not store) andinv_rel_window_jbe(LLVM layout, JBE, 7 entries, default in front of the check, zero-extending copy inside the block). Guard words on both sides of the stored word must not change, including for selectors past the table and selectors with upper bits set.Assumption: the MASM source assembles with ML64 as the existing fixtures do; I could only check an equivalent copy with LLVM.
docs/experiments.mdhas the new paragraph and the exact commands.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T03:06:10Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
1ced906ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.