feat(libSceNKWebKit): implement WebCore::BlobDataFileReference #21422

Merged
RiverWhy merged 4 commits from upstream-pr/21422 into main 2026-11-17 21:05:26 +00:00
RiverWhy commented 2026-11-16 05:57:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-16T05:57:33Z.


What

Implements the 11 exports of WebCore::BlobDataFileReference, the reference-counted file a Blob is backed by. It is ported from BlobDataFileReference.cpp at e12a212a531a, the 2021 revision whose WTF ABI the module matches. PlayStation has no FILE_REPLACEMENT, so the replacement-file generation paths are not part of it.

  • Constructors (C1, C2): vtable, reference count 1, both paths copied, size 0, no expected modification time.
  • create: allocates with the guest operator new and constructs (the class is not WTF_MAKE_FAST_ALLOCATED), returned as a Ref.
  • Destructors (D1, D2, and D0, which also calls the guest operator delete): a non-null replacement path is deleted the way that revision's FileSystem::deleteFile does (not when it is a directory, unlink).
  • path(): the replacement path when it is not null, otherwise the path.
  • expectedModificationTime(): Optional<WallTime>, empty until tracking found the file.
  • startTrackingModifications(): takes the modification time of the path; the size comes from the replacement file when there is one, otherwise from the path. If the path is missing, nothing changes; if only the replacement is missing, the time is kept and the size is not set.
  • prepareForFileAccess, revokeFileAccess: no-ops, as in the source.

Layout and ABI, measured on a Linux build of that revision (-fdump-lang-class, offsetof, generated assembly) and checked with static_asserts:

  • 48 bytes: vtable, RefCounted count at 8, path at 16, replacement path at 24, size at 0x20 (where the existing BlobDataFileReference::size() getter already reads it), Markable<WallTime> at 40 with NaN as empty.
  • Vtable: complete destructor, deleting destructor, prepareForFileAccess, revokeFileAccess.
  • Optional<WallTime> is not trivially copyable, so it is returned through a hidden pointer as {bool, double}. The host type copies that, and the compiled export stores the flag at 0 and the time at 8, as the 2021 build's code does.

File metadata follows that revision's fileMetadataFollowingSymlinks, which the module does not export: a guest stat (it follows links), the modification time in whole seconds (file_clock::to_time_t in libc++), and a length only for regular files (directory_entry::file_size fails for anything else and WebKit then uses 0).

expectedModificationTime was a legacy stub in LegacyExports.hpp, so it has no debt row; the other 10 come out of the inventory.

A null object or path throws.

Debt: a fragment, docs/dev/debt/changes/feat-nkwebkit-blob-data-file-reference.md, adds the entry under Functional and removes the 10 inventory rows.

Overlap: pr_overlap.py --names finds no open PR with these exports. --branch could not merge-compare 25 older NKWebKit PRs that conflict with main; none of their diffs mentions BlobDataFileReference. Other NKWebKit PRs touch Export.cpp, InventoryExports.hpp and the end of libSceNKWebKit.hpp, which can give line conflicts only.

Tested

