WebAssembly / WebAssembly/spec
[js-api] Integration with the ResizableArrayBuffer and GrowableSharedArrayBuffer proposal
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 3.5k
- Forks
- 539
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 13
Description
The ResizableArrayBuffer and GrowableSharedArrayBuffer proposal is a TC39 proposal that is currently stage 2.
There was some discussion of how the proposal might integrate with the Wasm/JS API. It seems better to move the discussion here to get a concrete plan and to get more Wasm eyes on the issue.
As a starting point, I suggest the following changes to the WebAssembly.Memory API:
Memorywill have a newresizableBufferattribute.- Returns a
ResizableArrayBufferorGrowableSharedArrayBufferinstance. - If an
ArrayBufferwas vended by thebufferattribute on the same instance, thatArrayBufferinstance will be detached.SharedArrayBuffersandGrowableSharedArrayBufferwill alias the same memory. - If the
Memorywas created with a maximum size, that size will be reflected on theResizableArrayBufferorGrowableSharedArrayBufferinstance. - Otherwise, the maximum size is
2^32.
- Returns a
Memory'sbufferattribute will detach anyResizableArrayBufferbuffers vended by theresizableBufferattribute.ResizableArrayBuffers gotten viaMemory'sresizableBufferattribute will:- Throw on
transfer(), since they can't be detached. - Throw on
resize()calls that are shrinks. - Throw on
resize()calls that are not in multiples of the wasm page size. (Thanks @conrad-watt)
- Throw on
GrowableArrayBuffers gotten viaMemory'sresizableBufferattribute will:- Throw on
grow()calls that are not in multiples of the wasm page size.
- Throw on
Thoughts welcome.
(Also, what is the process for bringing such a "normative PR" that's not a full proposal to the CG? Is it just an agenda item?)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the linked ResizableArrayBuffer and GrowableSharedArrayBuffer proposal and its referenced TC39 discussion, then compare the suggested behavior with the WebAssembly.Memory API specification. The issue needs an agreed normative plan for the new resizableBuffer behavior, detachment rules, and size validation, followed by the appropriate standards process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, wasm
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100