feat(libSceNKWebKit): implement WTF symbol strings #14919

Closed
w4rc0n wants to merge 3 commits from upstream-pr/14919 into main
w4rc0n commented 2026-11-02 01:31:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by w4rc0n on 2026-11-02T01:31:38Z.


What

WTF symbol strings were missing: SymbolImpl::nextHashForSymbol, SymbolImpl::create, SymbolImpl::createNullSymbol and PrivateSymbolImpl::create were NotImplemented stubs. #14917's destruction and #14918's atom paths also threw for symbols. JavaScriptCore makes a symbol for every JS Symbol(), so those paths stopped. All four now follow the pinned PS5 WebKit 11.x SymbolImpl.cpp:

  • Layout: SymbolImpl is 40 bytes, following SymbolImpl.h:

    • the 24-byte StringImpl header;
    • the buffer owner;
    • the identity hash: nonzero, distinct and clear of the flag bits, including concurrent calls;
    • the flags (null symbol and private).

    It is pinned with static_assert.

  • Creation: symbols share their text's buffer and hold a reference to its owner, as createSubstringSharingImpl does.

  • Hash counter: nextHashForSymbol returns distinct nonzero values with the low s_flagCount bits clear, from a relaxed std::atomic counter shifted past the flags. It skips 0, because StringImpl treats a zero hash as not yet computed. It is written independently and doesn't reproduce the pinned sequence (a step of 1 << s_flagCount with the top bit set); the debt entry says so.

  • Destruction: null, ordinary and private symbols release their owner through the existing substring path (StringImpl.cpp:113-157), so "symbol" drops out of #14917's debt entry.

  • Atomization: following AtomStringImpl.cpp:340-408, atomizing a symbol never inserts the symbol itself. It copies short text, or makes an ordinary substring that shares the owner, so "symbol" drops out of #14918's debt entry.

RegisteredSymbolImpl and SymbolRegistry::symbolForKey / ~SymbolRegistry stay NotImplemented, because they need the guest HashSet<RefPtr<StringImpl>> layout. Registered symbols and external buffers still throw where they reach destruction, and the debt records it.

Adapted source. The symbol constructors and the shared-substring constructor are adapted from the pinned SymbolImpl.cpp:45-54, SymbolImpl.h:90-118 and StringImpl.h:991. They sit beside #14918's adapted code in src/WtfAtoms.cpp, with those files' notices in the same form. nextHashForSymbol is independent (above).

tools/pr_overlap.py on this head, with main at 0eba5db30d: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge with main, GitHub's file lists show none of them changing these exports either. #13992, #14172, #14607, #15214, #15241 and #15867 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14917, #14918 and #14920, in the same stack.

Tested

