Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

TypedArray(typedArray) must be modified for SharedArrayBuffer #149

Closed
lars-t-hansen opened this issue Nov 3, 2016 · 1 comment
Closed

Comments

@lars-t-hansen
Copy link
Collaborator

The problem is that if the current spec is taken as-is, we end up with some weird objects, eg, I've seen an ArrayBuffer with a prototype that is the SharedArrayBufferPrototype.

See https://bugzilla.mozilla.org/show_bug.cgi?id=1314564 for more information. Excerpted from there:

me:

The intent of the Shared Memory spec is that the TypedArray methods should
construct plain ArrayBuffers in this case. I'll take a look at the prose
you point to.

@anba:

Okay. In that case, the Shared Memory spec needs to specify the following changes to 22.2.4.3, steps 17-18:

17. If SameValue(elementType, srcType) is true, then
    a. Let srcLength be typedArray.[[ByteLength]].
    b. If IsSharedArrayBuffer(srcData) is false, then
        i. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, srcLength).
    c. Else,
        i. Let data be ? CloneArrayBuffer(srcData, srcByteOffset, srcLength, %ArrayBuffer%).
18. Else,
    a. If IsSharedArrayBuffer(srcData) is false, then
        i. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%).
    b. Else,
        i. Let bufferConstructor be %ArrayBuffer%.
    b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength).

This seems reasonable to me. Discuss.

@lars-t-hansen
Copy link
Collaborator Author

It also does not seem that there are other, analogous cases in the spec that need similar handling.

lars-t-hansen pushed a commit that referenced this issue Nov 15, 2016
lars-t-hansen pushed a commit that referenced this issue Nov 15, 2016
lars-t-hansen pushed a commit that referenced this issue Nov 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant