feat(libSceNKWebKit): implement 104 exports that delegate to a member's virtual function #23471

Merged
RiverWhy merged 1 commit from upstream-pr/23471 into main 2026-11-19 04:40:02 +00:00
RiverWhy commented 2026-11-19 04:00:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-19T04:00:35Z.


What

Implements 104 libSceNKWebKit exports that forward a call to a virtual function of one of the object's members. All 104 throw NotImplemented on main today.

In the libSceNKWebKit.sprx with SHA-256 3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d (the module the existing Constant-return exports debt entry reads as 11.00), each body is

mov  off(%rdi), %rdi     ; this->m_member
mov  (%rdi), %rax        ; its vtable
jmp  *slot(%rax)         ; tail call (22 use mov slot(%rax),%rax; jmp *%rax)

That is upstream's void MediaPlayer::pause() { m_private->pause(); } pattern. They are implemented in src/DelegatingExports.cpp as the same assembly tail jump with each export's offset and slot, the way ForwardExports.cpp handles plain jmp aliases. Every argument and return register passes through untouched, so no prototype is assumed. One difference from the module: a null object or null member jumps to a helper that throws invalid_argument, where the module would fault.

Class Member offset Exports
MediaPlayer 0x50 (m_private) 49
MediaPlayer 0x18 (m_client) 36
HTMLInputElement 0xf8 (m_inputType) 7
Chrome 0x10 (m_client) 4
RenderLayerBacking 0x38 2
FrameLoader 0x8 2
BackForwardController 0x8 2
CanvasRenderingContext 0x18 1
Page 0x78 1

The two MediaPlayer offsets match playerPrivate() (0x50) and client() (0x18), which main already implements in FieldGetters.cpp from the same module. AnyPS5 does not construct any of these classes with a layout of its own.

Left out: four WK* C API exports (WKPageRun*ResultListenerCall, WKBundlePageOverlaySetAccessibilityClient) have the same body. They are left out because AnyPS5's own API objects (Object.hpp) don't use the module's layout, so the module's offset would read the wrong field.

How the table was produced: I recomputed each NID from the declared name, found it in the module's symbol table and decoded offset and slot from the bytes. A second pass re-parsed all 104 from objdump output and matched every one.
Debt: the fragment docs/dev/debt/changes/feat-nkwebkit-delegating-virtual-calls.md adds the Functional entry and removes the 97 inventory rows.
Overlap: I fetched every open PR head and diffed it against main. None removes any of these stubs.

Tested