Debian 12, GCC 12.2, Linux 6.18, Release, at the head 911bcec53185ff3d6d24d11b08789048bfbaa8c2. It sits on #14918's head 129fe3b329162644709464a22d3f1e129f9f1a8b, which sits on #14917's head 95dfdd5f7ea918208115e660db29009d06db3174. No local changes.

  • guest_nkwebkit_dates, guest_nkwebkit_numbers, nkwebkit_base, nkwebkit_config, nkwebkit_constants, nkwebkit_fastbitvector, nkwebkit_jsc, nkwebkit_palsessionid, nkwebkit_preferences, nkwebkit_resourceresponse, nkwebkit_webcoregeometry, nkwebkit_wtf, guest_nkwebkit_urls and public_headers pass. The new nkwebkit_wtf cases cover:
    • distinct hashes across calls;
    • symbols from 8-bit and 16-bit text and from a substring, with owner reference counts;
    • the null and private flags;
    • destroying each kind of symbol and getting the owner's reference back;
    • atom lookups of a symbol's text not finding the symbol;
    • atom adds with a symbol input.
  • tools/progress.py: the four exports count as implemented (libSceNKWebKit 1332, against 1328 with #14918).
  • tools/check_conventions.py passes.
  • Windows (GitHub-hosted CI in the author's fork): run 41816855710 built feat/nkwebkit-external-strings at its previous head 9d1e021975e6ecbdaf395584d055bc9653d825d2, which contains this PR's commit. It is AnyPS5's Build workflow, dispatched in the author's fork with select=true: the branch merged into main at b11c7bf84f5d2f636ff60166cc3371bd071e24d5, built on windows-latest with WinLibs GCC 15.2 (MinGW-w64, UCRT). All 1390 selected tests passed, none skipped, including the twelve NKWebKit tests, public_headers and patched_libraries. The run started before the fork had a test graph for this main, so it selected more tests than usual. A fork-internal pull request existed only to give the workflow a number. The rebase onto main at 0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4 after #15911 changed only docs/dev/debt/libSceNKWebKit.md, so git range-diff shows the code and tests under test are the same as at that run.

Not built or run: macOS. No title or homebrew was 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: #14918
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5113581229 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14919). Originally posted by [w4rc0n](https://github.com/w4rc0n) on 2026-11-02T01:31:38Z. --- ### What WTF symbol strings were missing: `SymbolImpl::nextHashForSymbol`, `SymbolImpl::create`, `SymbolImpl::createNullSymbol` and `PrivateSymbolImpl::create` were `NotImplemented` stubs. #14917's destruction and #14918's atom paths also threw for symbols. JavaScriptCore makes a symbol for every JS `Symbol()`, so those paths stopped. All four now follow the pinned PS5 WebKit 11.x [`SymbolImpl.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/SymbolImpl.cpp#L37-L66): - **Layout:** `SymbolImpl` is 40 bytes, following [`SymbolImpl.h`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/SymbolImpl.h): - the 24-byte `StringImpl` header; - the buffer owner; - the identity hash: nonzero, distinct and clear of the flag bits, including concurrent calls; - the flags (null symbol and private). It is pinned with `static_assert`. - **Creation:** symbols share their text's buffer and hold a reference to its owner, as `createSubstringSharingImpl` does. - **Hash counter:** `nextHashForSymbol` returns distinct nonzero values with the low `s_flagCount` bits clear, from a relaxed `std::atomic` counter shifted past the flags. It skips 0, because `StringImpl` treats a zero hash as not yet computed. It is written independently and doesn't reproduce the pinned sequence (a step of `1 << s_flagCount` with the top bit set); the debt entry says so. - **Destruction:** null, ordinary and private symbols release their owner through the existing substring path ([`StringImpl.cpp:113-157`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringImpl.cpp#L113-L157)), so "symbol" drops out of #14917's debt entry. - **Atomization:** following [`AtomStringImpl.cpp:340-408`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/AtomStringImpl.cpp#L340-L408), atomizing a symbol never inserts the symbol itself. It copies short text, or makes an ordinary substring that shares the owner, so "symbol" drops out of #14918's debt entry. `RegisteredSymbolImpl` and `SymbolRegistry::symbolForKey` / `~SymbolRegistry` stay `NotImplemented`, because they need the guest `HashSet<RefPtr<StringImpl>>` layout. Registered symbols and external buffers still throw where they reach destruction, and the debt records it. **Adapted source.** The symbol constructors and the shared-substring constructor are adapted from the pinned [`SymbolImpl.cpp:45-54`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/SymbolImpl.cpp#L45-L54), [`SymbolImpl.h:90-118`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/SymbolImpl.h#L90-L118) and [`StringImpl.h:991`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringImpl.h#L991). They sit beside #14918's adapted code in `src/WtfAtoms.cpp`, with those files' notices in the same form. `nextHashForSymbol` is independent (above). `tools/pr_overlap.py` on this head, with `main` at `0eba5db30d`: no other open PR changes these exports or adds the same files. For the PRs it couldn't compare because they no longer merge with `main`, GitHub's file lists show none of them changing these exports either. #13992, #14172, #14607, #15214, #15241 and #15867 change nearby lines in the same files; whichever merges later keeps both sides. The only exports it shares are with #14917, #14918 and #14920, in the same stack. ### 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. --> Debian 12, GCC 12.2, Linux 6.18, Release, at the head `911bcec53185ff3d6d24d11b08789048bfbaa8c2`. It sits on #14918's head `129fe3b329162644709464a22d3f1e129f9f1a8b`, which sits on #14917's head `95dfdd5f7ea918208115e660db29009d06db3174`. No local changes. - `guest_nkwebkit_dates`, `guest_nkwebkit_numbers`, `nkwebkit_base`, `nkwebkit_config`, `nkwebkit_constants`, `nkwebkit_fastbitvector`, `nkwebkit_jsc`, `nkwebkit_palsessionid`, `nkwebkit_preferences`, `nkwebkit_resourceresponse`, `nkwebkit_webcoregeometry`, `nkwebkit_wtf`, `guest_nkwebkit_urls` and `public_headers` pass. The new `nkwebkit_wtf` cases cover: - distinct hashes across calls; - symbols from 8-bit and 16-bit text and from a substring, with owner reference counts; - the null and private flags; - destroying each kind of symbol and getting the owner's reference back; - atom lookups of a symbol's text not finding the symbol; - atom adds with a symbol input. - `tools/progress.py`: the four exports count as implemented (libSceNKWebKit 1332, against 1328 with #14918). - `tools/check_conventions.py` passes. - **Windows (GitHub-hosted CI in the author's fork):** [run 41816855710](https://github.com/w4rc0n/AnyPS5/actions/runs/41816855710) built `feat/nkwebkit-external-strings` at its previous head `9d1e021975e6ecbdaf395584d055bc9653d825d2`, which contains this PR's commit. It is AnyPS5's `Build` workflow, dispatched in the author's fork with `select=true`: the branch merged into `main` at `b11c7bf84f5d2f636ff60166cc3371bd071e24d5`, built on `windows-latest` with WinLibs GCC 15.2 (MinGW-w64, UCRT). All 1390 selected tests passed, none skipped, including the twelve NKWebKit tests, `public_headers` and `patched_libraries`. The run started before the fork had a test graph for this `main`, so it selected more tests than usual. A fork-internal pull request existed only to give the workflow a number. The rebase onto `main` at `0eba5db30d8a3d03789e52e5c1a9ff853e4e33e4` after #15911 changed only `docs/dev/debt/libSceNKWebKit.md`, so `git range-diff` shows the code and tests under test are the same as at that run. Not built or run: macOS. No title or homebrew was 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: #14918 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

Pull request closed

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!14919
No description provided.