Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe0aa79252484e5da584cf525ccc930e7698deef
      
https://github.com/WebKit/WebKit/commit/fe0aa79252484e5da584cf525ccc930e7698deef
  Author: Yusuke Suzuki <[email protected]>
  Date:   2023-10-23 (Mon, 23 Oct 2023)

  Changed paths:
    M JSTests/stress/v8-harmony-arraybuffer-transfer.js
    M JSTests/test262/config.yaml
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/runtime/CommonIdentifiers.h
    M Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp

  Log Message:
  -----------
  [JSC] Implement ArrayBuffer#transfer
https://bugs.webkit.org/show_bug.cgi?id=263518
rdar://117337535

Reviewed by Mark Lam and Ross Kirsling.

This patch implements ArrayBuffer#transfer proposal[1], which is stage-3 and 
implemented in the other engines too.
It implements two functions and one getter.

1. ArrayBuffer#transfer. It transfers internal ArrayBuffer to a new ArrayBuffer 
and detach the original buffer.
   This only works with normal ArrayBuffer and it throws an error against 
SharedArrayBuffer. This preserves resizability
   of the original ArrayBuffer, it means that if we transfer resizable 
ArrayBuffer, we get resizable transferred ArrayBuffer.
2. ArrayBuffer#transferToFixedLength is similar to ArrayBuffer#transfer. But 
this always creates non-resizable ArrayBuffer.
   It means, internally, we create a new ArrayBuffer if resizability is 
different and copy the underlying content.

In both cases, if ArrayBuffer is not resizable and result size is the same, 
then it just changes underlying buffer's ownership and
does not allocate and copy contents. If it is ArrayBuffer#transfer and the 
input ArrayBuffer is resizable, then we also just changes
the ownership and resize the resulted ArrayBuffer's size.

3. ArrayBuffer#detach getter returns boolean whether ArrayBuffer is detached or 
not.

[1]: https://tc39.es/proposal-arraybuffer-transfer/

* JSTests/test262/config.yaml:
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/runtime/CommonIdentifiers.h:
* Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp:
(JSC::arrayBufferCopyAndDetach):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSArrayBufferPrototype::finishCreation):

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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to