feat(libSceNKWebKit): implement 53 branchy call wrappers translated from the module #23999

Closed
RiverWhy wants to merge 23 commits from upstream-pr/23999 into main
RiverWhy commented 2026-11-20 00:41:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-20T00:41:09Z.


What

Implements 53 libSceNKWebKit exports whose module body has forward branches (no loops, globals, stack locals, atomics or indirect calls) and calls other named exports. All 53 throw NotImplemented on main today. Stacked on #23758 (lifted wrappers), which is stacked on #23755 (lifted leaf functions); it reuses src/LiftedAbi.hpp and Call from them.

Source: the libSceNKWebKit.sprx with SHA-256 3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d (the module the existing Constant-return exports debt entry reads as 11.00). Each body was translated instruction by instruction into C++ with the same translator as #23758, extended with forward-branch lowering:

  • Every branch, call, load and store keeps its order. Every call keeps its target and all six argument registers as the module leaves them.
  • The result width is the width the body returns (a path that never writes rax returns void). Parameter and return types are register widths, not source prototypes.
  • A low (null-page) address throws std::invalid_argument where the module would fault.
  • Callees are declared in the existing export headers (libSceNKWebKit.hpp); this PR declares none.

42 distinct callees: 5 are implemented today, 37 are still stubs. 49 of the 53 exports therefore throw NotImplemented from a callee until that callee is implemented (the same as the forwarded exports, #23758 and the jump-outs PR); 4 are fully working today.

Exports that call still-stubbed exports:

  • WKAccessibilityRootObject: _ZN7WebCore13AXObjectCache10rootObjectEv, _ZN7WebCore13AXObjectCache19enableAccessibilityEv, _ZNK7WebCore8Document13axObjectCacheEv
  • _ZN3JSC12StackVisitor5Frame8sourceIDEv: _ZN3JSC14SourceProvider5getIDEv
  • _ZN3JSC17DebuggerCallFrame20sourceIDForCallFrameEPNS_9CallFrameE: _ZN3JSC14SourceProvider5getIDEv
  • _ZN3JSC9Structure16isValidPrototypeENS_7JSValueE: _ZN3JSC6JSCell9getObjectEv
  • _ZN3WTF10StringView16GraphemeClusters8IteratorD1Ev: _ZN3WTF31NonSharedCharacterBreakIteratorD1Ev
  • _ZN3WTF10StringView16GraphemeClusters8IteratorD2Ev: _ZN3WTF31NonSharedCharacterBreakIteratorD1Ev
  • _ZN7WebCore11MemoryCache14evictResourcesEv: _ZN7WebCore11MemoryCache11setDisabledEb
  • _ZN7WebCore12EventHandler30setCapturingMouseEventsElementEPNS_7ElementE: _ZN7WebCore4Node14removedLastRefEv
  • _ZN7WebCore13JSDOMRectListD1Ev: _ZN7WebCore11DOMRectListD1Ev
  • _ZN7WebCore13JSDOMRectListD2Ev: _ZN7WebCore11DOMRectListD1Ev
  • _ZN7WebCore13JSDOMRectListaSERKS0_: _ZN7WebCore11DOMRectListD1Ev
  • _ZN7WebCore13displayStringERKN3WTF6StringEPKNS_4NodeE: _ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE
  • _ZN7WebCore20HTMLFrameElementBase5widthEv: _ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsENS0_18RunPostLayoutTasksE, _ZNK7WebCore4Node9renderBoxEv
  • _ZN7WebCore20HTMLFrameElementBase6heightEv: _ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsENS0_18RunPostLayoutTasksE, _ZNK7WebCore4Node9renderBoxEv
  • _ZN7WebCore22makeRangeSelectingNodeERNS_4NodeE: _ZNK7WebCore4Node16computeNodeIndexEv
  • _ZN7WebCore23ApplicationCacheStorageC1ERKN3WTF6StringES4_: _ZN7WebCore14SQLiteDatabaseC1Ev
  • _ZN7WebCore23ApplicationCacheStorageC2ERKN3WTF6StringES4_: _ZN7WebCore14SQLiteDatabaseC1Ev
  • _ZN7WebCore23MediaQueryParserContextC1ERKNS_8DocumentE: _ZNK7WebCore8Document4pageEv
  • _ZN7WebCore23MediaQueryParserContextC2ERKNS_8DocumentE: _ZNK7WebCore8Document4pageEv
  • _ZN7WebCore26makeBoundaryPointAfterNodeERNS_4NodeE: _ZNK7WebCore4Node16computeNodeIndexEv
  • _ZN7WebCore27makeBoundaryPointBeforeNodeERNS_4NodeE: _ZNK7WebCore4Node16computeNodeIndexEv
  • _ZN7WebCore30makeRangeSelectingNodeContentsERNS_4NodeE: _ZNK7WebCore13ContainerNode15countChildNodesEv
  • _ZN7WebCore4Node11appendChildERS0_: _ZN7WebCore13ContainerNode11appendChildERNS_4NodeE
  • _ZN7WebCore4Node11removeChildERS0_: _ZN7WebCore13ContainerNode11removeChildERNS_4NodeE
  • _ZN7WebCore4Node6removeEv: _ZN7WebCore13ContainerNode11removeChildERNS_4NodeE
  • _ZN7WebCore4toJSEPN3JSC14JSGlobalObjectERNS_9DOMWindowE: _ZN7WebCore4toJSEPN3JSC14JSGlobalObjectERNS_11WindowProxyE, _ZNK7WebCore9DOMWindow5frameEv
  • _ZN7WebCore8JSPath2DD1Ev: _ZN7WebCore6Path2DD1Ev
  • _ZN7WebCore8JSPath2DD2Ev: _ZN7WebCore6Path2DD1Ev
  • _ZN7WebCore8JSPath2DaSERKS0_: _ZN7WebCore6Path2DD1Ev
  • _ZN7bmalloc13IsoSharedPage9tryCreateEv: _ZN7bmalloc11IsoPageBase18allocatePageMemoryEv
  • _ZN9Inspector22InspectorDebuggerAgent19clearExceptionValueEv: _ZN9Inspector21InjectedScriptManager19clearExceptionValueEv
  • _ZN9Inspector31NetworkBackendDispatcherHandler20LoadResourceCallbackD1Ev: _ZN9Inspector17BackendDispatcherD2Ev
  • _ZN9Inspector32DatabaseBackendDispatcherHandler18ExecuteSQLCallbackD1Ev: _ZN9Inspector17BackendDispatcherD2Ev
  • _ZN9Inspector32DatabaseBackendDispatcherHandler18ExecuteSQLCallbackD2Ev: _ZN9Inspector17BackendDispatcherD2Ev
  • _ZNK7WebCore12NamedNodeMap6lengthEv: _ZNK7WebCore7Element13hasAttributesEv
  • _ZNK7WebCore13HitTestResult11textContentEv: _ZNK7WebCore4Node11textContentEb
  • _ZNK7WebCore13HitTestResult15absoluteLinkURLEv: _ZNK7WebCore7Element15absoluteLinkURLEv
  • _ZNK7WebCore14DocumentLoader21archiveResourceForURLERKN3WTF3URLE: _ZN7WebCore25ArchiveResourceCollection21archiveResourceForURLERKN3WTF3URLE
  • _ZNK7WebCore14FrameSelection18isFocusedAndActiveEv: _ZNK7WebCore8Document4pageEv
  • _ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv: _ZNK7WebCore16VisibleSelection19rootEditableElementEv
  • _ZNK7WebCore16DOMGuardedObject11isSuspendedEv: _ZNK7WebCore17ActiveDOMCallback17canInvokeCallbackEv
  • _ZNK7WebCore20ScrollingCoordinator32coordinatesScrollingForFrameViewERKNS_9FrameViewE: _ZNK7WebCore10RenderView15usesCompositingEv, _ZNK7WebCore5Frame15contentRendererEv
  • _ZNK7WebCore27ScriptedAnimationController17throttlingReasonsEv: _ZNK7WebCore8Document4pageEv
  • _ZNK7WebCore4Page27pageExtendedBackgroundColorEv: _ZN7WebCore10RenderView10compositorEv, _ZNK7WebCore9FrameView10renderViewEv
  • _ZNK7WebCore5Frame31displayStringModifiedByEncodingERKN3WTF6StringE: _ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE
  • _ZNK7WebCore6Editor6clientEv: _ZNK7WebCore8Document4pageEv
  • _ZNK7WebCore6Editor9canDeleteEv: _ZNK7WebCore16VisibleSelection19rootEditableElementEv
  • _ZNK7WebCore6Quirks70shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasEv: _ZNK7WebCore8Document11topDocumentEv, _ZNK7WebCore8Settings23needsSiteSpecificQuirksEv
  • _ZNK7WebCore8Document6domainEv: _ZNK7WebCore15SecurityContext14securityOriginEv

Left out: of the 72 branchy wrappers the translator accepted, 18 were dropped after the checks below and 1 is implemented by an open PR:

  • OpaqueJSString::tryCreate(const String&): implemented by open PR #23826.
  • Edges that no non-crashing trial can reach, or a still-unexplained mismatch, so the evidence stays below the bar: OpaqueJSString::tryCreate(String&&) (an edge needs a second read of an argument field to be 0 right after a non-zero read with only a 32-bit store of 1 in between: unreachable), HistoryController::setCurrentItem (needs a1 == a0 + 8 aliasing, after which the next dereference uses 1 as a pointer: crashes in the module too), InspectorFrontendClientLocal::windowObjectCleared, both JSCell::getString overloads and SecurityOrigin::isSameSchemeHostPort (edges need a mock-returned pointer that aliases an argument field), CSSParser D1 (one unexplained mismatch of 4 trials seen once, never reproduced in 470+ reruns of the deterministic build) and its sibling D2.
  • A mutant of the C++ still escaped the harness after the generator was improved, so the function was dropped by rule rather than argued equivalent: EditingStyle D1 and D2, PageOverlay::frame, Widget::convertToContainingView (IntRect, IntPoint), Widget::convertFromContainingView (IntRect, IntPoint), ResourceLoader::isAllowedToAskUserForCredentials, FrameView::useDarkAppearance and its _ZThn64_ thunk. The convertFrom and useDarkAppearance pairs were dropped as families after one member each escaped.
  • Other stubs: 31 stack-local wrappers, 37 loops and further jump-outs are not part of this PR.

Debt: the fragment docs/dev/debt/changes/feat-nkwebkit-lifted-branchy-wrappers.md adds the Functional entry and removes the 44 inventory rows that exist for these exports.
Overlap: every open PR touching libSceNKWebKit (151 of 2017 open) was diffed against the 54 names; apart from #23826 (excluded above) none contains them. No name is implemented on main (8e158a83d9).
Other change: tests/Forwarding.cpp no longer expects the forwarding alias ScriptCallFrame::operator== to hit a stub, because it jumps to ScriptCallFrame::isEqual, which is implemented here.

How it was checked

Offline, against the module's own code (none of it is in the repository):

  • Differential harness: the original bytes with each rel32 call patched to a recording mock, side by side with the C++, on randomized memory (arena, arguments and mock return values). The harness compares the call log (callee and six argument registers), the memory and the return value. 54/54 passed 3000 trials with 0 mismatches and the same crash behaviour (the 53 here are a subset of them).
  • Biased trial generator: a first version, which only made small values through random() % 17, let 13 mutants escape on exactly the branches that compare against refcounts, type bytes and aliased arguments, and crashed 70-90 % of trials on 3-deep pointer chains. The generator now has a pointer-rich mode (pointers drawn from a pool of six, pointers aliasing earlier arguments) and hint words taken from the immediates of the lifted code (imm, imm - 1, 32- and 64-bit, refcount plus flag words). The mode comes from the seed, so a recorded seed replays the same inputs anywhere.
  • Edge coverage: every if in the 54 candidates was instrumented (220 true/false edges; 214 belong to the 53 here; ternaries are not counted). A 40000-seed scan found the 8 recorded seeds per export (picked greedily by coverage) so that together they hit every edge of every kept function (220/220), and every recorded seed is non-crashing in the module. Crashes stay frequent for some functions (up to about 70 % of random trials), which is why the seeds were selected rather than the first 8.
  • Mutation testing: 8 rounds (seeds 1 2 3 5 8 13 21 22) of mutants applied to the C++ (a changed call argument, a dropped call, a changed constant or offset, and a flipped branch condition): 299 mutants, 299 caught, 0 missed. The mutator samples about 37 functions per round, so this covers the sampled mutants, not every possible one.
  • Recorded digests: 8 seeds per export (424 in total). Each digest covers the call log, the arena and the return value, with the arena at the fixed address the test maps (0x5a0000000000), recorded by running the module's bytes (recorder: 0 disagreements with the C++). Call ids in the digest are the callee's index in the sorted callee list, so the digests were re-recorded for exactly these 53 exports.

In the repository, the new nkwebkit_liftedbranchywrappers test:

  • On Linux, the test executable defines every callee as a recording mock, linked with -rdynamic so it interposes on the library's calls. It runs the same biased generator as the recorder and replays the 424 recorded seeds, comparing digests. When not recording, a mock forwards to the real export through dlsym(RTLD_NEXT). The CMake change is limited to this one test on Linux.
  • On every platform, it checks that 21 exports whose first action is a load through the object throw on a null object.

Tested

Linux Mint 22.3, GCC 13.3, Release:

  • nkwebkit_liftedbranchywrappers passes. Negative control: changing one load offset in WKAccessibilityRootObject (a0 + 0x38 instead of a0 + 0x30) makes it abort with a digest mismatch.
  • Full NKWebKit suite: 160/160 tests matching nkwebkit pass.
  • tools/check_conventions.py and the public-headers audit (test_public_headers.py --audit-only) pass.
  • git merge-tree of the branch with current main is clean.
  • Not run on Windows locally. On Windows only the null-object part runs.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #23758
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5405573019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23999). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-20T00:41:09Z. --- ### What Implements 53 `libSceNKWebKit` exports whose module body has forward branches (no loops, globals, stack locals, atomics or indirect calls) and calls other named exports. All 53 throw `NotImplemented` on `main` today. Stacked on #23758 (lifted wrappers), which is stacked on #23755 (lifted leaf functions); it reuses `src/LiftedAbi.hpp` and `Call` from them. Source: the `libSceNKWebKit.sprx` with SHA-256 `3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d` (the module the existing *Constant-return exports* debt entry reads as 11.00). Each body was translated instruction by instruction into C++ with the same translator as #23758, extended with forward-branch lowering: - Every branch, call, load and store keeps its order. Every call keeps its target and all six argument registers as the module leaves them. - The result width is the width the body returns (a path that never writes `rax` returns void). Parameter and return types are register widths, not source prototypes. - A low (null-page) address throws `std::invalid_argument` where the module would fault. - Callees are declared in the existing export headers (`libSceNKWebKit.hpp`); this PR declares none. 42 distinct callees: 5 are implemented today, 37 are still stubs. 49 of the 53 exports therefore throw `NotImplemented` from a callee until that callee is implemented (the same as the forwarded exports, #23758 and the jump-outs PR); 4 are fully working today. Exports that call still-stubbed exports: - `WKAccessibilityRootObject`: `_ZN7WebCore13AXObjectCache10rootObjectEv`, `_ZN7WebCore13AXObjectCache19enableAccessibilityEv`, `_ZNK7WebCore8Document13axObjectCacheEv` - `_ZN3JSC12StackVisitor5Frame8sourceIDEv`: `_ZN3JSC14SourceProvider5getIDEv` - `_ZN3JSC17DebuggerCallFrame20sourceIDForCallFrameEPNS_9CallFrameE`: `_ZN3JSC14SourceProvider5getIDEv` - `_ZN3JSC9Structure16isValidPrototypeENS_7JSValueE`: `_ZN3JSC6JSCell9getObjectEv` - `_ZN3WTF10StringView16GraphemeClusters8IteratorD1Ev`: `_ZN3WTF31NonSharedCharacterBreakIteratorD1Ev` - `_ZN3WTF10StringView16GraphemeClusters8IteratorD2Ev`: `_ZN3WTF31NonSharedCharacterBreakIteratorD1Ev` - `_ZN7WebCore11MemoryCache14evictResourcesEv`: `_ZN7WebCore11MemoryCache11setDisabledEb` - `_ZN7WebCore12EventHandler30setCapturingMouseEventsElementEPNS_7ElementE`: `_ZN7WebCore4Node14removedLastRefEv` - `_ZN7WebCore13JSDOMRectListD1Ev`: `_ZN7WebCore11DOMRectListD1Ev` - `_ZN7WebCore13JSDOMRectListD2Ev`: `_ZN7WebCore11DOMRectListD1Ev` - `_ZN7WebCore13JSDOMRectListaSERKS0_`: `_ZN7WebCore11DOMRectListD1Ev` - `_ZN7WebCore13displayStringERKN3WTF6StringEPKNS_4NodeE`: `_ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE` - `_ZN7WebCore20HTMLFrameElementBase5widthEv`: `_ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsENS0_18RunPostLayoutTasksE`, `_ZNK7WebCore4Node9renderBoxEv` - `_ZN7WebCore20HTMLFrameElementBase6heightEv`: `_ZN7WebCore8Document36updateLayoutIgnorePendingStylesheetsENS0_18RunPostLayoutTasksE`, `_ZNK7WebCore4Node9renderBoxEv` - `_ZN7WebCore22makeRangeSelectingNodeERNS_4NodeE`: `_ZNK7WebCore4Node16computeNodeIndexEv` - `_ZN7WebCore23ApplicationCacheStorageC1ERKN3WTF6StringES4_`: `_ZN7WebCore14SQLiteDatabaseC1Ev` - `_ZN7WebCore23ApplicationCacheStorageC2ERKN3WTF6StringES4_`: `_ZN7WebCore14SQLiteDatabaseC1Ev` - `_ZN7WebCore23MediaQueryParserContextC1ERKNS_8DocumentE`: `_ZNK7WebCore8Document4pageEv` - `_ZN7WebCore23MediaQueryParserContextC2ERKNS_8DocumentE`: `_ZNK7WebCore8Document4pageEv` - `_ZN7WebCore26makeBoundaryPointAfterNodeERNS_4NodeE`: `_ZNK7WebCore4Node16computeNodeIndexEv` - `_ZN7WebCore27makeBoundaryPointBeforeNodeERNS_4NodeE`: `_ZNK7WebCore4Node16computeNodeIndexEv` - `_ZN7WebCore30makeRangeSelectingNodeContentsERNS_4NodeE`: `_ZNK7WebCore13ContainerNode15countChildNodesEv` - `_ZN7WebCore4Node11appendChildERS0_`: `_ZN7WebCore13ContainerNode11appendChildERNS_4NodeE` - `_ZN7WebCore4Node11removeChildERS0_`: `_ZN7WebCore13ContainerNode11removeChildERNS_4NodeE` - `_ZN7WebCore4Node6removeEv`: `_ZN7WebCore13ContainerNode11removeChildERNS_4NodeE` - `_ZN7WebCore4toJSEPN3JSC14JSGlobalObjectERNS_9DOMWindowE`: `_ZN7WebCore4toJSEPN3JSC14JSGlobalObjectERNS_11WindowProxyE`, `_ZNK7WebCore9DOMWindow5frameEv` - `_ZN7WebCore8JSPath2DD1Ev`: `_ZN7WebCore6Path2DD1Ev` - `_ZN7WebCore8JSPath2DD2Ev`: `_ZN7WebCore6Path2DD1Ev` - `_ZN7WebCore8JSPath2DaSERKS0_`: `_ZN7WebCore6Path2DD1Ev` - `_ZN7bmalloc13IsoSharedPage9tryCreateEv`: `_ZN7bmalloc11IsoPageBase18allocatePageMemoryEv` - `_ZN9Inspector22InspectorDebuggerAgent19clearExceptionValueEv`: `_ZN9Inspector21InjectedScriptManager19clearExceptionValueEv` - `_ZN9Inspector31NetworkBackendDispatcherHandler20LoadResourceCallbackD1Ev`: `_ZN9Inspector17BackendDispatcherD2Ev` - `_ZN9Inspector32DatabaseBackendDispatcherHandler18ExecuteSQLCallbackD1Ev`: `_ZN9Inspector17BackendDispatcherD2Ev` - `_ZN9Inspector32DatabaseBackendDispatcherHandler18ExecuteSQLCallbackD2Ev`: `_ZN9Inspector17BackendDispatcherD2Ev` - `_ZNK7WebCore12NamedNodeMap6lengthEv`: `_ZNK7WebCore7Element13hasAttributesEv` - `_ZNK7WebCore13HitTestResult11textContentEv`: `_ZNK7WebCore4Node11textContentEb` - `_ZNK7WebCore13HitTestResult15absoluteLinkURLEv`: `_ZNK7WebCore7Element15absoluteLinkURLEv` - `_ZNK7WebCore14DocumentLoader21archiveResourceForURLERKN3WTF3URLE`: `_ZN7WebCore25ArchiveResourceCollection21archiveResourceForURLERKN3WTF3URLE` - `_ZNK7WebCore14FrameSelection18isFocusedAndActiveEv`: `_ZNK7WebCore8Document4pageEv` - `_ZNK7WebCore14FrameSelection36rootEditableElementOrDocumentElementEv`: `_ZNK7WebCore16VisibleSelection19rootEditableElementEv` - `_ZNK7WebCore16DOMGuardedObject11isSuspendedEv`: `_ZNK7WebCore17ActiveDOMCallback17canInvokeCallbackEv` - `_ZNK7WebCore20ScrollingCoordinator32coordinatesScrollingForFrameViewERKNS_9FrameViewE`: `_ZNK7WebCore10RenderView15usesCompositingEv`, `_ZNK7WebCore5Frame15contentRendererEv` - `_ZNK7WebCore27ScriptedAnimationController17throttlingReasonsEv`: `_ZNK7WebCore8Document4pageEv` - `_ZNK7WebCore4Page27pageExtendedBackgroundColorEv`: `_ZN7WebCore10RenderView10compositorEv`, `_ZNK7WebCore9FrameView10renderViewEv` - `_ZNK7WebCore5Frame31displayStringModifiedByEncodingERKN3WTF6StringE`: `_ZNK7WebCore8Document31displayStringModifiedByEncodingERKN3WTF6StringE` - `_ZNK7WebCore6Editor6clientEv`: `_ZNK7WebCore8Document4pageEv` - `_ZNK7WebCore6Editor9canDeleteEv`: `_ZNK7WebCore16VisibleSelection19rootEditableElementEv` - `_ZNK7WebCore6Quirks70shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreasEv`: `_ZNK7WebCore8Document11topDocumentEv`, `_ZNK7WebCore8Settings23needsSiteSpecificQuirksEv` - `_ZNK7WebCore8Document6domainEv`: `_ZNK7WebCore15SecurityContext14securityOriginEv` Left out: of the 72 branchy wrappers the translator accepted, 18 were dropped after the checks below and 1 is implemented by an open PR: - `OpaqueJSString::tryCreate(const String&)`: implemented by open PR #23826. - Edges that no non-crashing trial can reach, or a still-unexplained mismatch, so the evidence stays below the bar: `OpaqueJSString::tryCreate(String&&)` (an edge needs a second read of an argument field to be 0 right after a non-zero read with only a 32-bit store of 1 in between: unreachable), `HistoryController::setCurrentItem` (needs `a1 == a0 + 8` aliasing, after which the next dereference uses 1 as a pointer: crashes in the module too), `InspectorFrontendClientLocal::windowObjectCleared`, both `JSCell::getString` overloads and `SecurityOrigin::isSameSchemeHostPort` (edges need a mock-returned pointer that aliases an argument field), `CSSParser` D1 (one unexplained mismatch of 4 trials seen once, never reproduced in 470+ reruns of the deterministic build) and its sibling D2. - A mutant of the C++ still escaped the harness after the generator was improved, so the function was dropped by rule rather than argued equivalent: `EditingStyle` D1 and D2, `PageOverlay::frame`, `Widget::convertToContainingView` (IntRect, IntPoint), `Widget::convertFromContainingView` (IntRect, IntPoint), `ResourceLoader::isAllowedToAskUserForCredentials`, `FrameView::useDarkAppearance` and its `_ZThn64_` thunk. The convertFrom and useDarkAppearance pairs were dropped as families after one member each escaped. - Other stubs: 31 stack-local wrappers, 37 loops and further jump-outs are not part of this PR. Debt: the fragment `docs/dev/debt/changes/feat-nkwebkit-lifted-branchy-wrappers.md` adds the Functional entry and removes the 44 inventory rows that exist for these exports. Overlap: every open PR touching `libSceNKWebKit` (151 of 2017 open) was diffed against the 54 names; apart from #23826 (excluded above) none contains them. No name is implemented on `main` (`8e158a83d9`). Other change: `tests/Forwarding.cpp` no longer expects the forwarding alias `ScriptCallFrame::operator==` to hit a stub, because it jumps to `ScriptCallFrame::isEqual`, which is implemented here. ### How it was checked Offline, against the module's own code (none of it is in the repository): - **Differential harness:** the original bytes with each `rel32` call patched to a recording mock, side by side with the C++, on randomized memory (arena, arguments and mock return values). The harness compares the call log (callee and six argument registers), the memory and the return value. 54/54 passed 3000 trials with 0 mismatches and the same crash behaviour (the 53 here are a subset of them). - **Biased trial generator:** a first version, which only made small values through `random() % 17`, let 13 mutants escape on exactly the branches that compare against refcounts, type bytes and aliased arguments, and crashed 70-90 % of trials on 3-deep pointer chains. The generator now has a pointer-rich mode (pointers drawn from a pool of six, pointers aliasing earlier arguments) and hint words taken from the immediates of the lifted code (`imm`, `imm - 1`, 32- and 64-bit, refcount plus flag words). The mode comes from the seed, so a recorded seed replays the same inputs anywhere. - **Edge coverage:** every `if` in the 54 candidates was instrumented (220 true/false edges; 214 belong to the 53 here; ternaries are not counted). A 40000-seed scan found the 8 recorded seeds per export (picked greedily by coverage) so that together they hit every edge of every kept function (220/220), and every recorded seed is non-crashing in the module. Crashes stay frequent for some functions (up to about 70 % of random trials), which is why the seeds were selected rather than the first 8. - **Mutation testing:** 8 rounds (seeds 1 2 3 5 8 13 21 22) of mutants applied to the C++ (a changed call argument, a dropped call, a changed constant or offset, and a flipped branch condition): 299 mutants, 299 caught, 0 missed. The mutator samples about 37 functions per round, so this covers the sampled mutants, not every possible one. - **Recorded digests:** 8 seeds per export (424 in total). Each digest covers the call log, the arena and the return value, with the arena at the fixed address the test maps (`0x5a0000000000`), recorded by running the module's bytes (recorder: 0 disagreements with the C++). Call ids in the digest are the callee's index in the sorted callee list, so the digests were re-recorded for exactly these 53 exports. In the repository, the new `nkwebkit_liftedbranchywrappers` test: - On Linux, the test executable defines every callee as a recording mock, linked with `-rdynamic` so it interposes on the library's calls. It runs the same biased generator as the recorder and replays the 424 recorded seeds, comparing digests. When not recording, a mock forwards to the real export through `dlsym(RTLD_NEXT)`. The CMake change is limited to this one test on Linux. - On every platform, it checks that 21 exports whose first action is a load through the object throw on a null object. ### Tested Linux Mint 22.3, GCC 13.3, Release: - `nkwebkit_liftedbranchywrappers` passes. Negative control: changing one load offset in `WKAccessibilityRootObject` (`a0 + 0x38` instead of `a0 + 0x30`) makes it abort with a digest mismatch. - Full NKWebKit suite: 160/160 tests matching `nkwebkit` pass. - `tools/check_conventions.py` and the public-headers audit (`test_public_headers.py --audit-only`) pass. - `git merge-tree` of the branch with current `main` is clean. - Not run on Windows locally. On Windows only the null-object part runs. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #23758 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-20 01:05:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T01:05:49Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 61ff5a105f:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_forwarding_tests, nkwebkit_liftedbranchywrappers_tests, nkwebkit_liftedleaffunctions_tests, nkwebkit_liftedwrappers_tests built cleanly.
  • CTest (nkwebkit_forwarding, nkwebkit_liftedbranchywrappers, nkwebkit_liftedleaffunctions, nkwebkit_liftedwrappers):
    1/4 Test #4685: nkwebkit_forwarding ..............   Passed    0.04 sec
    2/4 Test #4712: nkwebkit_liftedbranchywrappers ...   Passed    1.51 sec
    3/4 Test #4714: nkwebkit_liftedwrappers ..........   Passed    2.55 sec
    4/4 Test #4713: nkwebkit_liftedleaffunctions .....   Passed    7.88 sec
    100% tests passed, 0 tests failed out of 4
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/Api.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/LiftedBranchyWrappers.cpp, core/libs/prx/libSceNKWebKit/src/LiftedLeafFunctions.cpp, core/libs/prx/libSceNKWebKit/src/LiftedWrappers.cpp reverted to main and the new tests kept, the suite fails:
    1/4 Test #4714: nkwebkit_liftedwrappers ..........Subprocess aborted***Exception:   0.53 sec
    2/4 Test #4713: nkwebkit_liftedleaffunctions .....Subprocess aborted***Exception:   0.62 sec
    3/4 Test #4685: nkwebkit_forwarding ..............   Passed    0.03 sec
    4/4 Test #4712: nkwebkit_liftedbranchywrappers ...Subprocess aborted***Exception:   0.51 sec
    25% tests passed, 3 tests failed out of 4
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified removal of 53 lifted branchy wrapper exports from Export.cpp where they previously threw NotImplemented_nid_no_patch.
    • Checked CMakeLists.txt target_link_options (-rdynamic) and target_link_libraries (${CMAKE_DL_LIBS}) additions for Linux test executables.
    • Verified forward-branch lowering semantics and instruction-level translation against LiftedAbi.hpp and Call requirements.
    • Verified AGENTS.md conventions including no forbidden comments, no special-cased game logic, and proper debt/test handling.
    • Confirmed build.ok and CTest cleanly passing on Linux with negative control verification.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5985982911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23999#pullrequestreview-5985982911). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-20T01:05:49Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `61ff5a105f`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_forwarding_tests`, `nkwebkit_liftedbranchywrappers_tests`, `nkwebkit_liftedleaffunctions_tests`, `nkwebkit_liftedwrappers_tests` built cleanly. - **CTest** (`nkwebkit_forwarding`, `nkwebkit_liftedbranchywrappers`, `nkwebkit_liftedleaffunctions`, `nkwebkit_liftedwrappers`): ``` 1/4 Test #4685: nkwebkit_forwarding .............. Passed 0.04 sec 2/4 Test #4712: nkwebkit_liftedbranchywrappers ... Passed 1.51 sec 3/4 Test #4714: nkwebkit_liftedwrappers .......... Passed 2.55 sec 4/4 Test #4713: nkwebkit_liftedleaffunctions ..... Passed 7.88 sec 100% tests passed, 0 tests failed out of 4 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/Api.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/LiftedBranchyWrappers.cpp`, `core/libs/prx/libSceNKWebKit/src/LiftedLeafFunctions.cpp`, `core/libs/prx/libSceNKWebKit/src/LiftedWrappers.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/4 Test #4714: nkwebkit_liftedwrappers ..........Subprocess aborted***Exception: 0.53 sec 2/4 Test #4713: nkwebkit_liftedleaffunctions .....Subprocess aborted***Exception: 0.62 sec 3/4 Test #4685: nkwebkit_forwarding .............. Passed 0.03 sec 4/4 Test #4712: nkwebkit_liftedbranchywrappers ...Subprocess aborted***Exception: 0.51 sec 25% tests passed, 3 tests failed out of 4 ``` Restoring the change makes it pass again. - **Code reading**: - Verified removal of 53 lifted branchy wrapper exports from Export.cpp where they previously threw NotImplemented_nid_no_patch. - Checked CMakeLists.txt target_link_options (-rdynamic) and target_link_libraries (${CMAKE_DL_LIBS}) additions for Linux test executables. - Verified forward-branch lowering semantics and instruction-level translation against LiftedAbi.hpp and Call requirements. - Verified AGENTS.md conventions including no forbidden comments, no special-cased game logic, and proper debt/test handling. - Confirmed build.ok and CTest cleanly passing on Linux with negative control verification. Looks Good To Me
