Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: da573f8d6dcaa5b04b588465b1b9f4b009e0bdf2
      
https://github.com/WebKit/WebKit/commit/da573f8d6dcaa5b04b588465b1b9f4b009e0bdf2
  Author: Geoffrey Garen <[email protected]>
  Date:   2026-03-27 (Fri, 27 Mar 2026)

  Changed paths:
    A LayoutTests/fast/webgpu/regression/repro_173266457-expected.txt
    A LayoutTests/fast/webgpu/regression/repro_173266457.html
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    A Source/WTF/wtf/Borrow.h
    M Source/WTF/wtf/CMakeLists.txt
    A Source/WTF/wtf/CanBorrow.h
    M Source/WebGPU/WebGPU/Buffer.h
    M Source/WebGPU/WebGPU/Buffer.mm
    M Source/WebGPU/WebGPU/Queue.mm

  Log Message:
  -----------
  Initial implementation of Borrow and CanBorrow
https://bugs.webkit.org/show_bug.cgi?id=310655
rdar://173266457

Reviewed by Mike Wyrzykowski and Ryosuke Niwa.

Adopted in WebGPU::Buffer to inform our experiment with Swift in WebGPU.

This test adoption already found an invalid borrow bug, where the author
captured a span in a lambda when they meant to capture a copy instead.

The consequence of the bug is minor (since the lambda also captures the owning
buffer), but it is a welcome validation of the approach.

I'm suppressing the SaferCPP failures around borrow(x)-> for now, while we
decide how SaferCPP should model borrow() / Borrow<T>.

* LayoutTests/fast/webgpu/regression/repro_173266457-expected.txt: Added.
* LayoutTests/fast/webgpu/regression/repro_173266457.html: Added. Regression
test for the observable side effect of the minor bug I described above.
After submitting an invalid set of GPU commands, the program should see
its buffer unchanged, rather than zeroed.

* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/Borrow.h: Added.
(WTF::Borrow::Borrow):
(WTF::Borrow::~Borrow):
(WTF::Borrow::assertIsOnStack):
(WTF::borrow):
* Source/WTF/wtf/CMakeLists.txt: List new headers.

* Source/WTF/wtf/CanBorrow.h: Added.
(WTF::CanBorrow::~CanBorrow):
(WTF::CanBorrow::crashIfBorrowed):
(WTF::CanBorrow::setIsBorrowed): New types to describe runtime borrowing.

* Source/WebGPU/WebGPU/Buffer.h:
* Source/WebGPU/WebGPU/Buffer.mm:
(WebGPU::Buffer::destroy):
(WebGPU::Buffer::takeSlowIndexValidationPath):
(WebGPU::Buffer::takeSlowIndirectIndexValidationPath):
(WebGPU::Buffer::takeSlowIndirectValidationPath): Make sure to borrow. Copying
a Borrow is not allowed, and that revealed a pre-existing bug: The code copied a
span across an async lambda callback. The code's intention was to make a deep
copy, so I've switched to a Vector. We don't care that this is slow because it's
already in the invalid slow path.

* Source/WebGPU/WebGPU/Queue.mm:
(WebGPU::Queue::writeBuffer): Make sure to borrow.

Canonical link: https://commits.webkit.org/310068@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to