Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: feadeb57979a3e0fbf3d66f812c2148457620d22
      
https://github.com/WebKit/WebKit/commit/feadeb57979a3e0fbf3d66f812c2148457620d22
  Author: Geoffrey Garen <[email protected]>
  Date:   2026-04-06 (Mon, 06 Apr 2026)

  Changed paths:
    M JSTests/stress/PrintStream-truncation-for-extremely-long-strings.js
    M Source/WTF/wtf/Forward.h
    M Source/WTF/wtf/Vector.h

  Log Message:
  -----------
  Support CanBorrow in Vector<T>
https://bugs.webkit.org/show_bug.cgi?id=311221
rdar://173810770

Reviewed by Ryosuke Niwa.

We don't want to inherit CanBorrow because we want to save space. So instead we
stuff a single borrow bit in the high bit of our capacity.

This means that Vector<T> now has a maximum capacity of 2^31 - 1. Chrome has a
similar Vector<T> capacity limit, and much lower limits for web-facing APIs, so
this should not raise any interop concerns.

* JSTests/stress/PrintStream-truncation-for-extremely-long-strings.js: Test the
precise cutoff we implemented in PrintStream / printInternal to make sure we
test that function's limit and not the Vector<T> capacity limit when converting
to CString.

* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/Vector.h:
(WTF::isValidCapacityForVector): Update maximum capacity because we've stolen a 
bit.
(WTF::VectorBufferBase::VectorBufferBase):
(WTF::VectorBufferBase::exchangeCapacity):
(WTF::VectorBufferBase::swapCapacity): New helper functions since you can't take
the address of a bitfield.

(WTF::VectorBufferBase::isBorrowed const):
(WTF::VectorBufferBase::setIsBorrowed):
(WTF::VectorBufferBase::crashIfBorrowed const): Conform to the CanBorrow 
protocol.

(WTF::VectorBuffer::swap):
(WTF::VectorBuffer::VectorBuffer):
(WTF::VectorBuffer::adopt): Use the new helper functions.

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



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

Reply via email to