MarcZX10 commented 2026-11-20 05:25:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T05:25:48Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change based on the inspected code; the points below are optional.

What I ran

Reviewed head 61ff5a105f3c018ed1b7de1b21f070fc6125307e, base main. No commands or tests were run; reported test results below are author supplied.

Results

Check Result Note
Code review passed Inspected wrapper implementation and test setup
PR reported tests not run Linux results are author reported
Windows validation not run Author reports Windows was not tested locally

Findings

Blocking

None.

Non-blocking

None.

Not verified

Reviewed the added CMake configuration, LiftedAbi.hpp, LiftedBranchyWrappers.cpp lines 1–420 and 900–997, LiftedBranchyWrappersExports.hpp, libSceNKWebKit.hpp, and Forwarding.cpp lines 1–100, along with the PR description, commits, and the available diff excerpts. The review bundle lists 19 changed files; the other changed files’ added lines were not read. Export.cpp was excluded from the bundle for size and was not read through the reader. The test implementation was only partially inspected. Therefore the full change and its claimed differential coverage are not verified. The PR description reports Linux Mint 22.3/GCC 13.3 results and says Windows was not run locally.

To get this to a good state

Nothing is required. The full added implementations and test code remain unreviewed in this pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5987957108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23999#pullrequestreview-5987957108). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T05:25:48Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change based on the inspected code; the points below are optional. ## What I ran Reviewed head `61ff5a105f3c018ed1b7de1b21f070fc6125307e`, base `main`. No commands or tests were run; reported test results below are author supplied. ## Results | Check | Result | Note | |---|---|---| | Code review | passed | Inspected wrapper implementation and test setup | | PR reported tests | not run | Linux results are author reported | | Windows validation | not run | Author reports Windows was not tested locally | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Reviewed the added CMake configuration, `LiftedAbi.hpp`, `LiftedBranchyWrappers.cpp` lines 1–420 and 900–997, `LiftedBranchyWrappersExports.hpp`, `libSceNKWebKit.hpp`, and `Forwarding.cpp` lines 1–100, along with the PR description, commits, and the available diff excerpts. The review bundle lists 19 changed files; the other changed files’ added lines were not read. `Export.cpp` was excluded from the bundle for size and was not read through the reader. The test implementation was only partially inspected. Therefore the full change and its claimed differential coverage are not verified. The PR description reports Linux Mint 22.3/GCC 13.3 results and says Windows was not run locally. ## To get this to a good state Nothing is required. The full added implementations and test code remain unreviewed in this pass.
MarcZX10 commented 2026-11-20 13:49:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T13:49:56Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected changes blocks merging; the author-reported Linux validation is substantial, but I could not run the checks or inspect all reviewed files.

