feat(libSceNKWebKit): implement WTF time, MediaTime and ASCIILiteral dump #21957

Merged
frankea merged 8 commits from upstream-pr/21957 into main 2026-11-20 14:46:21 +00:00
frankea commented 2026-11-16 23:04:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-11-16T23:04:38Z.


What

Implements six libSceNKWebKit WTF dump(PrintStream&) exports that were NotImplemented_nid_no_patch stubs: Seconds::dump, WallTime::dump, MonotonicTime::dump, TimeWithDynamicClockType::dump, MediaTime::dump and ASCIILiteral::dump.

Source is a mirror of Sony's PS5 WebKit 11.x source release, neonmodder123/PS5-WebKit-11.x@80f77e94, the same tree #19828 cites: Seconds.cpp L80-L83 (m_value, " sec"), WallTime.cpp L41-L44, MonotonicTime.cpp L41-L44, TimeWithDynamicClockType.cpp L131-L134 with the Wall/Monotonic/Approximate names of ClockType.cpp L33-L47, MediaTime.cpp L539-L545 and text/ASCIILiteral.cpp L33-L36.

Each out.print(...) follows PrintStream.h: begin() on the stream, printInternal on the stream begin() returned for each value, then end() on the original stream. printInternal for const char*, double, long and unsigned passes %s, %lf, %ld and %u to the guest stream's vprintf with a SysV va_list (as VaList*, the way sceFiosPrintf and sceAvPlayerPrintf forward theirs), as PrintStream.cpp does; formatting stays the stream's job. printInternal(ClockType) nests its own print, as upstream does. The guest vtable slots (vprintf 2, begin 4, end 5) come from the declaration order in PrintStream.h. MediaTime::toDouble is the existing export in Media.cpp.

The dumps call the vtable slots directly through a private helper instead of the printInternal exports, so building and testing this PR does not need #19839 (PrintStream::printf and printInternal for scalars, C strings, CString and RawPointer, and dumpCharacter) or #19841 (printInternal for the remaining integer widths, float and ClockType, stacked on #19839); once those merge the helper can be replaced by their exports in a follow-up. At run time there is one dependency: end() is a virtual call, so a guest stream that keeps the base WTF::PrintStream::end reaches main's _ZN3WTF11PrintStream3endEv stub (libSceNKWebKit/Export.cpp line 14277) and throws not implemented after the values have been printed. #19380 (WTF StackBounds, TimingScope::scopeDidEnd and PrintStream::end) gives end WebKit's empty body; until it merges, these dumps complete only on streams that override end(). An unknown ClockType throws (WebKit RELEASE_ASSERT_NOT_REACHED), and null this or stream pointers throw where WebKit faults. The debt fragment removes the six rows, adds an entry for the unmeasured slots and layouts, and narrows the Media stubs entry to PlatformTimeRanges::dump.

Tested

