The field ordering here is actually significant because of the drop
order: we want to drop the artifact before dropping the engine.
The reason for this is that dropping the Artifact will de-register the
trap handling metadata from the global registry. This must be done before
the code memory for the artifact is freed (which happens when the store
is dropped) since there is a chance that this memory could be reused by
another module which will try to register its own trap information.
Note that in Rust, the drop order for struct fields is from top to
bottom: the opposite of C++.
In the future, this code should be refactored to properly describe the
ownership of the code and its metadata.
Fixes#2434
2728: Replace RuntimeError::raise with RuntimeError::custom r=syrusakbary a=Amanieu
`RuntimeError::raise` should not be exposed to user code since it perfoms a `longjmp` internally which is unsound if there are any destructors on the stack. Instead a custom error type should be returned using `RuntimeError::custom` which can be passed through WASM code and later retrieved using `RuntimeError::downcast`.
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2693: Add extra validation to compilers & engines r=ptitSeb a=Amanieu
- Cranelift and singlepass now properly cross-compile with no dependency on the host target.
- Staticlib engine now panics if you try to run a freshly compiled module.
- CPU features used when a module was compiled are now checked against the host CPU features during instantiation.
Fixes#1567Fixes#2590
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
This allows the contents of an existing namespace to be added to by
extracting an `Exports` from it, adding to that `Exports` and then
replacing the existing namespace with the modified `Exports`.