Skip to content

Allow SharedArrayBuffer #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions encoding.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ dictionary TextDecodeOptions {
interface TextDecoder {
constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options = {});

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

<p class=warning id=sharedarraybuffer-warning>The memory exposed by <code>SharedArrayBuffer</code>
objects does not adhere to data race freedom properties required by the memory model of
programming languages typically used for implementations. When implementing, take care to use the
appropriate facilities when accessing memory exposed by <code>SharedArrayBuffer</code> objects.

<li><p>Let <var>output</var> be a new <a for=/>stream</a>.

<li>
Expand Down Expand Up @@ -1303,7 +1308,7 @@ interface TextEncoder {
constructor();

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

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

<li><p>Write the bytes in <var>result</var> into <var>destinationBytes</var>, from byte
offset <var>written</var>.
<li>
<p>Write the bytes in <var>result</var> into <var>destinationBytes</var>, from byte offset
<var>written</var>.

<p class=warning>See the
<a href=#sharedarraybuffer-warning>warning for <code>SharedArrayBuffer</code> objects</a>
above.

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

<dt><code><var>decoder</var> . <a attribute for=GenericTransformStream>writable</a></code>
<dd>
<p>Returns a <a>writable stream</a> which accepts {{BufferSource}} chunks and runs them through
<a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a> before making them available to
{{GenericTransformStream/readable}}.
<p>Returns a <a>writable stream</a> which accepts
<code>[<a extended-attribute>AllowShared</a>] <a typedef>BufferSource</a></code> chunks and runs
them through <a for=TextDecoderCommon>encoding</a>'s <a for=/>decoder</a> before making them
available to {{GenericTransformStream/readable}}.

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

<ol>
<li><p>Let <var>bufferSource</var> be the result of
<a lt="converted to an IDL value">converting</a> <var>chunk</var> to a {{BufferSource}}. If this
throws an exception, then return a promise rejected with that exception.
<a lt="converted to an IDL value">converting</a> <var>chunk</var> to an
<code>[<a extended-attribute>AllowShared</a>] <a typedef>BufferSource</a></code>. If this throws an
exception, then return a promise rejected with that exception.

<li>
<p><a>Push</a> a <a lt="get a copy of the buffer source">copy of</a> <var>bufferSource</var> to
<var>dec</var>'s <a for=TextDecoderStream>stream</a>. If this throws an exception, then return a
promise rejected with that exception.

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

<li><p>Let <var>controller</var> be <var>dec</var>'s
<a for=GenericTransformStream>transform</a>.\[[transformStreamController]].
Expand Down Expand Up @@ -3266,6 +3282,7 @@ Aneesh Agrawal,
Arkadiusz Michalski,
Asmus Freytag,
Ben Noordhuis,
Bnaya Peretz,
Boris Zbarsky,
Bruno Haible,
Cameron McCormack,
Expand Down