feat(libSceNKWebKit): implement the WTF::StringBuilder and WTF::TextStream exports #14172

Merged
winstrex merged 10 commits from upstream-pr/14172 into main 2026-11-05 18:01:33 +00:00
winstrex commented 2026-10-31 22:00:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-31T22:00:07Z.


Source of the behaviour

Ported from public WebKit at commit c55364d53f97 (September 2020), the revision #13564 and #13565 use. The module's revision is a strong inference from the exported names, not a proof: the 27 names exist together from bddada44652f (January 2020, which adds operator<<(TextStream&, Seconds)) until e12a212a531a (May 2021, which removes appendNumber(float)). Across that range both layouts are the same (the TextStream flags become one byte after 1d10fce7651a, with the bit the exports read unchanged), and the ported files change only by a guard this port already has (5a14e48f02dd). PS5-WebKit-11.x has none of these exports and a different StringBuilder layout, so it was not used. No console module was checked. The layouts below come from the source and the Itanium and System V rules, and the debt entry says they are not checked against the binary.

Behaviour WebKit source
StringBuilder members: String m_string, RefPtr<StringImpl> m_buffer, the 8/16-bit buffer pointer union, Checked<int32_t, ConditionalCrashOnOverflow> m_length (two bools then the int32_t), bool m_is8Bit; m_isReified only with ASSERT_ENABLED, which is 0 under NDEBUG StringBuilder.h#L365-L376, CheckedArithmetic.h#L91-L114, #L647, #L940, PlatformEnable.h#L63-L69
TextStream members: the StringBuilder, unsigned m_formattingFlags, int m_indent, bool m_multiLineMode; NumberRespectingIntegers is 1 << 1 TextStream.h#L47-L51, #L168-L171
Inline members the exports reach: append(const String&) adopts the string into an empty builder without a buffer, append(LChar) writes in place while there is room and no reified string, append(const char*), toString, clear StringBuilder.h#L82-L103, #L157-L161, #L186-L198, #L233-L245, #L330-L337
Growth to max(required, 16, 2 × capacity), reifyString (the buffer itself when full, else a substring sharing it), allocation, reallocation and up-conversion, reserveCapacity, the append paths, shrinkToFit below 80 % use, appendNumber(float) StringBuilder.cpp#L36-L68, #L107-L377, #L424-L456
Which length overflows crash and which only record: Checked<int32_t> + unsigned is computed as unsigned with a fresh handler that crashes, then narrowed to CheckedInt32, which records; assignment clears the flag CheckedArithmetic.h#L276-L297, #L476-L494, #L655-L711, #L943-L953, #L991-L994
appendQuotedJSONString: capacity roundUpToPowerOfTwo(length + 2 + 6n), the escape table, lowercase \u00XX, unpaired surrogates escaped StringBuilderJSON.cpp#L19-L154
TextStream operators, release, groups, lines and indent; floating point as fixedWidth(value, 2), or as an integer when NumberRespectingIntegers is set and the value has no fraction above 0.0001 TextStream.cpp#L33-L186, StringConcatenateNumbers.h#L100-L106
operator<<(TextStream&, Seconds) writes the value then s; operator<<(TextStream&, const URL&) writes url.string() Seconds.cpp#L74-L78, URL.cpp#L1014-L1018
Number text: ToShortestSingle and ToFixed of the ECMAScript converter (Infinity, NaN, unique zero, e+ exponents, decimal between 1e-6 and 1e21, nothing for ToFixed at 1e21 or above or past 100 digits, ties rounded up) dtoa.cpp#L26-L31, #L107-L120, double-conversion.cc#L48-L238, double-conversion.h#L41-L42
All of these files are built for every port WTF CMakeLists.txt#L433-L491

ABI from the mangled names under the Itanium and System V rules: every member takes this first; release() returns WTF::String, which has a non-trivial destructor, through a hidden result pointer; the TextStream operators return TextStream& in rax; Seconds is a class with one double and is passed in xmm0; long and unsigned long are 64-bit; appendNumber(float) and operator<<(float) take the float in xmm0.

AnyPS5 lines replaced:

What

Implements the 27 WTF::StringBuilder and WTF::TextStream exports of libSceNKWebKit that still threw, ported from the files above:

  • StringBuilder: appendCharacters (Latin-1 and UTF-16), reserveCapacity, shrinkToFit, reifyString, appendNumber(float) and appendQuotedJSONString.
  • TextStream: the 13 operator<< members (bool, char, the six integer types, float, double, const char*, const void*, const String&), release, startGroup, endGroup, nextLine, writeIndent, and the free operator<< for Seconds and URL.

