feat(libSceNKWebKit): implement WTF::ParkingLot and the Lock slow paths #14921
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14921"
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 w4rc0n on 2026-11-02T01:31:54Z.
What
Every WTF locking slow path in libSceNKWebKit was a
NotImplementedstub. Guest WebKit code stopped as soon as aWTF::Lockwas contended or aWTF::Conditionwaited, because their inline fast paths fall through to these exports. Eight of them now follow the pinned PS5 WebKit 11.x source:ParkingLot:parkConditionallyImpl,unparkOne,unparkOneImpl,unparkCountandunparkAll.unparkOneImplcallback run under the queue lock, andbeforeSleepruns after the lock is released.TimeWithDynamicClockTypedeadlines (past, finite and infinite) use the existing clocks. As in the source, a wall-clock deadline waits on the absolute wall time, so a clock change is seen; monotonic and approximate deadlines wait on the host's steady clock and recheck the same clock.UnparkResultis reported as the source reports it, andtimeToBeFairstays false because the pinned source never sets it.Lock::lockSlow,unlockSlowandsafepointSlow, using the one-byte protocol ofLockAlgorithmInlines.hon the guest's own byte (held bit 1, parked bit 2), so they work alongside the guest's inline fast paths.The guest's
ScopedLambdacallbacks are called through their function pointers, and theParkResult,UnparkResultandScopedLambdalayouts are pinned withstatic_assert. The parking state is allocated once and never freed, as WebKit's table is, so a thread that wakes during process exit doesn't touch a destroyed object.ParkingLot::forEachImplstaysNotImplementedbecause the guestWTF::Threadlayout isn't modelled. The debt entry records it, along with the single host queue and the fairness timing, which hasn't been measured on a console.Adapted source. The code adapted from the pinned source is now in its own file,
src/WtfLock.cpp, under a "Derived from" line and the upstream notice for each pinned source file, verbatim apart from trailing whitespace, the form #13766 uses: Apple's BSD notices fromLockAlgorithmInlines.h,LockAlgorithm.handParkingLot.cpp. Adapted: the lock slow path (LockAlgorithmInlines.h:40-103), the unlock slow path (:106-154), the safepoint wrapper (LockAlgorithm.h:141-145) and the fairness timer (ParkingLot.cpp:129-170). Independent: the park queue and the host glue, which stay inWtfSystem.cpp.tools/pr_overlap.pyon this head, withmainat0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge withmain, GitHub's file lists show none of them changing these exports either. #13992, #14172 and #15866 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14922, in the same stack.Tested
Debian 12, GCC 12.2, Linux 6.18, Release, at the head
43e5f65b65b95b14fcc2a5f6a75fe26880525385, no local changes:guest_nkwebkit_dates,guest_nkwebkit_numbers,nkwebkit_base,nkwebkit_config,nkwebkit_constants,nkwebkit_fastbitvector,nkwebkit_jsc,nkwebkit_palsessionid,nkwebkit_preferences,nkwebkit_resourceresponse,nkwebkit_webcoregeometry,nkwebkit_wtf,guest_nkwebkit_urlsandpublic_headerspass. At an earlier commit with the same patch,nkwebkit_wtfalso passed 20 repeated runs.nkwebkit_wtfcases cover:beforeSleep;beforeSleepand unlocking;unparkOneImplcallback with no waiter;UnparkResultflags;unparkCountandunparkAll, kept separate per address;safepointSlowhanding the lock straight to a parked thread.tools/progress.py: the eight exports count as implemented (libSceNKWebKit 1320, 1312 onmain), andforEachImplstays unimplemented.tools/check_conventions.pypasses.feat/nkwebkit-binary-semaphoreat its previous headf54a49c07fd92fbc915bd64bd9a8241ad532f2ca, which contains this PR's commit. It is AnyPS5'sBuildworkflow, dispatched in the author's fork withselect=true: the branch merged intomainatb11c7bf84f5d2f636ff60166cc3371bd071e24d5, built onwindows-latestwith WinLibs GCC 15.2 (MinGW-w64, UCRT). All 809 selected tests passed, none skipped, including the twelve NKWebKit tests,public_headersandpatched_libraries. A fork-internal pull request existed only to give the workflow a number. The rebase ontomainat0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4after #15911 changed onlydocs/dev/debt/libSceNKWebKit.md, sogit range-diffshows the code and tests under test are the same as at that run.Not built or run: macOS. A wall-clock jump during a wait was not tested. No title or homebrew was run.
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)Pull request closed