cpu: cover seven jump-table dispatch lowerings #669
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/675"
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 Leyukaka on 2026-11-22T19:22:50Z.
Change
This closes seven coverage gaps in the jump-table dispatch lowering of
tools/cpu_switch_aot.py. Each was a one-line mutation that passed everycpu_test onmain. The switch fixture, its check, its export list inCMakeLists.txtanddocs/experiments.mdchange; the translator does not.tests/cpu/switch.asmgainsselect_rel_edges: a three-entry LLVM-layout table bounded byJAE, with the default placed before the guard, all three entries aliasing one target placed more than 32 KiB before the table, and a zero DWORD after the table.switch_check.pyruns it on the source, translated and swapped-table builds, and adds three byte-patch rejection controls.select_rvapatched tocmp ecx, 7+JGE, must be rejectedJGEbound acceptedselect_rel_edgesbuilds and selector 3 takes the defaultJAEtable counted one entry too manyselect_rvatable load, must be rejectedselect_rel_edges(0, x)reaches the far targetselect_rel_edgesload base patched to R11, must be rejectedselect_rel_edges(3, x)takes the backwardJAEselect_rel_edges(2, x)reaches the third aliasTwo of the mutations (
JAEcount, 16-bit entries) make the translator rejectselect_rel_edges, so they fail at build time. The 16-bit case needs the target more than 32 KiB away, hence the padding.Verification
On
d3b58ee(branch onff7f68a), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14:All 295 tests pass.
tests/docs_links_check.pypasses.Each mutation was applied to
tools/cpu_switch_aot.pyone at a time, and allcpu_tests were run. Onmain, all of them passed for each mutation. A control that dropped the+ 1forJAbounds was caught bycpu_aot_jump_tablesandcpu_aot_image_data, so the run does detect a broken translator. On this branch, five mutations failcpu_aot_jump_tables, and the other two fail the build because the translation ofselect_rel_edgesis rejected (edge at RVA ... overlaps an instruction,edge outside owned ranges). With the third-alias mutation, the lifted function reachesabort(), which in a Debug build opens the CRT dialog, so that case ends only when the dialog closes.Checklist
AI-assisted.