New files: src/StringBuilder.cpp, src/StringBuilderJSON.cpp (kept apart because the original is MPL 2.0), src/TextStream.cpp and src/WtfNumberFormat.cpp, each with the original licence notice and a "Derived from" line; src/WtfTextAbi.hpp holds both layouts with static_assert on every offset and the size. WtfStringAbi.hpp gains a copy assignment for String, and WtfString.cpp exposes its empty string, uninitialised allocation and shared substring to the new files. The uninitialised allocation uses TryAllocate, as WebKit's tryCreateUninitialized uses tryMalloc, so a failed allocation returns null and the builder records an overflow (or throws, for a builder that crashes on overflow) instead of aborting.

  • Guest code inlines much of StringBuilder (append(UChar), append(const String&), length()), so it works on the same fields: the buffer is a StringImpl whose length is the capacity, and the growth, reification and shrink rules are WebKit's, including the odd ones, such as a zero-length fixedWidth append still allocating a 16-character buffer.
  • The number text is not WebKit's code: std::to_chars gives the shortest float digits and the exact decimal expansion, and the ECMAScript formatting and round-half-up of ToFixed are applied to them.
  • Where WebKit crashes, the call throws: an overflow of a builder that crashes on overflow, a length sum above UINT32_MAX (which crashes in WebKit even for a recording builder), toString after an overflow, null characters with a nonzero length. A recording builder records the overflow and ignores later appends, as in WebKit. Two debug assertions that guard memory WebKit would corrupt also throw: reserveCapacity on an empty 16-bit builder without a buffer, and appendQuotedJSONString of a 16-bit string into an 8-bit builder that holds an adopted string and no buffer, which WebKit up-converts from a null pointer.
  • operator<<(const void*) formats like the tree's libc %p (FormatPointer), since WebKit calls the console's snprintf.
  • Debt: a new "WTF text builder layouts" entry says the layouts, growth and shrink threshold are not checked against a console binary and names the range of WebKit revisions the exported names fit; two Functional entries list the throwing cases, the allocation limit and the reallocation, and the %p format.

No open PR implements these exports or adds these files. tools/pr_overlap.py reports line conflicts only: #13930 edits the stub next to appendNumber(float) in Export.cpp, and #13930, #13936, #13947 and #13992 change the two count lines of the debt file. It could not compare #13515, #13744, #13766, #13770 and #13772, which conflict with main; their diffs touch none of the 27 names and none of the new files. Whichever merges later rebases. #13992 declares a 24-byte JsonAbi::StringBuilder (the later layout) as the parameter type of the writeJSON slot it leaves throwing, without reading its fields; once both land, that slot should take WtfAbi::StringBuilder.

