diff --git a/source b/source index a55ca40e49e..89f51b9f021 100644 --- a/source +++ b/source @@ -495,6 +495,13 @@ be thought of as completely serializing the execution of all scripts in all browsing contexts.
+The exception to this general design principle is the JavaScript SharedArrayBuffer
+ class. Using SharedArrayBuffer
s, it can in fact be observed that scripts in other
+ event loops are executing simultaneously. Furthermore, due to the
+ JavaScript memory model, there are situations which not only are un-representable via serialized
+ script execution, but also un-representable via serialized statement execution
+ among those scripts.
Otherwise, if value has an [[ArrayBufferData]] internal slot, then:
If IsDetachedBuffer(value) is true, then throw a
- "DataCloneError
" DOMException
.
Let size be value.[[ArrayBufferByteLength]].
If IsSharedArrayBuffer(value) is true, then set + serialized to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]: + value.[[ArrayBufferData]], [[ArrayBufferByteLength]]: size, + [[EventLoop]]: current Realm Record's settings object's responsible event + loop }.
Let dataCopy be ? CreateByteDataBlock(size).
+Otherwise:
-This can throw a RangeError
exception upon
- allocation failure.
If IsDetachedBuffer(value) is true, then throw a
+ "DataCloneError
" DOMException
.
Let dataCopy be ? CreateByteDataBlock(size).
-Perform ! CopyDataBlockBytes(dataCopy, 0, - value.[[ArrayBufferData]], 0, size).
This can throw a RangeError
exception
+ upon allocation failure.
Perform ! CopyDataBlockBytes(dataCopy, 0, + value.[[ArrayBufferData]], 0, size).
Set serialized to { [[Type]]: "ArrayBuffer", [[ArrayBufferData]]: - dataCopy, [[ArrayBufferByteLength]]: size }.
Set serialized to { [[Type]]: "ArrayBuffer", [[ArrayBufferData]]: + dataCopy, [[ArrayBufferByteLength]]: size }.
Otherwise, if serialized.[[Type]] is "ArrayBuffer", then set value to a new ArrayBuffer - object in targetRealm whose [[ArrayBufferData]] internal slot value is - serialized.[[ArrayBufferData]], and whose [[ArrayBufferByteLength]] internal slot +
Otherwise, if serialized.[[Type]] is "SharedArrayBuffer", then:
+ +If targetRealm's settings
+ object's responsible event loop is not in the same unit of
+ share-within-able event loops as serialized.[[EventLoop]], then then throw a
+ "DataCloneError
" DOMException
.
Otherwise, set value to a new SharedArrayBuffer object in + targetRealm whose [[ArrayBufferData]] internal slot value is + serialized.[[ArrayBufferData]] and whose [[ArrayBufferByteLength]] internal slot + value is serialized.[[ArrayBufferByteLength]].
Otherwise, if serialized.[[Type]] is "ArrayBuffer", then set value to a + new ArrayBuffer object in targetRealm whose [[ArrayBufferData]] internal slot value + is serialized.[[ArrayBufferData]], and whose [[ArrayBufferByteLength]] internal slot value is serialized.[[ArrayBufferByteLength]].
+If this throws an exception, then throw a "DataCloneError
"
+ DOMException
.
This step might throw an exception if there is not enough memory available to create such an ArrayBuffer object.
DataCloneError
" DOMException
.
- If transferable has an [[ArrayBufferData]] internal slot and ! +
If transferable has an [[ArrayBufferData]] internal slot and either !
+ IsSharedArrayBuffer(transferable) is true or !
IsDetachedBuffer(transferable) is true, then throw a
"DataCloneError
" DOMException
.