Why is buffer frozen?
Let status be SetIntegrityLevel(buffer, "frozen").
What does this accomplish?
Note that freezing an ArrayBuffer does not prevent mutating its data:
const ab = new ArrayBuffer(20);
Object.freeze(ab);
const ta = new Uint8Array(ab);
ta[0] = 5; // works fine
So I'm not sure why you'd want to freeze the buffer. A note in the spec would be helpful explaining the purpose.
Here's the discussion: https://github.com/WebAssembly/threads/pull/32#issuecomment-310238458
Another interesting point is that, because grow_memory can happen in other agents, it's quite racy which SAB you'll get on any given invocation of the .buffer getter. It seems like any use of expandos would be hazardous and I was thinking maybe the SAB returned by .buffer should be frozen. Identity is still observable (via ===) and expandos are still possible (via WeakMap), so this would just be a deterrent.
A note in the spec would be helpful explaining the purpose.
Sounds good.
(whoops, meant to make a PR, clicked the wrong button)