Tested

  • Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release: ctest -R nkwebkit passes (10 suites), including the new nkwebkit_wtftext (all 27 exports: growth, up-conversion, reification and shrinking with their reference counts, overflow on recording and crashing builders, JSON escaping and capacity, float text, TextStream values, flags, strings, groups and indent) and nkwebkit_wtftext_allocation, which builds the builder and string sources with a test allocator that fails on demand and checks every free against its allocation and guard bytes: a failed initial allocation, growth of an owned and of a shared 8-bit and 16-bit buffer, reserveCapacity and up-conversion each record an overflow on a recording builder and throw on a crashing one, leaving the character pointer null, and the 16-bit length limit records an overflow without allocating. Full suite on 9ef85aeeb2 (before the allocation change), on the same PC with its GPU (RTX 5070 Ti, Overwolf's Vulkan layers disabled): 3198 of 3201 pass, 12 skipped; the 3 failures (guest_wide_formatting, log_macros, log_macros_timestamps) fail the same way on main 613f9b8edf on this machine.
  • Negative controls: with the four new sources replaced by the 27 throwing stubs main has (typed, so the test still builds), the test aborts with _ZN3WTF13StringBuilder16appendCharactersEPKhj not implemented. 28 single-line mutations, each rebuilt and run: 27 make the test fail (minimum capacity, shrink threshold, string adoption, reallocation copy, up-conversion, crash and record on overflow, the UINT32_MAX crash, the zero-length append, the Latin-1 shortcut, JSON capacity, escapes and hex case, fixed ties, 1e21 and negative zero, the shortest exponent bounds and sign, NumberRespectingIntegers, its tolerance and the INT_MIN truncation, group and line indent in both modes, the Seconds unit, the pointer format, release clearing, bool text). The one that passes, sharing a substring when the buffer is full, is equivalent: SubstringSharingImpl of the whole string returns the buffer itself. Without the TryAllocate change the allocation test aborts in the fatal allocator; 11 mutations of the failure paths (fatal allocator, empty string or a stale character pointer on failure, no length limit, 16-bit storage sized for 8 bits, each of the three builder null checks, the reallocation leaking the old buffer, the flag not set): 10 make it fail. The one that passes, a zero length allocating, is unreachable: every caller asks for 16 or more, and a reallocation to zero takes another path.
  • Differential check outside the tree: WebKit's own double-conversion from the pinned commit (DoubleToStringConverter::EcmaScriptConverter, built on the host with stub config.h, Assertions.h and ASCIICType.h) against WtfNumberFormat.cpp. ToShortestSingle: 70.4 million floats (every 61st bit pattern, plus the neighbours of every power of two, both signs) gave identical text. ToFixed: 22.9 million doubles (random bit patterns, decimals with three digits, multiples of 1/8, values just off the half-cent ties, scaled mantissas) with 2 digits and a random 0 to 7, plus the ties, 1e21, the subnormals and 100 and 101 digits, gave identical text.
  • python tools/check_conventions.py --base upstream/main passes. tools/progress.py --compare: +27 implemented functions in libSceNKWebKit.
  • No title tested.

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:5101929070 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14172). Originally posted by [winstrex](https://github.com/winstrex) on 2026-10-31T22:00:07Z. --- ### Source of the behaviour Ported from public WebKit at commit [`c55364d53f97`](https://github.com/WebKit/WebKit/commit/c55364d53f97) (September 2020), the revision #13564 and #13565 use. The module's revision is a strong inference from the exported names, not a proof: the 27 names exist together from [`bddada44652f`](https://github.com/WebKit/WebKit/commit/bddada44652f) (January 2020, which adds `operator<<(TextStream&, Seconds)`) until [`e12a212a531a`](https://github.com/WebKit/WebKit/commit/e12a212a531a) (May 2021, which removes `appendNumber(float)`). Across that range both layouts are the same (the `TextStream` flags become one byte after [`1d10fce7651a`](https://github.com/WebKit/WebKit/commit/1d10fce7651a), with the bit the exports read unchanged), and the ported files change only by a guard this port already has ([`5a14e48f02dd`](https://github.com/WebKit/WebKit/commit/5a14e48f02dd)). `PS5-WebKit-11.x` has none of these exports and a different `StringBuilder` layout, so it was not used. No console module was checked. The layouts below come from the source and the Itanium and System V rules, and the debt entry says they are not checked against the binary. | Behaviour | WebKit source | | --- | --- | | `StringBuilder` members: `String m_string`, `RefPtr<StringImpl> m_buffer`, the 8/16-bit buffer pointer union, `Checked<int32_t, ConditionalCrashOnOverflow> m_length` (two `bool`s then the `int32_t`), `bool m_is8Bit`; `m_isReified` only with `ASSERT_ENABLED`, which is 0 under `NDEBUG` | [StringBuilder.h#L365-L376](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L365-L376), [CheckedArithmetic.h#L91-L114](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L91-L114), [#L647](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L647), [#L940](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L940), [PlatformEnable.h#L63-L69](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/PlatformEnable.h#L63-L69) | | `TextStream` members: the `StringBuilder`, `unsigned m_formattingFlags`, `int m_indent`, `bool m_multiLineMode`; `NumberRespectingIntegers` is `1 << 1` | [TextStream.h#L47-L51](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/TextStream.h#L47-L52), [#L168-L171](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/TextStream.h#L168-L171) | | Inline members the exports reach: `append(const String&)` adopts the string into an empty builder without a buffer, `append(LChar)` writes in place while there is room and no reified string, `append(const char*)`, `toString`, `clear` | [StringBuilder.h#L82-L103](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L82-L102), [#L157-L161](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L157-L161), [#L186-L198](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L186-L199), [#L233-L245](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L233-L245), [#L330-L337](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.h#L330-L337) | | Growth to `max(required, 16, 2 × capacity)`, `reifyString` (the buffer itself when full, else a substring sharing it), allocation, reallocation and up-conversion, `reserveCapacity`, the append paths, `shrinkToFit` below 80 % use, `appendNumber(float)` | [StringBuilder.cpp#L36-L68](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.cpp#L36-L68), [#L107-L377](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.cpp#L107-L378), [#L424-L456](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilder.cpp#L424-L456) | | Which length overflows crash and which only record: `Checked<int32_t> + unsigned` is computed as `unsigned` with a fresh handler that crashes, then narrowed to `CheckedInt32`, which records; assignment clears the flag | [CheckedArithmetic.h#L276-L297](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L276-L297), [#L476-L494](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L476-L494), [#L655-L711](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L655-L711), [#L943-L953](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L943-L953), [#L991-L994](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CheckedArithmetic.h#L991-L994) | | `appendQuotedJSONString`: capacity `roundUpToPowerOfTwo(length + 2 + 6n)`, the escape table, lowercase `\u00XX`, unpaired surrogates escaped | [StringBuilderJSON.cpp#L19-L154](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringBuilderJSON.cpp#L19-L150) | | `TextStream` operators, `release`, groups, lines and indent; floating point as `fixedWidth(value, 2)`, or as an integer when `NumberRespectingIntegers` is set and the value has no fraction above 0.0001 | [TextStream.cpp#L33-L186](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/TextStream.cpp#L33-L186), [StringConcatenateNumbers.h#L100-L106](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/text/StringConcatenateNumbers.h#L100-L106) | | `operator<<(TextStream&, Seconds)` writes the value then `s`; `operator<<(TextStream&, const URL&)` writes `url.string()` | [Seconds.cpp#L74-L78](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/Seconds.cpp#L74-L78), [URL.cpp#L1014-L1018](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/URL.cpp#L1014-L1018) | | Number text: `ToShortestSingle` and `ToFixed` of the ECMAScript converter (`Infinity`, `NaN`, unique zero, `e+` exponents, decimal between 1e-6 and 1e21, nothing for `ToFixed` at 1e21 or above or past 100 digits, ties rounded up) | [dtoa.cpp#L26-L31](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/dtoa.cpp#L26-L31), [#L107-L120](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/dtoa.cpp#L107-L120), [double-conversion.cc#L48-L238](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/dtoa/double-conversion.cc#L48-L238), [double-conversion.h#L41-L42](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/dtoa/double-conversion.h#L41-L42) | | All of these files are built for every port | [WTF CMakeLists.txt#L433-L491](https://github.com/WebKit/WebKit/blob/c55364d53f97/Source/WTF/wtf/CMakeLists.txt#L433-L491) | ABI from the mangled names under the Itanium and System V rules: every member takes `this` first; `release()` returns `WTF::String`, which has a non-trivial destructor, through a hidden result pointer; the `TextStream` operators return `TextStream&` in `rax`; `Seconds` is a class with one `double` and is passed in `xmm0`; `long` and `unsigned long` are 64-bit; `appendNumber(float)` and `operator<<(float)` take the `float` in `xmm0`. AnyPS5 lines replaced: - [Export.cpp#L12370-L12373](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/Export.cpp#L12370-L12373), [#L18814-L18885](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/Export.cpp#L18814-L18885), [#L19138-L19157](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/Export.cpp#L19138-L19157), [#L20622-L20629](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/Export.cpp#L20622-L20629) and [#L36954-L36957](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/Export.cpp#L36954-L36957): the 27 throwing stubs. - [InventoryExports.hpp#L1584-L1601](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp#L1584-L1601), [#L1665-L1669](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp#L1665-L1669), [#L2047-L2048](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp#L2047-L2048), [#L6130](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp#L6130) and [Api.hpp#L81](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/core/libs/prx/libSceNKWebKit/include/Api.hpp#L81): the parameterless declarations, now typed in `WtfExports.hpp`. - [libSceNKWebKit.md#L1609-L1626](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/docs/dev/debt/libSceNKWebKit.md#L1609-L1626), [#L1690-L1694](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/docs/dev/debt/libSceNKWebKit.md#L1690-L1694), [#L2061-L2062](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/docs/dev/debt/libSceNKWebKit.md#L2061-L2062) and [#L6144](https://github.com/boykopovar/AnyPS5/blob/613f9b8edf05/docs/dev/debt/libSceNKWebKit.md#L6144): 26 rows of the throwing-export table; `appendNumber(float)` was one of the 131 in the previous section, now 130. ### What Implements the 27 `WTF::StringBuilder` and `WTF::TextStream` exports of `libSceNKWebKit` that still threw, ported from the files above: - `StringBuilder`: `appendCharacters` (Latin-1 and UTF-16), `reserveCapacity`, `shrinkToFit`, `reifyString`, `appendNumber(float)` and `appendQuotedJSONString`. - `TextStream`: the 13 `operator<<` members (`bool`, `char`, the six integer types, `float`, `double`, `const char*`, `const void*`, `const String&`), `release`, `startGroup`, `endGroup`, `nextLine`, `writeIndent`, and the free `operator<<` for `Seconds` and `URL`. New files: `src/StringBuilder.cpp`, `src/StringBuilderJSON.cpp` (kept apart because the original is MPL 2.0), `src/TextStream.cpp` and `src/WtfNumberFormat.cpp`, each with the original licence notice and a "Derived from" line; `src/WtfTextAbi.hpp` holds both layouts with `static_assert` on every offset and the size. `WtfStringAbi.hpp` gains a copy assignment for `String`, and `WtfString.cpp` exposes its empty string, uninitialised allocation and shared substring to the new files. The uninitialised allocation uses `TryAllocate`, as WebKit's `tryCreateUninitialized` uses `tryMalloc`, so a failed allocation returns null and the builder records an overflow (or throws, for a builder that crashes on overflow) instead of aborting. - Guest code inlines much of `StringBuilder` (`append(UChar)`, `append(const String&)`, `length()`), so it works on the same fields: the buffer is a `StringImpl` whose length is the capacity, and the growth, reification and shrink rules are WebKit's, including the odd ones, such as a zero-length `fixedWidth` append still allocating a 16-character buffer. - The number text is not WebKit's code: `std::to_chars` gives the shortest float digits and the exact decimal expansion, and the ECMAScript formatting and round-half-up of `ToFixed` are applied to them. - Where WebKit crashes, the call throws: an overflow of a builder that crashes on overflow, a length sum above `UINT32_MAX` (which crashes in WebKit even for a recording builder), `toString` after an overflow, null characters with a nonzero length. A recording builder records the overflow and ignores later appends, as in WebKit. Two debug assertions that guard memory WebKit would corrupt also throw: `reserveCapacity` on an empty 16-bit builder without a buffer, and `appendQuotedJSONString` of a 16-bit string into an 8-bit builder that holds an adopted string and no buffer, which WebKit up-converts from a null pointer. - `operator<<(const void*)` formats like the tree's libc `%p` (`FormatPointer`), since WebKit calls the console's `snprintf`. - Debt: a new "WTF text builder layouts" entry says the layouts, growth and shrink threshold are not checked against a console binary and names the range of WebKit revisions the exported names fit; two `Functional` entries list the throwing cases, the allocation limit and the reallocation, and the `%p` format. No open PR implements these exports or adds these files. `tools/pr_overlap.py` reports line conflicts only: #13930 edits the stub next to `appendNumber(float)` in `Export.cpp`, and #13930, #13936, #13947 and #13992 change the two count lines of the debt file. It could not compare #13515, #13744, #13766, #13770 and #13772, which conflict with `main`; their diffs touch none of the 27 names and none of the new files. Whichever merges later rebases. #13992 declares a 24-byte `JsonAbi::StringBuilder` (the later layout) as the parameter type of the `writeJSON` slot it leaves throwing, without reading its fields; once both land, that slot should take `WtfAbi::StringBuilder`. ### 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 (10.0.26300), WinLibs GCC 15.2.0 r7, Release: `ctest -R nkwebkit` passes (10 suites), including the new `nkwebkit_wtftext` (all 27 exports: growth, up-conversion, reification and shrinking with their reference counts, overflow on recording and crashing builders, JSON escaping and capacity, float text, `TextStream` values, flags, strings, groups and indent) and `nkwebkit_wtftext_allocation`, which builds the builder and string sources with a test allocator that fails on demand and checks every free against its allocation and guard bytes: a failed initial allocation, growth of an owned and of a shared 8-bit and 16-bit buffer, `reserveCapacity` and up-conversion each record an overflow on a recording builder and throw on a crashing one, leaving the character pointer null, and the 16-bit length limit records an overflow without allocating. Full suite on 9ef85aeeb2 (before the allocation change), on the same PC with its GPU (RTX 5070 Ti, Overwolf's Vulkan layers disabled): 3198 of 3201 pass, 12 skipped; the 3 failures (`guest_wide_formatting`, `log_macros`, `log_macros_timestamps`) fail the same way on `main` 613f9b8edf on this machine. - Negative controls: with the four new sources replaced by the 27 throwing stubs `main` has (typed, so the test still builds), the test aborts with `_ZN3WTF13StringBuilder16appendCharactersEPKhj not implemented`. 28 single-line mutations, each rebuilt and run: 27 make the test fail (minimum capacity, shrink threshold, string adoption, reallocation copy, up-conversion, crash and record on overflow, the `UINT32_MAX` crash, the zero-length append, the Latin-1 shortcut, JSON capacity, escapes and hex case, fixed ties, 1e21 and negative zero, the shortest exponent bounds and sign, `NumberRespectingIntegers`, its tolerance and the `INT_MIN` truncation, group and line indent in both modes, the `Seconds` unit, the pointer format, `release` clearing, `bool` text). The one that passes, sharing a substring when the buffer is full, is equivalent: `SubstringSharingImpl` of the whole string returns the buffer itself. Without the `TryAllocate` change the allocation test aborts in the fatal allocator; 11 mutations of the failure paths (fatal allocator, empty string or a stale character pointer on failure, no length limit, 16-bit storage sized for 8 bits, each of the three builder null checks, the reallocation leaking the old buffer, the flag not set): 10 make it fail. The one that passes, a zero length allocating, is unreachable: every caller asks for 16 or more, and a reallocation to zero takes another path. - Differential check outside the tree: WebKit's own `double-conversion` from the pinned commit (`DoubleToStringConverter::EcmaScriptConverter`, built on the host with stub `config.h`, `Assertions.h` and `ASCIICType.h`) against `WtfNumberFormat.cpp`. `ToShortestSingle`: 70.4 million floats (every 61st bit pattern, plus the neighbours of every power of two, both signs) gave identical text. `ToFixed`: 22.9 million doubles (random bit patterns, decimals with three digits, multiples of 1/8, values just off the half-cent ties, scaled mantissas) with 2 digits and a random 0 to 7, plus the ties, 1e21, the subnormals and 100 and 101 digits, gave identical text. - `python tools/check_conventions.py --base upstream/main` passes. `tools/progress.py --compare`: +27 implemented functions in libSceNKWebKit. - No title tested. ### 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
MarcZX10 commented 2026-10-31 22:13:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T22:13:12Z.

Review: COMMENTED


Reviewed — approval withheld pending ABI evidence

I reviewed head 9ef85aeeb26f7c798037140083b358ba630d8b63; I could not verify that the guest StringBuilder and TextStream layouts match the target module ABI.

What I ran

The PR head is 9ef85aeeb26f7c798037140083b358ba630d8b63; the current main base is f776fddcffd1cfece220ecdd894371988b164f6a. The merge preview was clean; the common ancestor was b9bf246ea2efb00b58218c4709b8c4dd9e13a826. Checks ran on Linux x86_64, Debian 12, Python 3.11.2, with GCC 12.2.0 available. I did not build or compile.

git diff --check f776fddcffd1cfece220ecdd894371988b164f6a...9ef85aeeb26f7c798037140083b358ba630d8b63
python3 tools/check_conventions.py --base f776fddcffd1cfece220ecdd894371988b164f6a --head 9ef85aeeb26f7c798037140083b358ba630d8b63 --title 'feat(libSceNKWebKit): implement the WTF::StringBuilder and WTF::TextStream exports' --body /tmp/pr14172-body.md
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base f776fddcffd1cfece220ecdd894371988b164f6a --head 9ef85aeeb26f7c798037140083b358ba630d8b63 --json

Results

Check Result
git diff --check Passed; exit 0, no output.
Repository conventions and PR template Passed.
Export audit Passed with no lexical findings; it does not verify calling convention or binary ABI.
Author-reported tests The PR reports 9 nkwebkit CTest suites passing on Windows 11/GCC 15.2, plus differential float-format checks and mutation tests. I did not run these.
Hosted CI Eligibility, intake, library-portability, and report passed; Windows was in progress; conventions and labels were queued. Other platform jobs were skipped.
Local build or C++ tests Not run, per the no-build initial-review rule.
Unedited local check output

git diff --check produced no output and exited 0.

All conventions checks passed.
status: passed
symbols: 10336
findings: 0
limitations: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.; An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects.

Findings

Blocking

No reproducible code-level defect was established in the inspected implementation. The ABI uncertainty below prevents me from treating the review as complete.

Non-blocking

No separate source-level defect was established.

Sources

Not verified

  • Compilation or CTest on this head; I did not build during the initial review.
  • Linux, macOS, console, or title runtime behavior. The reported CTest, differential, and mutation results are author-provided, not independently reproduced.
  • Whether the declared object layouts match the target console module.

To get this to a good state

Please add evidence for the target object layouts or leave these exports throwing until the ABI is verified. I can repeat the same no-build checks and inspect the evidence on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725200885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14172#pullrequestreview-5725200885). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T22:13:12Z. **Review:** COMMENTED --- # Reviewed — approval withheld pending ABI evidence I reviewed head `9ef85aeeb26f7c798037140083b358ba630d8b63`; I could not verify that the guest `StringBuilder` and `TextStream` layouts match the target module ABI. ## What I ran The PR head is `9ef85aeeb26f7c798037140083b358ba630d8b63`; the current `main` base is `f776fddcffd1cfece220ecdd894371988b164f6a`. The merge preview was clean; the common ancestor was `b9bf246ea2efb00b58218c4709b8c4dd9e13a826`. Checks ran on Linux x86_64, Debian 12, Python 3.11.2, with GCC 12.2.0 available. I did not build or compile. ```sh git diff --check f776fddcffd1cfece220ecdd894371988b164f6a...9ef85aeeb26f7c798037140083b358ba630d8b63 python3 tools/check_conventions.py --base f776fddcffd1cfece220ecdd894371988b164f6a --head 9ef85aeeb26f7c798037140083b358ba630d8b63 --title 'feat(libSceNKWebKit): implement the WTF::StringBuilder and WTF::TextStream exports' --body /tmp/pr14172-body.md python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base f776fddcffd1cfece220ecdd894371988b164f6a --head 9ef85aeeb26f7c798037140083b358ba630d8b63 --json ``` ## Results | Check | Result | |---|---| | `git diff --check` | Passed; exit 0, no output. | | Repository conventions and PR template | Passed. | | Export audit | Passed with no lexical findings; it does not verify calling convention or binary ABI. | | Author-reported tests | The PR reports 9 `nkwebkit` CTest suites passing on Windows 11/GCC 15.2, plus differential float-format checks and mutation tests. I did not run these. | | Hosted CI | Eligibility, intake, library-portability, and report passed; Windows was in progress; conventions and labels were queued. Other platform jobs were skipped. | | Local build or C++ tests | Not run, per the no-build initial-review rule. | <details><summary>Unedited local check output</summary> `git diff --check` produced no output and exited 0. ```text All conventions checks passed. ``` ```text status: passed symbols: 10336 findings: 0 limitations: This lexical audit does not parse C++ fully, prove calling-convention or binary ABI correctness, verify runtime version tables, or replace compilation.; An absent source declaration or explicit alias can be intentional for assembly exports, conditional platform code, or generated interfaces; inspect findings before treating them as defects. ``` </details> ## Findings ### Blocking No reproducible code-level defect was established in the inspected implementation. The ABI uncertainty below prevents me from treating the review as complete. ### Non-blocking No separate source-level defect was established. ## Sources - [The asserted `StringBuilder` and `TextStream` layouts at this PR head](https://github.com/boykopovar/AnyPS5/blob/9ef85aeeb26f7c798037140083b358ba630d8b63/core/libs/prx/libSceNKWebKit/src/WtfTextAbi.hpp) - [Tests that construct those same declared layouts at this PR head](https://github.com/boykopovar/AnyPS5/blob/9ef85aeeb26f7c798037140083b358ba630d8b63/core/libs/prx/libSceNKWebKit/tests/WtfText.cpp) ## Not verified - Compilation or CTest on this head; I did not build during the initial review. - Linux, macOS, console, or title runtime behavior. The reported CTest, differential, and mutation results are author-provided, not independently reproduced. - Whether the declared object layouts match the target console module. ## To get this to a good state Please add evidence for the target object layouts or leave these exports throwing until the ABI is verified. I can repeat the same no-build checks and inspect the evidence on the updated head.
MarcZX10 commented 2026-10-31 23:38:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T23:38:19Z.

Review: COMMENTED


Re-checked — new head, allocation fix verified; ABI evidence still pending

Head 83413ef46807f8ae6fa37b4f93d54ac6691db910 adds a non-fatal allocation path and a failure-injection test that the Windows workflow built and passed.

What I ran

Reviewed the exact head 83413ef46807f8ae6fa37b4f93d54ac6691db910 against PR base f776fddcffd1cfece220ecdd894371988b164f6a; the clean merge preview used current main at b08c539c505c48341146c705bc72d9b603cdb3a7. Environment: Linux 6.1.0-54-amd64, Python 3.11.2. I did not build locally.

git diff --check b08c539c505c48341146c705bc72d9b603cdb3a7...83413ef46807f8ae6fa37b4f93d54ac6691db910
git merge-tree --write-tree b08c539c505c48341146c705bc72d9b603cdb3a7 83413ef46807f8ae6fa37b4f93d54ac6691db910
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14172
gh pr checks 14172 --repo boykopovar/AnyPS5
gh run view 41250986185 --repo boykopovar/AnyPS5 --job 124685680765 --log | grep -F '1857/2541 Test #2309: nkwebkit_wtftext_allocation'

Results

Check Result
Patch whitespace Passed; no output
Current-main merge preview Clean; merge-tree d211e617007b3c7d1faf212d64a1e2ca6ad96ac5
Windows changed guest-test workflow Passed; built and ran nkwebkit_wtftext_allocation, test 2309, in 0.02 s
Hosted conventions, library portability, eligibility, report Passed
Labels Pending at final refresh
Linux and specialized jobs Skipped
Local build/test Not run
Repository precheck Unavailable: the helper’s gh metadata read fails with Invalid \uXXXX escape
Unedited relevant outputs

git diff --check produced no output and exited 0.

d211e617007b3c7d1faf212d64a1e2ca6ad96ac5
labels	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986193/job/124690241603
conventions	pass	23s	https://github.com/boykopovar/AnyPS5/actions/runs/41250986242/job/124684267428
library-portability	pass	1m5s	https://github.com/boykopovar/AnyPS5/actions/runs/41250986125/job/124684264754
report	pass	38s	https://github.com/boykopovar/AnyPS5/actions/runs/41250986145/job/124684264919
windows	pass	10m24s	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685680765
linux	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682097
register-context	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682023
relinker	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685681859
relinker-asan	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682235
write-watch	skipping	0	https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685681778
windows	Build and run changed guest core/libs tests	2026-10-31T23:29:40.4811506Z 1857/2541 Test #2309: nkwebkit_wtftext_allocation ..............................................   Passed    0.02 sec

Findings

The maintainer's allocation-failure finding is addressed: TryCreateUninitialized now uses NKWebKit::TryAllocate, and the new test injects failures for initial allocation, growth, reserve, and 8-to-16-bit conversion. The new head still does not resolve the ABI uncertainty from my prior review. The updated PR description itself says no console module was checked, and its debt entry still says the StringBuilder and TextStream layouts are not checked against a console binary. I am not approving until the target ABI is supported by evidence.

Sources

Not verified

No Linux, macOS, console, or local build was run. The Windows workflow's exact test result is hosted CI, not a local run.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725471291 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14172#pullrequestreview-5725471291). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T23:38:19Z. **Review:** COMMENTED --- # Re-checked — new head, allocation fix verified; ABI evidence still pending Head `83413ef46807f8ae6fa37b4f93d54ac6691db910` adds a non-fatal allocation path and a failure-injection test that the Windows workflow built and passed. ## What I ran Reviewed the exact head `83413ef46807f8ae6fa37b4f93d54ac6691db910` against PR base `f776fddcffd1cfece220ecdd894371988b164f6a`; the clean merge preview used current `main` at `b08c539c505c48341146c705bc72d9b603cdb3a7`. Environment: Linux 6.1.0-54-amd64, Python 3.11.2. I did not build locally. ```sh git diff --check b08c539c505c48341146c705bc72d9b603cdb3a7...83413ef46807f8ae6fa37b4f93d54ac6691db910 git merge-tree --write-tree b08c539c505c48341146c705bc72d9b603cdb3a7 83413ef46807f8ae6fa37b4f93d54ac6691db910 python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14172 gh pr checks 14172 --repo boykopovar/AnyPS5 gh run view 41250986185 --repo boykopovar/AnyPS5 --job 124685680765 --log | grep -F '1857/2541 Test #2309: nkwebkit_wtftext_allocation' ``` ## Results | Check | Result | |---|---| | Patch whitespace | Passed; no output | | Current-main merge preview | Clean; merge-tree `d211e617007b3c7d1faf212d64a1e2ca6ad96ac5` | | Windows changed guest-test workflow | Passed; built and ran `nkwebkit_wtftext_allocation`, test 2309, in 0.02 s | | Hosted conventions, library portability, eligibility, report | Passed | | Labels | Pending at final refresh | | Linux and specialized jobs | Skipped | | Local build/test | Not run | | Repository precheck | Unavailable: the helper’s `gh` metadata read fails with `Invalid \uXXXX escape` | <details><summary>Unedited relevant outputs</summary> `git diff --check` produced no output and exited 0. ```text d211e617007b3c7d1faf212d64a1e2ca6ad96ac5 ``` ```text labels pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986193/job/124690241603 conventions pass 23s https://github.com/boykopovar/AnyPS5/actions/runs/41250986242/job/124684267428 library-portability pass 1m5s https://github.com/boykopovar/AnyPS5/actions/runs/41250986125/job/124684264754 report pass 38s https://github.com/boykopovar/AnyPS5/actions/runs/41250986145/job/124684264919 windows pass 10m24s https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685680765 linux skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682097 register-context skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682023 relinker skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685681859 relinker-asan skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685682235 write-watch skipping 0 https://github.com/boykopovar/AnyPS5/actions/runs/41250986185/job/124685681778 ``` ```text windows Build and run changed guest core/libs tests 2026-10-31T23:29:40.4811506Z 1857/2541 Test #2309: nkwebkit_wtftext_allocation .............................................. Passed 0.02 sec ``` </details> ## Findings The maintainer's allocation-failure finding is addressed: `TryCreateUninitialized` now uses `NKWebKit::TryAllocate`, and the new test injects failures for initial allocation, growth, reserve, and 8-to-16-bit conversion. The new head still does not resolve the ABI uncertainty from my prior review. The updated PR description itself says no console module was checked, and its debt entry still says the `StringBuilder` and `TextStream` layouts are not checked against a console binary. I am not approving until the target ABI is supported by evidence. ## Sources - [Allocation path at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/83413ef46807f8ae6fa37b4f93d54ac6691db910/core/libs/prx/libSceNKWebKit/src/WtfString.cpp) - [Failure-injection tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/83413ef46807f8ae6fa37b4f93d54ac6691db910/core/libs/prx/libSceNKWebKit/tests/allocation/WtfTextAllocation.cpp) - [Remaining ABI limitation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/83413ef46807f8ae6fa37b4f93d54ac6691db910/docs/dev/debt/libSceNKWebKit.md) ## Not verified No Linux, macOS, console, or local build was run. The Windows workflow's exact test result is hosted CI, not a local run.
CnRJay commented 2026-11-01 19:49:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:29Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14172#pullrequestreview-5729922402). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:29Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
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!14172
No description provided.