From 36209aad475a929a03e01984845fc46ceded67f0 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Mon, 24 Jan 2022 16:46:05 -0500 Subject: [PATCH] Editorial: simplify CloneArrayBuffer AO In ECMA262 today, the CloneArrayBuffer abstract operation has two call sites. Only one of the two provides a variable value for the final parameter; the other provides a fixed value (namely, the well-known intrinsic, %ArrayBuffer%). The "Resizable ArrayBuffer" proposal removes the first call site, obviating the need for the parameter. Simplify the CloneArrayBuffer abstract operation by removing the final parameter and referencing %ArrayBuffer% directly. Update the only remaining call site as appropriate. --- spec.html | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/spec.html b/spec.html index d2a975b..9d6945e 100644 --- a/spec.html +++ b/spec.html @@ -45,6 +45,29 @@

+ +

+ CloneArrayBuffer ( + _srcBuffer_: an ArrayBuffer or a SharedArrayBuffer, + _srcByteOffset_: a non-negative integer, + _srcLength_: a non-negative integer, + _cloneConstructor_: a constructor, + ) +

+
+
description
+
It creates a new ArrayBuffer whose data is a copy of _srcBuffer_'s data over the range starting at _srcByteOffset_ and continuing for _srcLength_ bytes.
+
+ + 1. Let _targetBuffer_ be ? AllocateArrayBuffer(_cloneConstructor_%ArrayBuffer%, _srcLength_). + 1. If IsDetachedBuffer(_srcBuffer_) is *true*, throw a *TypeError* exception. + 1. Let _srcBlock_ be _srcBuffer_.[[ArrayBufferData]]. + 1. Let _targetBlock_ be _targetBuffer_.[[ArrayBufferData]]. + 1. Perform CopyDataBlockBytes(_targetBlock_, 0, _srcBlock_, _srcByteOffset_, _srcLength_). + 1. Return _targetBuffer_. + +
+

AllocateArrayBuffer ( @@ -929,7 +952,7 @@

1. Else, let _same_ be SameValue(_srcBuffer_, _targetBuffer_). 1. If _same_ is *true*, then 1. Let _srcByteLength_ be _source_.[[ByteLength]]IntegerIndexedObjectByteLength(_source_, _getSrcBufferByteLength_). - 1. Set _srcBuffer_ to ? CloneArrayBuffer(_srcBuffer_, _srcByteOffset_, _srcByteLength_, %ArrayBuffer%). + 1. Set _srcBuffer_ to ? CloneArrayBuffer(_srcBuffer_, _srcByteOffset_, _srcByteLength_, %ArrayBuffer%). 1. NOTE: %ArrayBuffer% is used to clone _srcBuffer_ because is it known to not have any observable side-effects. 1. Let _srcByteIndex_ be 0. 1. Else, let _srcByteIndex_ be _srcByteOffset_.