-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[RFC]: add @stdlib/wasm/instantiate #14208
Copy link
Copy link
Labels
AcceptedRFC feature request which has been accepted.RFC feature request which has been accepted.FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.WebAssemblyIssue involves or relates to WebAssembly.Issue involves or relates to WebAssembly.
Description
Activity
Metadata
Metadata
Assignees
Labels
AcceptedRFC feature request which has been accepted.RFC feature request which has been accepted.FeatureIssue or pull request for adding a new feature.Issue or pull request for adding a new feature.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.WebAssemblyIssue involves or relates to WebAssembly.Issue involves or relates to WebAssembly.
Description
This RFC proposes to add
@stdlib/wasm/instantiateFindings
@stdlib/wasm/module-wrapperstill calls platform globals for compilation and instantiation. Async paths useWebAssembly.instantiate; sync paths useWebAssembly.ModuleandWebAssembly.Instance. Those TODOs point at@stdlib/wasm/instantiate(and related packages).The existing
@stdlib/wasm/memorypackage is the right pattern: feature-detect with@stdlib/assert/has-wasm-support, export a strict native alias when supported, otherwise a polyfill that throwsnot implemented.@stdlib/wasm/instantiateshould follow that same shape, except the export is a function (not a constructor).@stdlib/promise/ctor(with polyfill) already under review in #14140 and will be used bymodule-wrapperforinitialize(). That item is done and is not part of this work.WebAssembly.instantiateandnew WebAssembly.Instance(...)are different APIs. The TODOs map both names to@stdlib/wasm/instantiate, but they should stay separate:instantiatefor the async function, and a later@stdlib/wasm/instancefor the sync constructor (same idea asmemory/module).Native
instantiatehas two overloads that must pass through unchanged:Promise<{ module, instance }>Promise<Instance>Future plan
@stdlib/wasm/instantiateas a thin alias ofWebAssembly.instantiate(package, tests, docs, namespace export). Done.@stdlib/wasm/moduleforWebAssembly.Module.@stdlib/wasm/instanceforWebAssembly.Instance.module-wrapperto use the new packages and remove the remaining TODOs.PAGE_SIZEto@stdlib/constants/wasm/page-size.Related Issues
Related PR #14140
Questions
No.
Other
No.
Checklist
RFC:.