feat(fiber): execute contextless fibers on the caller stack #10047
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10047"
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 boykopovar/AnyPS5. Originally posted by atharvjairath on 2026-10-23T06:15:26Z.
What
Contextless-execution follow-up to #9072. After that PR, running or switching to a fiber initialized with a null context and size zero still throws. This change executes it on the original calling thread's stack and restarts its entry after each yield. A context can subsequently be attached, after which the fiber retains its continuation normally.
Contextless switches restore the calling thread's Windows stack bounds, preserve the caller's nonvolatile registers and FPU state, and honor #9072's
0x100FPU initialization flag. ContextlesssceFiberGetInforeports no context or size-check margin.#9072 merged on 2026-10-24 as
d962e7b9b43b474da1e2a3af31d2ec37f38fb655. This branch now contains only the contextless follow-up,676a0e007250a92f8f768e95cb4cbf713abc57cc, directly on main933c0e4f1d502fc9702b990f2d6009179da3a40b. The redundant dependency commit has been dropped. The implementation, fixture, CMake registration and debt entry are byte-for-byte unchanged from the reviewed follow-up; the new tree has been rebuilt and retested.Semantics follow shadPS4 commit
f68923fe807f657348e6719ce658bcbd0a2b1c72: run, switch, and return. Not measured on a PS5; recorded in the existing debt entry.Overlap check: the refreshed scan and manual inspection found no competing contextless implementation. #6044 relocates and labels the fiber fixture; #7149 changes Windows host-stack allocation. Both peers conflict with main, so their shared-file diffs were inspected directly. The pre-push self-comparison with this PR's previous head is not competing work.
Tested
All current results below were rerun on exact head
676a0e007250a92f8f768e95cb4cbf713abc57cc, tree69dfc7ff3228dd9726c56612512cd5332066ded3, after rebasing onto main933c0e4f1d502fc9702b990f2d6009179da3a40b. Author and committer areatharvjairath <[email protected]>.libcandlibSceFiberlibraries andfiber_tests. Both focused modes pass under native ARM QEMU 11.0.3: 2/2, 0.13 s total (fiber0.06 s,fiber_contextless0.04 s).WINELOADERNOEXEC=1: 2/2, 6.72 s total (fiber3.34 s,fiber_contextless3.36 s). No assertions or write-watch behavior were disabled for these tests.-fno-sanitize-recover=all, instrumentinglibSceFiberand its fixture and linking the rebuilt, uninstrumented reallibc: 2/2, 0.12 s total (fiber0.05 s,fiber_contextless0.04 s).origin/main,git diff --check, and the refreshed overlap scan/manual review pass.These are focused runtime builds. Native x86 hardware, native Windows, whole-project builds, PS5 hardware and commercial titles remain untested. QEMU 11 is required in this Apple Silicon setup because the default x86 translation masks MXCSR DAZ; the FPU assertions remain intact.
Standalone focused build recipe
Run from the PR checkout in a Linux x86-64 build environment with GCC, CMake and Ninja. This writes the driver/build outside the repository and initializes the two pinned submodules (
zstd f8745da6,ZArchive 965b66c8).On my Apple Silicon host, the x86-64 container build additionally uses
-DCMAKE_CROSSCOMPILING_EMULATOR=/path/to/native-arm-qemu-x86_64with QEMU 11.0.3. Omit that option on a native x86-64 Linux host. The reported run used QEMU; native hardware and the whole-project build remain untested.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:25:57Z.
Review: COMMENTED
I reviewed the explicitly scoped follow-up range
f1612d73ede97701b24d293876540c7a7fdcad8f...9ba4da78f2afc1b0ff5a4815478ecad23559bd25, not the dependency implementation. In that range, the contextless switch path saves/restores the caller thread stack and bounds, starts the fiber trampoline with the target fiber, then clears the contextless saved stack when it yields. The tests cover restart after yield, repeated switches without stack growth, attached/contextless transitions, thread migration, nonvolatile registers, frame pointer, Windows stack bounds, and the0x100FPU behavior. The new debt entry clearly marks the semantics as inferred from shadPS4 rather than measured on hardware.The declared dependency #9072 is still open at
43d4eebe518da686d89629e6e7a386644f899214; the PR body correctly says to merge it first and drop that unchanged implementation commit when rebasing. So this review is limited to the follow-up range and does not treat the complete branch as independently mergeable.The focused Linux/Windows/Wine and UBSan runs in the description are detailed and consistent with the added coverage. Hosted eligibility, conventions, intake, labels, and progress-report checks pass; hosted product build jobs are skipped. I tried configuring a local focused build, but the fetched snapshot has uninitialized submodules (including SDL2), and
ANYPS5_RELINKER_ONLY=ONexcludescore/libs, sofiber_testsis not generated. No local fiber test ran. Please retain the matched current-main/dependency context when refreshing after #9072 lands, and rerun the focused tests on the resulting tree.