mirror of
https://github.com/sp00nznet/xboxrecomp.git
synced 2026-12-06 02:22:30 +00:00
3200511b73
The existing lifter tests compare emitted *text* against an expected string. That catches a rewrite that changes the form and nothing else, because nothing in the loop ever executes either side. Every bug in the v0.6.0 changelog was of the kind that passes such a test: `repe cmpsb` reporting equal regardless of input, `movaps` moving 4 of 16 bytes, a signed compare at the wrong width. This is ps3recomp's methodology, which transfers almost intact -- but it gets stronger here, and that is the point. ps3recomp has to check its PPU lifter against a *model* of PowerPC, because the host is not a PPC; a model can be wrong in the same places the lifter is. We target x86 and run on x86, so the host CPU is the reference implementation. There is nothing to disagree with. Per case, `tools/conformance` writes the snippet into an MSVC `__asm` block bracketed by nop markers, compiles with /FAc, reads the exact bytes back out of the listing (MSVC is the assembler -- we never hand-encode), lifts those bytes through the real Disassembler + lift_basic_block, and runs both the native function and the lifted C over the same inputs. 26 cases, 1,560 vectors, currently all passing. Inputs sit on the boundaries that separate a correct implementation from a plausible one -- 0x7F/0x80/0xFF, 0x7FFF/0x8000, INT_MIN, -1 -- since a bug that evaluates an 8-bit operand at 32 bits is invisible at 5 and obvious at 0xFF. It found one real gap: **stc/clc/cmc were unhandled** and lifted to `/* TODO: stc */`, so the carry a following adc/sbb reads kept whatever the last arithmetic left in it. MSVC emits these around multi-word arithmetic and the "return a bool in CF" idiom. Now lifted, and only when something downstream consumes CF -- which is also the only time the enclosing function declares _cf. It also found two bugs in itself first, both of which produced confident false reports, and both recorded in the doc because they generalise: - Lifting per-instruction instead of per-block. The peephole that turns cmp + jcc/setcc/cmovcc into a real condition lives at block level, so lift_instruction reports a stale `_flags` the block pass never emits. It claimed 22 failures in 60 on the first case; the lifter was correct. - The .cod byte column wraps after five bytes onto a continuation line with no address. Missing that silently dropped every instruction longer than five bytes -- every 32-bit immediate. A dropped instruction is the exact failure this tool exists to catch, so having it in the harness was worse than having no harness. The rule underneath both: if the harness does not drive the lifter exactly as the recompiler does, it is testing a path that does not ship. Runs under pytest too, skipped rather than failed without a 32-bit MSVC, so the suite stays meaningful on Linux. pytest tools/: 141 passed. x87/SSE state comparison and whole-function lifting (ps3recomp's lift_selftest.py shape) are the natural extensions; both are noted in docs/technical/conformance-testing.md. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PZDe6qTWAvohfDtYXbpRyM
0 lines
0 B
Python
0 lines
0 B
Python
The file is empty.