From 77ad7fef14647171c7a718f0e5cc4cdd5dc32195 Mon Sep 17 00:00:00 2001 From: Yulia Startsev Date: Wed, 16 Oct 2024 20:50:37 +0200 Subject: [PATCH 1/3] Normative: Remove Species check for TypedArrays ArrayBuffers and SharedArrayBuffers --- spec.html | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/spec.html b/spec.html index 2871f040e5..3091114362 100644 --- a/spec.html +++ b/spec.html @@ -6572,6 +6572,12 @@

1. If IsConstructor(_S_) is *true*, return _S_. 1. Throw a *TypeError* exception. + +

Species constructor is only available for Array, RegExp and Promise built-in classes. It + will not be provided to any other built-in classes. Species are an expensive and complex + operation that did not end up being used by the community, resulting in the feature being + deprecated.

+
@@ -40793,7 +40799,7 @@

%TypedArray%.prototype.filter ( _callback_ [ , _thisArg_ ] )

1. Append _kValue_ to _kept_. 1. Set _captured_ to _captured_ + 1. 1. Set _k_ to _k_ + 1. - 1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_captured_) »). + 1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_captured_) »). 1. Let _n_ be 0. 1. For each element _e_ of _kept_, do 1. Perform ! Set(_A_, ! ToString(𝔽(_n_)), _e_, *true*). @@ -41019,7 +41025,7 @@

%TypedArray%.prototype.map ( _callback_ [ , _thisArg_ ] )

1. Let _taRecord_ be ? ValidateTypedArray(_O_, ~seq-cst~). 1. Let _len_ be TypedArrayLength(_taRecord_). 1. If IsCallable(_callback_) is *false*, throw a *TypeError* exception. - 1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_len_) »). + 1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_len_) »). 1. Let _k_ be 0. 1. Repeat, while _k_ < _len_, 1. Let _Pk_ be ! ToString(𝔽(_k_)). @@ -41235,7 +41241,7 @@

%TypedArray%.prototype.slice ( _start_, _end_ )

1. Else if _relativeEnd_ < 0, let _endIndex_ be max(_srcArrayLength_ + _relativeEnd_, 0). 1. Else, let _endIndex_ be min(_relativeEnd_, _srcArrayLength_). 1. Let _countBytes_ be max(_endIndex_ - _startIndex_, 0). - 1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_countBytes_) »). + 1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_countBytes_) »). 1. If _countBytes_ > 0, then 1. Set _taRecord_ to MakeTypedArrayWithBufferWitnessRecord(_O_, ~seq-cst~). 1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. @@ -41347,7 +41353,7 @@

%TypedArray%.prototype.subarray ( _start_, _end_ )

1. Else, let _endIndex_ be min(_relativeEnd_, _srcLength_). 1. Let _newLength_ be max(_endIndex_ - _startIndex_, 0). 1. Let _argumentsList_ be « _buffer_, 𝔽(_beginByteOffset_), 𝔽(_newLength_) ». - 1. Return ? TypedArraySpeciesCreate(_O_, _argumentsList_). + 1. Return ? TypedArrayCreateSameType(_O_, _argumentsList_).

This method is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.

@@ -41465,27 +41471,6 @@

get %TypedArray%.prototype [ %Symbol.toStringTag% ]

Abstract Operations for TypedArray Objects

- -

- TypedArraySpeciesCreate ( - _exemplar_: a TypedArray, - _argumentList_: a List of ECMAScript language values, - ): either a normal completion containing a TypedArray or a throw completion -

-
-
description
-
It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray.
-
- - 1. Let _defaultConstructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in . - 1. Let _constructor_ be ? SpeciesConstructor(_exemplar_, _defaultConstructor_). - 1. Let _result_ be ? TypedArrayCreateFromConstructor(_constructor_, _argumentList_). - 1. Assert: _result_ has [[TypedArrayName]] and [[ContentType]] internal slots. - 1. If _result_.[[ContentType]] is not _exemplar_.[[ContentType]], throw a *TypeError* exception. - 1. Return _result_. - -
-