What I ran

Reviewed head a703f0dbdcef6f63b6c832c08adc75db3618c055. I read the prepared description, commit list, manifest, diff, and available changed files through repo_read.py; no build or tests were run.

Results

Check Result Note
Diff and targeted code review passed Reviewed key wrapper, test, ABI, and build sections
Build and tests not run Linux results are author-reported

Negative control

Not run by me. The description reports that changing a load offset caused the differential test to fail.

Findings

Blocking

None in the inspected code.

Non-blocking

None.

Not verified

I did not read every added line in the changed files. Export.cpp was excluded from the review folder because it was too large; I inspected its relevant removals in diff.patch, but not its full head text. Full text for changed files was available but not fully read for LiftedLeafFunctions.cpp, LiftedWrappers.cpp, LiftedLeafFunctionsExports.hpp, LiftedWrappersExports.hpp, libSceNKWebKit.hpp, tests/LiftedLeafFunctions.cpp, tests/LiftedWrappers.cpp, tests/Forwarding.cpp, and the three debt documents. The diff’s other sections and repository behavior outside the inspected ranges were not verified. The author reports Linux Mint 22.3/GCC 13.3 checks and says Windows was not run locally.

To get this to a good state

Nothing is required. Optional: run the NKWebKit suite on the exact head and verify the behavior on Windows.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5993710965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23999#pullrequestreview-5993710965). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T13:49:56Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected changes blocks merging; the author-reported Linux validation is substantial, but I could not run the checks or inspect all reviewed files. ## What I ran Reviewed head `a703f0dbdcef6f63b6c832c08adc75db3618c055`. I read the prepared description, commit list, manifest, diff, and available changed files through `repo_read.py`; no build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted code review | passed | Reviewed key wrapper, test, ABI, and build sections | | Build and tests | not run | Linux results are author-reported | ## Negative control Not run by me. The description reports that changing a load offset caused the differential test to fail. ## Findings ### Blocking None in the inspected code. ### Non-blocking None. ## Not verified I did not read every added line in the changed files. `Export.cpp` was excluded from the review folder because it was too large; I inspected its relevant removals in `diff.patch`, but not its full head text. Full text for changed files was available but not fully read for `LiftedLeafFunctions.cpp`, `LiftedWrappers.cpp`, `LiftedLeafFunctionsExports.hpp`, `LiftedWrappersExports.hpp`, `libSceNKWebKit.hpp`, `tests/LiftedLeafFunctions.cpp`, `tests/LiftedWrappers.cpp`, `tests/Forwarding.cpp`, and the three debt documents. The diff’s other sections and repository behavior outside the inspected ranges were not verified. The author reports Linux Mint 22.3/GCC 13.3 checks and says Windows was not run locally. ## To get this to a good state Nothing is required. Optional: run the NKWebKit suite on the exact head and verify the behavior on Windows.
MarcZX10 commented 2026-11-20 20:19:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:19:42Z.