macOS 27 (Apple Silicon, x86_64 build under Rosetta, Release, Ninja). Merged onto main 2e48261498a and rebuilt; the four focused tests pass again there. New test nkwebkit_wtftimedump (core/libs/prx/libSceNKWebKit/tests/WtfTimeDump.cpp) drives every dump through a recording guest PrintStream whose begin returns a second stream and whose vprintf formats with the guest vsnprintf: exact begin/vprintf/end sequences for all six dumps, all three clock types, rational, double, infinite and large negative MediaTime values, an unknown ClockType throwing before begin, and null this/stream pointers throwing. Control: the same test with main's stub bodies throws not implemented on the first dump (exit 134). public_headers and its 64 compile tests, nkwebkit_mediatime, nkwebkit_argumentreturn and nkwebkit_wtf also pass (69/69). On that main, libressl_crypto does not build on macOS (libressl/strlcat.c and strlcpy.c from #17961 collide with the _FORTIFY_SOURCE macros in the macOS string.h), so for this run those two files had a local #undef that is not part of this PR. python3 tools/check_conventions.py --base origin/main and python3 tools/debt_fold.py --check pass apart from the existing failure in main's docs-nkwebkit-drop-readded-count-lines.md fragment. tools/progress.py --module libSceNKWebKit: libSceNKWebKit 3240/11268 (28.75%) on main 2e48261498, 3246/11268 (28.81%) after, the six dumps moving from todo to implemented. Windows: src/WtfTimeDump.cpp compiled alone on Windows 11 with winlibs GCC 15.2.0 (the CI toolchain), using the libSceNKWebKit compile line from a Windows build tree (-O3 -DNDEBUG -std=gnu++20 -fno-asynchronous-unwind-tables -include HostStandardStreams.hpp), and again at -O0 and -O2: the object builds; the library and tests were not linked or run on Windows. The MSYS2 UCRT64 GCC 16 nightly toolchain was not tried. tools/pr_overlap.py --branch reports no open pull request changing the same lines, exports or new files.

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 to build and test; #19380 at run time for streams that keep the base end() (see What)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5346829611 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21957). Originally posted by [frankea](https://github.com/frankea) on 2026-11-16T23:04:38Z. --- ### What Implements six libSceNKWebKit WTF `dump(PrintStream&)` exports that were `NotImplemented_nid_no_patch` stubs: `Seconds::dump`, `WallTime::dump`, `MonotonicTime::dump`, `TimeWithDynamicClockType::dump`, `MediaTime::dump` and `ASCIILiteral::dump`. Source is a mirror of Sony's PS5 WebKit 11.x source release, [neonmodder123/PS5-WebKit-11.x@80f77e94](https://github.com/neonmodder123/PS5-WebKit-11.x/tree/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf), the same tree #19828 cites: [Seconds.cpp L80-L83](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/Seconds.cpp#L80-L83) (`m_value, " sec"`), [WallTime.cpp L41-L44](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/WallTime.cpp#L41-L44), [MonotonicTime.cpp L41-L44](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/MonotonicTime.cpp#L41-L44), [TimeWithDynamicClockType.cpp L131-L134](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/TimeWithDynamicClockType.cpp#L131-L134) with the `Wall`/`Monotonic`/`Approximate` names of [ClockType.cpp L33-L47](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/ClockType.cpp#L33-L47), [MediaTime.cpp L539-L545](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/MediaTime.cpp#L539-L545) and [text/ASCIILiteral.cpp L33-L36](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/ASCIILiteral.cpp#L33-L36). Each `out.print(...)` follows [PrintStream.h](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/PrintStream.h#L53-L101): `begin()` on the stream, `printInternal` on the stream `begin()` returned for each value, then `end()` on the original stream. `printInternal` for `const char*`, `double`, `long` and `unsigned` passes `%s`, `%lf`, `%ld` and `%u` to the guest stream's `vprintf` with a SysV `va_list` (as `VaList*`, the way `sceFiosPrintf` and `sceAvPlayerPrintf` forward theirs), as [PrintStream.cpp](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/PrintStream.cpp#L71-L190) does; formatting stays the stream's job. `printInternal(ClockType)` nests its own `print`, as upstream does. The guest vtable slots (`vprintf` 2, `begin` 4, `end` 5) come from the declaration order in PrintStream.h. `MediaTime::toDouble` is the existing export in Media.cpp. The dumps call the vtable slots directly through a private helper instead of the `printInternal` exports, so building and testing this PR does not need #19839 (`PrintStream::printf` and `printInternal` for scalars, C strings, `CString` and `RawPointer`, and `dumpCharacter`) or #19841 (`printInternal` for the remaining integer widths, float and `ClockType`, stacked on #19839); once those merge the helper can be replaced by their exports in a follow-up. At run time there is one dependency: `end()` is a virtual call, so a guest stream that keeps the base `WTF::PrintStream::end` reaches main's `_ZN3WTF11PrintStream3endEv` stub (`libSceNKWebKit/Export.cpp` line 14277) and throws `not implemented` after the values have been printed. #19380 (WTF `StackBounds`, `TimingScope::scopeDidEnd` and `PrintStream::end`) gives `end` WebKit's empty body; until it merges, these dumps complete only on streams that override `end()`. An unknown `ClockType` throws (WebKit `RELEASE_ASSERT_NOT_REACHED`), and null `this` or stream pointers throw where WebKit faults. The debt fragment removes the six rows, adds an entry for the unmeasured slots and layouts, and narrows the Media stubs entry to `PlatformTimeRanges::dump`. ### Tested macOS 27 (Apple Silicon, x86_64 build under Rosetta, Release, Ninja). Merged onto main `2e48261498a` and rebuilt; the four focused tests pass again there. New test `nkwebkit_wtftimedump` (core/libs/prx/libSceNKWebKit/tests/WtfTimeDump.cpp) drives every dump through a recording guest `PrintStream` whose `begin` returns a second stream and whose `vprintf` formats with the guest `vsnprintf`: exact begin/vprintf/end sequences for all six dumps, all three clock types, rational, double, infinite and large negative `MediaTime` values, an unknown `ClockType` throwing before `begin`, and null `this`/stream pointers throwing. Control: the same test with main's stub bodies throws `not implemented` on the first dump (exit 134). `public_headers` and its 64 compile tests, `nkwebkit_mediatime`, `nkwebkit_argumentreturn` and `nkwebkit_wtf` also pass (69/69). On that main, `libressl_crypto` does not build on macOS (`libressl/strlcat.c` and `strlcpy.c` from #17961 collide with the `_FORTIFY_SOURCE` macros in the macOS `string.h`), so for this run those two files had a local `#undef` that is not part of this PR. `python3 tools/check_conventions.py --base origin/main` and `python3 tools/debt_fold.py --check` pass apart from the existing failure in main's `docs-nkwebkit-drop-readded-count-lines.md` fragment. `tools/progress.py --module libSceNKWebKit`: libSceNKWebKit 3240/11268 (28.75%) on `main` 2e48261498a, 3246/11268 (28.81%) after, the six dumps moving from todo to implemented. Windows: `src/WtfTimeDump.cpp` compiled alone on Windows 11 with winlibs GCC 15.2.0 (the CI toolchain), using the libSceNKWebKit compile line from a Windows build tree (`-O3 -DNDEBUG -std=gnu++20 -fno-asynchronous-unwind-tables -include HostStandardStreams.hpp`), and again at `-O0` and `-O2`: the object builds; the library and tests were not linked or run on Windows. The MSYS2 UCRT64 GCC 16 nightly toolchain was not tried. `tools/pr_overlap.py --branch` reports no open pull request changing the same lines, exports or new files. ### 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) 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 to build and test; #19380 at run time for streams that keep the base `end()` (see What) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code)
PrivacyOnion commented 2026-11-16 23:19:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T23:19:32Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 523d4550d0:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_wtftimedump_tests built cleanly.
  • CTest (nkwebkit_wtftimedump):
    1/1 Test #4414: nkwebkit_wtftimedump .............   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp, core/libs/prx/libSceNKWebKit/src/WtfTimeDump.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Checked pointer validation in all 6 exported dump functions (_ZNK3WTF...dump...); null self and null out properly throw std::invalid_argument.
    • Verified PrintStream vtable layout and calling convention matches PS5 WebKit 11.x (slots: Vprintf 2, Begin 4, End 5) with APS5_VABI and SysV/MS ABI handling for variadic calls.
    • Checked integer format specifiers in PrintInternal across LP64 and LLP64 platforms; std::int64_t uses %ld, uint32_t uses %u, double uses %lf.
    • Verified MediaTime::dump branch for double value vs rational (timeValue/timeScale = toDouble) against upstream WebKit implementation.
    • Audited AGENTS.md compliance: license headers present, no prohibited comments, debt changes fragment properly formatted in docs/dev/debt/changes/feat-nkwebkit-wtf-time-dumps.md, and test coverage exercises all dumped types and null inputs.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5929646066 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21957#pullrequestreview-5929646066). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T23:19:32Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `523d4550d0`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_wtftimedump_tests` built cleanly. - **CTest** (`nkwebkit_wtftimedump`): ``` 1/1 Test #4414: nkwebkit_wtftimedump ............. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp`, `core/libs/prx/libSceNKWebKit/src/WtfTimeDump.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Checked pointer validation in all 6 exported dump functions (_ZNK3WTF...dump...); null self and null out properly throw std::invalid_argument. - Verified PrintStream vtable layout and calling convention matches PS5 WebKit 11.x (slots: Vprintf 2, Begin 4, End 5) with APS5_VABI and SysV/MS ABI handling for variadic calls. - Checked integer format specifiers in PrintInternal across LP64 and LLP64 platforms; std::int64_t uses %ld, uint32_t uses %u, double uses %lf. - Verified MediaTime::dump branch for double value vs rational (timeValue/timeScale = toDouble) against upstream WebKit implementation. - Audited AGENTS.md compliance: license headers present, no prohibited comments, debt changes fragment properly formatted in docs/dev/debt/changes/feat-nkwebkit-wtf-time-dumps.md, and test coverage exercises all dumped types and null inputs. Looks Good To Me
