feat(libSceJsc): implement WTF hash, hex and MediaTime helpers #18951

Merged
MatteoSid merged 5 commits from upstream-pr/18951 into main 2026-11-14 10:13:27 +00:00
MatteoSid commented 2026-11-12 15:41:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MatteoSid on 2026-11-12T15:41:39Z.


What

Implements three WTF helpers in libSceJsc that were NotImplemented_nid_no_patch stubs. Each follows pinned WebKit c55364d53f97, the revision docs/dev/debt/libSceJsc.md already pins for the WTF string search (its declarations match these mangled names too):

Export NID Prototype (demangled) Source
_ZN3WTF31integerToSixCharacterHashStringEj bhNTXZsyzkE std::array<char, 7> WTF::integerToSixCharacterHashString(unsigned) SixCharacterHash.cpp
_ZN3WTF8Internal9appendHexEPhjmjNS_17HexConversionModeE J9Fo8pqmVZ4 std::pair<LChar*, unsigned> WTF::Internal::appendHex(LChar*, unsigned, uintmax_t, unsigned, HexConversionMode) HexNumber.cpp, HexNumber.h
_ZNK3WTF9MediaTimeneERKS0_ oJV+0NA8pss bool WTF::MediaTime::operator!=(const MediaTime&) const MediaTime.h, MediaTime.cpp compare
  • integerToSixCharacterHashString fills six characters from the 62-character table, most significant first, plus a NUL; the 7-byte array comes back in RAX.
  • appendHex writes the digits backwards from buffer + bufferSize, pads with '0' up to min(minimumDigits, bufferSize) and returns {start, length} in RAX:RDX. Any mode other than Lowercase is uppercase, as in WebKit.
  • MediaTime::operator!= is compare(rhs) != EqualTo on the 16-byte MediaTime (value or double at 0, time scale at 8, flags at 12). Titles build MediaTime values themselves, since both constructors are constexpr and inline in MediaTime.h. libSceNKWebKit already has a compare in src/Media.cpp, but libSceJsc does not link libSceNKWebKit and no prx library shares source with another, so compare is ported here from WebKit.

Where WebKit corrupts memory or faults, these throw std::invalid_argument: null this, reference or buffer arguments; a number with more hex digits than the buffer holds (WebKit writes before the buffer); and a zero time scale that compare would divide by. The remainder products in compare, which can overflow int64_t in WebKit, wrap as the x86-64 multiply does.

The three source files follow WebKit's control flow, so each starts with the notice of the WebKit files it follows, copied verbatim, plus a Derived from line, as src/WtfStringSearch.cpp does.

Left out: SHA1::computeHash (ALtdQuwSy0A). #19188 has since implemented it on main, and this branch takes its version through the merge. In WebKit the SHA1 constructor and addBytes are out of line (SHA1.h, SHA1.cpp); libSceJsc exports neither, and no library here exports addBytes, so no title can fill a SHA1 for it. The first version of this PR implemented it, and commit ccb6e329c7 restored the stub. SHA1::hexDigest (pF6MaJY4tLM) also stays a stub; it needs a CString allocator, which #18430 adds.

Gaps, in a new debt entry: none of this is compared with a console module, the console WTF version and layouts are unverified, and appendHex assumes the guest std::pair<LChar*, unsigned> is returned in RAX:RDX (trivially copyable, as on the host). After merging main, the "Additional callable exports" count goes from main's 325 to 322 (325 minus this PR's 3); the 136 Api.hpp throwing exports are unchanged.

Tested

