mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-16 17:18:57 +00:00
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:
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user