Skip to content

Commit f33a06a

Browse files
committed
Stop assuming "transfer" is same-agent cluster
The previous text assumed that the AllocateArrayBuffer step would never throw, since it was basically spec fiction for retargeting a pointer. However, if we transfer across agent clusters, memory allocation will be needed. And even then, we shouldn't be normatively asserting that implementations use the pointer-retargeting strategy. Instead, we can explain it in a note.
1 parent 192be41 commit f33a06a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

index.bs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9036,9 +9036,10 @@ a reference to the same object that the IDL value represents.
90369036
|arrayBuffer| to a JavaScript value.
90379037
1. Perform [=?=] [$DetachArrayBuffer$](|jsArrayBuffer|).
90389038

9039-
<p class="note">This will throw an exception if |jsArrayBuffer| has an \[[ArrayBufferDetachKey]]
9040-
that is not undefined, such as is the case with the value of {{Memory|WebAssembly.Memory}}'s
9041-
{{Memory/buffer}} attribute. [[WASM-JS-API-1]]
9039+
<p class="note" id="note-ArrayBuffer-detach-exceptions">This will throw an exception if
9040+
|jsArrayBuffer| has an \[[ArrayBufferDetachKey]] that is not undefined, such as is the case
9041+
with the value of {{Memory|WebAssembly.Memory}}'s {{Memory/buffer}} attribute.
9042+
[[WASM-JS-API-1]]
90429043

90439044
<p class="note">Detaching a buffer that is already [=BufferSource/detached=] is a no-op.
90449045
</div>
@@ -9081,16 +9082,26 @@ a reference to the same object that the IDL value represents.
90819082
1. Let |arrayBufferByteLength| be |jsArrayBuffer|.\[[ArrayBufferByteLength]].
90829083
1. Perform [=?=] [$DetachArrayBuffer$](|jsArrayBuffer|).
90839084
1. If |targetRealm| is not given, let |targetRealm| be the [=current realm=].
9084-
1. Let |jsTransferred| be [=!=]
9085+
1. Let |jsTransferred| be [=?=]
90859086
[$AllocateArrayBuffer$](|targetRealm|.\[[Intrinsics]].[[{{%ArrayBuffer%}}]], 0).
90869087
1. Set |jsTransferred|.\[[ArrayBufferData]] to |arrayBufferData|.
90879088
1. Set |jsTransferred|.\[[ArrayBufferByteLength]] to |arrayBufferByteLength|.
90889089
1. Return the result of [=converted to an IDL value|converting=] |jsTransferred| to an IDL
90899090
value of type {{ArrayBuffer}}.
90909091

9091-
<p class="note">This will throw an exception under the same circumstances as
9092-
[=ArrayBuffer/detaching=], and also for {{ArrayBuffer}}s that are already
9093-
[=BufferSource/detached=].
9092+
<div class="note" id="note-ArrayBuffer-transfer-exceptions">
9093+
This will throw an exception under any of the following circumstances:
9094+
9095+
* |arrayBuffer| cannot be [=BufferSource/detached=], for the reasons
9096+
<a href="#note-ArrayBuffer-detach-exceptions">explained in that algorithm's
9097+
definition</a>;
9098+
* |arrayBuffer| is already [=BufferSource/detached=];
9099+
* Sufficient memory cannot be allocated in |realm|. Generally this will only be the case
9100+
if |realm| is in a different [=agent cluster=] than the one in which |arrayBuffer| was
9101+
allocated. If they are in the same [=agent cluster=], then implementations will just
9102+
change the backing pointers to get the same observable results with better performance
9103+
and no allocations.
9104+
</div>
90949105
</div>
90959106

90969107
<h4 id="js-frozen-array" oldids="es-frozen-array">Frozen arrays — FrozenArray&lt;|T|&gt;</h4>

0 commit comments

Comments
 (0)