Linux Mint 22.3:

  • Layout, vtable order and the Optional<WallTime> return checked against a Linux build of e12a212a531a (probe of the class with WTF's own RefCounted, Markable and Optional), and the export's assembly compared with that build's.
  • New nkwebkit_blobdatafilereference test, with files under a guest path alias:
    • construction over poisoned storage, both constructors, and path() with and without a replacement;
    • tracking a file: size and a whole-second time equal to the guest stat;
    • the size taken from the replacement and the time from the path;
    • a missing replacement (time kept, size 0), missing and empty paths (nothing set), a directory (time, size 0);
    • create allocating one object on a recording guest heap, the four vtable slots called as guest code would, and the deleting destructor freeing it;
    • the destructor deleting the replacement but never the path or a directory;
    • null refusals.
  • ctest -R nkwebkit: 105 tests passed.

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:5331906033 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21422). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-16T05:57:33Z. --- ### What Implements the 11 exports of `WebCore::BlobDataFileReference`, the reference-counted file a `Blob` is backed by. It is ported from [BlobDataFileReference.cpp](https://github.com/WebKit/WebKit/blob/e12a212a531aeddc11259e8515671cf5188e038d/Source/WebCore/platform/network/BlobDataFileReference.cpp) at `e12a212a531a`, the 2021 revision whose WTF ABI the module matches. PlayStation has no `FILE_REPLACEMENT`, so the replacement-file generation paths are not part of it. - Constructors (`C1`, `C2`): vtable, reference count 1, both paths copied, size 0, no expected modification time. - `create`: allocates with the guest `operator new` and constructs (the class is not `WTF_MAKE_FAST_ALLOCATED`), returned as a `Ref`. - Destructors (`D1`, `D2`, and `D0`, which also calls the guest `operator delete`): a non-null replacement path is deleted the way that revision's `FileSystem::deleteFile` does (not when it is a directory, `unlink`). - `path()`: the replacement path when it is not null, otherwise the path. - `expectedModificationTime()`: `Optional<WallTime>`, empty until tracking found the file. - `startTrackingModifications()`: takes the modification time of the path; the size comes from the replacement file when there is one, otherwise from the path. If the path is missing, nothing changes; if only the replacement is missing, the time is kept and the size is not set. - `prepareForFileAccess`, `revokeFileAccess`: no-ops, as in the source. Layout and ABI, measured on a Linux build of that revision (`-fdump-lang-class`, `offsetof`, generated assembly) and checked with `static_assert`s: - 48 bytes: vtable, `RefCounted` count at 8, path at 16, replacement path at 24, size at 0x20 (where the existing `BlobDataFileReference::size()` getter already reads it), `Markable<WallTime>` at 40 with NaN as empty. - Vtable: complete destructor, deleting destructor, `prepareForFileAccess`, `revokeFileAccess`. - `Optional<WallTime>` is not trivially copyable, so it is returned through a hidden pointer as `{bool, double}`. The host type copies that, and the compiled export stores the flag at 0 and the time at 8, as the 2021 build's code does. File metadata follows that revision's `fileMetadataFollowingSymlinks`, which the module does not export: a guest `stat` (it follows links), the modification time in whole seconds (`file_clock::to_time_t` in libc++), and a length only for regular files (`directory_entry::file_size` fails for anything else and WebKit then uses 0). `expectedModificationTime` was a legacy stub in `LegacyExports.hpp`, so it has no debt row; the other 10 come out of the inventory. A null object or path throws. Debt: a fragment, `docs/dev/debt/changes/feat-nkwebkit-blob-data-file-reference.md`, adds the entry under Functional and removes the 10 inventory rows. Overlap: `pr_overlap.py --names` finds no open PR with these exports. `--branch` could not merge-compare 25 older NKWebKit PRs that conflict with `main`; none of their diffs mentions `BlobDataFileReference`. Other NKWebKit PRs touch `Export.cpp`, `InventoryExports.hpp` and the end of `libSceNKWebKit.hpp`, which can give line conflicts only. ### Tested Linux Mint 22.3: - Layout, vtable order and the `Optional<WallTime>` return checked against a Linux build of `e12a212a531a` (probe of the class with WTF's own `RefCounted`, `Markable` and `Optional`), and the export's assembly compared with that build's. - New `nkwebkit_blobdatafilereference` test, with files under a guest path alias: - construction over poisoned storage, both constructors, and `path()` with and without a replacement; - tracking a file: size and a whole-second time equal to the guest `stat`; - the size taken from the replacement and the time from the path; - a missing replacement (time kept, size 0), missing and empty paths (nothing set), a directory (time, size 0); - `create` allocating one object on a recording guest heap, the four vtable slots called as guest code would, and the deleting destructor freeing it; - the destructor deleting the replacement but never the path or a directory; - null refusals. - `ctest -R nkwebkit`: 105 tests passed. ### Checklist - [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-16 06:21:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T06:21:56Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 205f48ba63:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_blobdatafilereference_tests built cleanly.
  • CTest (nkwebkit_blobdatafilereference):
    1/1 Test #4269: nkwebkit_blobdatafilereference ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified export removal in Export.cpp, InventoryExports.hpp, and LegacyExports.hpp and matching declarations in BlobDataFileReferenceExports.hpp for all 11 WebCore::BlobDataFileReference symbols.
    • Checked null pointer validation via Checked() and CheckedPath() across constructors (C1/C2), destructors (D0/D1/D2), create(), path(), expectedModificationTime(), startTrackingModifications(), prepareForFileAccess(), and revokeFileAccess().
    • Verified WebKit e12a212a531a semantics for startTrackingModifications() (reading modification time from path and file size from replacementPath when non-null, or path otherwise), expectedModificationTime() NaN handling, and DeleteFile() in ~BlobDataFileReference().
    • Confirmed BlobDataFileReferenceRef ABI layout (8-byte Ref wrapper), guest heap allocation via _Znwm_nid_postfix / _ZdlPv_nid_postfix, and CMakeLists.txt test linkage with libkernel.
    • Verified compliance with AGENTS.md rules, upstream Apple/Canon license headers, and mechanical convention checks.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915811212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21422#pullrequestreview-5915811212). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T06:21:56Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `205f48ba63`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_blobdatafilereference_tests` built cleanly. - **CTest** (`nkwebkit_blobdatafilereference`): ``` 1/1 Test #4269: nkwebkit_blobdatafilereference ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/libSceNKWebKit.hpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified export removal in Export.cpp, InventoryExports.hpp, and LegacyExports.hpp and matching declarations in BlobDataFileReferenceExports.hpp for all 11 WebCore::BlobDataFileReference symbols. - Checked null pointer validation via Checked() and CheckedPath() across constructors (C1/C2), destructors (D0/D1/D2), create(), path(), expectedModificationTime(), startTrackingModifications(), prepareForFileAccess(), and revokeFileAccess(). - Verified WebKit e12a212a531a semantics for startTrackingModifications() (reading modification time from path and file size from replacementPath when non-null, or path otherwise), expectedModificationTime() NaN handling, and DeleteFile() in ~BlobDataFileReference(). - Confirmed BlobDataFileReferenceRef ABI layout (8-byte Ref wrapper), guest heap allocation via _Znwm_nid_postfix / _ZdlPv_nid_postfix, and CMakeLists.txt test linkage with libkernel. - Verified compliance with AGENTS.md rules, upstream Apple/Canon license headers, and mechanical convention checks. Looks Good To Me
