feat(libSceNKWebKit): implement six WebCore::StorageMap exports on a guest HashMap<String, String> #24883
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24883"
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 ToRaNek on 2026-11-21T09:03:12Z.
What
Implements six
WebCore::StorageMapexports that were stubs:key,getItem,setItem,setItemIgnoringQuota,removeItemandcontains.Which class. The six names are the same in the 3.20-era source and in the pinned 11.x one (return types are not mangled), but the classes differ: the old one is reference counted and returns a
RefPtrfromsetItem; the pinned one is{ Ref<Impl> m_impl; unsigned m_quotaSize; }withvoidreturns (StorageMap.h L36-L80). These six are in the 11.x inventory, so they follow the pinned class. One independent check: #23757 translatesStorageMap::lengthfrom the module, and it reads*this, then+8, then the key count before the table, which ism_impl->map.size()of this layout.The functions follow StorageMap.cpp L74-L163 line by line:
String::sizeInBytes()(one byte per 8-bit character, two per 16-bit one), added in a checked 32-bit sum and refused when the sum is above the quota, not when it is equal;setItemandremoveItemcopy theImplfirst when it is shared, and report the old value;key(index)walks it forward from the start or from where it is;setItemIgnoringQuotalifts the quota for the call and puts it back.The table. The map is the guest's
WTF::HashMap<String, String>, which guest code also reads inline, so the table has to be the real one. It is in its own file (WtfHashMapString.cpp) so that other users of this map type can share it, and it follows the pinned HashTable.h:unsignedbefore the bucketsi = (i + ++probeCount) & mask; an empty bucket ends the search-1; on insert the last deleted bucket of the probe sequence is reusedHashTraits.h, add loopkeyCount * 6 < size * 2keyCount * 6 < sizeandsize > 8computeBestTableSizeand refilled in bucket orderHashes come from the existing
StringImpl::hashSlowCaseexport, which also fills the cache in the string; the table is allocated withfastZeroedMalloc.Where the source crashes, this throws instead: a null key on a non-empty table, a size that overflows 32 bits with no quota, an underflow in
removeItem.Left as stubs:
create,copyandimportItems. They are 3.20 exports of the older class (andimportItemsof the pinned class has another mangled name, sinceHashMapgained a template parameter). Implementing them would create objects of the other layout. No export of the inventory constructs the 11.x object, so the test builds it by hand.Tested
Windows 11, MinGW GCC 15.2.
nkwebkit_storagemap); onmainthe six functions are untyped stubs that throw.Addnot overwriting andSetoverwriting; the empty map; set, get and remove with 8-bit and 16-bit keys that compare equal; the exact sequence of table sizes while growing and shrinking; the reuse of deleted buckets with four keys of the same home bucket; the quota to the byte, a quota of 0,setItemIgnoringQuota; overflow and underflow; copy on write, including no copy when the quota refuses or the key is absent; the old value released from the output parameter; and 900 pseudo-random operations against astd::mapmodel.setItem; the iterator kept afterremoveItem; the quota not put back;Setnot releasing the old value; another shrink threshold; another growth threshold; the value kept in a deleted bucket; no eager growth in the best size;removeItemwriting into a shared map; and, for deleted buckets, not reused, first one kept instead of the last, counter not decremented. The first version of the test missed the deleted-bucket reuse; I added that case and it now fails for the three variants.nkwebkit_*tests andpatched_librariespass on the branch.python tools/check_conventions.py --base origin/mainandpython tools/debt_fold.py --checkpass.Not tested on a console; the layouts are read from the source.
Overlap (
python tools/pr_overlap.py --branch feat/nkwebkit-storage-map):StorageMap::length, the stub next togetIteminExport.cppandInventoryExports.hpp: whichever merges second resolves an adjacent-line conflict by keeping both removals. Itslengthreads the layout used here.mainand shareExport.cpp,InventoryExports.hpporlibSceNKWebKit.hpp, the files every implementation edits. I searched each of their diffs: none changes any of the six symbols.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 repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T09:05:14Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
c07fb2350e:tools/check_conventions.pypassed.nkwebkit_storagemap_testsbuilt cleanly.nkwebkit_storagemap):core/libs/prx/libSceNKWebKit/Export.cpp,core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp,core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp,core/libs/prx/libSceNKWebKit/src/StorageMap.cpp,core/libs/prx/libSceNKWebKit/src/WtfHashMapString.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-21T09:25:29Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and its focused tests are consistent with the stated goal.
What I ran
Reviewed head
c07fb2350e2d87e208e3dce00c9df5739ded84ac. I did not run commands or tests; the test and build results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No test or build was run in this review. I read all files listed as reviewed in
manifest.json:Export.cpp,InventoryExports.hpp,StorageMapExports.hpp,libSceNKWebKit.hpp,StorageMap.cpp,StorageMapAbi.hpp,WtfHashMapString.cpp,WtfHashMapStringAbi.hpp,tests/StorageMap.cpp, anddocs/dev/debt/changes/feat-nkwebkit-storage-map.md. The excluded-files list has no entries;Export.cppandInventoryExports.hppwere read throughrepo_read.pybecause their full text was not included in the review folder. No other changed files were excluded.To get this to a good state
Nothing is required.