Skip to content

Commit d6927d5

Browse files
Introduce a "transferable" algorithm for BufferSource
This is particularly helpful if several buffers are processed in a batch, as the validity of the operation can be determined up front, rather than during processing which could leave the buffers in a mix of states. See discussion in webmachinelearning/webnn#351.
1 parent 3fb6ab4 commit d6927d5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.bs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9054,6 +9054,21 @@ a reference to the same object that the IDL value represents.
90549054
1. Return [$IsDetachedBuffer$](|jsArrayBuffer|).
90559055
</div>
90569056

9057+
<div algorithm>
9058+
A [=buffer source type=] instance |bufferSource| is
9059+
<dfn for="BufferSource" export>transferable</dfn> if the following steps return true:
9060+
9061+
1. Let |jsArrayBuffer| be the result of [=converted to a JavaScript value|converting=]
9062+
|bufferSource| to a JavaScript value.
9063+
1. If |jsArrayBuffer| has a \[[ViewedArrayBuffer]] internal slot, then set |jsArrayBuffer| to
9064+
|jsArrayBuffer|.\[[ViewedArrayBuffer]].
9065+
1. If [$IsSharedArrayBuffer$](|jsArrayBuffer|) is true, then return false.
9066+
1. If [$IsDetachedBuffer$](|jsArrayBuffer|) is true, then return false.
9067+
1. If |jsArrayBuffer|.\[[ArrayBufferDetachKey]] is not <emu-val>undefined</emu-val>, then
9068+
return false.
9069+
1. Return true.
9070+
</div>
9071+
90579072
<div algorithm>
90589073
To <dfn for="ArrayBuffer" export>transfer</dfn> an {{ArrayBuffer}} |arrayBuffer|, optionally
90599074
given a [=realm=] |targetRealm|:

0 commit comments

Comments
 (0)