Skip to content

Commit c1ad763

Browse files
authored
Allow SharedArrayBuffer
Tests: web-platform-tests/wpt#19531. Fixes #172.
1 parent 370ad80 commit c1ad763

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

encoding.bs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ dictionary TextDecodeOptions {
11471147
interface TextDecoder {
11481148
constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {});
11491149

1150-
USVString decode(optional BufferSource input, optional TextDecodeOptions options = {});
1150+
USVString decode(optional [AllowShared] BufferSource input, optional TextDecodeOptions options = {});
11511151
};
11521152
TextDecoder includes TextDecoderCommon;
11531153
</pre>
@@ -1240,6 +1240,11 @@ method, when invoked, must run these steps:
12401240
avoids this copy. When doing so they will have to make sure that changes to <var>input</var> do
12411241
not affect future calls to <a method><code>decode()</code></a>.
12421242

1243+
<p class=warning id=sharedarraybuffer-warning>The memory exposed by <code>SharedArrayBuffer</code>
1244+
objects does not adhere to data race freedom properties required by the memory model of
1245+
programming languages typically used for implementations. When implementing, take care to use the
1246+
appropriate facilities when accessing memory exposed by <code>SharedArrayBuffer</code> objects.
1247+
12431248
<li><p>Let <var>output</var> be a new <a for=/>stream</a>.
12441249

12451250
<li>
@@ -1303,7 +1308,7 @@ interface TextEncoder {
13031308
constructor();
13041309

13051310
[NewObject] Uint8Array encode(optional USVString input = "");
1306-
TextEncoderEncodeIntoResult encodeInto(USVString source, Uint8Array destination);
1311+
TextEncoderEncodeIntoResult encodeInto(USVString source, [AllowShared] Uint8Array destination);
13071312
};
13081313
TextEncoder includes TextEncoderCommon;
13091314
</pre>
@@ -1409,8 +1414,13 @@ method, when invoked, must run these steps:
14091414

14101415
<li><p>Otherwise, increment <var>read</var> by 1.
14111416

1412-
<li><p>Write the bytes in <var>result</var> into <var>destinationBytes</var>, from byte
1413-
offset <var>written</var>.
1417+
<li>
1418+
<p>Write the bytes in <var>result</var> into <var>destinationBytes</var>, from byte offset
1419+
<var>written</var>.
1420+
1421+
<p class=warning>See the
1422+
<a href=#sharedarraybuffer-warning>warning for <code>SharedArrayBuffer</code> objects</a>
1423+
above.
14141424

14151425
<li><p>Increment <var>written</var> by the number of bytes in <var>result</var>.
14161426
</ol>
@@ -1518,9 +1528,10 @@ TextDecoderStream includes GenericTransformStream;
15181528

15191529
<dt><code><var>decoder</var> . <a attribute for=GenericTransformStream>writable</a></code>
15201530
<dd>
1521-
<p>Returns a <a>writable stream</a> which accepts {{BufferSource}} chunks and runs them through
1522-
<a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a> before making them available to
1523-
{{GenericTransformStream/readable}}.
1531+
<p>Returns a <a>writable stream</a> which accepts
1532+
<code>[<a extended-attribute>AllowShared</a>] <a typedef>BufferSource</a></code> chunks and runs
1533+
them through <a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a> before making them
1534+
available to {{GenericTransformStream/readable}}.
15241535

15251536
<p>Typically this will be used via the {{ReadableStream/pipeThrough()}} method on a
15261537
{{ReadableStream}} source.
@@ -1584,12 +1595,17 @@ byteReadable
15841595

15851596
<ol>
15861597
<li><p>Let <var>bufferSource</var> be the result of
1587-
<a lt="converted to an IDL value">converting</a> <var>chunk</var> to a {{BufferSource}}. If this
1588-
throws an exception, then return a promise rejected with that exception.
1598+
<a lt="converted to an IDL value">converting</a> <var>chunk</var> to an
1599+
<code>[<a extended-attribute>AllowShared</a>] <a typedef>BufferSource</a></code>. If this throws an
1600+
exception, then return a promise rejected with that exception.
1601+
1602+
<li>
1603+
<p><a>Push</a> a <a lt="get a copy of the buffer source">copy of</a> <var>bufferSource</var> to
1604+
<var>dec</var>'s <a for=TextDecoderStream>stream</a>. If this throws an exception, then return a
1605+
promise rejected with that exception.
15891606

1590-
<li><p><a>Push</a> a <a lt="get a copy of the buffer source">copy of</a> <var>bufferSource</var> to
1591-
<var>dec</var>'s <a for=TextDecoderStream>stream</a>. If this throws an exception, then return a
1592-
promise rejected with that exception.
1607+
<p class=warning>See the
1608+
<a href=#sharedarraybuffer-warning>warning for <code>SharedArrayBuffer</code> objects</a> above.
15931609

15941610
<li><p>Let <var>controller</var> be <var>dec</var>'s
15951611
<a for=GenericTransformStream>transform</a>.\[[transformStreamController]].
@@ -3266,6 +3282,7 @@ Aneesh Agrawal,
32663282
Arkadiusz Michalski,
32673283
Asmus Freytag,
32683284
Ben Noordhuis,
3285+
Bnaya Peretz,
32693286
Boris Zbarsky,
32703287
Bruno Haible,
32713288
Cameron McCormack,

0 commit comments

Comments
 (0)