Linux (Ubuntu 24.04 container, GCC 13.3), Release, -DBUILD_TESTING=ON, on head 8beebd5b35, a merge of main 74900e8b0f (which brings #19188 and #19313) into the branch: built libSceJsc, the patched core/libs/libs/libSceJsc.prx and every libSceJsc test target. ctest -R '^(guest_jsc_string|jsc_placement_new|jsc_wtf_string_search|jsc_wtf_random|jsc_wtf_url|guest_jsc_trivial_returns|jsc_wtf_helpers|guest_jsc_register_sets_and_constructors|jsc_wtf_sha1|guest_jsc_script_value|jsc_wtf_bit_vector|public_headers)$' passes 12 of 12, including #19188's jsc_wtf_sha1 and #19313's jsc_wtf_random. Earlier heads: 86549b9df3 (merge of main 6871f7f142) passed the 9 tests that existed then, and ccb6e329c7 (based on 63f37bf00e) passed 8 of 8. PrivacyOnion's review was on 344b5ec3dc.

Windows (before the SHA-1 removal): JJenkx ran jsc_wtf_helpers on head 8ea9f9a577 merged onto main (Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs, none skipped (comment).

The new jsc_wtf_helpers test uses independent vectors:

  • six-character hashes of 0, 1, 61, 62, 62^5, 0x12345678 and 0xFFFFFFFF, computed with a short Python port of SixCharacterHash.cpp, and the terminating NUL;
  • appendHex in both modes, with zero, UINTMAX_MAX, padding to 8 digits, a minimum larger than the buffer, an exact-fit buffer, a mode value of 7, the returned pointer and length, and untouched bytes on both sides of the written range;
  • MediaTime equal and unequal pairs: equal fractions with different scales, negative values, zero, a HasBeenRounded flag, invalid against invalid and valid, the infinite and indefinite combinations, double against double and against a rational, and the overflow path of compare with values near 2^62 and scales of 2·10^9 and 4·10^9;
  • argument validation throws: null arguments, too-small buffers, a zero time scale reached by the division.

Every one of these 13 mutations, applied one at a time, makes the test fail: another table modulus, no NUL, swapped hex modes, no zero padding, an off-by-one buffer check, == for !=, invalid-invalid not equal, indefinite missing from the shared-infinite check, the double comparison inverted, a scaled rational in the mixed double path, no whole-part LessThan, an unscaled remainder, and no zero-scale guard (SIGFPE). They were run on 344b5ec3dc; the later commits change no code in these three functions.

nm -D on the patched libSceJsc.prx lists bhNTXZsyzkE, J9Fo8pqmVZ4 and oJV+0NA8pss at the addresses of the three symbols (ALtdQuwSy0A is #19188's implementation since the merge), and appendHex returns in RAX:RDX in the built library. tools/check_conventions.py --base origin/main --head HEAD passes and git diff --check origin/main is clean. The second commit, 8ea9f9a577, only drops trailing spaces from two copied WebKit notice lines. The third, ccb6e329c7, restores the SHA1::computeHash stub, its declaration and debt table row, and removes its source file, layout and tests. The merge commit 86549b9df3 resolves only the row-count line in docs/dev/debt/libSceJsc.md (328, counted in the merged table). #19104's debt entries are kept, and on it check_conventions and git diff --check origin/main pass. The merge commit 8beebd5b35 removes the adjacent stubs from both sides in Export.cpp and InventoryExports.hpp: cryptographicallyRandomNumber (#19313), SHA1::computeHash (#19188) and this PR's three. It keeps both includes in libSceJsc.hpp and sets the count to 322 (main's 325 minus 3). In docs/dev/debt/libSceJsc.md, which merges with merge=union, it keeps one count line and drops the table rows the union brought back. On it, check_conventions and git diff --check origin/main pass.

tools/pr_overlap.py --branch reports line conflicts only with #18430 and #18442 (neighbouring stub deletions in Export.cpp and InventoryExports.hpp, the include list in libSceJsc.hpp, the table row count and nearby table rows in the debt file). Neither implements these three functions; whichever merges second needs a trivial rebase, which I am happy to do. It could not compare #14212, which conflicts with main; by hand, it only rewrites the table row count line in docs/dev/debt/libSceJsc.md, which this PR also edits. 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 functionally; proposed to merge after #18430 and #18442, adjacent-line overlap only (see comment)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5280422253 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18951). Originally posted by [MatteoSid](https://github.com/MatteoSid) on 2026-11-12T15:41:39Z. --- ### What Implements three WTF helpers in libSceJsc that were `NotImplemented_nid_no_patch` stubs. Each follows pinned WebKit [`c55364d53f97`](https://github.com/WebKit/WebKit/commit/c55364d53f971f63a709976f168d932d558b8909), the revision `docs/dev/debt/libSceJsc.md` already pins for the WTF string search (its declarations match these mangled names too): | Export | NID | Prototype (demangled) | Source | |---|---|---|---| | `_ZN3WTF31integerToSixCharacterHashStringEj` | `bhNTXZsyzkE` | `std::array<char, 7> WTF::integerToSixCharacterHashString(unsigned)` | [SixCharacterHash.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/SixCharacterHash.cpp#L58-L69) | | `_ZN3WTF8Internal9appendHexEPhjmjNS_17HexConversionModeE` | `J9Fo8pqmVZ4` | `std::pair<LChar*, unsigned> WTF::Internal::appendHex(LChar*, unsigned, uintmax_t, unsigned, HexConversionMode)` | [HexNumber.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/HexNumber.cpp#L27-L42), [HexNumber.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/HexNumber.h#L29-L38) | | `_ZNK3WTF9MediaTimeneERKS0_` | `oJV+0NA8pss` | `bool WTF::MediaTime::operator!=(const MediaTime&) const` | [MediaTime.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/MediaTime.h#L77), [MediaTime.cpp `compare`](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/MediaTime.cpp#L337-L428) | - `integerToSixCharacterHashString` fills six characters from the 62-character table, most significant first, plus a NUL; the 7-byte array comes back in RAX. - `appendHex` writes the digits backwards from `buffer + bufferSize`, pads with `'0'` up to `min(minimumDigits, bufferSize)` and returns `{start, length}` in RAX:RDX. Any mode other than `Lowercase` is uppercase, as in WebKit. - `MediaTime::operator!=` is `compare(rhs) != EqualTo` on the 16-byte `MediaTime` (value or double at 0, time scale at 8, flags at 12). Titles build `MediaTime` values themselves, since both constructors are `constexpr` and inline in [MediaTime.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/MediaTime.h#L151-L167). libSceNKWebKit already has a `compare` in `src/Media.cpp`, but libSceJsc does not link libSceNKWebKit and no prx library shares source with another, so `compare` is ported here from WebKit. Where WebKit corrupts memory or faults, these throw `std::invalid_argument`: null `this`, reference or buffer arguments; a number with more hex digits than the buffer holds (WebKit writes before the buffer); and a zero time scale that `compare` would divide by. The remainder products in `compare`, which can overflow `int64_t` in WebKit, wrap as the x86-64 multiply does. The three source files follow WebKit's control flow, so each starts with the notice of the WebKit files it follows, copied verbatim, plus a `Derived from` line, as `src/WtfStringSearch.cpp` does. Left out: `SHA1::computeHash` (`ALtdQuwSy0A`). #19188 has since implemented it on `main`, and this branch takes its version through the merge. In WebKit the `SHA1` constructor and `addBytes` are out of line ([SHA1.h](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/SHA1.h#L46-L57), [SHA1.cpp](https://github.com/WebKit/WebKit/blob/c55364d53f971f63a709976f168d932d558b8909/Source/WTF/wtf/SHA1.cpp#L99-L113)); libSceJsc exports neither, and no library here exports `addBytes`, so no title can fill a `SHA1` for it. The first version of this PR implemented it, and commit `ccb6e329c7` restored the stub. `SHA1::hexDigest` (`pF6MaJY4tLM`) also stays a stub; it needs a `CString` allocator, which #18430 adds. Gaps, in a new debt entry: none of this is compared with a console module, the console WTF version and layouts are unverified, and `appendHex` assumes the guest `std::pair<LChar*, unsigned>` is returned in RAX:RDX (trivially copyable, as on the host). After merging `main`, the "Additional callable exports" count goes from main's 325 to 322 (325 minus this PR's 3); the 136 `Api.hpp` throwing exports are unchanged. ### Tested Linux (Ubuntu 24.04 container, GCC 13.3), Release, `-DBUILD_TESTING=ON`, on head `8beebd5b35`, a merge of `main` `74900e8b0f` (which brings #19188 and #19313) into the branch: built `libSceJsc`, the patched `core/libs/libs/libSceJsc.prx` and every libSceJsc test target. `ctest -R '^(guest_jsc_string|jsc_placement_new|jsc_wtf_string_search|jsc_wtf_random|jsc_wtf_url|guest_jsc_trivial_returns|jsc_wtf_helpers|guest_jsc_register_sets_and_constructors|jsc_wtf_sha1|guest_jsc_script_value|jsc_wtf_bit_vector|public_headers)$'` passes 12 of 12, including #19188's `jsc_wtf_sha1` and #19313's `jsc_wtf_random`. Earlier heads: `86549b9df3` (merge of `main` `6871f7f142`) passed the 9 tests that existed then, and `ccb6e329c7` (based on `63f37bf00e`) passed 8 of 8. PrivacyOnion's review was on `344b5ec3dc`. Windows (before the SHA-1 removal): JJenkx ran `jsc_wtf_helpers` on head `8ea9f9a577` merged onto `main` (Windows 11, WinLibs GCC 15.2 UCRT, Release); it passes in 3 of 3 runs, none skipped ([comment](https://github.com/boykopovar/AnyPS5/pull/18951#issuecomment-6831795514)). The new `jsc_wtf_helpers` test uses independent vectors: - six-character hashes of 0, 1, 61, 62, 62^5, `0x12345678` and `0xFFFFFFFF`, computed with a short Python port of `SixCharacterHash.cpp`, and the terminating NUL; - `appendHex` in both modes, with zero, `UINTMAX_MAX`, padding to 8 digits, a minimum larger than the buffer, an exact-fit buffer, a mode value of 7, the returned pointer and length, and untouched bytes on both sides of the written range; - `MediaTime` equal and unequal pairs: equal fractions with different scales, negative values, zero, a `HasBeenRounded` flag, invalid against invalid and valid, the infinite and indefinite combinations, double against double and against a rational, and the overflow path of `compare` with values near 2^62 and scales of 2·10^9 and 4·10^9; - argument validation throws: null arguments, too-small buffers, a zero time scale reached by the division. Every one of these 13 mutations, applied one at a time, makes the test fail: another table modulus, no NUL, swapped hex modes, no zero padding, an off-by-one buffer check, `==` for `!=`, invalid-invalid not equal, indefinite missing from the shared-infinite check, the double comparison inverted, a scaled rational in the mixed double path, no whole-part `LessThan`, an unscaled remainder, and no zero-scale guard (SIGFPE). They were run on `344b5ec3dc`; the later commits change no code in these three functions. `nm -D` on the patched `libSceJsc.prx` lists `bhNTXZsyzkE`, `J9Fo8pqmVZ4` and `oJV+0NA8pss` at the addresses of the three symbols (`ALtdQuwSy0A` is #19188's implementation since the merge), and `appendHex` returns in RAX:RDX in the built library. `tools/check_conventions.py --base origin/main --head HEAD` passes and `git diff --check origin/main` is clean. The second commit, `8ea9f9a577`, only drops trailing spaces from two copied WebKit notice lines. The third, `ccb6e329c7`, restores the `SHA1::computeHash` stub, its declaration and debt table row, and removes its source file, layout and tests. The merge commit `86549b9df3` resolves only the row-count line in `docs/dev/debt/libSceJsc.md` (328, counted in the merged table). #19104's debt entries are kept, and on it `check_conventions` and `git diff --check origin/main` pass. The merge commit `8beebd5b35` removes the adjacent stubs from both sides in `Export.cpp` and `InventoryExports.hpp`: `cryptographicallyRandomNumber` (#19313), `SHA1::computeHash` (#19188) and this PR's three. It keeps both includes in `libSceJsc.hpp` and sets the count to 322 (main's 325 minus 3). In `docs/dev/debt/libSceJsc.md`, which merges with `merge=union`, it keeps one count line and drops the table rows the union brought back. On it, `check_conventions` and `git diff --check origin/main` pass. `tools/pr_overlap.py --branch` reports line conflicts only with #18430 and #18442 (neighbouring stub deletions in `Export.cpp` and `InventoryExports.hpp`, the include list in `libSceJsc.hpp`, the table row count and nearby table rows in the debt file). Neither implements these three functions; whichever merges second needs a trivial rebase, which I am happy to do. It could not compare #14212, which conflicts with `main`; by hand, it only rewrites the table row count line in `docs/dev/debt/libSceJsc.md`, which this PR also edits. 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 functionally; proposed to merge after #18430 and #18442, adjacent-line overlap only (see [comment](https://github.com/boykopovar/AnyPS5/pull/18951#issuecomment-6828251282)) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-12 15:49:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T15:49:47Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 344b5ec3dc:

  • Conventions: tools/check_conventions.py passed; git diff --check reported whitespace errors.
  • Build: jsc_wtf_helpers_tests built cleanly.
  • CTest (jsc_wtf_helpers):
    1/1 Test #3324: jsc_wtf_helpers ..................   Passed    0.00 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceJsc/Export.cpp, core/libs/prx/libSceJsc/include/InventoryExports.hpp, core/libs/prx/libSceJsc/libSceJsc.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified pointer validation (!buffer), bounds validation (HexDigitCount(number) > bufferSize), reverse digit formatting, minimum digit zero-padding, and RAX:RDX pair return for _ZN3WTF8Internal9appendHexEPhjmjNS_17HexConversionModeE in src/WtfHexNumber.cpp.
    • Verified null operand guards (!self || !rhs), NaN/infinity/indefinite classification, double/rational comparisons, zero-timescale exception handling before division, and overflow handling via __builtin_mul_overflow and WrappingMultiply in src/WtfMediaTime.cpp.
    • Verified null operand guards (!self || !digest), cursor bounds validation (cursor >= 64), single- and two-block message padding, big-endian digest byte writing, and state reset in src/WtfSha1.cpp.
    • Verified base-62 table indexing, loop termination, NUL byte termination at index 6, and std::array<char, 7> return in _ZN3WTF31integerToSixCharacterHashStringEj in src/WtfSixCharacterHash.cpp.
    • Verified ABI struct layouts and alignments via static_asserts (MediaTime size 16, SHA1 size 104, HexResult size 16, SixCharacterHash size 7) and LP64/LLP64 type compatibility in src/WtfHelperAbi.hpp and include/WtfHelperExports.hpp.
    • Verified removal of the four NotImplemented_nid_no_patch stubs from Export.cpp and InventoryExports.hpp, decrement of callable NID count from 337 to 333, and technical debt documentation in docs/dev/debt/libSceJsc.md.
    • Verified comprehensive test coverage in tests/WtfHelpers.cpp exercising all standard vectors, boundary cases (0, UINTMAX_MAX, 55/56/63/64-byte SHA-1 states, time scales near 2^62), buffer canary checks, invalid_argument throws, and CMakeLists.txt test configuration.
  • Minor: please drop the Generated with footer from the description; the AI-assisted checkbox can stay.

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5877512935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18951#pullrequestreview-5877512935). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T15:49:47Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `344b5ec3dc`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` reported whitespace errors. - **Build**: `jsc_wtf_helpers_tests` built cleanly. - **CTest** (`jsc_wtf_helpers`): ``` 1/1 Test #3324: jsc_wtf_helpers .................. Passed 0.00 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceJsc/Export.cpp`, `core/libs/prx/libSceJsc/include/InventoryExports.hpp`, `core/libs/prx/libSceJsc/libSceJsc.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified pointer validation (!buffer), bounds validation (HexDigitCount(number) > bufferSize), reverse digit formatting, minimum digit zero-padding, and RAX:RDX pair return for _ZN3WTF8Internal9appendHexEPhjmjNS_17HexConversionModeE in src/WtfHexNumber.cpp. - Verified null operand guards (!self || !rhs), NaN/infinity/indefinite classification, double/rational comparisons, zero-timescale exception handling before division, and overflow handling via __builtin_mul_overflow and WrappingMultiply in src/WtfMediaTime.cpp. - Verified null operand guards (!self || !digest), cursor bounds validation (cursor >= 64), single- and two-block message padding, big-endian digest byte writing, and state reset in src/WtfSha1.cpp. - Verified base-62 table indexing, loop termination, NUL byte termination at index 6, and std::array<char, 7> return in _ZN3WTF31integerToSixCharacterHashStringEj in src/WtfSixCharacterHash.cpp. - Verified ABI struct layouts and alignments via static_asserts (MediaTime size 16, SHA1 size 104, HexResult size 16, SixCharacterHash size 7) and LP64/LLP64 type compatibility in src/WtfHelperAbi.hpp and include/WtfHelperExports.hpp. - Verified removal of the four NotImplemented_nid_no_patch stubs from Export.cpp and InventoryExports.hpp, decrement of callable NID count from 337 to 333, and technical debt documentation in docs/dev/debt/libSceJsc.md. - Verified comprehensive test coverage in tests/WtfHelpers.cpp exercising all standard vectors, boundary cases (0, UINTMAX_MAX, 55/56/63/64-byte SHA-1 states, time scales near 2^62), buffer canary checks, invalid_argument throws, and CMakeLists.txt test configuration. - Minor: please drop the `Generated with` footer from the description; the AI-assisted checkbox can stay. Requesting changes for the points above.
PrivacyOnion commented 2026-11-14 08:25:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-14T08:25:31Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 8beebd5b35:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: jsc_wtf_helpers_tests built cleanly.
  • CTest (jsc_wtf_helpers):
    1/1 Test #3492: jsc_wtf_helpers ..................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceJsc/Export.cpp, core/libs/prx/libSceJsc/include/InventoryExports.hpp, core/libs/prx/libSceJsc/libSceJsc.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceJsc/src/WtfSixCharacterHash.cpp: verified WTF::integerToSixCharacterHashString (NID bhNTXZsyzkE) radix-62 indexing, reverse buffer filling across indices 5 down to 0, explicit null termination at index 6, and return value ABI (std::array<char, 7> in RAX) matching pinned WebKit SixCharacterHash.cpp.
    • core/libs/prx/libSceJsc/src/WtfHexNumber.cpp: verified WTF::Internal::appendHex (NID J9Fo8pqmVZ4) null buffer and buffer overflow validation (HexDigitCount(number) > bufferSize throwing std::invalid_argument), zero-padding clamped with std::min(minimumDigits, bufferSize), and return layout std::pair<LChar*, unsigned> matching guest RAX:RDX register convention.
    • core/libs/prx/libSceJsc/src/WtfMediaTime.cpp: verified WTF::MediaTime::operator!= (NID oJV+0NA8pss) null pointer checks for self and rhs, comparison handling for Valid/Indefinite/PositiveInfinite/NegativeInfinite flags, and float conversion in ToDouble matching WebKit MediaTime.cpp.
    • core/libs/prx/libSceJsc/src/WtfMediaTime.cpp: verified integer multiplication safety via __builtin_mul_overflow for factor cross-products, zero-scale check before whole/remainder divisions, and unsigned modular arithmetic in WrappingMultiply preventing undefined behavior on remainder products.
    • core/libs/prx/libSceJsc/CMakeLists.txt and docs/dev/debt/libSceJsc.md: verified correct stub removals from Export.cpp and InventoryExports.hpp, test executable integration, accurate debt table count reduction from 325 to 322, and strict AGENTS.md rule compliance (no code comments outside WebKit notice headers and namespace endings).
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5903129417 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18951#pullrequestreview-5903129417). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-14T08:25:31Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `8beebd5b35`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `jsc_wtf_helpers_tests` built cleanly. - **CTest** (`jsc_wtf_helpers`): ``` 1/1 Test #3492: jsc_wtf_helpers .................. Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceJsc/Export.cpp`, `core/libs/prx/libSceJsc/include/InventoryExports.hpp`, `core/libs/prx/libSceJsc/libSceJsc.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libSceJsc/src/WtfSixCharacterHash.cpp: verified WTF::integerToSixCharacterHashString (NID bhNTXZsyzkE) radix-62 indexing, reverse buffer filling across indices 5 down to 0, explicit null termination at index 6, and return value ABI (std::array<char, 7> in RAX) matching pinned WebKit SixCharacterHash.cpp. - core/libs/prx/libSceJsc/src/WtfHexNumber.cpp: verified WTF::Internal::appendHex (NID J9Fo8pqmVZ4) null buffer and buffer overflow validation (HexDigitCount(number) > bufferSize throwing std::invalid_argument), zero-padding clamped with std::min(minimumDigits, bufferSize), and return layout std::pair<LChar*, unsigned> matching guest RAX:RDX register convention. - core/libs/prx/libSceJsc/src/WtfMediaTime.cpp: verified WTF::MediaTime::operator!= (NID oJV+0NA8pss) null pointer checks for self and rhs, comparison handling for Valid/Indefinite/PositiveInfinite/NegativeInfinite flags, and float conversion in ToDouble matching WebKit MediaTime.cpp. - core/libs/prx/libSceJsc/src/WtfMediaTime.cpp: verified integer multiplication safety via __builtin_mul_overflow for factor cross-products, zero-scale check before whole/remainder divisions, and unsigned modular arithmetic in WrappingMultiply preventing undefined behavior on remainder products. - core/libs/prx/libSceJsc/CMakeLists.txt and docs/dev/debt/libSceJsc.md: verified correct stub removals from Export.cpp and InventoryExports.hpp, test executable integration, accurate debt table count reduction from 325 to 322, and strict AGENTS.md rule compliance (no code comments outside WebKit notice headers and namespace endings). - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!18951
No description provided.