feat(libSceNKWebKit): implement the WTF::BitVector slow paths #14152

Merged
gazaret merged 4 commits from upstream-pr/14152 into main 2026-11-07 00:43:43 +00:00
gazaret commented 2026-10-31 21:05:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gazaret on 2026-10-31T21:05:55Z.


What

Implements ten WTF::BitVector exports in libSceNKWebKit, which were throwing stubs: OutOfLineBits::create, resize, setSlow, clearAll, mergeSlow, excludeSlow, isEmptySlow, bitCountSlow, hashSlowCase and equalsSlowCase. They follow BitVector.cpp and the one-word layout in BitVector.h from the pinned PS5 WebKit 11.x source the debt file already uses:

  • a vector is one word: up to 63 bits inline with the top bit set, or an OutOfLineBits pointer shifted right by one, whose numBits is rounded up to whole words;
  • create allocates through WTF::fastMalloc without clearing the words, and the code frees through WTF::fastFree, which is what OutOfLineBits::destroy does upstream;
  • resize, setSlow, mergeSlow and excludeSlow grow, copy, shrink back inline and combine words as upstream does, including the empty (0) and deleted (1) hash-table values in setSlow.

Where this differs from WebKit, as recorded in docs/dev/debt/libSceNKWebKit.md:

  • mergeSlow ORs only the words both out-of-line vectors hold. WebKit reads past the other vector's words when this one is longer.
  • isEmptySlow, bitCountSlow and hashSlowCase on an inline, empty or deleted vector, and a null vector anywhere, throw where WebKit reads through an invalid pointer.
  • equalsSlowCase on two inline vectors compares their words.

OutOfLineBits::destroy is forwarded to fastFree by #13947, now merged, so a title's BitVector destructor frees the out-of-line vectors these functions produce. dump still throws, since WTF::PrintStream is not implemented. The declarations, with the WTF::BitVector layout, are in a new include/WtfBitVector.hpp, and the code is in src/WtfBitVector.cpp, so no CMake change is needed. The stubs are removed from Export.cpp, InventoryExports.hpp and the debt table, whose count drops to 7361. On main the count says 7369 while the table has 7371 rows (concurrent merges each edit the same line), so it is recounted from the table rather than lowered by ten.

Tested

