feat(libSceNKWebKit): implement WTF::String::simplifyWhiteSpace #16890

Merged
AlexWhitehouse merged 1 commit from upstream-pr/16890 into main 2026-11-11 15:54:56 +00:00
AlexWhitehouse commented 2026-11-07 20:42:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexWhitehouse on 2026-11-07T20:42:08Z.


What

libSceNKWebKit WTF::String::simplifyWhiteSpace(bool (*)(UChar)) const (_ZNK3WTF6String18simplifyWhiteSpaceEPFbDsE, NID xuaSjMP7VYc) threw not implemented. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94:

Behaviour, line for line with upstream:

  • characters the predicate matches are skipped at both ends;
  • each interior run of matching characters becomes one ASCII space;
  • changedToSpace records a matched character other than ' ';
  • if nothing changed, the same StringImpl is returned (one more reference). Otherwise a new impl of the same width is built through the existing TryCreateUninitialized, which gives the shared empty impl for an all-matching string, as StringImpl::adopt does.

The predicate is called in upstream's order. It is a guest function, so it is called with the guest's System V ABI (APS5_VABI) on every host.

A null this, or a non-empty string with no character storage or no predicate, throws, because upstream would dereference null. The new source starts with the notices of both files, byte for byte. The stub and its inventory row are removed, the NKWebKit count drops from 6368 to 6367, and a debt entry records that the console ABI and behaviour are unverified.

Tested

  • New test: nkwebkit_wtfwhitespace (core/libs/prx/libSceNKWebKit/tests/WtfWhitespace.cpp) covers:
    • null, empty, all-matching (giving the empty impl) and unchanged strings (the same impl, with the reference count checked);
    • leading and trailing runs, and mixed tabs and spaces;
    • 8-bit and UTF-16 strings;
    • a custom predicate that matches punctuation;
    • the exact sequence of characters passed to the predicate, compared with upstream's traversal.
  • Linux x86-64 (Ubuntu 26.04, GCC 15, Release):
    • on main, the test fails with _ZNK3WTF6String18simplifyWhiteSpaceEPFbDsE not implemented;
    • with this PR, it passes.
  • Windows 11: (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): nkwebkit_wtfwhitespace, nkwebkit_wtftext and nkwebkit_wtftext_allocation pass at a8d8e85152, so the System V predicate calls work under MinGW, with no compiler warnings in the changed files.
  • Mutation check: skipping the trailing trim fails the result-length assertion.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • python3 tools/pr_overlap.py: no open PR implements simplifyWhiteSpace.
    • #15246, #16316 and my #16642, #16643 and #16853 conflict only on the NKWebKit count line. Whichever merges second recounts.
    • #16041 removes Logger exports right before this stub: Export.cpp merges cleanly, and the neighbouring header and debt lines conflict textually.
    • I checked the changed lines of the other 73 NKWebKit PRs the tool listed. None implements this export.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5205660140 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16890). Originally posted by [AlexWhitehouse](https://github.com/AlexWhitehouse) on 2026-11-07T20:42:08Z. --- ### What libSceNKWebKit `WTF::String::simplifyWhiteSpace(bool (*)(UChar)) const` (`_ZNK3WTF6String18simplifyWhiteSpaceEPFbDsE`, NID `xuaSjMP7VYc`) threw `not implemented`. This PR ports it from the PS5 WebKit tree the other NKWebKit ports use, 80f77e94: - [`WTFString.cpp` lines 162–166](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/WTFString.cpp#L162-L166): a null String returns null; otherwise it forwards to the impl. - [`StringImpl.cpp` lines 749–789](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/text/StringImpl.cpp#L749-L789): `simplifyMatchedCharactersToSpace`, for 8-bit or 16-bit strings. Behaviour, line for line with upstream: - characters the predicate matches are skipped at both ends; - each interior run of matching characters becomes one ASCII space; - `changedToSpace` records a matched character other than `' '`; - if nothing changed, the same `StringImpl` is returned (one more reference). Otherwise a new impl of the same width is built through the existing `TryCreateUninitialized`, which gives the shared empty impl for an all-matching string, as `StringImpl::adopt` does. The predicate is called in upstream's order. It is a guest function, so it is called with the guest's System V ABI (`APS5_VABI`) on every host. A null `this`, or a non-empty string with no character storage or no predicate, throws, because upstream would dereference null. The new source starts with the notices of both files, byte for byte. The stub and its inventory row are removed, the NKWebKit count drops from 6368 to 6367, and a debt entry records that the console ABI and behaviour are unverified. ### Tested - **New test:** `nkwebkit_wtfwhitespace` (`core/libs/prx/libSceNKWebKit/tests/WtfWhitespace.cpp`) covers: - null, empty, all-matching (giving the empty impl) and unchanged strings (the same impl, with the reference count checked); - leading and trailing runs, and mixed tabs and spaces; - 8-bit and UTF-16 strings; - a custom predicate that matches punctuation; - the exact sequence of characters passed to the predicate, compared with upstream's traversal. - **Linux x86-64** (Ubuntu 26.04, GCC 15, Release): - on `main`, the test fails with `_ZNK3WTF6String18simplifyWhiteSpaceEPFbDsE not implemented`; - with this PR, it passes. - **Windows 11:** (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release): `nkwebkit_wtfwhitespace`, `nkwebkit_wtftext` and `nkwebkit_wtftext_allocation` pass at a8d8e85152, so the System V predicate calls work under MinGW, with no compiler warnings in the changed files. - **Mutation check:** skipping the trailing trim fails the result-length assertion. - `python3 tools/check_conventions.py --base origin/main`: all checks passed. - **`python3 tools/pr_overlap.py`:** no open PR implements `simplifyWhiteSpace`. - #15246, #16316 and my #16642, #16643 and #16853 conflict only on the NKWebKit count line. Whichever merges second recounts. - #16041 removes Logger exports right before this stub: `Export.cpp` merges cleanly, and the neighbouring header and debt lines conflict textually. - I checked the changed lines of the other 73 NKWebKit PRs the tool listed. None implements this export. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
gabichuuuuu commented 2026-11-07 22:15:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T22:15:43Z.

Review: COMMENTED


Read a8d8e85152 against main.

Simplify follows simplifyMatchedCharactersToSpace (StringImpl.cpp:749-789) step by step: the same predicate call order, changedToSpace only for non-space matches, the trailing-space trim, and reuse of the same impl when nothing changed. outc can't exceed the input length. TryCreateUninitialized(0) returns the retained 8-bit empty impl, which matches adopt returning *empty(), and the width is preserved otherwise. The sret, this and predicate argument order match the Itanium const member, and the predicate is called as APS5_VABI. I found no defect. The 6368 to 6367 count is right for current main; it collides only with #16901 and #16853 on that line.

Not run here; this is from reading the code.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5815249435 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16890#pullrequestreview-5815249435). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T22:15:43Z. **Review:** COMMENTED --- Read `a8d8e85152` against `main`. `Simplify` follows `simplifyMatchedCharactersToSpace` (StringImpl.cpp:749-789) step by step: the same predicate call order, `changedToSpace` only for non-space matches, the trailing-space trim, and reuse of the same impl when nothing changed. `outc` can't exceed the input length. `TryCreateUninitialized(0)` returns the retained 8-bit empty impl, which matches `adopt` returning `*empty()`, and the width is preserved otherwise. The sret, `this` and predicate argument order match the Itanium const member, and the predicate is called as `APS5_VABI`. I found no defect. The 6368 to 6367 count is right for current `main`; it collides only with #16901 and #16853 on that line. Not run here; this is from reading the code. 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!16890
No description provided.