feat(libSceNKWebKit): implement Inspector script call stacks #16261

Merged
gslashm merged 4 commits from upstream-pr/16261 into main 2026-11-17 09:45:15 +00:00
gslashm commented 2026-11-06 01:40:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gslashm on 2026-11-06T01:40:54Z.


What

Implements 23 libSceNKWebKit exports from Source/JavaScriptCore/inspector/ScriptCallFrame.cpp, ScriptCallStack.cpp and AsyncStackTrace.cpp at 80f77e94c6.

ScriptCallFrame: copy constructor (C1, C2), destructor (D1, D2), copy assignment and isNative.
ScriptCallStack: create, constructors (C1, C2), destructors (D1, D2), at, firstNonNativeCallFrame and isEqual.
AsyncStackTrace: destructors (D1, D2), isPending, isLocked, willDispatchAsyncCall, didDispatchAsyncCall, didCancelAsyncCall, truncate and remove.

Six exports that main already implements are dropped: ScriptCallFrame::functionName (ArgumentReturn.cpp), sourceURL, lineNumber, columnNumber and sourceID (FieldGetters.cpp), and ScriptCallStack::size (FieldGetters.cpp).

Offsets: main reads the line at +0x14, the column at +0x18 and the source ID at +0x10. The pinned ScriptCallFrame.h has three String members (8 bytes each) at 0, 8 and 16, then JSC::SourceID at 24, unsigned lineNumber at 28 and unsigned column at 32; SourceID is uint32_t (Source/JavaScriptCore/bytecode/SourceID.h:30), so the frame is 40 bytes, not 48. main's +0x10, +0x14 and +0x18 are the high halves of the scriptName and preRedirectURL pointers and the source ID, not the intended fields. This PR changes FieldGetters.cpp to +0x18/+0x1c/+0x20 and updates nkwebkit_fieldgetters to write and read 24, 28 and 32; nkwebkit_inspectorcallstack also checks the getters. The frame layout is pinned with static_assert(sizeof(ScriptCallFrame) == 40) in src/InspectorCallStackAbi.hpp and the same offsets are asserted by the test.

Placement: the three files are hand-written ports in core/libs/prx/libSceNKWebKit/src/, with the upstream Apple licence notices kept verbatim, as the other NKWebKit ports do. The guest layouts are pinned in src/InspectorCallStackAbi.hpp and the tests are in tests/. There is no submodule and no new build target; this follows the review decision against a WebKit submodule. The stack and trace reference counts are relaxed atomics in the same 4 bytes at offset 0; the pinned RefCounted is non-atomic, so the port is stricter but layout-compatible.

