feat(libSceNKWebKit): implement WTF::Logger string conversions #16041

Merged
gslashm merged 2 commits from upstream-pr/16041 into main 2026-11-08 17:45:25 +00:00
gslashm commented 2026-11-05 12:48:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gslashm on 2026-11-05T12:48:49Z.


What

Implements two libSceNKWebKit exports from Source/WTF/wtf/Logger.cpp:38-48 at 80f77e94c6:

  • WTF::Logger::LogSiteIdentifier::toString() const
  • WTF::LogArgument<void const*>::toString(const void*)

LogArgument<const void*>::toString is static (Logger.h:382-384), so it takes only the pointer argument. LogSiteIdentifier is className at 0, methodName at 8 and objectPtr at 16, size 24 (Logger.h:284-286), pinned in src/WtfStringAbi.hpp. Both return WTF::String by value; String is 8 bytes with a non-trivial destructor, so the result goes through the hidden return pointer, as the existing String exports do.

The two functions follow makeString over 8-bit adapters (StringConcatenate.h:472-496). LogArgument<const void*>::toString returns (<hex>). LogSiteIdentifier::toString returns <className>::<methodName>(<hex>) when className is non-null, even when it is empty, and <methodName>(<hex>) otherwise; both end with a space. hex is uppercase, has no 0x prefix and no minimum digits, and 0 prints 0 (HexNumber.cpp:33-45). const char* arguments are copied as bytes (StringConcatenate.h:84-106,135-141), so every result is 8-bit and bytes above 0x7F are kept.

Where upstream crashes, this throws and the debt file says so: a null methodName reaches strlen(nullptr), a null self is dereferenced, a single name above String::MaxLength (INT32_MAX, StringImpl.h:151) hits RELEASE_ASSERT (StringConcatenate.h:97-102), and a total above it reaches makeString's CRASH() (StringConcatenate.h:493-494). Here a null self or methodName throws std::invalid_argument and an oversized result throws std::length_error, the same exception the existing StringImpl::create export uses. Not compared with a console module.

tools/pr_overlap.py lists #13486 under the same exports. That PR is a relinker draft whose head is unchanged at 0bde10d243 and whose merge base 87755c8519 predates the 8703 stubs, so its diff re-adds them, all still throwing; it implements neither export. No open PR adds the same new files. The tool could not compare 44 PRs that conflict with main; toolchain/nkwebkit_batch_check.py compared their changed lines and none shares either export, and a scan of all 101 open NKWebKit heads found no other LogSiteIdentifier or WtfLogger reference. Line conflicts are the debt count line (docs/dev/debt/libSceNKWebKit.md:39), the lines the new debt entry occupies (:14-15, #16016), the neighbouring stubs (Export.cpp:36497-36508, InventoryExports.hpp:6121-6123, #13992), the deleted debt rows (:6044-6046, #13992) and the end of src/WtfStringAbi.hpp, where #15866 adds SHA1 and #15517 also edits the file. Whichever merges later keeps both sides.

Tested