MarcZX10 commented 2026-11-20 05:21:45 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — comments

The reviewed changes implement six dump exports with tests, but their direct guest vtable calls and time layouts are explicitly unmeasured on console, so approval is not justified from the available evidence.

What I ran

Reviewed head bea07ca55a15904592197c3d00e7ae5124da3904. I read the prepared description, commits, diff, manifest, all changed files included in the review folder, and targeted repository context through repo_read.py. No commands or tests were run by me; test results below are author-reported.

Results

Check Result Note
Source review passed Changed implementation and tests read
Tests not run Description reports 69/69 on merged main
Console ABI not verified Vtable slots and time layouts unmeasured

Findings

Blocking

None.

Non-blocking

  • WtfTimeDump.cpp:247-265 calls the guest vprintf slot with an assumed VaList* representation, and WtfDumpStreamAbi.hpp:11-14 hard-codes the vtable slots. These assumptions are disclosed in the debt entry, but have not been confirmed against a console stream. A console-level check would provide evidence for the runtime ABI claims.

Not verified

  • I did not run the tests or build. The test results and control run are author-reported.
  • Console behavior and the PrintStream vtable and time layouts are not verified, as the debt entry also records.
  • Export.cpp and InventoryExports.hpp were read through the pinned reader because the prepared bundle excluded their full text for size; other changed files were included in the bundle and read. No changed files were excluded from review.

