Pin call translator signed imm8, import name case, link-name and ASCII checks #1009
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1016"
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-23T21:21:36Z.
Change
This closes four gaps in the test coverage of
tools/cpu_call_aot.py. Each gap is shown by a small mutation of the translator that still passes the whole^cpu_suite onmainatca52bbc. The translator does not change; the native fixture DLL stays the reference for the differential cases.call_pair.asm:add rax, 11inmix_argsbecomessub rax, -11, written as the bytes48 83 E8 F5so the signed-imm8 encoding is pinned whatever the assembler picks (same result, same length)sub/add r64, imm8read as unsignedcpu_aot_call_paircall_pair_check.py: themov r8, rsireload before the second call replaced withmov rsi, rsiis refused (undefined register)cpu_aot_call_pair(already caught onmainbycpu_aot_repeated_call; added here for the two-callee caller)import_check.py: the modelled import descriptor names the provider DLL with different letter case and still bindscpu_aot_import_callimport_check.py: a named import given an explicit link name is refused (unexpected link name for named import)cpu_aot_import_callimport_check.py: an ordinal import bound with the link nameméis refused (unsupported C import name)cpu_aot_ordinal_importThe
sub rax, -11form keeps the native return value and the Python reference unchanged. The patched image is only translated, never executed, and the import models are only passed toresolve_import.docs/experiments.mddescribes the R8 control, the signed-imm8 form and the non-ASCII link name.Verification
On
a8d5f062(based onmainatca52bbc), Windows 11, MSVC 14.44.35207, Python 3.14:All 7 tests pass, and the docs check passes.
Each mutation was applied to
tools/cpu_call_aot.pyone at a time and the project was rebuilt. Withmainatca52bbc, the whole^cpu_suite passed under mutations 1, 3, 4 and 5, andcpu_aot_repeated_callfailed under mutation 2. With this branch, at least one of the seven tests above fails under each of the five; the last column names the check written for it. With the unmutated translator everything passes.The five edits to
tools/cpu_call_aot.py, numbered as in the table:imm = struct.unpack_from("b", body, pos + 3)[0]->"B"available.intersection_update({"rbx", "rsi"})->{"rbx", "rsi", "r8"}if dll.casefold() != provider.name.casefold() or symbol != name:->if dll != provider.name or symbol != name:raise ValueError(f"unexpected link name for named import {identity}")afterif not by_ordinal and link_name is not None:->link_name = Noneif not identifier.isascii() or not identifier.isidentifier():->if not identifier.isidentifier():Evidence and follow-up
No new fixture file: the
sub rax, -11bytes are intests/cpu/call_pair.asm, and the other cases are a byte patch or import models inside the checks. No follow-up is needed.Checklist
AI-assisted.