dtolnay / watt

Runtime for executing procedural macros as WebAssembly
Apache License 2.0
1.29k stars 29 forks source link

Cache module instantiations per-thread #21

Closed alexcrichton closed 5 years ago

alexcrichton commented 5 years ago

This commit continues to rejigger the API of watt by having a top-level Instance type now instead of a suite of top-level functions. By using a top-level struct we can store an internal identifier (usize) which is used to key a thread-local cache for wasm blobs. This should allow us to share resources like module instantiations across macro invocations, ensuring that we only instantiate modules once-per-process.

Closes #16

alexcrichton commented 5 years ago

Another alternative could be:

watt::instantiate_wasm!(WASM, "path/to/foo.wasm");

or

static WASM: watt::Instance = watt::instantiate_file!("path/to/foo.wasm");