feat(icu): compare counted StringPiece byte strings #23063

Merged
MrSourceee merged 3 commits from upstream-pr/23063 into main 2026-11-26 10:52:09 +00:00
MrSourceee commented 2026-11-18 17:16:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MrSourceee on 2026-11-18T17:16:54Z.


What

Implement the existing ICU 68 operator==(const StringPiece&, const StringPiece&) export. It compares counted bytes rather than NUL-terminated text and returns the one-byte UBool result. Unequal lengths do not inspect the backing bytes; two empty views compare equal. Nonempty comparisons check the last byte, then compare the prefix in fixed-size chunks using the existing guest-copy API. No ICU object ownership, shared state or game-specific path changes.

Reference: ICU 68.2 implementation and class layout. The console ABI has not been independently measured. The documentation fragment distinguishes invalid input handling from the upstream contract.

Tested

Linux x86-64, GCC 14.2, focused source-linked builds on 6286d36449. The original export threw not implemented; the new regression passed with the actual project guest-copy code. Covered empty views, unequal lengths, embedded NULs, byte and chunk-boundary differences, unreadable input, equal negative lengths and errno on valid comparisons. The adjacent ICU Compare and Resource tests also passed.

Separately linked the exact ICU 68.2 Linux release, constructed real icu_68::StringPiece objects, and compared the two implementations on 12,000 deterministic generated pairs: no mismatches. git diff --check, tools/check_conventions.py --base origin/main, tools/debt_fold.py --check and test_public_headers.py --audit-only passed. Overlap checked via GitHub API, including the head sources of #14144 and #14340; no implementation found. The full-project CMake suite, Windows, PS5 hardware and titles were not tested. No game-unblock or speed claim.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5380690917 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23063). Originally posted by [MrSourceee](https://github.com/MrSourceee) on 2026-11-18T17:16:54Z. --- ### What Implement the existing ICU 68 `operator==(const StringPiece&, const StringPiece&)` export. It compares counted bytes rather than NUL-terminated text and returns the one-byte `UBool` result. Unequal lengths do not inspect the backing bytes; two empty views compare equal. Nonempty comparisons check the last byte, then compare the prefix in fixed-size chunks using the existing guest-copy API. No ICU object ownership, shared state or game-specific path changes. Reference: [ICU 68.2 implementation](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/common/stringpiece.cpp) and [class layout](https://github.com/unicode-org/icu/blob/84e1f26ea77152936e70d53178a816dbfbf69989/icu4c/source/common/unicode/stringpiece.h). The console ABI has not been independently measured. The documentation fragment distinguishes invalid input handling from the upstream contract. ### Tested Linux x86-64, GCC 14.2, focused source-linked builds on `6286d36449`. The original export threw `not implemented`; the new regression passed with the actual project guest-copy code. Covered empty views, unequal lengths, embedded NULs, byte and chunk-boundary differences, unreadable input, equal negative lengths and errno on valid comparisons. The adjacent ICU Compare and Resource tests also passed. Separately linked the exact ICU 68.2 Linux release, constructed real `icu_68::StringPiece` objects, and compared the two implementations on 12,000 deterministic generated pairs: no mismatches. `git diff --check`, `tools/check_conventions.py --base origin/main`, `tools/debt_fold.py --check` and `test_public_headers.py --audit-only` passed. Overlap checked via GitHub API, including the head sources of #14144 and #14340; no implementation found. The full-project CMake suite, Windows, PS5 hardware and titles were not tested. No game-unblock or speed claim. <!-- 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. --> ### 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) and the licence notice of code adapted from upstream (see AGENTS.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
PrivacyOnion commented 2026-11-18 17:18:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T17:18:33Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 2a336d5058:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_icu_string_piece_tests built cleanly.
  • CTest (guest_icu_string_piece):
    1/1 Test #3819: guest_icu_string_piece ...........   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/StringPiece.cpp reverted to main and the new tests kept, the suite fails:
    1/1 Test #3819: guest_icu_string_piece ...........Subprocess aborted***Exception:   0.23 sec
    0% tests passed, 1 tests failed out of 1
    
    Restoring the change makes it pass again.
  • Code reading:
    • core/libs/prx/libSceIcu/StringPiece.cpp: _ZN6icu_68eqERKNS_11StringPieceES2__nid_postfix verifies length equality, handles empty strings (length == 0), checks negative lengths with std::invalid_argument, checks last byte first, and compares remaining bytes in 1024-byte chunks
    • core/libs/prx/libSceIcu/StringPiece.cpp: Verified GuestCopyIn_nid_no_patch error handling on unreadable StringPiece structures and data buffers
    • core/libs/prx/libSceIcu/StringPiece.cpp: Checked address overflow guard on base + offset computation against std::numeric_limitsstd::uintptr_t::max()
    • core/libs/prx/libSceIcu/include/StringPiece.hpp: Verified struct StringPiece layout, 64-bit alignment, and offset/size static assertions match standard ICU StringPiece layout (ptr + int32_t length + padding)
    • docs/dev/debt/changes/feat-icu-string-piece-equality.md: Verified documentation fragment correctly formats gap tracking and complies with AGENTS.md
    • core/libs/prx/libSceIcu/tests/StringPiece.cpp: Verified unit tests thoroughly exercise empty strings, unequal lengths, embedded NULs, differences across 1024-byte chunk boundaries, negative lengths, and invalid memory

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5961640927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23063#pullrequestreview-5961640927). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T17:18:33Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `2a336d5058`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_icu_string_piece_tests` built cleanly. - **CTest** (`guest_icu_string_piece`): ``` 1/1 Test #3819: guest_icu_string_piece ........... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/StringPiece.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/1 Test #3819: guest_icu_string_piece ...........Subprocess aborted***Exception: 0.23 sec 0% tests passed, 1 tests failed out of 1 ``` Restoring the change makes it pass again. - **Code reading**: - core/libs/prx/libSceIcu/StringPiece.cpp: _ZN6icu_68eqERKNS_11StringPieceES2__nid_postfix verifies length equality, handles empty strings (length == 0), checks negative lengths with std::invalid_argument, checks last byte first, and compares remaining bytes in 1024-byte chunks - core/libs/prx/libSceIcu/StringPiece.cpp: Verified GuestCopyIn_nid_no_patch error handling on unreadable StringPiece structures and data buffers - core/libs/prx/libSceIcu/StringPiece.cpp: Checked address overflow guard on base + offset computation against std::numeric_limits<std::uintptr_t>::max() - core/libs/prx/libSceIcu/include/StringPiece.hpp: Verified struct StringPiece layout, 64-bit alignment, and offset/size static assertions match standard ICU StringPiece layout (ptr + int32_t length + padding) - docs/dev/debt/changes/feat-icu-string-piece-equality.md: Verified documentation fragment correctly formats gap tracking and complies with AGENTS.md - core/libs/prx/libSceIcu/tests/StringPiece.cpp: Verified unit tests thoroughly exercise empty strings, unequal lengths, embedded NULs, differences across 1024-byte chunk boundaries, negative lengths, and invalid memory Looks Good To Me
MarcZX10 commented 2026-11-21 07:05:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:05:43Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the review found no verified defect, but the declared console layout has not been independently measured.