Review: COMMENTED


Reviewed — comments

The prepared description reports extensive differential and repository testing, but this review did not run those checks and did not read all changed files, so a formal merge decision is not justified.

What I ran

No build or tests were run. I inspected the prepared description, commits, diff, manifest, changed branchy-wrapper implementation and test, shared ABI helpers, CMake configuration, and export header.

Results

Check Result Note
Source inspection passed Targeted files and ranges read
Build and tests not run Results in the PR description are author-reported

Findings

Blocking

None identified in the inspected ranges.

Non-blocking

  • The PR description reports 49 of the 53 wrappers still reach a stubbed callee and only four work end to end today. Keep that limitation visible to callers relying on these exports.

Not verified

The full text of Export.cpp was excluded as too large; its changed hunks were present in the prepared diff but were not inspected through the reader. The implementation and tests for the stacked leaf-function and wrapper changes, and other changed files, were not read. No build, test, or merge-preview check was run. The Linux test results and Windows limitations in the description are author-reported, not independently confirmed.

To get this to a good state

Nothing is required. Optional: run the reported checks on this head and review the excluded Export.cpp changes before treating this review as a complete approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998812129 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23999#pullrequestreview-5998812129). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T20:19:42Z. **Review:** COMMENTED --- # Reviewed — comments The prepared description reports extensive differential and repository testing, but this review did not run those checks and did not read all changed files, so a formal merge decision is not justified. ## What I ran No build or tests were run. I inspected the prepared description, commits, diff, manifest, changed branchy-wrapper implementation and test, shared ABI helpers, CMake configuration, and export header. ## Results | Check | Result | Note | |---|---|---| | Source inspection | passed | Targeted files and ranges read | | Build and tests | not run | Results in the PR description are author-reported | ## Findings ### Blocking None identified in the inspected ranges. ### Non-blocking - The PR description reports 49 of the 53 wrappers still reach a stubbed callee and only four work end to end today. Keep that limitation visible to callers relying on these exports. ## Not verified The full text of `Export.cpp` was excluded as too large; its changed hunks were present in the prepared diff but were not inspected through the reader. The implementation and tests for the stacked leaf-function and wrapper changes, and other changed files, were not read. No build, test, or merge-preview check was run. The Linux test results and Windows limitations in the description are author-reported, not independently confirmed. ## To get this to a good state Nothing is required. Optional: run the reported checks on this head and review the excluded `Export.cpp` changes before treating this review as a complete approval.

Pull request closed

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
boykopovar/AnyPS5!23999
No description provided.