To get this to a good state

Nothing is required. Optional: verify the guest stream ABI on console and update the debt note with the observed result.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5987918867 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21957#pullrequestreview-5987918867). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T05:21:45Z. **Review:** COMMENTED --- # Reviewed — comments The reviewed changes implement six dump exports with tests, but their direct guest vtable calls and time layouts are explicitly unmeasured on console, so approval is not justified from the available evidence. ## What I ran Reviewed head `bea07ca55a15904592197c3d00e7ae5124da3904`. I read the prepared description, commits, diff, manifest, all changed files included in the review folder, and targeted repository context through `repo_read.py`. No commands or tests were run by me; test results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | Changed implementation and tests read | | Tests | not run | Description reports 69/69 on merged main | | Console ABI | not verified | Vtable slots and time layouts unmeasured | ## Findings ### Blocking None. ### Non-blocking - `WtfTimeDump.cpp:247-265` calls the guest `vprintf` slot with an assumed `VaList*` representation, and `WtfDumpStreamAbi.hpp:11-14` hard-codes the vtable slots. These assumptions are disclosed in the debt entry, but have not been confirmed against a console stream. A console-level check would provide evidence for the runtime ABI claims. ## Not verified - I did not run the tests or build. The test results and control run are author-reported. - Console behavior and the `PrintStream` vtable and time layouts are not verified, as the debt entry also records. - `Export.cpp` and `InventoryExports.hpp` were read through the pinned reader because the prepared bundle excluded their full text for size; other changed files were included in the bundle and read. No changed files were excluded from review. ## To get this to a good state Nothing is required. Optional: verify the guest stream ABI on console and update the debt note with the observed result.
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!21957
No description provided.