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 SharedArrayBuffers, 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.

+ @@ -2912,6 +2919,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • The IsConstructor abstract operation
  • The IsDataDescriptor abstract operation
  • The IsDetachedBuffer abstract operation
  • +
  • The IsSharedArrayBuffer abstract operation
  • The NewObjectEnvironment abstract operation
  • The OrdinaryGetPrototypeOf abstract operation
  • @@ -7858,23 +7866,36 @@ interface DOMStringList {

    Otherwise, if value has an [[ArrayBufferData]] internal slot, then:

      -
    1. If IsDetachedBuffer(value) is true, then throw a - "DataCloneError" DOMException.

    2. -
    3. Let size be value.[[ArrayBufferByteLength]].

    4. +
    5. 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 }.

    6. +
    7. -

      Let dataCopy be ? CreateByteDataBlock(size).

      +

      Otherwise:

      -

      This can throw a RangeError exception upon - allocation failure.

      -
    8. +
        +
      1. If IsDetachedBuffer(value) is true, then throw a + "DataCloneError" DOMException.

      2. + +
      3. +

        Let dataCopy be ? CreateByteDataBlock(size).

        -
      4. Perform ! CopyDataBlockBytes(dataCopy, 0, - value.[[ArrayBufferData]], 0, size).

      5. +

        This can throw a RangeError exception + upon allocation failure.

        + + +
      6. Perform ! CopyDataBlockBytes(dataCopy, 0, + value.[[ArrayBufferData]], 0, size).

      7. -
      8. Set serialized to { [[Type]]: "ArrayBuffer", [[ArrayBufferData]]: - dataCopy, [[ArrayBufferByteLength]]: size }.

      9. +
      10. Set serialized to { [[Type]]: "ArrayBuffer", [[ArrayBufferData]]: + dataCopy, [[ArrayBufferByteLength]]: size }.

      11. +
      +
    @@ -8261,11 +8282,30 @@ o.myself = o; serialized.[[OriginalFlags]].

  • -

    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:

    + +
      +
    1. 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.

    2. + +
    3. 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]].

    4. +
    +
  • + +
  • +

    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.

  • @@ -8474,7 +8514,8 @@ o.myself = o; [[Detached]] internal slot, then throw a "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.