Skip to content

Commit

Permalink
Introduce a "transferable" algorithm for BufferSource
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
inexorabletash committed Jul 19, 2024
1 parent 3fb6ab4 commit d6927d5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -9054,6 +9054,21 @@ a reference to the same object that the IDL value represents.
1. Return [$IsDetachedBuffer$](|jsArrayBuffer|).
</div>

<div algorithm>
A [=buffer source type=] instance |bufferSource| is
<dfn for="BufferSource" export>transferable</dfn> if the following steps return true:

1. Let |jsArrayBuffer| be the result of [=converted to a JavaScript value|converting=]
|bufferSource| to a JavaScript value.
1. If |jsArrayBuffer| has a \[[ViewedArrayBuffer]] internal slot, then set |jsArrayBuffer| to
|jsArrayBuffer|.\[[ViewedArrayBuffer]].
1. If [$IsSharedArrayBuffer$](|jsArrayBuffer|) is true, then return false.
1. If [$IsDetachedBuffer$](|jsArrayBuffer|) is true, then return false.
1. If |jsArrayBuffer|.\[[ArrayBufferDetachKey]] is not <emu-val>undefined</emu-val>, then
return false.
1. Return true.
</div>

<div algorithm>
To <dfn for="ArrayBuffer" export>transfer</dfn> an {{ArrayBuffer}} |arrayBuffer|, optionally
given a [=realm=] |targetRealm|:
Expand Down

0 comments on commit d6927d5

Please sign in to comment.