MarcZX10 commented 2026-11-16 06:34:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T06:34:38Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected implementation has no verified blocking defect, but the full review is incomplete because two changed files were excluded from the review folder and no checks were run.

What I ran

Reviewed head 205f48ba63f2f87fccfc4820019da0e143d1db8c using the prepared diff and repo_read.py. No build or tests were run.

Read: description.md, commits.md, manifest.json, diff.patch; CMakeLists.txt, BlobDataFileReferenceExports.hpp, libSceNKWebKit.hpp, BlobDataFileReference.cpp, and BlobDataFileReferenceAbi.hpp.

Excluded: full text of Export.cpp and InventoryExports.hpp (too large for the review folder). The changed hunks for both are present in diff.patch.

Results

Check Result Note
Change and implementation review passed Inspected included implementation and changed hunks
Build and tests not run No local checks performed
Full changed-file review not run Two full files were excluded

Findings

Blocking

None verified in the inspected code.

Non-blocking

None.

Sources

Behavior and implementation claims are based on the prepared diff and files read at the pinned head. No external sources were consulted.

Not verified

The full contents of Export.cpp and InventoryExports.hpp were not read. Build and test results reported in the PR description were author-reported and not independently run.

To get this to a good state

Nothing is required. The review remains incomplete until the excluded changed files and checks are reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5915913133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21422#pullrequestreview-5915913133). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T06:34:38Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected implementation has no verified blocking defect, but the full review is incomplete because two changed files were excluded from the review folder and no checks were run. ## What I ran Reviewed head `205f48ba63f2f87fccfc4820019da0e143d1db8c` using the prepared diff and `repo_read.py`. No build or tests were run. Read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`; `CMakeLists.txt`, `BlobDataFileReferenceExports.hpp`, `libSceNKWebKit.hpp`, `BlobDataFileReference.cpp`, and `BlobDataFileReferenceAbi.hpp`. Excluded: full text of `Export.cpp` and `InventoryExports.hpp` (too large for the review folder). The changed hunks for both are present in `diff.patch`. ## Results | Check | Result | Note | |---|---|---| | Change and implementation review | passed | Inspected included implementation and changed hunks | | Build and tests | not run | No local checks performed | | Full changed-file review | not run | Two full files were excluded | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking None. ## Sources Behavior and implementation claims are based on the prepared diff and files read at the pinned head. No external sources were consulted. ## Not verified The full contents of `Export.cpp` and `InventoryExports.hpp` were not read. Build and test results reported in the PR description were author-reported and not independently run. ## To get this to a good state Nothing is required. The review remains incomplete until the excluded changed files and checks are reviewed.
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!21422
No description provided.