feat(libSceNKWebKit): implement 53 branchy call wrappers translated from the module #23999
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23999"
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 RiverWhy on 2026-11-20T00:41:09Z.
What
Implements 53
libSceNKWebKitexports whose module body has forward branches (no loops, globals, stack locals, atomics or indirect calls) and calls other named exports. All 53 throwNotImplementedonmaintoday. Stacked on #23758 (lifted wrappers), which is stacked on #23755 (lifted leaf functions); it reusessrc/LiftedAbi.hppandCallfrom them.Source: the
libSceNKWebKit.sprxwith SHA-2563af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d(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:raxreturns void). Parameter and return types are register widths, not source prototypes.std::invalid_argumentwhere the module would fault.libSceNKWebKit.hpp); this PR declares none.42 distinct callees: 5 are implemented today, 37 are still stubs. 49 of the 53 exports therefore throw
NotImplementedfrom 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:_ZNK7WebCore15SecurityContext14securityOriginEvLeft 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.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(needsa1 == a0 + 8aliasing, after which the next dereference uses 1 as a pointer: crashes in the module too),InspectorFrontendClientLocal::windowObjectCleared, bothJSCell::getStringoverloads andSecurityOrigin::isSameSchemeHostPort(edges need a mock-returned pointer that aliases an argument field),CSSParserD1 (one unexplained mismatch of 4 trials seen once, never reproduced in 470+ reruns of the deterministic build) and its sibling D2.EditingStyleD1 and D2,PageOverlay::frame,Widget::convertToContainingView(IntRect, IntPoint),Widget::convertFromContainingView(IntRect, IntPoint),ResourceLoader::isAllowedToAskUserForCredentials,FrameView::useDarkAppearanceand its_ZThn64_thunk. The convertFrom and useDarkAppearance pairs were dropped as families after one member each escaped.Debt: the fragment
docs/dev/debt/changes/feat-nkwebkit-lifted-branchy-wrappers.mdadds 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 onmain(8e158a83d9).Other change:
tests/Forwarding.cppno longer expects the forwarding aliasScriptCallFrame::operator==to hit a stub, because it jumps toScriptCallFrame::isEqual, which is implemented here.How it was checked
Offline, against the module's own code (none of it is in the repository):
rel32call 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).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.ifin 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.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_liftedbranchywrapperstest:-rdynamicso 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 throughdlsym(RTLD_NEXT). The CMake change is limited to this one test on Linux.Tested
Linux Mint 22.3, GCC 13.3, Release:
nkwebkit_liftedbranchywrapperspasses. Negative control: changing one load offset inWKAccessibilityRootObject(a0 + 0x38instead ofa0 + 0x30) makes it abort with a digest mismatch.nkwebkitpass.tools/check_conventions.pyand the public-headers audit (test_public_headers.py --audit-only) pass.git merge-treeof the branch with currentmainis clean.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 PrivacyOnion on 2026-11-20T01:05:49Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
61ff5a105f:tools/check_conventions.pypassed.nkwebkit_forwarding_tests,nkwebkit_liftedbranchywrappers_tests,nkwebkit_liftedleaffunctions_tests,nkwebkit_liftedwrappers_testsbuilt cleanly.nkwebkit_forwarding,nkwebkit_liftedbranchywrappers,nkwebkit_liftedleaffunctions,nkwebkit_liftedwrappers):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.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
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, basemain. No commands or tests were run; reported test results below are author supplied.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Reviewed the added CMake configuration,
LiftedAbi.hpp,LiftedBranchyWrappers.cpplines 1–420 and 900–997,LiftedBranchyWrappersExports.hpp,libSceNKWebKit.hpp, andForwarding.cpplines 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.cppwas 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.
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 throughrepo_read.py; no build or tests were run.Results
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.cppwas excluded from the review folder because it was too large; I inspected its relevant removals indiff.patch, but not its full head text. Full text for changed files was available but not fully read forLiftedLeafFunctions.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.
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
Findings
Blocking
None identified in the inspected ranges.
Non-blocking
Not verified
The full text of
Export.cppwas 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.cppchanges before treating this review as a complete approval.Pull request closed