Skip to content

Use WebAssembly.Memory#toResizableBuffer() in JS bindings #2942

@CountBleck

Description

@CountBleck

Feature suggestion

When WebAssembly memories are grown, any existing ArrayBuffers are detached...unless we use the brand-new toResizableBuffer() method on WebAssembly.Memory objects.

Calling this method in our JS bindings would be beneficial for AssemblyScript because it prevents us (in bindings) and users from worrying about views into the Wasm memory detaching, because they won't detach and will actually grow automatically if the view isn't constructed with a set length: see the resizable ArrayBuffer proposal and the merged spec (see steps 4-9). This could, in the future, maybe let us pass TypedArrays to users without copying them in the ESM bindings, if we want to (re?)add that feature.

This change should be very very very simple (shouldn't take more than 10 or 20 lines of code).

This is being created as an issue first, because browsers haven't widely implemented this yet, so we have to wait until they do.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions