feat(libSceNKWebKit): implement WebCore::computeSharedStringHash #14607
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14607"
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 ashwin280802 on 2026-11-01T16:21:38Z.
What
Implements both
WebCore::computeSharedStringHashoverloads in libSceNKWebKit,(const char16_t*, unsigned)and(const WTF::String&), and removes theirNotImplemented_nid_no_patchstubs.docs/dev/debt/libSceNKWebKit.mddrops both table rows.Both follow the pinned PS5-WebKit-11.x SharedStringHash.cpp: the unmasked
StringHasherhash of the characters, passed throughAlreadyHashed::avoidDeletedValue(StringHash.h L220-L227). The hash is the existingStringHasherinWtfString.cpp, which matches the pinned StringHasher.h (start value, two-character step, last-character step, final mixing, zero guard).There is no console measurement, so behaviour is matched to source only. One deliberate divergence from the pinned source: its
avoidDeletedValueORs the sign bit in (hash | (!(hash + 1) << 31)), which leaves a raw hash of0xFFFFFFFF, the hash-table deleted value, unchanged, and the same function assertsnewHash != 0xFFFFFFFF. This patch XORs instead and returns0x7FFFFFFF, as WebKit's fix of that function does. Which of the two the console module computes is unmeasured and is recorded indocs/dev/debt/libSceNKWebKit.md; the two differ only for a raw hash of0xFFFFFFFF. A nullStringhashes as the empty string, as upstream does for a zero length; a null pointer with a nonzero length, or a nullStringpointer, throws.No open PR implements these functions.
pr_overlap.pycould not compare 6 PRs that conflict withmain(#13515, #13766, #14152, #14212, #14303, #14345); I read their diffs and none mentionscomputeSharedStringHash. #14479 (mimeTypeFromDataURLandURL::stringCenterEllipsizedToLength, same author) appends at the same end ofWtfString.cpp, and #13930, #13947, #13992, #14138, #14172, #14259 and #14391 edit the debt count line, so whichever merges second needs a trivial rebase.Tested
Windows 11 (MinGW GCC), commit
1145addee8,ctest -R nkwebkit --output-on-failurein the build directory (all nine tests that depend on libSceNKWebKit; thenkwebkit_wtfline and the total are shown):python3 tools/check_conventions.py --base origin/mainpasses.The new test checks the hash of the empty string,
a,ab,abcand a URL through both overloads (8-bit and 16-bit strings, with the representation asserted), a non-Latin-1 pair, the raw-hash0xFFFFFFFFcase (expecting0x7FFFFFFF), and the null inputs. The expected values come from a separate Python implementation of the algorithm (not from this code), which reproduces all seven.Mutation check: the mutation tool lists no mutants for these lines, so I changed five expressions by hand, one at a time (
^to|, which restores the pinned OR; dropping the deleted-value step; and masking or mislabelling the input in each overload). The test failed on all five.Not covered by a test: nothing; all five mutants failed it.
Full suite on this machine, run on the first commit of this PR (
e1d94e4545, which still had the OR and no notices), before the XOR change: Windows 3273 of 3284 passed, 0 failed, 11 skipped (guest_fopen_errorsis among the skips; it needs symlink creation). Linux in Docker 3051 of 3167 passed, 1 failed, 115 skipped. The Linux failure isguest_mmap_executable(aborts atGuestMemory.cpp:3436), andguest_http_uri_localeandsavedata_memory_growth_read_failureskip. Onmain(f2d874c1fd), same machine, the same three tests fail and skip the same way, so none of them depends on this change. The full suite was not re-run on the current head.Not verified: no PS5 or real WebKit build was used.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T16:48:50Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new test requires both overloads to return the hash-table deleted sentinel
0xffffffff, although the implementation's referenced helper asserts that this value must be avoided.What I ran
Reviewed head
44633d6e5791750f490b8e3afd5a7d0757494c49against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the merge preview is clean. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test was run.Results
GLOBincludestests/Wtf.cpp.Precheck and audit details
Negative control
Not run: the changed C++ test needs a built executable. The review did not exercise its assertions.
Findings
Blocking:
AvoidDeletedHashValueuseshash | (static_cast<unsigned>(!(hash + 1)) << 31). Forhash == 0xffffffff, the expression returns0xffffffffunchanged. The addeddeletedValueassertions require exactly that result for both exported functions. The pinnedAlreadyHashed::avoidDeletedValuereference hasASSERT(newHash != 0xFFFFFFFF), so the test pins a result the referenced implementation explicitly rejects, and this value is the hash-table deleted sentinel. Please use an operation that avoids the sentinel (the current WebKit implementation uses XOR) and change the expected result to0x7fffffff, or provide target evidence that this legacy behavior is intentional and revise the test and debt claim to describe the known sentinel limitation rather than treating it as a valid hash.Non-blocking: None.
Sources
0xffffffffNot verified
No PS5 runtime behavior was measured. The author-reported test runs, other operating systems, full build, and queued hosted checks were not independently verified.
To get this to a good state
Please resolve the deleted-sentinel case or provide evidence for preserving it. I will rerun the same applicable checks on the new head; the C++ test requires a build.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T19:06:16Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The sentinel fix is present, but the PR description still documents the previous implementation and claims a compatibility gap is recorded when the debt file contains no such note.
What I ran
Reviewed head
2945a395d46463e4712fe33dd967923650474c52against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the merge preview is clean. Environment: Debian 12, Linux 6.1, Python 3.11.2, GCC 12.2.0, Git 2.39.5. I did not build or run C++ tests locally.Results
tests/*.cppglob includesWtf.cpp.Precheck result table
Negative control
I did not run a mutation or negative control. The author reports that four of five manual mutations failed the test; the fifth (removing the sentinel adjustment) is observationally equivalent for the tested values.
Findings
Blocking
The PR description's
Whatsection says this head follows the pinned PS5-WebKit source's OR operation, produces0xfffffffffor the deleted-value input, and records that uncertainty indocs/dev/debt/libSceNKWebKit.md. This head instead uses XOR and expects0x7fffffff; the debt file only removes the two stub inventory rows and has no compatibility note. TheTestedsection also says omitting the deleted-value adjustment is unobservable under OR, but with this head's XOR the0xffffffffvector distinguishes that mutation. The pinned PS5-WebKit source contains the OR expression and an assertion excluding0xffffffff, while the later WebKit fix changes OR to XOR. Please update the description and mutation results to match this head, and retain a debt note that console behavior is unmeasured, or provide PS5 evidence supporting the XOR behavior and update the description accordingly.Non-blocking
None.
Sources
Not verified
I did not run a local C++ build, the
nkwebkit_wtftest, Linux tests, or PS5 runtime tests. Linux and GPU hosted jobs were skipped. The author's test results are self-reported.To get this to a good state
Please correct the PR description and document the unmeasured PS5 behavior, or provide PS5 evidence. I will rerun the same checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T20:01:07Z.
Review: COMMENTED
Reviewed — no blocking findings
I found no source-level blocker at head
1145addee812c38b9a0737280f5db5fa1bc630c2; the Windows check is still pending, so this is a comment and not an approval.What I ran
Reviewed head
1145addee812c38b9a0737280f5db5fa1bc630c2against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the PR previews cleanly against currentmain. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. I did not configure or build locally.I inspected all six changed files, the
StringHasher/null handling paths, the test assertions and CMake registration. The precheck's ABI and test-quality invocations could not find workspace-only helper scripts in its isolated PR snapshot; I reran them from the workspace against the exact head/base or snapshot.Results
tests/*.cpp.main; no declared dependencies.Selected unedited output
Conventions:
ABI audit summary:
Test-quality heuristic finding:
CMake registration uses a glob:
Current hosted status:
Negative control
Not run. Testing that these assertions detect a wrong implementation requires building and executing the C++ target; the PR author reports five manual mutations failed, but I did not reproduce those runs.
Findings
Blocking
None found in the source review.
Non-blocking
For a raw hash of
0xFFFFFFFF, this implementation XORs the sign bit and returns0x7FFFFFFF; the pinned PS5-WebKit source uses an OR expression that leaves that sentinel unchanged in a release build. The PR records that the console result is unmeasured and explains the intended hash-table invariant. I found no evidence in this review that resolves the console behavior, so I am treating it as a disclosed limitation rather than asserting equivalence for that input.Sources
Not verified
No local build, CTest, console run, or independent PS5 hash measurement was performed. The PR's Windows tests, full-suite comparison, and mutation results are author-reported; the current hosted Windows job has not completed.
To get this to a good state
No code change is requested from this source review. Once the Windows check completes, I will refresh the head and checks and decide whether an approval is supported.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T18:56:07Z.
Review: APPROVED
Re-checked — same head, approved
The source review already found no blocker on this head, and the previously pending Windows job has now passed along with the required policy checks, so I approve this exact revision.
What I ran
Confirmed open PR #14607 is still at head
1145addee812c38b9a0737280f5db5fa1bc630c2, based onf2d874c1fdccf781c0fa5d86619bb5dd8894b958. The exact head previews cleanly against currentmaina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The diff since2945a395d46463e4712fe33dd967923650474c52changes only the debt note; implementation and test files are unchanged. Environment: Debian 12, Linux 6.1.0-54-amd64, Python 3.11.2, Git 2.39.5. No local build or C++ test was run.The author reports the focused
nkwebkitCTest group passed 9/9 on this exact head; this is author-reported, not a local run. The author also reports five manual mutations caused the test to fail; I did not reproduce those controls.Results
a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8.nkwebkitCTestSelected unedited command output
Stack preview:
Hosted check output:
Author-reported focused CTest output:
Negative control
The author reports the test failed under five manual mutations, including changing XOR back to OR and removing the deleted-value adjustment. I did not run those mutations locally, so their outcomes are not independently verified here.
Findings
Blocking
None found in the full source review of this head.
Non-blocking
The console's result for a raw hash of
0xFFFFFFFFremains unmeasured; this head returns0x7FFFFFFFwhile the pinned PS5-WebKit expression leaves0xFFFFFFFFin a non-asserting build. The PR and debt note disclose this difference, so this approval does not claim the console result was measured.Sources
Not verified
No local build, CTest, full-suite run on this head, or PS5 runtime measurement was performed. Linux and specialized hosted jobs were skipped. The focused CTest and mutation results are author-reported.