Ubuntu 22.04 (WSL2), GCC 13.4, Release, rebased on main d78531d356, full BUILD_TESTING=ON build:

  • New nkwebkit_wtfbitvector: word rounding in create; growing, shrinking and returning inline in resize; deep copies and empty or deleted values in setSlow; clearAll; mergeSlow and excludeSlow for every mix of inline and out-of-line vectors; the three queries; and equalsSlowCase across sizes and trailing zero words. Passes 3 of 3 runs. The throwing paths are not asserted.

  • ctest -R 'nkwebkit|public_headers|patched_librar|nid_': 112 of 112 pass.

  • tools/check_conventions.py --base origin/main: no findings.

  • Open pull requests were checked for these ten functions: none implements them.

  • Test merges (git merge at the current heads) with the 107 open pull requests that change libSceNKWebKit:

    • conflict in Export.cpp, InventoryExports.hpp or libSceNKWebKit.hpp, at adjacent stub deletions with no duplicate export: 29, such as #13515, #14374, #14919 to #14948 and #15516; each of them already conflicts with main;
    • conflict only at the pending-export count in the debt file: 39 others, from #14138 to #16383, since nearly every libSceNKWebKit pull request edits that line;
    • 10 others, such as #14860 and #15151 (include/WebKitValueExports.hpp), #15157 to #15185 (src/Types.hpp, tests/Base.cpp), #14921 and #15213 (include/WtfExports.hpp) and #14212, already conflict with main in files this pull request does not change;
    • clean: #6989, #14330, #14607, #14923, #15043 and 24 others;
    • none implements these ten.

    Whichever lands second needs a rebase that keeps both deletions and recounts the debt file. An earlier version of this description said every merge was clean; that came from a check that missed conflict markers and was wrong.

  • 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 (#13947, which forwards OutOfLineBits::destroy, is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5101536781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14152). Originally posted by [gazaret](https://github.com/gazaret) on 2026-10-31T21:05:55Z. --- ### What Implements ten `WTF::BitVector` exports in libSceNKWebKit, which were throwing stubs: `OutOfLineBits::create`, `resize`, `setSlow`, `clearAll`, `mergeSlow`, `excludeSlow`, `isEmptySlow`, `bitCountSlow`, `hashSlowCase` and `equalsSlowCase`. They follow [BitVector.cpp](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/BitVector.cpp#L41-L274) and the one-word layout in [BitVector.h](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/BitVector.h#L455-L509) from the pinned PS5 WebKit 11.x source the debt file already uses: - a vector is one word: up to 63 bits inline with the top bit set, or an `OutOfLineBits` pointer shifted right by one, whose `numBits` is rounded up to whole words; - `create` allocates through `WTF::fastMalloc` without clearing the words, and the code frees through `WTF::fastFree`, which is what `OutOfLineBits::destroy` does upstream; - `resize`, `setSlow`, `mergeSlow` and `excludeSlow` grow, copy, shrink back inline and combine words as upstream does, including the empty (0) and deleted (1) hash-table values in `setSlow`. Where this differs from WebKit, as recorded in `docs/dev/debt/libSceNKWebKit.md`: - `mergeSlow` ORs only the words both out-of-line vectors hold. WebKit reads past the other vector's words when this one is longer. - `isEmptySlow`, `bitCountSlow` and `hashSlowCase` on an inline, empty or deleted vector, and a null vector anywhere, throw where WebKit reads through an invalid pointer. - `equalsSlowCase` on two inline vectors compares their words. `OutOfLineBits::destroy` is forwarded to `fastFree` by #13947, now merged, so a title's `BitVector` destructor frees the out-of-line vectors these functions produce. `dump` still throws, since `WTF::PrintStream` is not implemented. The declarations, with the `WTF::BitVector` layout, are in a new `include/WtfBitVector.hpp`, and the code is in `src/WtfBitVector.cpp`, so no CMake change is needed. The stubs are removed from `Export.cpp`, `InventoryExports.hpp` and the debt table, whose count drops to 7361. On `main` the count says 7369 while the table has 7371 rows (concurrent merges each edit the same line), so it is recounted from the table rather than lowered by ten. ### Tested Ubuntu 22.04 (WSL2), GCC 13.4, Release, rebased on `main` d78531d356, full `BUILD_TESTING=ON` build: - New `nkwebkit_wtfbitvector`: word rounding in `create`; growing, shrinking and returning inline in `resize`; deep copies and empty or deleted values in `setSlow`; `clearAll`; `mergeSlow` and `excludeSlow` for every mix of inline and out-of-line vectors; the three queries; and `equalsSlowCase` across sizes and trailing zero words. Passes 3 of 3 runs. The throwing paths are not asserted. - `ctest -R 'nkwebkit|public_headers|patched_librar|nid_'`: 112 of 112 pass. - `tools/check_conventions.py --base origin/main`: no findings. - Open pull requests were checked for these ten functions: none implements them. - Test merges (`git merge` at the current heads) with the 107 open pull requests that change libSceNKWebKit: - conflict in `Export.cpp`, `InventoryExports.hpp` or `libSceNKWebKit.hpp`, at adjacent stub deletions with no duplicate export: 29, such as #13515, #14374, #14919 to #14948 and #15516; each of them already conflicts with `main`; - conflict only at the pending-export count in the debt file: 39 others, from #14138 to #16383, since nearly every libSceNKWebKit pull request edits that line; - 10 others, such as #14860 and #15151 (`include/WebKitValueExports.hpp`), #15157 to #15185 (`src/Types.hpp`, `tests/Base.cpp`), #14921 and #15213 (`include/WtfExports.hpp`) and #14212, already conflict with `main` in files this pull request does not change; - clean: #6989, #14330, #14607, #14923, #15043 and 24 others; - none implements these ten. Whichever lands second needs a rebase that keeps both deletions and recounts the debt file. An earlier version of this description said every merge was clean; that came from a check that missed conflict markers and was wrong. - 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 (#13947, which forwards `OutOfLineBits::destroy`, is merged) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-31 21:46:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T21:46:56Z.

Review: APPROVED


Reviewed — looks good

The ten slow paths match the pinned WebKit representation, with the out-of-range merge read avoided, and the exact-head Windows CI built and passed the new nkwebkit_wtfbitvector test.

What I ran

Reviewed head 53120e3badaeeec709a8bfc830af83838366d10e, on PR base 01df56f7b77e01fc439802a3e59057115c497872; the merge preview against current main c21eb9a4d0748c11d3061cf402737eda2a30d00f was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build locally.

git diff --check refs/review/anyps5-main...refs/review/14152
python3 tools/check_conventions.py --base refs/review/anyps5-main --head refs/review/14152
python3 tools/pr_abi_audit.py --base 01df56f7b77e01fc439802a3e59057115c497872 --head 53120e3badaeeec709a8bfc830af83838366d10e --json | python3 -c 'import json,sys;x=json.load(sys.stdin);print("status:",x["status"]);print("findings:",len(x["findings"]));print("symbols audited:",len(x["symbols"]))'
python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceNKWebKit/tests/WtfBitVector.cpp
python3 tools/pr_stack_check.py 14152 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/stack-14152-latest
git merge-tree --write-tree refs/review/anyps5-main refs/review/14152

Results

Check Result
Diff check and conventions Passed.
ABI audit Passed; no findings. It does not validate C++ ABI at runtime or build.
Source review Compared the slow paths and representation with the PR's pinned PS5 WebKit source. The bounded word loops in mergeSlow avoid reading beyond a shorter source vector.
Test registration/quality The heuristic warned because the source path is registered by the tests/*.cpp CMake glob rather than a literal path. The Windows CI log confirms it built and ran nkwebkit_wtfbitvector.
Current-main merge preview Clean against c21eb9a4d0748c11d3061cf402737eda2a30d00f; no declared dependency.
Exact-head hosted test Windows job passed on 53120e3badaeeec709a8bfc830af83838366d10e; nkwebkit_wtfbitvector passed. Conventions and labels also passed. Linux and specialized build jobs were skipped.
Precheck Its isolated snapshot lacked workspace-only ABI and test-quality helper scripts, so those two invocations could not start. I ran them locally against the exact revisions.
Selected unedited output
All conventions checks passed.
status: passed
findings: 0
symbols audited: 10109
1855/2537 Test #2307: nkwebkit_wtfbitvector ....................................................   Passed    0.02 sec
7e162d0d84e2851d79c107defe1e98be574eb227
{
  "findings": [
    {
      "path": "core/libs/prx/libSceNKWebKit/tests/WtfBitVector.cpp",
      "line": 1,
      "kind": "possible-unregistered-cpp-test",
      "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."
    }
  ],
  "negative_control_candidates": [],
  "limits": [
    "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.",
    "A test that passes against base is not by itself proof that the PR test is inadequate.",
    "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."
  ]
}

Negative control

No local negative control was run; I did not build the test binary locally.

Sources

Not verified

No local build or test run. I did not independently run the Linux tests or verify behavior on a PS5; the PR description reports 89/89 Linux CTests, but describes that run against main 0836dfdf4f, so I do not count it as exact-head evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725050984 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14152#pullrequestreview-5725050984). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T21:46:56Z. **Review:** APPROVED --- # Reviewed — looks good The ten slow paths match the pinned WebKit representation, with the out-of-range merge read avoided, and the exact-head Windows CI built and passed the new `nkwebkit_wtfbitvector` test. ## What I ran Reviewed head `53120e3badaeeec709a8bfc830af83838366d10e`, on PR base `01df56f7b77e01fc439802a3e59057115c497872`; the merge preview against current `main` `c21eb9a4d0748c11d3061cf402737eda2a30d00f` was clean. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. I did not build locally. ```sh git diff --check refs/review/anyps5-main...refs/review/14152 python3 tools/check_conventions.py --base refs/review/anyps5-main --head refs/review/14152 python3 tools/pr_abi_audit.py --base 01df56f7b77e01fc439802a3e59057115c497872 --head 53120e3badaeeec709a8bfc830af83838366d10e --json | python3 -c 'import json,sys;x=json.load(sys.stdin);print("status:",x["status"]);print("findings:",len(x["findings"]));print("symbols audited:",len(x["symbols"]))' python3 tools/pr_test_quality.py --root /marc/AnyPS5 --json core/libs/prx/libSceNKWebKit/tests/WtfBitVector.cpp python3 tools/pr_stack_check.py 14152 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/stack-14152-latest git merge-tree --write-tree refs/review/anyps5-main refs/review/14152 ``` ## Results | Check | Result | |---|---| | Diff check and conventions | Passed. | | ABI audit | Passed; no findings. It does not validate C++ ABI at runtime or build. | | Source review | Compared the slow paths and representation with the PR's pinned PS5 WebKit source. The bounded word loops in `mergeSlow` avoid reading beyond a shorter source vector. | | Test registration/quality | The heuristic warned because the source path is registered by the `tests/*.cpp` CMake glob rather than a literal path. The Windows CI log confirms it built and ran `nkwebkit_wtfbitvector`. | | Current-main merge preview | Clean against `c21eb9a4d0748c11d3061cf402737eda2a30d00f`; no declared dependency. | | Exact-head hosted test | Windows job passed on `53120e3badaeeec709a8bfc830af83838366d10e`; `nkwebkit_wtfbitvector` passed. Conventions and labels also passed. Linux and specialized build jobs were skipped. | | Precheck | Its isolated snapshot lacked workspace-only ABI and test-quality helper scripts, so those two invocations could not start. I ran them locally against the exact revisions. | <details><summary>Selected unedited output</summary> ```text All conventions checks passed. ``` ```text status: passed findings: 0 symbols audited: 10109 ``` ```text 1855/2537 Test #2307: nkwebkit_wtfbitvector .................................................... Passed 0.02 sec ``` ```text 7e162d0d84e2851d79c107defe1e98be574eb227 ``` ```text { "findings": [ { "path": "core/libs/prx/libSceNKWebKit/tests/WtfBitVector.cpp", "line": 1, "kind": "possible-unregistered-cpp-test", "message": "Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage." } ], "negative_control_candidates": [], "limits": [ "Heuristics can miss weak assertions and can flag valid tests; inspect every finding.", "A test that passes against base is not by itself proof that the PR test is inadequate.", "Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error." ] } ``` </details> ## Negative control No local negative control was run; I did not build the test binary locally. ## Sources - [Pinned PS5 WebKit `BitVector.cpp`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/BitVector.cpp#L41-L274) and [layout in `BitVector.h`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/BitVector.h#L455-L509) - [Implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/53120e3badaeeec709a8bfc830af83838366d10e/core/libs/prx/libSceNKWebKit/src/WtfBitVector.cpp) - [New tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/53120e3badaeeec709a8bfc830af83838366d10e/core/libs/prx/libSceNKWebKit/tests/WtfBitVector.cpp) ## Not verified No local build or test run. I did not independently run the Linux tests or verify behavior on a PS5; the PR description reports 89/89 Linux CTests, but describes that run against `main` `0836dfdf4f`, so I do not count it as exact-head evidence.
CnRJay commented 2026-11-01 19:49:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:31Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922501 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14152#pullrequestreview-5729922501). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:31Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
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!14152
No description provided.