Fix/compile not in memory (#3573)

* Example of allocated artifact
* Better error when Instancing fail because of OS/Arch issue
* Add missing brnach for new error
---------

Co-authored-by: Syrus Akbary <me@syrusakbary.com>
This commit is contained in:
ptitSeb
2023-02-06 10:28:39 +01:00
committed by GitHub
parent 0ebc872f06
commit 1387363a7b
6 changed files with 109 additions and 28 deletions

View File

@@ -67,6 +67,11 @@ pub enum InstantiationError {
/// This error occurs when an import from a different store is used.
#[error("cannot mix imports from different stores")]
DifferentStores,
/// Import from a different Store.
/// This error occurs when an import from a different store is used.
#[error("incorrect OS or architecture")]
DifferentArchOS,
}
impl From<wasmer_compiler::InstantiationError> for InstantiationError {

View File

@@ -317,6 +317,11 @@ impl Module {
store: &mut impl AsStoreMut,
imports: &[crate::Extern],
) -> Result<VMInstance, InstantiationError> {
if !self.artifact.allocated() {
// Return an error mentioning that the artifact is compiled for a different
// platform.
return Err(InstantiationError::DifferentArchOS);
}
// Ensure all imports come from the same context.
for import in imports {
if !import.is_from_store(store) {