Windows 11 Pro, WinLibs GCC 15.2.0. No title and no console module. nkwebkit_wtflogger pins both signatures with static_assert and, for every result, checks a non-null impl, the 8-bit flag (hashAndFlags & 4), the exact length and the exact bytes: (0), (10), (ABC) and (FFFFFFFFFFFFFFFF); Cls::run(1F) , run(1F) , ::run(0) and caf\xE9::m(1) with the byte above 0x7F kept; a null method name and a null self throw. The oversized path is not exercised, because it needs a string of about 2 GB. The test runs and prints both expected lines; ctest -R nkwebkit_wtflogger passes. cmake --build build --parallel -- -k 0 exits 0. ctest -R nkwebkit: 14 of 14 pass. ctest -R public_headers: 65 of 65 pass. tools/progress.py: 1323 of 11248, two more than main (1321). Whole suite not run.

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 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:5171811977 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16041). Originally posted by [gslashm](https://github.com/gslashm) on 2026-11-05T12:48:49Z. --- ### What Implements two `libSceNKWebKit` exports from `Source/WTF/wtf/Logger.cpp:38-48` at `80f77e94c6`: - `WTF::Logger::LogSiteIdentifier::toString() const` - `WTF::LogArgument<void const*>::toString(const void*)` `LogArgument<const void*>::toString` is `static` (`Logger.h:382-384`), so it takes only the pointer argument. `LogSiteIdentifier` is `className` at 0, `methodName` at 8 and `objectPtr` at 16, size 24 (`Logger.h:284-286`), pinned in `src/WtfStringAbi.hpp`. Both return `WTF::String` by value; `String` is 8 bytes with a non-trivial destructor, so the result goes through the hidden return pointer, as the existing `String` exports do. The two functions follow `makeString` over 8-bit adapters (`StringConcatenate.h:472-496`). `LogArgument<const void*>::toString` returns `(<hex>)`. `LogSiteIdentifier::toString` returns `<className>::<methodName>(<hex>) ` when `className` is non-null, even when it is empty, and `<methodName>(<hex>) ` otherwise; both end with a space. `hex` is uppercase, has no `0x` prefix and no minimum digits, and 0 prints `0` (`HexNumber.cpp:33-45`). `const char*` arguments are copied as bytes (`StringConcatenate.h:84-106,135-141`), so every result is 8-bit and bytes above 0x7F are kept. Where upstream crashes, this throws and the debt file says so: a null `methodName` reaches `strlen(nullptr)`, a null `self` is dereferenced, a single name above `String::MaxLength` (`INT32_MAX`, `StringImpl.h:151`) hits `RELEASE_ASSERT` (`StringConcatenate.h:97-102`), and a total above it reaches `makeString`'s `CRASH()` (`StringConcatenate.h:493-494`). Here a null `self` or `methodName` throws `std::invalid_argument` and an oversized result throws `std::length_error`, the same exception the existing `StringImpl::create` export uses. Not compared with a console module. `tools/pr_overlap.py` lists #13486 under the same exports. That PR is a relinker draft whose head is unchanged at `0bde10d243` and whose merge base `87755c8519` predates the 8703 stubs, so its diff re-adds them, all still throwing; it implements neither export. No open PR adds the same new files. The tool could not compare 44 PRs that conflict with `main`; `toolchain/nkwebkit_batch_check.py` compared their changed lines and none shares either export, and a scan of all 101 open NKWebKit heads found no other `LogSiteIdentifier` or `WtfLogger` reference. Line conflicts are the debt count line (`docs/dev/debt/libSceNKWebKit.md:39`), the lines the new debt entry occupies (`:14-15`, #16016), the neighbouring stubs (`Export.cpp:36497-36508`, `InventoryExports.hpp:6121-6123`, #13992), the deleted debt rows (`:6044-6046`, #13992) and the end of `src/WtfStringAbi.hpp`, where #15866 adds `SHA1` and #15517 also edits the file. Whichever merges later keeps both sides. ### 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. No title and no console module. `nkwebkit_wtflogger` pins both signatures with `static_assert` and, for every result, checks a non-null `impl`, the 8-bit flag (`hashAndFlags & 4`), the exact length and the exact bytes: `(0)`, `(10)`, `(ABC)` and `(FFFFFFFFFFFFFFFF)`; `Cls::run(1F) `, `run(1F) `, `::run(0) ` and `caf\xE9::m(1) ` with the byte above 0x7F kept; a null method name and a null `self` throw. The oversized path is not exercised, because it needs a string of about 2 GB. The test runs and prints both expected lines; `ctest -R nkwebkit_wtflogger` passes. `cmake --build build --parallel -- -k 0` exits 0. `ctest -R nkwebkit`: 14 of 14 pass. `ctest -R public_headers`: 65 of 65 pass. `tools/progress.py`: 1323 of 11248, two more than `main` (1321). Whole suite not run. ### 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 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
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!16041
No description provided.