cpu: cover eight jump-table translator semantics that no test observed #372

Manually merged
github merged 1 commit from gh-pr/372/head into gh-pr/372/base 2026-11-26 21:46:45 +00:00
Owner

@⁠Leyukaka on GitHub · 2026-11-21 23:39 UTC · original
Leyukaka:jump-table-controls → main · +56 −5 · 4 files · 1 commits · merged 2026-11-21 23:56 UTC

Change

This closes eight coverage gaps in the jump-table translator, tools/cpu_switch_aot.py. Each was a one-line mutation of the translator that passed every cpu_ test on main. Only the cpu_aot_narrow_returns fixture, its check and its CMake export list change; the translator does not.

tests/cpu/narrow.asm gains two exports:

  • qword_ops: a 64-bit imul rax, rdx; shl and sar of RDX by CL; and movsx r11, dl. Each result is written to the trace.
  • flag_results: inc al then sete; test then setb; cmp then setle and sets.

Both run on a focused input that pins the mutations, (32, 0x8000000000000080) and (255, 255), followed by the fixture's general input pairs. narrow_check.py computes their reference values in Python, independently of the translator.

Verification

On 06b7bd9 (branch on 9bdbb20), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -R '^cpu_aot_narrow_returns$' -V

It passes, and so does the full suite (146 of 146 tests).

Each mutation was applied to tools/cpu_switch_aot.py one at a time, followed by a rebuild and the whole cpu_ family. On main, all 42 cpu_ tests passed for each one. A control that swapped the e/ne conditions was caught by cpu_aot_jump_tables, so the run does detect a broken translator. On this branch, each mutation fails cpu_aot_narrow_returns:

Mutation Caught through
imul reads operand 0 twice qword_ops RAX: 0x1000 expected, 0x400 mutated
movsx source cast unsigned trace word 2: 0xffffffffffffff80 expected
QWORD CL count masked with 31 trace word 0: SHL by 32 must not be a no-op
64-bit sar source cast unsigned trace word 1: 0xffffffff80000000 expected
inc flags computed from the operand before the increment flag_results trace word 0: inc al from 255 sets ZF
test sets CF trace word 1: CF must be clear
le without equality trace word 2: setle at RCX == RDX
s as <= 0 RAX: sets after a zero difference

Evidence and follow-up

The fixture and check changes were drafted with Codex from the mutation list, then reviewed, built and mutation-tested locally. No open PR touches tests/cpu/narrow*. Similar gaps found in cpu_chained_aot.py/cpu_call_aot.py (six mutations) and pixel_aot.py (five) are queued as separate PRs.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-21 23:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/372) `Leyukaka:jump-table-controls` → `main` · +56 −5 · 4 files · 1 commits · merged 2026-11-21 23:56 UTC ## Change This closes eight coverage gaps in the jump-table translator, `tools/cpu_switch_aot.py`. Each was a one-line mutation of the translator that passed every `cpu_` test on `main`. Only the `cpu_aot_narrow_returns` fixture, its check and its CMake export list change; the translator does not. `tests/cpu/narrow.asm` gains two exports: - `qword_ops`: a 64-bit `imul rax, rdx`; `shl` and `sar` of RDX by CL; and `movsx r11, dl`. Each result is written to the trace. - `flag_results`: `inc al` then `sete`; `test` then `setb`; `cmp` then `setle` and `sets`. Both run on a focused input that pins the mutations, `(32, 0x8000000000000080)` and `(255, 255)`, followed by the fixture's general input pairs. `narrow_check.py` computes their reference values in Python, independently of the translator. ## Verification On `06b7bd9` (branch on `9bdbb20`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -R '^cpu_aot_narrow_returns$' -V ``` It passes, and so does the full suite (146 of 146 tests). Each mutation was applied to `tools/cpu_switch_aot.py` one at a time, followed by a rebuild and the whole `cpu_` family. On `main`, all 42 `cpu_` tests passed for each one. A control that swapped the `e`/`ne` conditions was caught by `cpu_aot_jump_tables`, so the run does detect a broken translator. On this branch, each mutation fails `cpu_aot_narrow_returns`: | Mutation | Caught through | |---|---| | `imul` reads operand 0 twice | `qword_ops` RAX: `0x1000` expected, `0x400` mutated | | `movsx` source cast unsigned | trace word 2: `0xffffffffffffff80` expected | | QWORD CL count masked with `31` | trace word 0: SHL by 32 must not be a no-op | | 64-bit `sar` source cast unsigned | trace word 1: `0xffffffff80000000` expected | | `inc` flags computed from the operand before the increment | `flag_results` trace word 0: `inc al` from 255 sets ZF | | `test` sets CF | trace word 1: CF must be clear | | `le` without equality | trace word 2: `setle` at `RCX == RDX` | | `s` as `<= 0` | RAX: `sets` after a zero difference | ## Evidence and follow-up The fixture and check changes were drafted with Codex from the mutation list, then reviewed, built and mutation-tested locally. No open PR touches `tests/cpu/narrow*`. Similar gaps found in `cpu_chained_aot.py`/`cpu_call_aot.py` (six mutations) and `pixel_aot.py` (five) are queued as separate PRs. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
qword_ops checks a 64-bit IMUL source, SHL and SAR by CL = 32 on a
negative 64-bit value, and MOVSX of a negative byte. flag_results checks
the ZF of INC wrapping AL, the CF that TEST clears, SETLE at equality and
the SF of a zero CMP difference. Each covers a cpu_switch_aot mutation
that passed every cpu_ test before.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:46:43 +00:00
github manually merged commit 06b7bd9893 into gh-pr/372/base 2026-11-26 21:46:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.