cpu: cover seven string direction and single-transfer lowerings #716

Merged
Leyukaka merged 1 commit from upstream-pr/722 into main 2026-11-22 23:04:33 +00:00
Leyukaka commented 2026-11-22 22:52:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T22:52:02Z.


Change

This closes seven coverage gaps in the direction-flag tracking and single-element string transfers of tools/cpu_switch_aot.py. Each was a one-line mutation that passed every cpu_ test on main. The string fixture (tests/cpu/switch_strings.{asm,def,py}) and its counts in docs/experiments.md change; the translator does not.

New case Mutation it covers Kind
once_movsb_cleared: STD, then CLD, then one MOVSB (must step forward) CLD keeps the previous direction x86 semantics
one MOVSB with RSI = RDI on a PAGE_NOACCESS page (must fault) the copy skipped when RSI = RDI x86 semantics
bad_df_mixed_call: STD on one path before a call call checked only when DF is set on every path ABI rule (DF clear at calls)
bad_df_host_call: STD before a bound host call host calls exempt from the check ABI rule
bad_df_back_edge: STD on a loop back edge reaching RET back edges ignored by the DF propagation ABI rule
bad_once_stosb_rcx: RCX read after a call and one STOSB a single STOSB treated as defining RCX translator rule
67 a4 (addr32 MOVSB) lowered directly (must be rejected) the addressing check applied to REP forms only translator rule

The bad_* functions are only translated, never executed. bad_df_host_call uses the raw bytes of call [rip+0], and the check gives it a synthetic HostImport. The documented counts become 43 exports, 24,915 comparisons and 96 access violations, from this run.

Verification

On dfc7623 (branch on 787ace7), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14:

ctest --preset dev --no-tests=error -j 4

All 304 tests pass. tests/docs_links_check.py passes.

Each mutation was applied to tools/cpu_switch_aot.py one at a time, the project was rebuilt, and all cpu_ tests were run. On main, all of them passed for each mutation. A control that made STD leave DF clear was caught by cpu_aot_switch_strings, so the run does detect a broken translator. On this branch, each of the seven mutations fails cpu_aot_switch_strings.

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. (Counts only.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6548860836 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/722). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-22T22:52:02Z. --- ## Change This closes seven coverage gaps in the direction-flag tracking and single-element string transfers of `tools/cpu_switch_aot.py`. Each was a one-line mutation that passed every `cpu_` test on `main`. The string fixture (`tests/cpu/switch_strings.{asm,def,py}`) and its counts in `docs/experiments.md` change; the translator does not. | New case | Mutation it covers | Kind | |---|---|---| | `once_movsb_cleared`: STD, then CLD, then one MOVSB (must step forward) | CLD keeps the previous direction | x86 semantics | | one MOVSB with RSI = RDI on a `PAGE_NOACCESS` page (must fault) | the copy skipped when RSI = RDI | x86 semantics | | `bad_df_mixed_call`: STD on one path before a call | call checked only when DF is set on every path | ABI rule (DF clear at calls) | | `bad_df_host_call`: STD before a bound host call | host calls exempt from the check | ABI rule | | `bad_df_back_edge`: STD on a loop back edge reaching RET | back edges ignored by the DF propagation | ABI rule | | `bad_once_stosb_rcx`: RCX read after a call and one STOSB | a single STOSB treated as defining RCX | translator rule | | `67 a4` (addr32 MOVSB) lowered directly (must be rejected) | the addressing check applied to REP forms only | translator rule | The `bad_*` functions are only translated, never executed. `bad_df_host_call` uses the raw bytes of `call [rip+0]`, and the check gives it a synthetic `HostImport`. The documented counts become 43 exports, 24,915 comparisons and 96 access violations, from this run. ## Verification On `dfc7623` (branch on `787ace7`), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14: ```text ctest --preset dev --no-tests=error -j 4 ``` All 304 tests pass. `tests/docs_links_check.py` passes. Each mutation was applied to `tools/cpu_switch_aot.py` one at a time, the project was rebuilt, and all `cpu_` tests were run. On `main`, all of them passed for each mutation. A control that made STD leave DF clear was caught by `cpu_aot_switch_strings`, so the run does detect a broken translator. On this branch, each of the seven mutations fails `cpu_aot_switch_strings`. ## 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. - [x] I updated README/docs when a capability or build requirement changed. (Counts only.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:30 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!716
No description provided.