From 273bedf95fbe526b0e3c2990aa7ace86f080d022 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 30 May 2023 14:56:22 +0200 Subject: [PATCH 1/5] Give SharedArrayBuffer a dedicated type Generally IDL objects have been 1:1 with ECMAScript objects, except for SharedArrayBuffer. That was instead represented as [AllowShared] ArrayBuffer, although that includes ArrayBuffer as well. This created a number of challenges, e.g., how to return a SharedArrayBuffer object. So we make these changes here that will also require corresponding downstream fixes: * SharedArrayBuffer is now its own type. * [AllowShared] only applies to buffer view types. * AllowSharedBufferSource takes over from [AllowShared] BufferSource. Fixes #865 and fixes #961. --- index.bs | 223 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 151 insertions(+), 72 deletions(-) diff --git a/index.bs b/index.bs index 88df0b13..8e55aed9 100644 --- a/index.bs +++ b/index.bs @@ -5465,6 +5465,8 @@ The string types are {{DOMString}}, all [=enumeration types=], {{ByteString}} and {{USVString}}. +The buffer types are {{ArrayBuffer}} and {{SharedArrayBuffer}}. + The typed array types are {{Int8Array}}, {{Int16Array}}, @@ -5478,10 +5480,9 @@ The typed array types are {{Float32Array}}, and {{Float64Array}}. -The buffer source types -are {{ArrayBuffer}}, -{{DataView}}, -and the [=typed array types=]. +The buffer view types are {{DataView}} and the [=typed array types=]. + +The buffer source types are the [=buffer types=] and the [=buffer view types=]. The {{object}} type, all [=interface types=], and @@ -6328,27 +6329,28 @@ For any type, the [=extended attributes associated with=] it must only contain There are a number of types that correspond to sets of all possible non-null references to objects that represent a buffer of data or a view on to a buffer of -data. The table below lists these types and the kind of buffer or view they represent. +data. The table below lists these types and the kind of buffer or view they represent. - + + - + - + - + - +
TypeKind of buffer
ArrayBufferAn object that holds a pointer (which can be null) to a buffer of a fixed number of bytes
DataViewA view on to an {{ArrayBuffer}} that allows typed access to integers and floating point values stored at arbitrary offsets into the buffer
SharedArrayBufferAn object that holds a pointer (which cannot be null) to a shared buffer of a fixed number of bytes
DataViewA view on to a [=buffer type=] that allows typed access to integers and floating point values stored at arbitrary offsets into the buffer
Int8Array,
Int16Array,
Int32Array,
BigInt64Array
A view on to an {{ArrayBuffer}} that exposes it as an array of two's complement signed integers of the given size in bits
A view on to a [=buffer type=] that exposes it as an array of two's complement signed integers of the given size in bits
Uint8Array,
Uint16Array,
Uint32Array,
BigUint64Array
A view on to an {{ArrayBuffer}} that exposes it as an array of unsigned integers of the given size in bits
A view on to a [=buffer type=] that exposes it as an array of unsigned integers of the given size in bits
Uint8ClampedArrayA view on to an {{ArrayBuffer}} that exposes it as an array of unsigned 8-bit integers with clamped conversions
A view on to a [=buffer type=] that exposes it as an array of unsigned 8-bit integers with clamped conversions
Float32Array,
Float64Array
A view on to an {{ArrayBuffer}} that exposes it as an array of IEEE 754 floating point numbers of the given size in bits
A view on to a [=buffer type=] that exposes it as an array of IEEE 754 floating point numbers of the given size in bits
Note: These types all correspond to classes defined in ECMAScript. @@ -6362,6 +6364,7 @@ in [[#es-buffer-source-types]].
     BufferRelatedType :
         "ArrayBuffer"
+        "SharedArrayBuffer"
         "DataView"
         "Int8Array"
         "Int16Array"
@@ -8388,12 +8391,20 @@ that correspond to the union's [=member types=].
             [=implements=], then return the IDL value that is a reference to the object |V|.
         1.  If |types| includes {{object}}, then return the IDL value
             that is a reference to the object |V|.
-    1.  If Type(|V|) is Object and |V| has an \[[ArrayBufferData]] [=/internal slot=], then:
+    1.  If Type(|V|) is Object, |V| has an \[[ArrayBufferData]]
+        [=/internal slot=], and IsSharedArrayBuffer(|V|) is false, then:
         1.  If |types| includes {{ArrayBuffer}}, then return the
             result of [=converted to an IDL value|converting=]
             |V| to {{ArrayBuffer}}.
         1.  If |types| includes {{object}}, then return the IDL value
             that is a reference to the object |V|.
+    1.  If Type(|V|) is Object, |V|, has an \[[ArrayBufferData]]
+        [=/internal slot=], and IsSharedArrayBuffer(|V|) is true, then:
+        1.  If |types| includes {{SharedArrayBuffer}}, then return the
+            result of [=converted to an IDL value|converting=]
+            |V| to {{SharedArrayBuffer}}.
+        1.  If |types| includes {{object}}, then return the IDL value
+            that is a reference to the object |V|.
     1.  If Type(|V|) is Object and |V| has a \[[DataView]] [=/internal slot=], then:
         1.  If |types| includes {{DataView}}, then return the
             result of [=converted to an IDL value|converting=]
@@ -8480,33 +8491,41 @@ that correspond to the union's [=member types=].
 
 

Buffer source types

-Values of the IDL [=buffer source types=] -are represented by objects of the corresponding ECMAScript class, with the following additional restrictions on those objects. +A value of an IDL {{ArrayBuffer}} is represented by an object of the corresponding ECMAScript class. +If it is not [=extended attributes associated with|associated with=] the [{{AllowResizable}}] +[=extended attribute=], it can only be backed by ECMAScript {{ArrayBuffer}} objects |V| for which +IsResizableArrayBuffer(|V|) is false. + +A value of an IDL {{SharedArrayBuffer}} is represented by an object of the corresponding ECMAScript +class. If it is not [=extended attributes associated with|associated with=] the [{{AllowResizable}}] +[=extended attribute=], it can only be backed by ECMAScript {{ArrayBuffer}} objects |V| for which +IsResizableArrayBuffer(|V|) is false. + +Values of the IDL [=buffer view types=] are represented by objects of the corresponding ECMAScript +class, with the following additional restrictions on those objects. @@ -8518,9 +8537,7 @@ are represented by objects of the corresponding ECMAScript class, with the follo 1. If Type(|V|) is not Object, or |V| does not have an \[[ArrayBufferData]] [=/internal slot=], then [=ECMAScript/throw=] a {{TypeError}}. - 1. If the conversion is not to an IDL type - [=extended attributes associated with|associated with=] the [{{AllowShared}}] - [=extended attribute=], and IsSharedArrayBuffer(|V|) is true, then [=ECMAScript/throw=] + 1. If IsSharedArrayBuffer(|V|) is true, then [=ECMAScript/throw=] a {{TypeError}}. 1. If the conversion is not to an IDL type [=extended attributes associated with|associated with=] the [{{AllowResizable}}] @@ -8530,7 +8547,25 @@ are represented by objects of the corresponding ECMAScript class, with the follo to the same object as |V|. -
+
+ + An ECMAScript value |V| is [=converted to an IDL value|converted=] + to an IDL {{SharedArrayBuffer}} value by running the following algorithm: + + 1. If Type(|V|) is not Object, + or |V| does not have an \[[ArrayBufferData]] [=/internal slot=], + then [=ECMAScript/throw=] a {{TypeError}}. + 1. If IsSharedArrayBuffer(|V|) is false, then [=ECMAScript/throw=] + a {{TypeError}}. + 1. If the conversion is not to an IDL type + [=extended attributes associated with|associated with=] the [{{AllowResizable}}] + [=extended attribute=], and IsResizableArrayBuffer(|V|) is true, + then [=ECMAScript/throw=] a {{TypeError}}. + 1. Return the IDL {{SharedArrayBuffer}} value that is a reference + to the same object as |V|. +
+ +
An ECMAScript value |V| is [=converted to an IDL value|converted=] to an IDL {{DataView}} value by running the following algorithm: @@ -8583,10 +8618,12 @@ are represented by objects of the corresponding ECMAScript class, with the follo 1. Return the IDL value of type |T| that is a reference to the same object as |V|.
+
The result of [=converted to an ECMAScript value|converting=] an IDL value of any [=buffer source type=] to an ECMAScript value is the Object value that represents a reference to the same object that the IDL value represents. +

@@ -8604,9 +8641,22 @@ a reference to the same object that the IDL value represents.
- To create one of the {{ArrayBufferView}} types from a + To create a {{SharedArrayBuffer}} from a [=byte sequence=] |bytes| in a [=realm=] |realm|: + 1. Let |esSharedArrayBuffer| be [=?=] + [$AllocateSharedArrayBuffer$](|realm|.\[[Intrinsics]].[[{{%SharedArrayBuffer%}}]], |bytes|'s + [=byte sequence/length=]). + 1. Let |sharedArrayBuffer| be the result of [=converted to an IDL value|converting=] + |esSharedArrayBuffer| to an IDL value of type {{SharedArrayBuffer}}. + 1. [=buffer type/Write=] |bytes| into |sharedArrayBuffer|. + 1. Return |sharedArrayBuffer|. +
+ +
+ To create one of the + [=buffer view types=] from a [=byte sequence=] |bytes| in a [=realm=] |realm|: + 1. Assert: if the type is not {{DataView}}, then |bytes|'s [=byte sequence/length=] [=modulo=] the [=element size=] of that type is 0. 1. Let |arrayBuffer| be the result of [=ArrayBuffer/creating=] an {{ArrayBuffer}} from |bytes| @@ -8614,14 +8664,14 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. 1. Let |constructor| be the appropriate constructor from |realm|.\[[Intrinsics]] for the type - of {{ArrayBufferView}} being created. + of [=buffer view type=] being created. 1. Let |esView| be [=!=] [$Construct$](|constructor|, « |esArrayBuffer| »). 1. Return the result of [=converted to an IDL value|converting=] |esView| into the given type.
To get a copy of the bytes held by the buffer source - given a {{BufferSource}} |bufferSource|: + given a [=buffer source type=] |bufferSource|: 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8646,8 +8696,8 @@ a reference to the same object that the IDL value represents.
- The byte length of a {{BufferSource}} |bufferSource| is - the value returned by the following steps: + The byte length of a + [=buffer source type=] |bufferSource| is the value returned by the following steps: 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8655,21 +8705,24 @@ a reference to the same object that the IDL value represents. |esBufferSource|.\[[ByteLength]]. 1. Return |esBufferSource|.\[[ArrayBufferByteLength]].
+
- The underlying buffer of a {{BufferSource}} |bufferSource| - is the value returned by the following steps: + The + underlying buffer + of a [=buffer source type=] |bufferSource| is the value returned by the following steps: - 1. If |bufferSource| is an {{ArrayBuffer}}, return |bufferSource|. + 1. If |bufferSource| is a [=buffer type=], then return |bufferSource|. 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. 1. Return the result of [=converted to an IDL value|converting=] - |esBufferSource|.\[[ViewedArrayBuffer]] to an IDL value of type {{ArrayBuffer}}. + |esBufferSource|.\[[ViewedArrayBuffer]] to an IDL value of type [=buffer type=].
-
- To write a [=byte sequence=] |bytes| into an {{ArrayBuffer}} - |arrayBuffer|, optionally given a |startingOffset| +
+ To write a [=byte sequence=] |bytes| + into a [=buffer type=] |arrayBuffer|, optionally given a + |startingOffset| (default 0): 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] @@ -8681,10 +8734,11 @@ a reference to the same object that the IDL value represents. |i|, Uint8, |bytes|[|i| - |startingOffset|], true, Unordered).
-
- To write a [=byte sequence=] |bytes| into an - {{ArrayBufferView}} |view|, optionally given a - |startingOffset| (default 0): +
+ To write a [=byte sequence=] + |bytes| into an [=buffer view type=] |view|, optionally given a + |startingOffset| + (default 0): 1. Let |esView| be the result of [=converted to an ECMAScript value|converting=] |view| to an ECMAScript value. @@ -8701,9 +8755,9 @@ a reference to the same object that the IDL value represents.
Extreme care must be taken when writing specification text that - [=ArrayBuffer/writes=] into an {{ArrayBuffer}} or {{ArrayBufferView}}, as the underlying data + [=buffer type/writes=] into an [=buffer source type=], as the underlying data can easily be changed by the script author or other APIs at unpredictable times. This is - especially true if the [{{AllowShared}}] [=extended attribute=] is involved. + especially true if a {{SharedArrayBuffer}} object is involved. For the non-shared cases, a more recommended pattern is to [=ArrayBuffer/transfer=] the {{ArrayBuffer}} first if possible, to ensure the writes cannot overlap with other modifications, @@ -8718,6 +8772,8 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. 1. Assert: [$IsSharedArrayBuffer$](|esArrayBuffer|) is false. + 1. Perform [=?=] [$DetachArrayBuffer$](|esArrayBuffer|).

This will throw an exception if |esArrayBuffer| has an \[[ArrayBufferDetachKey]] @@ -8728,8 +8784,9 @@ a reference to the same object that the IDL value represents.

- A {{BufferSource}} |bufferSource| is detached if the - following steps return true: + A [=buffer source types=] |bufferSource| is + detached if the following + steps return true: 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8745,6 +8802,8 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. 1. Assert: [$IsSharedArrayBuffer$](|esArrayBuffer|) is false. + 1. Assert: [$IsDetachedBuffer$](|esArrayBuffer|) is false. 1. Let |arrayBufferData| be |esArrayBuffer|.\[[ArrayBufferData]]. 1. Let |arrayBufferByteLength| be |esArrayBuffer|.\[[ArrayBufferByteLength]]. @@ -8842,13 +8901,18 @@ whose presence affects the ECMAScript binding.

[AllowResizable]

-If the [{{AllowResizable}}] [=extended attribute=] appears on one of the [=buffer source types=] without the presence of the [{{AllowShared}}] [=extended attribute=], it -creates a new IDL type that allows the buffer source type to be backed by an ECMAScript -{{ArrayBuffer}} that is resizable, instead of only by a fixed-length {{ArrayBuffer}}. +If the [{{AllowResizable}}] [=extended attribute=] appears on a [=buffer type=], it creates a new +IDL type that allows for the respective corresponding ECMAScript {{ArrayBuffer}} or +{{SharedArrayBuffer}} object to be resizable. + +If the [{{AllowResizable}}] [=extended attribute=] appears on one of the [=buffer view types=] +and the [{{AllowShared}}] [=extended attribute=] does not, it creates a new IDL type +that allows the buffer source type to be backed by an ECMAScript {{ArrayBuffer}} that is resizable, +instead of only by a fixed-length {{ArrayBuffer}}. -If the [{{AllowResizable}}] [=extended attribute=] and the [{{AllowShared}}] [=extended attribute=] both appear on one of the [=buffer source types=], it -creates a new IDL type that allows the buffer source type to be additionally backed by an ECMAScript -{{SharedArrayBuffer}} that is growable. +If the [{{AllowResizable}}] [=extended attribute=] and the [{{AllowShared}}] [=extended attribute=] +both appear on one of the [=buffer view types=], it creates a new IDL type that allows the buffer +view type to be additionally backed by an ECMAScript {{SharedArrayBuffer}} that is growable. The [{{AllowResizable}}] extended attribute must [=takes no arguments|take no arguments=]. @@ -8863,16 +8927,16 @@ See the example in [[#AllowSha

[AllowShared]

-If the [{{AllowShared}}] [=extended attribute=] appears on one of the [=buffer source types=], it -creates a new IDL type that allows the buffer source type to be backed by an ECMAScript -{{SharedArrayBuffer}}, instead of only by a non-shared {{ArrayBuffer}}. +If the [{{AllowShared}}] [=extended attribute=] appears on one of the [=buffer view types=], it +creates a new IDL type that allows the object to be backed by an {{SharedArrayBuffer}} instead of +only by an {{ArrayBuffer}}. The [{{AllowShared}}] extended attribute must [=takes no arguments|take no arguments=]. -A type that is not a [=buffer source type=] must not be +A type that is not a [=buffer view type=] must not be [=extended attributes associated with|associated with=] the [{{AllowShared}}] extended attribute. -See the rules for converting ECMAScript values to IDL [=buffer source types=] in +See the rules for converting ECMAScript values to IDL [=buffer view types=] in [[#es-buffer-source-types]] for the specific requirements that the use of [{{AllowShared}}] entails.
@@ -8882,34 +8946,34 @@ See the rules for converting ECMAScript values to IDL [=buffer source types=] in
         [Exposed=Window]
         interface ExampleBufferFeature {
-          undefined writeInto(BufferSource dest);
-          undefined writeIntoResizable([AllowResizable] BufferSource dest);
-          undefined writeIntoShared([AllowShared] BufferSource dest);
-          undefined writeIntoSharedResizable([AllowResizable, AllowShared] BufferSource dest);
+          undefined writeInto(ArrayBufferView dest);
+          undefined writeIntoResizable([AllowResizable] ArrayBufferView dest);
+          undefined writeIntoShared([AllowShared] ArrayBufferView dest);
+          undefined writeIntoSharedResizable([AllowResizable, AllowShared] ArrayBufferView dest);
         };
     
With this definition,
  • - A call to writeInto with a resizable {{ArrayBuffer}} instance, a - {{SharedArrayBuffer}} instance, or any typed array or {{DataView}} - backed by either, will throw a {{TypeError}} exception. + A call to writeInto with any [=buffer view type=] backed by + either a resizable {{ArrayBuffer}} instance or a {{SharedArrayBuffer}} instance, + will throw a {{TypeError}} exception.
  • - A call to writeIntoResizable with a {{SharedArrayBuffer}} - instance, or any typed array or {{DataView}} backed by one, will throw a + A call to writeIntoResizable with any [=buffer view type=] backed by + a {{SharedArrayBuffer}} instance, will throw a {{TypeError}} exception.
  • - A call to writeIntoShared with a resizable {{ArrayBuffer}} - instance, a growable {{SharedArrayBuffer}} instance, or any typed array or - {{DataView}} backed by one, will throw a {{TypeError}} exception. + A call to writeIntoShared with any [=buffer view type=] backed by a + resizable {{ArrayBuffer}} instance or a growable {{SharedArrayBuffer}} instance, + will throw a {{TypeError}} exception.
  • - A call to writeIntoSharedResizable will accept an - {{ArrayBuffer}} instance, a {{SharedArrayBuffer}} instance, or any - typed array or {{DataView}} backed by either. + A call to writeIntoSharedResizable will accept any + [=buffer view type=] backed by a {{ArrayBuffer}} instance or a + {{SharedArrayBuffer}} instance.
@@ -10852,6 +10916,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]] 1. Otherwise: if Type(|V|) is Object, |V| has an \[[ArrayBufferData]] [=/internal slot=], and there is an entry in |S| that has one of the following types at position |i| of its type list, * {{ArrayBuffer}} + * {{SharedArrayBuffer}} * {{object}} * a [=nullable type|nullable=] version of either of the above types * an [=annotated type=] whose [=annotated types/inner type=] is one of the above types @@ -14356,7 +14421,8 @@ must support.
The {{ArrayBufferView}} typedef is used to represent -objects that provide a view on to an {{ArrayBuffer}}. +objects that provide a view on to an {{ArrayBuffer}} or +{{SharedArrayBuffer}} (when [{{AllowShared}}] is used).

BufferSource

@@ -14367,6 +14433,19 @@ The {{BufferSource}} typedef is used to represent objects that are either themselves an {{ArrayBuffer}} or which provide a view on to an {{ArrayBuffer}}. +Note: [{{AllowShared}}] cannot be used in conjunction as {{ArrayBuffer}} does not support it. +Use {{AllowSharedBufferSource}} instead. + + +

AllowSharedBufferSource

+ +
typedef (ArrayBuffer or SharedArrayBuffer or [AllowShared] ArrayBufferView) AllowSharedBufferSource;
+ +The {{AllowSharedBufferSource}} typedef is used to represent objects +that are either themselves an {{ArrayBuffer}} or {{SharedArrayBuffer}} or which +provide a view on to an {{ArrayBuffer}} or {{SharedArrayBuffer}}. + +

DOMException

The {{DOMException}} type is an [=interface type=] defined by the following IDL From cfafa34c2fb6dfdf8ee4e821ca8ad3593082abee Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 2 Jun 2023 10:32:12 +0200 Subject: [PATCH 2/5] Review - Turn the table into a proper table instead of using
. - Attempt to link ECMAScript for certain ArrayBuffer/SharedArrayBuffer references. - Use typedefs for the buffer source type algorithms again and don't change the for attribute (mostly). - Drop the IsSharedArrayBuffer asserts when we already (implicitly) assert it's an ArrayBuffer. --- index.bs | 154 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 68 deletions(-) diff --git a/index.bs b/index.bs index 8e55aed9..c80ba1e2 100644 --- a/index.bs +++ b/index.bs @@ -6332,25 +6332,44 @@ references to objects that represent a buffer of data or a view on to a buffer o data. The table below lists these types and the kind of buffer or view they represent. - - - - - - - - - - - - + + + + + + + + + + + + + + + +
TypeKind of buffer
ArrayBufferAn object that holds a pointer (which can be null) to a buffer of a fixed number of bytes
SharedArrayBufferAn object that holds a pointer (which cannot be null) to a shared buffer of a fixed number of bytes
DataViewA view on to a [=buffer type=] that allows typed access to integers and floating point values stored at arbitrary offsets into the buffer
Int8Array,
- Int16Array,
- Int32Array,
- BigInt64Array
A view on to a [=buffer type=] that exposes it as an array of two's complement signed integers of the given size in bits
Uint8Array,
- Uint16Array,
- Uint32Array,
- BigUint64Array
A view on to a [=buffer type=] that exposes it as an array of unsigned integers of the given size in bits
Uint8ClampedArrayA view on to a [=buffer type=] that exposes it as an array of unsigned 8-bit integers with clamped conversions
Float32Array,
- Float64Array
A view on to a [=buffer type=] that exposes it as an array of IEEE 754 floating point numbers of the given size in bits
Type + Kind of buffer +
ArrayBuffer + An object that holds a pointer (which can be null) to a buffer of a fixed number of bytes +
SharedArrayBuffer + An object that holds a pointer (which cannot be null) to a shared buffer of a fixed number of bytes +
DataView + A view on to a [=buffer type=] instance that allows typed access to integers and floating point values stored at arbitrary offsets into the buffer +
Int8Array + A view on to a [=buffer type=] instance that exposes it as an array of two's complement signed integers of the given size in bits +
Int16Array +
Int32Array +
BigInt64Array +
Uint8Array + A view on to a [=buffer type=] instance that exposes it as an array of unsigned integers of the given size in bits +
Uint16Array +
Uint32Array +
BigUint64Array +
Uint8ClampedArray + A view on to a [=buffer type=] instance that exposes it as an array of unsigned 8-bit integers with clamped conversions +
Float32Array + A view on to a [=buffer type=] that exposes it as an array of IEEE 754 floating point numbers of the given size in bits +
Float64Array
Note: These types all correspond to classes defined in ECMAScript. @@ -8493,12 +8512,13 @@ that correspond to the union's [=member types=]. A value of an IDL {{ArrayBuffer}} is represented by an object of the corresponding ECMAScript class. If it is not [=extended attributes associated with|associated with=] the [{{AllowResizable}}] -[=extended attribute=], it can only be backed by ECMAScript {{ArrayBuffer}} objects |V| for which -IsResizableArrayBuffer(|V|) is false. +[=extended attribute=], it can only be backed by ECMAScript {{ArrayBuffer}} +objects |V| for which IsResizableArrayBuffer(|V|) is false. A value of an IDL {{SharedArrayBuffer}} is represented by an object of the corresponding ECMAScript class. If it is not [=extended attributes associated with|associated with=] the [{{AllowResizable}}] -[=extended attribute=], it can only be backed by ECMAScript {{ArrayBuffer}} objects |V| for which +[=extended attribute=], it can only be backed by ECMAScript +{{SharedArrayBuffer}} objects |V| for which IsResizableArrayBuffer(|V|) is false. Values of the IDL [=buffer view types=] are represented by objects of the corresponding ECMAScript @@ -8508,24 +8528,27 @@ class, with the following additional restrictions on those objects.
  • If the type is not [=extended attributes associated with|associated with=] either the [{{AllowResizable}}] or [{{AllowShared}}] [=extended attribute=], if applicable, they can - only be backed by ECMAScript {{ArrayBuffer}} objects |V| for which {{ArrayBuffer}} objects |V| for which IsResizableArrayBuffer(|V|) is false.
  • If the type is [=extended attributes associated with|associated with=] the [{{AllowResizable}}] [=extended attribute=] but not with the [{{AllowShared}}] [=extended - attribute=], if applicable, they can only be backed by ECMAScript {{ArrayBuffer}} objects. + attribute=], if applicable, they can only be backed by ECMAScript + {{ArrayBuffer}} objects.
  • If the type is [=extended attributes associated with|associated with=] the [{{AllowShared}}] [=extended attribute=] but not with the [{{AllowResizable}}] [=extended attribute=], they - can only be backed by ECMAScript {{ArrayBuffer}} and {{SharedArrayBuffer}} objects |V| for - which IsResizableArrayBuffer(|V|) is false. + can only be backed by ECMAScript {{ArrayBuffer}} and + {{SharedArrayBuffer}} objects |V| for which + IsResizableArrayBuffer(|V|) is false.
  • If the type is [=extended attributes associated with|associated with=] both the [{{AllowResizable}}] and the [{{AllowShared}}] [=extended attribute|extended attributes=], - they can be backed by any ECMAScript {{ArrayBuffer}} or {{SharedArrayBuffer}} object. + they can be backed by any ECMAScript {{ArrayBuffer}} or + {{SharedArrayBuffer}} object.
  • @@ -8618,7 +8641,7 @@ class, with the following additional restrictions on those objects. 1. Return the IDL value of type |T| that is a reference to the same object as |V|. -
    +
    The result of [=converted to an ECMAScript value|converting=] an IDL value of any [=buffer source type=] to an ECMAScript value is the Object value that represents @@ -8654,8 +8677,8 @@ a reference to the same object that the IDL value represents.
    - To create one of the - [=buffer view types=] from a [=byte sequence=] |bytes| in a [=realm=] |realm|: + To create one of the {{ArrayBufferView}} types from a + [=byte sequence=] |bytes| in a [=realm=] |realm|: 1. Assert: if the type is not {{DataView}}, then |bytes|'s [=byte sequence/length=] [=modulo=] the [=element size=] of that type is 0. @@ -8664,7 +8687,7 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. 1. Let |constructor| be the appropriate constructor from |realm|.\[[Intrinsics]] for the type - of [=buffer view type=] being created. + of {{ArrayBufferView}} being created. 1. Let |esView| be [=!=] [$Construct$](|constructor|, « |esArrayBuffer| »). 1. Return the result of [=converted to an IDL value|converting=] |esView| into the given type.
    @@ -8696,8 +8719,8 @@ a reference to the same object that the IDL value represents.
    - The byte length of a - [=buffer source type=] |bufferSource| is the value returned by the following steps: + The byte length of a [=buffer source type=] instance + |bufferSource| is the value returned by the following steps: 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8708,21 +8731,23 @@ a reference to the same object that the IDL value represents.
    - The - underlying buffer - of a [=buffer source type=] |bufferSource| is the value returned by the following steps: + The underlying buffer of a [=buffer source type=] instance + |bufferSource| is the value returned by the following steps: - 1. If |bufferSource| is a [=buffer type=], then return |bufferSource|. - 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] + 1. If |bufferSource| is a [=buffer type=] instance, then return |bufferSource|. + 1. Let |esBufferView| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. - 1. Return the result of [=converted to an IDL value|converting=] - |esBufferSource|.\[[ViewedArrayBuffer]] to an IDL value of type [=buffer type=]. + 1. Let |esBuffer| be |esBufferView|.\[[ViewedArrayBuffer]]. + 1. If [$IsSharedArrayBuffer$](|esBuffer|) is false, then return the result of + [=converted to an IDL value|converting=] |esBuffer| to an IDL value of type {{ArrayBuffer}}. + 1. Return the result of [=converted to an IDL value|converting=] |esBuffer| to an IDL value of + type {{SharedArrayBuffer}}.
    - To write a [=byte sequence=] |bytes| - into a [=buffer type=] |arrayBuffer|, optionally given a - |startingOffset| + To write a + [=byte sequence=] |bytes| into a [=buffer type=] instance |arrayBuffer|, optionally given a + |startingOffset| (default 0): 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] @@ -8734,11 +8759,10 @@ a reference to the same object that the IDL value represents. |i|, Uint8, |bytes|[|i| - |startingOffset|], true, Unordered).
    -
    - To write a [=byte sequence=] - |bytes| into an [=buffer view type=] |view|, optionally given a - |startingOffset| - (default 0): +
    + To write a [=byte sequence=] |bytes| into an + {{ArrayBufferView}} |view|, optionally given a + |startingOffset| (default 0): 1. Let |esView| be the result of [=converted to an ECMAScript value|converting=] |view| to an ECMAScript value. @@ -8755,7 +8779,7 @@ a reference to the same object that the IDL value represents.
    Extreme care must be taken when writing specification text that - [=buffer type/writes=] into an [=buffer source type=], as the underlying data + [=ArrayBuffer/writes=] into a [=buffer source type=] instance, as the underlying data can easily be changed by the script author or other APIs at unpredictable times. This is especially true if a {{SharedArrayBuffer}} object is involved. @@ -8771,9 +8795,6 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. - 1. Assert: [$IsSharedArrayBuffer$](|esArrayBuffer|) is false. - 1. Perform [=?=] [$DetachArrayBuffer$](|esArrayBuffer|).

    This will throw an exception if |esArrayBuffer| has an \[[ArrayBufferDetachKey]] @@ -8784,9 +8805,8 @@ a reference to the same object that the IDL value represents.

    - A [=buffer source types=] |bufferSource| is - detached if the following - steps return true: + A [=buffer source type=] instance |bufferSource| is + detached if the following steps return true: 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8801,9 +8821,6 @@ a reference to the same object that the IDL value represents. 1. Let |esArrayBuffer| be the result of [=converted to an ECMAScript value|converting=] |arrayBuffer| to an ECMAScript value. - 1. Assert: [$IsSharedArrayBuffer$](|esArrayBuffer|) is false. - 1. Assert: [$IsDetachedBuffer$](|esArrayBuffer|) is false. 1. Let |arrayBufferData| be |esArrayBuffer|.\[[ArrayBufferData]]. 1. Let |arrayBufferByteLength| be |esArrayBuffer|.\[[ArrayBufferByteLength]]. @@ -8902,17 +8919,18 @@ whose presence affects the ECMAScript binding.

    [AllowResizable]

    If the [{{AllowResizable}}] [=extended attribute=] appears on a [=buffer type=], it creates a new -IDL type that allows for the respective corresponding ECMAScript {{ArrayBuffer}} or -{{SharedArrayBuffer}} object to be resizable. +IDL type that allows for the respective corresponding ECMAScript {{ArrayBuffer}} +or {{SharedArrayBuffer}} object to be resizable. -If the [{{AllowResizable}}] [=extended attribute=] appears on one of the [=buffer view types=] -and the [{{AllowShared}}] [=extended attribute=] does not, it creates a new IDL type -that allows the buffer source type to be backed by an ECMAScript {{ArrayBuffer}} that is resizable, -instead of only by a fixed-length {{ArrayBuffer}}. +If the [{{AllowResizable}}] [=extended attribute=] appears on one of the [=buffer view types=] and +the [{{AllowShared}}] [=extended attribute=] does not, it creates a new IDL type that allows the +buffer view type to be backed by an ECMAScript {{ArrayBuffer}} that is +resizable, instead of only by a fixed-length {{ArrayBuffer}}. If the [{{AllowResizable}}] [=extended attribute=] and the [{{AllowShared}}] [=extended attribute=] both appear on one of the [=buffer view types=], it creates a new IDL type that allows the buffer -view type to be additionally backed by an ECMAScript {{SharedArrayBuffer}} that is growable. +view type to be additionally backed by an ECMAScript {{SharedArrayBuffer}} +that is growable. The [{{AllowResizable}}] extended attribute must [=takes no arguments|take no arguments=]. @@ -8940,8 +8958,8 @@ See the rules for converting ECMAScript values to IDL [=buffer view types=] in [[#es-buffer-source-types]] for the specific requirements that the use of [{{AllowShared}}] entails.
    - In the following [=IDL fragment=], one operation's argument uses the [{{AllowResizable}}] extended - attribute, while the other does not: + The following [=IDL fragment=] demonstrates the possible combinations of the + [{{AllowResizable}}] and [{{AllowShared}}] [=extended attribute=]:
             [Exposed=Window]
    @@ -14433,7 +14451,7 @@ The {{BufferSource}} typedef is used to represent objects
     that are either themselves an {{ArrayBuffer}} or which
     provide a view on to an {{ArrayBuffer}}.
     
    -Note: [{{AllowShared}}] cannot be used in conjunction as {{ArrayBuffer}} does not support it.
    +Note: [{{AllowShared}}] cannot be used with {{BufferSource}} as {{ArrayBuffer}} does not support it.
     Use {{AllowSharedBufferSource}} instead.
     
     
    
    From 7087936877db03811ca8adff9780d8f7433456c5 Mon Sep 17 00:00:00 2001
    From: Anne van Kesteren 
    Date: Fri, 2 Jun 2023 10:48:47 +0200
    Subject: [PATCH 3/5] CI
    
    ---
     index.bs | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/index.bs b/index.bs
    index c80ba1e2..3633a16a 100644
    --- a/index.bs
    +++ b/index.bs
    @@ -8672,7 +8672,7 @@ a reference to the same object that the IDL value represents.
             [=byte sequence/length=]).
         1.  Let |sharedArrayBuffer| be the result of [=converted to an IDL value|converting=]
             |esSharedArrayBuffer| to an IDL value of type {{SharedArrayBuffer}}.
    -    1.  [=buffer type/Write=] |bytes| into |sharedArrayBuffer|.
    +    1.  [=SharedArrayBuffer/Write=] |bytes| into |sharedArrayBuffer|.
         1.  Return |sharedArrayBuffer|.
     
    From 22af0e504259ff1f158736a10bf6927329ce5b7c Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 14 Jun 2023 19:14:41 +0200 Subject: [PATCH 4/5] review --- index.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 3633a16a..fb2d624d 100644 --- a/index.bs +++ b/index.bs @@ -6367,7 +6367,7 @@ data. The table below lists these types and the kind of buffer or view they repr A view on to a [=buffer type=] instance that exposes it as an array of unsigned 8-bit integers with clamped conversions Float32Array - A view on to a [=buffer type=] that exposes it as an array of IEEE 754 floating point numbers of the given size in bits + A view on to a [=buffer type=] instance that exposes it as an array of IEEE 754 floating point numbers of the given size in bits Float64Array @@ -8694,7 +8694,7 @@ a reference to the same object that the IDL value represents.
    To get a copy of the bytes held by the buffer source - given a [=buffer source type=] |bufferSource|: + given a [=buffer source type=] instance |bufferSource|: 1. Let |esBufferSource| be the result of [=converted to an ECMAScript value|converting=] |bufferSource| to an ECMAScript value. @@ -8744,7 +8744,7 @@ a reference to the same object that the IDL value represents. type {{SharedArrayBuffer}}.
    -
    +
    To write a [=byte sequence=] |bytes| into a [=buffer type=] instance |arrayBuffer|, optionally given a |startingOffset| From 9ad215caff3df9ca0766a37f78a717e3f772d247 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 14 Jun 2023 19:16:15 +0200 Subject: [PATCH 5/5] CI --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index fb2d624d..cddde552 100644 --- a/index.bs +++ b/index.bs @@ -8744,7 +8744,7 @@ a reference to the same object that the IDL value represents. type {{SharedArrayBuffer}}.
    -
    +
    To write a [=byte sequence=] |bytes| into a [=buffer type=] instance |arrayBuffer|, optionally given a |startingOffset|