TypedArrayCreateFromConstructor ( @@ -41517,7 +41502,7 @@

description
-
It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. Unlike TypedArraySpeciesCreate, which can construct custom TypedArray subclasses through the use of %Symbol.species%, this operation always uses one of the built-in TypedArray constructors.
+
It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. This operation always uses one of the built-in TypedArray constructors.
1. Let _constructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in . @@ -43807,7 +43792,7 @@

ArrayBuffer.prototype.slice ( _start_, _end_ )

1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). 1. Else, let _final_ be min(_relativeEnd_, _len_). 1. Let _newLen_ be max(_final_ - _first_, 0). - 1. Let _ctor_ be ? SpeciesConstructor(_O_, %ArrayBuffer%). + 1. Let _ctor_ be %ArrayBuffer%. 1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). 1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). 1. If IsSharedArrayBuffer(_new_) is *true*, throw a *TypeError* exception. @@ -44125,7 +44110,7 @@

SharedArrayBuffer.prototype.slice ( _start_, _end_ )

1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). 1. Else, let _final_ be min(_relativeEnd_, _len_). 1. Let _newLen_ be max(_final_ - _first_, 0). - 1. Let _ctor_ be ? SpeciesConstructor(_O_, %SharedArrayBuffer%). + 1. Let _ctor_ be %SharedArrayBuffer%. 1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). 1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). 1. If IsSharedArrayBuffer(_new_) is *false*, throw a *TypeError* exception. From 5c744fd2a2810129a83762f3b6bae9ba18177cd6 Mon Sep 17 00:00:00 2001 From: Yulia Startsev Date: Thu, 17 Oct 2024 11:03:00 +0200 Subject: [PATCH 2/3] address review comments --- spec.html | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index 3091114362..95e49d0a96 100644 --- a/spec.html +++ b/spec.html @@ -6573,10 +6573,7 @@

1. Throw a *TypeError* exception. -

Species constructor is only available for Array, RegExp and Promise built-in classes. It - will not be provided to any other built-in classes. Species are an expensive and complex - operation that did not end up being used by the community, resulting in the feature being - deprecated.

+

Species constructor is only available for Array, RegExp, and Promise built-in classes.

@@ -41493,7 +41490,7 @@

- +

TypedArrayCreateSameType ( _exemplar_: a TypedArray, @@ -41502,7 +41499,7 @@

description
-
It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. This operation always uses one of the built-in TypedArray constructors.
+
It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. This operation always uses one of the built-in TypedArray constructors. Prior to the 2025 edition of the specification some TypedArray methods made use of SpeciesCreate, but that functionality has been removed.
1. Let _constructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in . @@ -43792,8 +43789,7 @@

ArrayBuffer.prototype.slice ( _start_, _end_ )

1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). 1. Else, let _final_ be min(_relativeEnd_, _len_). 1. Let _newLen_ be max(_final_ - _first_, 0). - 1. Let _ctor_ be %ArrayBuffer%. - 1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). + 1. Let _new_ be ? Construct(%ArrayBuffer%, « 𝔽(_newLen_) »). 1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). 1. If IsSharedArrayBuffer(_new_) is *true*, throw a *TypeError* exception. 1. If IsDetachedBuffer(_new_) is *true*, throw a *TypeError* exception. @@ -44110,8 +44106,7 @@

SharedArrayBuffer.prototype.slice ( _start_, _end_ )

1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). 1. Else, let _final_ be min(_relativeEnd_, _len_). 1. Let _newLen_ be max(_final_ - _first_, 0). - 1. Let _ctor_ be %SharedArrayBuffer%. - 1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). + 1. Let _new_ be ? Construct(%SharedArrayBuffer%, « 𝔽(_newLen_) »). 1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). 1. If IsSharedArrayBuffer(_new_) is *false*, throw a *TypeError* exception. 1. If _new_.[[ArrayBufferData]] is _O_.[[ArrayBufferData]], throw a *TypeError* exception. From 2276fddd05c9c897ca2d1bf1a25ff74beaa79eae Mon Sep 17 00:00:00 2001 From: Yulia Startsev Date: Wed, 23 Oct 2024 17:23:03 +0200 Subject: [PATCH 3/3] address formatting issues --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 95e49d0a96..c6ad7967e4 100644 --- a/spec.html +++ b/spec.html @@ -6573,7 +6573,7 @@

1. Throw a *TypeError* exception. -

Species constructor is only available for Array, RegExp, and Promise built-in classes.

+

Species constructor is only available for Array, RegExp and Promise built-in classes.