Reachability: ScriptCallStack::create() returns an empty stack, exactly as upstream. ScriptCallStack::create(Vector&&), append and the other internal helpers are not inventory NIDs, and the inspector factory exports (createScriptCallStack*) are still stubs, so no title in our traces fills frames through these exports; AsyncStackTrace has no create export. The getters and destructors are layout-compatible with stacks the guest creates internally. buildInspectorObject and buildInspectorArray remain stubs because they need JSON values (#13992). Null objects, invalid async states, an out-of-range at and a removal from a parent with no children throw where the console reads out of bounds or asserts.

Tested

Windows 11 Pro, WinLibs GCC 15.2.0. Full build exit 0. ctest -R nkwebkit: 63 of 63. ctest -R public_headers: 65 of 65. tools/check_conventions.py --base origin/main: no findings. tools/progress.py: libraries 2785 of 11258, 23 more than main's 2762 of 11258; debt 5974. git diff --check clean. No title or console module.

Based on main 65351c2931. #16383 adds no ScriptCallFrame, ScriptCallStack or AsyncStackTrace export; the debt count line is 5997 on main, 5974 here and 5955 after both.

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
  • 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 ported into core/ with its upstream licence notice kept verbatim, as the other NKWebKit files do; no new submodule, per review
  • Generic behaviour, not specific to one title
  • Depends on: #16383
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5181497697 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16261). Originally posted by [gslashm](https://github.com/gslashm) on 2026-11-06T01:40:54Z. --- ### What Implements 23 `libSceNKWebKit` exports from `Source/JavaScriptCore/inspector/ScriptCallFrame.cpp`, `ScriptCallStack.cpp` and `AsyncStackTrace.cpp` at `80f77e94c6`. `ScriptCallFrame`: copy constructor (`C1`, `C2`), destructor (`D1`, `D2`), copy assignment and `isNative`. `ScriptCallStack`: `create`, constructors (`C1`, `C2`), destructors (`D1`, `D2`), `at`, `firstNonNativeCallFrame` and `isEqual`. `AsyncStackTrace`: destructors (`D1`, `D2`), `isPending`, `isLocked`, `willDispatchAsyncCall`, `didDispatchAsyncCall`, `didCancelAsyncCall`, `truncate` and `remove`. Six exports that `main` already implements are dropped: `ScriptCallFrame::functionName` (`ArgumentReturn.cpp`), `sourceURL`, `lineNumber`, `columnNumber` and `sourceID` (`FieldGetters.cpp`), and `ScriptCallStack::size` (`FieldGetters.cpp`). Offsets: `main` reads the line at `+0x14`, the column at `+0x18` and the source ID at `+0x10`. The pinned `ScriptCallFrame.h` has three `String` members (8 bytes each) at 0, 8 and 16, then `JSC::SourceID` at 24, `unsigned lineNumber` at 28 and `unsigned column` at 32; `SourceID` is `uint32_t` (`Source/JavaScriptCore/bytecode/SourceID.h:30`), so the frame is 40 bytes, not 48. `main`'s `+0x10`, `+0x14` and `+0x18` are the high halves of the `scriptName` and `preRedirectURL` pointers and the source ID, not the intended fields. This PR changes `FieldGetters.cpp` to `+0x18`/`+0x1c`/`+0x20` and updates `nkwebkit_fieldgetters` to write and read 24, 28 and 32; `nkwebkit_inspectorcallstack` also checks the getters. The frame layout is pinned with `static_assert(sizeof(ScriptCallFrame) == 40)` in `src/InspectorCallStackAbi.hpp` and the same offsets are asserted by the test. Placement: the three files are hand-written ports in `core/libs/prx/libSceNKWebKit/src/`, with the upstream Apple licence notices kept verbatim, as the other NKWebKit ports do. The guest layouts are pinned in `src/InspectorCallStackAbi.hpp` and the tests are in `tests/`. There is no submodule and no new build target; this follows the review decision against a WebKit submodule. The stack and trace reference counts are relaxed atomics in the same 4 bytes at offset 0; the pinned `RefCounted` is non-atomic, so the port is stricter but layout-compatible. Reachability: `ScriptCallStack::create()` returns an empty stack, exactly as upstream. `ScriptCallStack::create(Vector&&)`, `append` and the other internal helpers are not inventory NIDs, and the inspector factory exports (`createScriptCallStack*`) are still stubs, so no title in our traces fills frames through these exports; `AsyncStackTrace` has no create export. The getters and destructors are layout-compatible with stacks the guest creates internally. `buildInspectorObject` and `buildInspectorArray` remain stubs because they need `JSON` values (#13992). Null objects, invalid async states, an out-of-range `at` and a removal from a parent with no children throw where the console reads out of bounds or asserts. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro, WinLibs GCC 15.2.0. Full build exit 0. `ctest -R nkwebkit`: 63 of 63. `ctest -R public_headers`: 65 of 65. `tools/check_conventions.py --base origin/main`: no findings. `tools/progress.py`: libraries 2785 of 11258, 23 more than `main`'s 2762 of 11258; debt 5974. `git diff --check` clean. No title or console module. Based on `main` `65351c2931`. #16383 adds no `ScriptCallFrame`, `ScriptCallStack` or `AsyncStackTrace` export; the debt count line is 5997 on `main`, 5974 here and 5955 after both. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) - [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 ported into `core/` with its upstream licence notice kept verbatim, as the other NKWebKit files do; no new submodule, per review - [x] Generic behaviour, not specific to one title - [x] Depends on: #16383 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-16 14:23:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T14:23:18Z.

Review: COMMENTED


Reviewed — comments

The prepared description reports successful Windows builds and tests, but I could not run checks here and several changed files were not read, so the evidence does not support a formal approval or a verified blocking finding.

What I ran

The change is pinned to head 7137c36b4b1a419ad1fb245a2d4e3344e9022112, based on main. No commands or tests were run; the available reader interface exposed the prepared bundle and repository reads only.

Results

Check Result Note
Prepared diff review passed Read the change summary and diff excerpts
Build and tests not run Only author-reported results are available
Full changed-file review not run Several changed files remain unread

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

The description reports a Windows 11 Pro build, nkwebkit and public_headers tests, convention checks, and a clean git diff --check; these were not run during this review. I read review/description.md, review/commits.md, review/manifest.json, the prepared file listing, core/libs/prx/libSceNKWebKit/src/InspectorScriptCallFrame.cpp, core/libs/prx/libSceNKWebKit/src/InspectorScriptCallStack.cpp, and portions of core/libs/prx/libSceNKWebKit/src/InspectorAsyncStackTrace.cpp, core/libs/prx/libSceNKWebKit/src/InspectorCallStackAbi.hpp, core/libs/prx/libSceNKWebKit/tests/InspectorCallStack.cpp, and review/diff.patch. The files marked excluded by the manifest were core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, and docs/dev/debt/libSceNKWebKit.md; they were not read. I also did not read all included changed files or the complete test file, so behavior outside the inspected sections is not verified.

To get this to a good state

Nothing is required. Optional: complete the review of the changed files that were not read and run the reported checks on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5921562004 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16261#pullrequestreview-5921562004). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T14:23:18Z. **Review:** COMMENTED --- # Reviewed — comments The prepared description reports successful Windows builds and tests, but I could not run checks here and several changed files were not read, so the evidence does not support a formal approval or a verified blocking finding. ## What I ran The change is pinned to head `7137c36b4b1a419ad1fb245a2d4e3344e9022112`, based on `main`. No commands or tests were run; the available reader interface exposed the prepared bundle and repository reads only. ## Results | Check | Result | Note | |---|---|---| | Prepared diff review | passed | Read the change summary and diff excerpts | | Build and tests | not run | Only author-reported results are available | | Full changed-file review | not run | Several changed files remain unread | ## Findings ### Blocking None verified. ### Non-blocking None. ## Not verified The description reports a Windows 11 Pro build, `nkwebkit` and `public_headers` tests, convention checks, and a clean `git diff --check`; these were not run during this review. I read `review/description.md`, `review/commits.md`, `review/manifest.json`, the prepared file listing, `core/libs/prx/libSceNKWebKit/src/InspectorScriptCallFrame.cpp`, `core/libs/prx/libSceNKWebKit/src/InspectorScriptCallStack.cpp`, and portions of `core/libs/prx/libSceNKWebKit/src/InspectorAsyncStackTrace.cpp`, `core/libs/prx/libSceNKWebKit/src/InspectorCallStackAbi.hpp`, `core/libs/prx/libSceNKWebKit/tests/InspectorCallStack.cpp`, and `review/diff.patch`. The files marked excluded by the manifest were `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, and `docs/dev/debt/libSceNKWebKit.md`; they were not read. I also did not read all included changed files or the complete test file, so behavior outside the inspected sections is not verified. ## To get this to a good state Nothing is required. Optional: complete the review of the changed files that were not read and run the reported checks on this head.
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!16261
No description provided.