Linux Mint 22.3, GCC 13.3, Release:

  • The new nkwebkit_delegatingexports test builds, for each of the 104 exports, an object with a fake member at the export's offset whose vtable has a recording function at the export's slot (every other slot aborts). It calls the export with five integer arguments and checks that the delegate got the member as this, received all five arguments unchanged and passed its return value back. It also checks that a null member and a null object throw, and that no NotImplemented call happened.
  • Negative controls: changing one slot to 0x8, or one MediaPlayer offset from 0x50 to 0x48, makes the test fail.
  • Full NKWebKit suite: 145/145 nkwebkit_* tests pass.
  • tools/check_conventions.py passes.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5388560205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23471). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-19T04:00:35Z. --- ### What Implements 104 `libSceNKWebKit` exports that forward a call to a virtual function of one of the object's members. All 104 throw `NotImplemented` on `main` today. In the `libSceNKWebKit.sprx` with SHA-256 `3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d` (the module the existing *Constant-return exports* debt entry reads as 11.00), each body is ```asm mov off(%rdi), %rdi ; this->m_member mov (%rdi), %rax ; its vtable jmp *slot(%rax) ; tail call (22 use mov slot(%rax),%rax; jmp *%rax) ``` That is upstream's `void MediaPlayer::pause() { m_private->pause(); }` pattern. They are implemented in `src/DelegatingExports.cpp` as the same assembly tail jump with each export's offset and slot, the way `ForwardExports.cpp` handles plain `jmp` aliases. Every argument and return register passes through untouched, so no prototype is assumed. One difference from the module: a null object or null member jumps to a helper that throws `invalid_argument`, where the module would fault. | Class | Member offset | Exports | |---|---|---| | `MediaPlayer` | 0x50 (`m_private`) | 49 | | `MediaPlayer` | 0x18 (`m_client`) | 36 | | `HTMLInputElement` | 0xf8 (`m_inputType`) | 7 | | `Chrome` | 0x10 (`m_client`) | 4 | | `RenderLayerBacking` | 0x38 | 2 | | `FrameLoader` | 0x8 | 2 | | `BackForwardController` | 0x8 | 2 | | `CanvasRenderingContext` | 0x18 | 1 | | `Page` | 0x78 | 1 | The two `MediaPlayer` offsets match `playerPrivate()` (0x50) and `client()` (0x18), which `main` already implements in `FieldGetters.cpp` from the same module. AnyPS5 does not construct any of these classes with a layout of its own. Left out: four `WK*` C API exports (`WKPageRun*ResultListenerCall`, `WKBundlePageOverlaySetAccessibilityClient`) have the same body. They are left out because AnyPS5's own API objects (`Object.hpp`) don't use the module's layout, so the module's offset would read the wrong field. How the table was produced: I recomputed each NID from the declared name, found it in the module's symbol table and decoded offset and slot from the bytes. A second pass re-parsed all 104 from `objdump` output and matched every one. Debt: the fragment `docs/dev/debt/changes/feat-nkwebkit-delegating-virtual-calls.md` adds the Functional entry and removes the 97 inventory rows. Overlap: I fetched every open PR head and diffed it against `main`. None removes any of these stubs. ### Tested Linux Mint 22.3, GCC 13.3, Release: - The new `nkwebkit_delegatingexports` test builds, for each of the 104 exports, an object with a fake member at the export's offset whose vtable has a recording function at the export's slot (every other slot aborts). It calls the export with five integer arguments and checks that the delegate got the member as `this`, received all five arguments unchanged and passed its return value back. It also checks that a null member and a null object throw, and that no `NotImplemented` call happened. - Negative controls: changing one slot to 0x8, or one `MediaPlayer` offset from 0x50 to 0x48, makes the test fail. - Full NKWebKit suite: 145/145 `nkwebkit_*` tests pass. - `tools/check_conventions.py` passes. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 04:12:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T04:12:33Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 525b232ae8:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_delegatingexports_tests built cleanly.
  • CTest (nkwebkit_delegatingexports):
    1/1 Test #4552: nkwebkit_delegatingexports .......   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/src/DelegatingExports.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #4552: nkwebkit_delegatingexports .......Subprocess aborted***Exception:   0.60 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified assembly tail call forwarding logic across all 104 exports in core/libs/prx/libSceNKWebKit/src/DelegatingExports.cpp against System V x86_64 ABI and member offset tables
    • Verified null checks on this pointer (%rdi) and member delegate pointer (%rdi after load) jumping to NKWebKitNullDelegate_nid_no_patch to prevent segfaults
    • Verified that NKWebKitNullDelegate_nid_no_patch adheres to AnyPS5 exception handling conventions and throws std::invalid_argument
    • Verified synchronization with docs/dev/debt/changes/feat-nkwebkit-delegating-virtual-calls.md technical debt fragment removing the implemented NIDs and documenting delegating virtual calls
    • Verified absence of prohibited code comments, compliance with AGENTS.md rules, and clean replacement of NotImplemented stubs in Export.cpp

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969206154 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23471#pullrequestreview-5969206154). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T04:12:33Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `525b232ae8`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_delegatingexports_tests` built cleanly. - **CTest** (`nkwebkit_delegatingexports`): ``` 1/1 Test #4552: nkwebkit_delegatingexports ....... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/src/DelegatingExports.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #4552: nkwebkit_delegatingexports .......Subprocess aborted***Exception: 0.60 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - Verified assembly tail call forwarding logic across all 104 exports in core/libs/prx/libSceNKWebKit/src/DelegatingExports.cpp against System V x86_64 ABI and member offset tables - Verified null checks on `this` pointer (%rdi) and member delegate pointer (%rdi after load) jumping to NKWebKitNullDelegate_nid_no_patch to prevent segfaults - Verified that NKWebKitNullDelegate_nid_no_patch adheres to AnyPS5 exception handling conventions and throws std::invalid_argument - Verified synchronization with docs/dev/debt/changes/feat-nkwebkit-delegating-virtual-calls.md technical debt fragment removing the implemented NIDs and documenting delegating virtual calls - Verified absence of prohibited code comments, compliance with AGENTS.md rules, and clean replacement of NotImplemented stubs in Export.cpp Looks Good To Me
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!23471
No description provided.