WebAssembly / wasm-c-api

Wasm C API prototype
Apache License 2.0
550 stars 77 forks source link

Does wasm_instance_new need the wasm_store_t parameter? #126

Closed alexcrichton closed 4 years ago

alexcrichton commented 4 years ago

Currently wasm_instance_new takes a wasm_store_t parameter as its first argument, but the second wasm_module_t argument was already created within a store and presumably this parameter could be inferred. Is this intended, though, to perhaps put instance cached data in one place and module cached data in another place?

rossberg commented 4 years ago

The API uniformly requires a store argument for every allocation operation. Depending on an engine's implementation choices, this could be extracted from other arguments in some cases, but that would potentially impose unnecessary constraints on implementations.

For example, in V8, the store corresponds directly to an isolate. It is a convention in the engine to pass an isolate to every internal operation that needs it. There is a way to get to the home isolate from heap objects, but it is expensive and partial, and thus considered more or less deprecated.

alexcrichton commented 4 years ago

Ok, sounds like this'll be sticking around then!