-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add immutable array buffer awareness to structuredClone #11033
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
base: main
Are you sure you want to change the base?
Changes from all commits
06282ff
2f4d3cb
a48c69a
1c0cf64
88b5fdf
56c3332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3047,6 +3047,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isconstructor">IsConstructor</dfn> abstract operation</li> | ||
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdatadescriptor">IsDataDescriptor</dfn> abstract operation</li> | ||
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</dfn> abstract operation</li> | ||
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-isimmutablebuffer">IsImmutableBuffer</dfn> abstract operation</li> | ||
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</dfn> abstract operation</li> | ||
<li>The <dfn data-x="js-NewObjectEnvironment" data-x-href="https://tc39.es/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</dfn> abstract operation</li> | ||
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-normalcompletion">NormalCompletion</dfn> abstract operation</li> | ||
|
@@ -9744,6 +9745,23 @@ interface <dfn interface>DOMStringList</dfn> { | |
</ol> | ||
</li> | ||
|
||
<li> | ||
<p>Otherwise, if <span>IsImmutableBuffer</span>(<var>value</var>) is true, then:</p> | ||
|
||
<ol> | ||
<li> | ||
<p>Set <var>serialized</var> to { [[Type]]: "ImmutableArrayBuffer", [[ArrayBufferData]]: | ||
<var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: | ||
<var>value</var>.[[ArrayBufferByteLength]] }.</p> | ||
|
||
<p class="note">To support deserialization by independent processes at arbitrary points in | ||
the future, the <em>contents</em> of <var>value</var>.[[ArrayBufferData]] need to be | ||
preserved when <var>forStorage</var> is true. But otherwise, a pointer <em>referencing</em> | ||
<var>value</var>.[[ArrayBufferData]] is expected to suffice.</p> | ||
</li> | ||
</ol> | ||
</li> | ||
|
||
<li> | ||
<p>Otherwise:</p> | ||
|
||
|
@@ -9791,7 +9809,8 @@ interface <dfn interface>DOMStringList</dfn> { | |
<var>memory</var>).</p></li> | ||
|
||
<li><p><span>Assert</span>: <var>bufferSerialized</var>.[[Type]] is "ArrayBuffer", | ||
"ResizableArrayBuffer", "SharedArrayBuffer", or "GrowableSharedArrayBuffer".</p></li> | ||
"ImmutableArrayBuffer", "ResizableArrayBuffer", "SharedArrayBuffer", or | ||
"GrowableSharedArrayBuffer".</p></li> | ||
|
||
<li><p>If <var>value</var> has a [[DataView]] internal slot, then set <var>serialized</var> to | ||
{ [[Type]]: "ArrayBufferView", [[Constructor]]: "DataView", [[ArrayBufferSerialized]]: | ||
|
@@ -10186,6 +10205,20 @@ o.myself = o;</code></pre> | |
</ol> | ||
</li> | ||
|
||
<li> | ||
<p>Otherwise, if <var>serialized</var>.[[Type]] is "ImmutableArrayBuffer", then:</p> | ||
|
||
<ol> | ||
<li><p>Set <var>value</var> to a new ArrayBuffer object in <var>targetRealm</var> whose | ||
[[ArrayBufferData]] internal slot value is <var>serialized</var>.[[ArrayBufferData]], whose | ||
[[ArrayBufferByteLength]] internal slot value is | ||
<var>serialized</var>.[[ArrayBufferByteLength]], and whose [[ArrayBufferIsImmutable]] internal | ||
slot value is undefined.</p></li> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible for a slot to not have a value in this way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically yes, but it's obviously not great and I see now that things are moving away from it. I've updated accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But for the record, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And in ECMAScript, Object Internal Methods and Internal Slots defines the initial value of an internal slot to be undefined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True although see also tc39/ecma262#3399 |
||
<li><p><span>Assert</span>: <span>IsImmutableBuffer</span>(<var>value</var>) is true.</p></li> | ||
</ol> | ||
</li> | ||
|
||
<li> | ||
<p>Otherwise, if <var>serialized</var>.[[Type]] is "ArrayBuffer", then set <var>value</var> to a | ||
new ArrayBuffer object in <var>targetRealm</var> whose [[ArrayBufferData]] internal slot value | ||
|
@@ -10462,8 +10495,9 @@ o.myself = o;</code></pre> | |
<span>[[Detached]]</span> internal slot, then throw a | ||
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li> | ||
|
||
<li><p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot and | ||
<span>IsSharedArrayBuffer</span>(<var>transferable</var>) is true, then throw a | ||
<li><p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot and either | ||
<span>IsSharedArrayBuffer</span>(<var>transferable</var>) is true or | ||
<span>IsImmutableBuffer</span>(<var>transferable</var>) is true, then throw a | ||
<span>"<code>DataCloneError</code>"</span> <code>DOMException</code>.</p></li> | ||
gibson042 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<li><p>If <var>memory</var>[<var>transferable</var>] <span data-x="map exists">exists</span>, | ||
|
Uh oh!
There was an error while loading. Please reload this page.