feat(libSceIcu): implement the ICU hash table exports #23917
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23917"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by larpsahur333 on 2026-11-19T21:58:03Z.
What
Thirty-eight
libSceIcuexports that answeredNotImplemented_nid_no_patchnow implement ICU's hash table, ported from ICU 68.2'suhash.cpp:uhash_open,uhash_openSize,uhash_init,uhash_initSize,uhash_close,uhash_deleteHashtableuhash_setKeyHasher,uhash_setKeyComparator,uhash_setValueComparator,uhash_setKeyDeleter,uhash_setValueDeleter,uhash_setResizePolicyuhash_put/iput/puti/iputi,uhash_get/iget/geti/igeti,uhash_remove/iremove/removei/iremovei,uhash_find,uhash_count,uhash_removeAll,uhash_removeElement,uhash_nextElement,uhash_equalsuhash_hashUChars,uhash_hashChars,uhash_hashIChars,uhash_hashLong,uhash_compareUChars,uhash_compareChars,uhash_compareIChars,uhash_compareLongThe layout is asserted at compile time against the header's own numbers:
UHashtableis 80 bytes withkeyHasherat 8,countat 48,primeIndexat 72;UHashElementis 24 bytes withvalueat 8 andkeyat 16. A guest that allocates aUHashtableforuhash_inittherefore gets the struct it expects, and the hasher, comparator and deleter pointers are called through theAPS5_VABIfunction types the rest of this library uses for guest callbacks.Still stubs:
uhash_hashUnicodeString,uhash_compareUnicodeString,uhash_hashCaselessUnicodeStringanduhash_compareCaselessUnicodeString, which take the ICUUnicodeStringthat this library does not model yet.tools/progress.py:libraries 17532/39558 (44.32%)before,17570/39558 (44.42%)after — 38 exports, +0.10 points. That is the largest single family left inlibSceIcuafter the UTF-16 text work.Tested
Windows 11 x86-64, MinGW-w64 GCC 15.2.0 (
x86_64-ucrt-posix-seh, WinLibs15.2.0posix-14.0.0-ucrt-r7), CMake 3.29.2, Ninja.guest_icu_uhash(new,core/libs/prx/libSceIcu/tests/UHash.cpp) passes:count,getfor a present and a missing key,find,puti/geti, replacement (putreturns the old value), andremovereturning the old value and shrinking the countuhash_nextElementkey-Nentries through the growth path, then reads back one stored before the growth and one afteruhash_removeAll, and checks that every value was releasediput/iputi/iget/igeti/iremove/iremoveiuhash_openSize+uhash_equalsfor empty, different and identical tablesuhash_initinto a stackUHashtableThe test declares the empty process-parameters section (
[[gnu::section(".procpar"), gnu::used]], two zero words) that the relinker normally emits, because the table allocates through the ICU allocator and test executables carry no heap metadata otherwise;test_public_headers.py --compiler g++reports413 libraries, 34735 exports: unique declarations and umbrella coverage verified, andctest -R "^guest_icu"reports100% tests passed, 0 tests failed out of 73.Not tested: no PS5 was involved. The four
UnicodeStringentries stay stubs, and the tests cover the API surface rather than a guest title's table usage.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T22:00:34Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
740a3e3b9b:tools/check_conventions.pypassed.guest_icu_uhash_testsfailed to build.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T22:07:42Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
de069d7094:tools/check_conventions.pypassed.guest_icu_uhash_testsbuilt cleanly.guest_icu_uhash):Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T22:43:47Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the lookup comparator condition and make
uhash_equalsreject absent keys before comparing values.What I ran
Reviewed head
de069d70944e97fb6d08c704721cdf38a299c6ff; no build or tests were run. Readdescription.md,commits.md,manifest.json,diff.patch, and all changed source, test, and debt-note files listed as included in the review folder.Results
Findings
Blocking
core/libs/prx/libSceIcu/UHash.cpp:217:Findreturns the occupied slot when the key comparator says the keys differ. It should continue probing; as written, a hash collision can make a distinct key appear present and overwrite the existing entry. Change the condition to return only when the comparator reports equality, and continue probing otherwise.core/libs/prx/libSceIcu/UHash.cpp:521:uhash_equalsdereferencesotherwithout checking whetherFindfound the key. With distinct tables having the same count but different keys, this can read an empty or deleted slot and compare its value as though it were a match. Return false whenotheris empty or deleted before comparing values.Non-blocking
None.
Not verified
No build, test, PS5, or guest-title run was performed. The author reports Windows 11/MinGW tests and a passing
ctestrun, but those results were not independently verified. The changedLegacyExports.cppandinclude/LegacyExports.hppcontain deletions only; no added lines were present in those files to review. No files were excluded according to the manifest.To get this to a good state
Fix both blocking lookup defects, then rerun the hash table tests and relevant build checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T12:13:21Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
e9f44224a2:tools/check_conventions.pypassed.guest_icu_uhash_testsbuilt cleanly.guest_icu_uhash):core/libs/prx/libSceIcu/LegacyExports.cpp,core/libs/prx/libSceIcu/include/LegacyExports.hpp,core/libs/prx/libSceIcu/libSceIcu.hpp,core/libs/prx/libSceIcu/UHash.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T12:13:39Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Not run. I could not access the prepared review files or invoke
repo_read.pyin this environment.Results
Findings
Blocking
None verified; the change was not inspected.
Non-blocking
None.
Not verified
The PR description, commits, diff, manifest, changed file contents, and repository context were not read. No checks were run. Files read: none. Files reviewed: none.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T14:58:50Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix hash table lookup and equality behavior.
What I ran
Reviewed head
6a19d918056a41b811b32620172a683e62433e2busing the prepared diff andrepo_read.py; no commands or tests were run. The description reports Windows 11/MinGW test results; these were not independently run.Results
Findings
Blocking
core/libs/prx/libSceIcu/UHash.cpp:218:Findreturns the current element when the key comparator says the keys differ. That causes collisions with matching hash codes to overwrite an unrelated key and causes lookups for absent colliding keys to return another key’s value. Return the element only when the comparator reports equality; otherwise continue probing.core/libs/prx/libSceIcu/UHash.cpp:535:uhash_equalsreturns false when the value comparator reports equality. This reverses the comparator result, so tables with equal corresponding values compare unequal, while tables with unequal values can compare equal. Return false when the comparator reports inequality.Non-blocking
None.
Not verified
No tests were run and no PS5 behavior was verified. The prepared bundle lists eight changed files; all eight were read:
core/libs/prx/libSceIcu/CMakeLists.txt,core/libs/prx/libSceIcu/LegacyExports.cpp,core/libs/prx/libSceIcu/UHash.cpp,core/libs/prx/libSceIcu/UHash.hpp,core/libs/prx/libSceIcu/include/LegacyExports.hpp,core/libs/prx/libSceIcu/libSceIcu.hpp,core/libs/prx/libSceIcu/tests/UHash.cpp, anddocs/dev/debt/changes/feat-libsceicu-uhash.md. No changed files were excluded.To get this to a good state
Fix both blocking defects and add regression coverage for colliding unequal keys, absent colliding-key lookup, and equal and unequal table values; rerun the reported checks on the revised head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:42:17Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the hash table lookup comparison so matching keys are found and duplicate keys do not get inserted.
What I ran
Reviewed head
85599c01e279d3fb9123ab222f8c2a35c3692ed4. No build or test commands were run; only the prepared diff and pinned source were inspected. The author reports Windows 11/MinGW tests in the PR description; these were not run during this review.Results
Findings
Blocking
core/libs/prx/libSceIcu/UHash.cpp:218:Findreturns the slot when the key comparator says the keys are different. This is the opposite of the match condition. A lookup for a different key with the same hash can therefore return an occupied element;Putoverwrites that entry rather than probing onward, while a lookup for the matching key can miss it. Return the element only when the comparator reports equality; otherwise continue probing.Non-blocking
None.
Not verified
Build and tests were not run. No changed files were excluded by the prepared manifest. The changed implementation, tests, API header, integration, debt note, and relevant CMake target lines were read;
LegacyExports.cppandinclude/LegacyExports.hppwere not read in full because their diff only removes the old stubs/declarations.To get this to a good state
Correct the comparator condition in
Find, then rerun the reportedguest_icutests and review the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T16:28:15Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: fix the collision probe so it continues past nonmatching keys with the same hash and returns an existing slot only when the comparator reports equality.
What I ran
Reviewed head
0e3b51abdfda93deeabaa5f2a1411d4ce0edfd52. I did not run commands or tests; author-reported test results are not independently verified.Results
Findings
Blocking
core/libs/prx/libSceIcu/UHash.cpp:220-221: When a slot has the requested hash but its key differs,Findimmediately returns that occupied slot. A colliding insertion therefore overwrites the existing entry instead of probing onward; lookup can also return the colliding key’s value. Continue the probe on comparator mismatch, and return the slot only when the comparator says the keys are equal. The collision tests described in the PR exercise this behavior, but their reported passing result does not match the reviewed implementation.Non-blocking
None.
Not verified
No tests or builds were run, and PS5 behavior was not verified.
LegacyExports.cpp,include/LegacyExports.hpp, and the build and test changes were inspected only at their changed hunks; their full contents were not read. Files excluded by the prepared bundle are not verified. The other reviewed changed files wereUHash.cpp,UHash.hpp,libSceIcu.hpp, anddocs/dev/debt/changes/feat-libsceicu-uhash.md.To get this to a good state
Fix
Findto keep probing after a same-hash key mismatch, then rerun the collision and hash table tests on the updated head.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:10:45Z.
Review: COMMENTED
Built the submitted UHash implementation against bundled ICU and ran the exact Linux fixture. It passed integer and string hash and comparator checks, table operations, and null-key handling.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.