cpu: lower JNE after TEST in cpu_chained_aot #167

Merged
Vonsek merged 1 commit from upstream-pr/168 into main 2026-11-21 18:10:00 +00:00
Vonsek commented 2026-11-21 17:54:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T17:54:05Z.


Change

Support JNE_REL8_64 and JNE_REL32_64 after TEST_RM64_R64 in tools/cpu_chained_aot.py.

Previously, cpu_chained_aot only accepted JE_REL8_64 and JE_REL32_64 following TEST_RM64_R64. It now also lowers JNE_REL8_64 and JNE_REL32_64 using != 0 and inverted allocator_null tracking on the taken and fallthrough paths, while continuing to reject other conditional branch opcodes after TEST.

Adds:

  • a USE_JNE build variant (cpu_chained_jne / cpu_chained_jne_lifted) of tests/cpu/chained.asm in CMakeLists.txt;
  • differential native-vs-lifted checks for both the JE and JNE fixtures in tests/cpu/chained_check.py, plus a rejection control patching JE to JS (0x78);
  • matching documentation updates in docs/experiments.md under Chained function ranges and early returns.

Verification

Tested on Windows 11 x64, VS 2022 Build Tools 17.14 (MSVC 19.44.35230.0, ML64 14.44.35230.0), Windows SDK 10.0.26100, Python 3.12.10 (pefile==2024.8.26, iced-x86==1.21.0), at commit 25d03f5:

  • Before the change in tools/cpu_chained_aot.py, building cpu_chained_jne_lifted fails as expected:
    cmake --build --preset dev --target cpu_chained_jne_lifted
    expected JE after TEST at 0x1009
    
  • After the change:
    cmake --build --preset dev --target cpu_chained_lifted cpu_chained_jne_lifted cpu_callback_lifted cpu_destroy_lifted cpu_register_probe
    ctest --preset dev --no-tests=error -R '^cpu_aot_(chained_ranges|object_callback|destroy_contract)$' -V
    1/3 Test #62: cpu_aot_destroy_contract .........   Passed    0.10 sec
    2/3 Test #63: cpu_aot_object_callback ..........   Passed    0.17 sec
    3/3 Test #64: cpu_aot_chained_ranges ...........   Passed    0.33 sec
    100% tests passed, 0 tests failed out of 3
    
    (cpu_aot_chained_ranges output: two null paths, two non-null inputs (JE and JNE), RBX/RSI, guarded writes, version-2 chained unwind and eight rejection controls passed)

Evidence and follow-up

Both fixtures are assembled from the original MASM source in tests/cpu/chained.asm and compared against native Windows x64 execution with physical RBX/RSI and guard-slot verification.

Other TEST-followed branch conditions remain intentionally rejected unless needed by a concrete profile.

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.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532391535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/168). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T17:54:05Z. --- ## Change Support `JNE_REL8_64` and `JNE_REL32_64` after `TEST_RM64_R64` in `tools/cpu_chained_aot.py`. Previously, `cpu_chained_aot` only accepted `JE_REL8_64` and `JE_REL32_64` following `TEST_RM64_R64`. It now also lowers `JNE_REL8_64` and `JNE_REL32_64` using `!= 0` and inverted `allocator_null` tracking on the taken and fallthrough paths, while continuing to reject other conditional branch opcodes after `TEST`. Adds: - a `USE_JNE` build variant (`cpu_chained_jne` / `cpu_chained_jne_lifted`) of `tests/cpu/chained.asm` in `CMakeLists.txt`; - differential native-vs-lifted checks for both the `JE` and `JNE` fixtures in `tests/cpu/chained_check.py`, plus a rejection control patching `JE` to `JS` (`0x78`); - matching documentation updates in `docs/experiments.md` under **Chained function ranges and early returns**. ## Verification Tested on Windows 11 x64, VS 2022 Build Tools 17.14 (MSVC 19.44.35230.0, ML64 14.44.35230.0), Windows SDK 10.0.26100, Python 3.12.10 (`pefile==2024.8.26`, `iced-x86==1.21.0`), at commit `25d03f5`: - Before the change in `tools/cpu_chained_aot.py`, building `cpu_chained_jne_lifted` fails as expected: ```text cmake --build --preset dev --target cpu_chained_jne_lifted expected JE after TEST at 0x1009 ``` - After the change: ```text cmake --build --preset dev --target cpu_chained_lifted cpu_chained_jne_lifted cpu_callback_lifted cpu_destroy_lifted cpu_register_probe ctest --preset dev --no-tests=error -R '^cpu_aot_(chained_ranges|object_callback|destroy_contract)$' -V 1/3 Test #62: cpu_aot_destroy_contract ......... Passed 0.10 sec 2/3 Test #63: cpu_aot_object_callback .......... Passed 0.17 sec 3/3 Test #64: cpu_aot_chained_ranges ........... Passed 0.33 sec 100% tests passed, 0 tests failed out of 3 ``` (`cpu_aot_chained_ranges` output: `two null paths, two non-null inputs (JE and JNE), RBX/RSI, guarded writes, version-2 chained unwind and eight rejection controls passed`) ## Evidence and follow-up Both fixtures are assembled from the original MASM source in `tests/cpu/chained.asm` and compared against native Windows x64 execution with physical RBX/RSI and guard-slot verification. Other `TEST`-followed branch conditions remain intentionally rejected unless needed by a concrete profile. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:41:38 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T17:56:14Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T17:59:33.632571Z 25d03f5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066877954 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/168#issuecomment-7066877954). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T17:56:14Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"25d03f508a1dbab687d5ec29d3bcc0b2834d3e7d","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T17:59:33.632571Z">2026-11-21T17:59:33.632571Z</relative-time> | `25d03f5` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
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!167
No description provided.