runtime: serve the Bink heap shim from era_heap #189

Manually merged
github merged 1 commit from gh-pr/189/head into gh-pr/189/base 2026-11-26 21:33:10 +00:00
Owner

@⁠raulmoracode on GitHub · 2026-11-21 18:10 UTC · original
raulmoracode:runtime/xmem-provider → main · +21 −4 · 4 files · 1 commits · merged 2026-11-21 18:13 UTC

Change

The Bink heap shim allocated with HeapAlloc and released with HeapFree, duplicating the policy that src/era_heap.cpp already implements from the decoded attribute word. The two could drift while both are described as XMemAlloc/XMemFree bindings.

windows_allocate now calls era_heap::allocate(bytes, flags) and windows_release calls era_heap::release_with_attributes(base, flags). The profile's guard (a nonempty payload needs 64 bytes of headroom) and the observer hooks used by the test are unchanged. The CMake target links src/era_heap.cpp and includes src.

bink_heap_check.py adds two direct calls to the binding: a 97- and a 129-byte request with 0x05e50000 must return a 32-byte-aligned, zeroed block, and the matching release must free it.

Fixes #188

Verification

Commit d4acade on Windows 10 22H2 build 19045.6466, VS Build Tools 2022 17.14, MSVC 14.44.35207, Windows SDK 10.0.26100, CMake 4.4.4, Python 3.12.10.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(cpu_aot_bink_heap|era_heap_)'

Result:

7/7 Test #60: cpu_aot_bink_heap ................   Passed    0.07 sec
100% tests passed out of 7

The seven are cpu_aot_bink_heap and the six era_heap_* scenarios, including era_heap_observed_words from #134.

Evidence and follow-up

The added assertions are the control for the changed allocation path: they read alignment and contents from the returned block. The previous HeapAlloc path made neither guarantee, so the check is meaningful even though a deterministic unaligned, dirty-memory allocator is not part of the fixture. The existing 32-residue loop in bink_heap_check.py still covers the caller's own headroom arithmetic.

The package-only case cpu_aot_bink_package_heap needs BINK_HEAP_IMAGE and was not run; this change does not touch its translation.

The remaining half of the shared contract is graphics memory: era_heap already serves GRAPHICS_1–6 through VirtualAlloc, but no experiment allocates from that path yet.

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.

AI-assisted.

**@⁠raulmoracode** on GitHub · 2026-11-21 18:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/189) `raulmoracode:runtime/xmem-provider` → `main` · +21 −4 · 4 files · 1 commits · merged 2026-11-21 18:13 UTC ## Change The Bink heap shim allocated with `HeapAlloc` and released with `HeapFree`, duplicating the policy that `src/era_heap.cpp` already implements from the decoded attribute word. The two could drift while both are described as `XMemAlloc`/`XMemFree` bindings. `windows_allocate` now calls `era_heap::allocate(bytes, flags)` and `windows_release` calls `era_heap::release_with_attributes(base, flags)`. The profile's guard (a nonempty payload needs 64 bytes of headroom) and the observer hooks used by the test are unchanged. The CMake target links `src/era_heap.cpp` and includes `src`. `bink_heap_check.py` adds two direct calls to the binding: a 97- and a 129-byte request with `0x05e50000` must return a 32-byte-aligned, zeroed block, and the matching release must free it. Fixes #188 ## Verification Commit `d4acade` on Windows 10 22H2 build 19045.6466, VS Build Tools 2022 17.14, MSVC 14.44.35207, Windows SDK 10.0.26100, CMake 4.4.4, Python 3.12.10. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^(cpu_aot_bink_heap|era_heap_)' ``` Result: ```text 7/7 Test #60: cpu_aot_bink_heap ................ Passed 0.07 sec 100% tests passed out of 7 ``` The seven are `cpu_aot_bink_heap` and the six `era_heap_*` scenarios, including `era_heap_observed_words` from #134. ## Evidence and follow-up The added assertions are the control for the changed allocation path: they read alignment and contents from the returned block. The previous `HeapAlloc` path made neither guarantee, so the check is meaningful even though a deterministic unaligned, dirty-memory allocator is not part of the fixture. The existing 32-residue loop in `bink_heap_check.py` still covers the caller's own headroom arithmetic. The package-only case `cpu_aot_bink_package_heap` needs `BINK_HEAP_IMAGE` and was not run; this change does not touch its translation. The remaining half of the shared contract is graphics memory: `era_heap` already serves `GRAPHICS_1`–`6` through `VirtualAlloc`, but no experiment allocates from that path yet. ## 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. _AI-assisted._
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:33:07 +00:00
github manually merged commit d4acadebf6 into gh-pr/189/base 2026-11-26 21:33:10 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.