What I ran

Reviewed head ca9825d4734ee1137a99aff0e13562bda80b89a5 using the prepared diff and pinned reader. No build or tests were run; test results in the PR description are author-reported.

Results

Check Result Note
Diff and changed files passed All eight changed files read
Targeted guest-copy implementation passed Copy failure is reported
Build and tests not run Linux results are author-reported
Console ABI and hardware not run Layout not independently measured

Findings

Blocking

None.

Non-blocking

None.

Sources

Reviewed core/libs/prx/libSceIcu/CMakeLists.txt, core/libs/prx/libSceIcu/LegacyExports.cpp, core/libs/prx/libSceIcu/StringPiece.cpp, core/libs/prx/libSceIcu/include/LegacyExports.hpp, core/libs/prx/libSceIcu/include/StringPiece.hpp, core/libs/prx/libSceIcu/libSceIcu.hpp, core/libs/prx/libSceIcu/tests/StringPiece.cpp, and docs/dev/debt/changes/feat-icu-string-piece-equality.md. The only declared file exclusions were none (manifest.json marks all changed files included). Targeted context read: core/libs/prx/libc/src/General.cpp.

Not verified

No commands or checks were run. Linux tests, generated-pair comparison, convention checks, and debt checks are claims from the PR description, not results from this review. Windows, PS5 hardware, game behavior, and independent verification of the console ABI remain unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003710145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23063#pullrequestreview-6003710145). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:05:43Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the review found no verified defect, but the declared console layout has not been independently measured. ## What I ran Reviewed head `ca9825d4734ee1137a99aff0e13562bda80b89a5` using the prepared diff and pinned reader. No build or tests were run; test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All eight changed files read | | Targeted guest-copy implementation | passed | Copy failure is reported | | Build and tests | not run | Linux results are author-reported | | Console ABI and hardware | not run | Layout not independently measured | ## Findings ### Blocking None. ### Non-blocking None. ## Sources Reviewed `core/libs/prx/libSceIcu/CMakeLists.txt`, `core/libs/prx/libSceIcu/LegacyExports.cpp`, `core/libs/prx/libSceIcu/StringPiece.cpp`, `core/libs/prx/libSceIcu/include/LegacyExports.hpp`, `core/libs/prx/libSceIcu/include/StringPiece.hpp`, `core/libs/prx/libSceIcu/libSceIcu.hpp`, `core/libs/prx/libSceIcu/tests/StringPiece.cpp`, and `docs/dev/debt/changes/feat-icu-string-piece-equality.md`. The only declared file exclusions were none (`manifest.json` marks all changed files included). Targeted context read: `core/libs/prx/libc/src/General.cpp`. ## Not verified No commands or checks were run. Linux tests, generated-pair comparison, convention checks, and debt checks are claims from the PR description, not results from this review. Windows, PS5 hardware, game behavior, and independent verification of the console ABI remain unverified.
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!23063
No description provided.