(engine: &Engine, artifact_name: &str)
| 96 | } |
| 97 | |
| 98 | pub(crate) fn load_artifact_module(engine: &Engine, artifact_name: &str) -> Result<Module> { |
| 99 | let artifact = install_artifact(artifact_name)?; |
| 100 | let cache_key = format!("{artifact_name}:{}", artifact.sha256); |
| 101 | let module_cache = MODULE_CACHE.get_or_init(|| Mutex::new(HashMap::new())); |
| 102 | let mut modules = module_cache.lock().expect("AOT module cache poisoned"); |
| 103 | if let Some(module) = modules.get(&cache_key) { |
| 104 | return Ok(module.clone()); |
| 105 | } |
| 106 | |
| 107 | let module = match deserialize_headless(engine, &artifact.path) { |
| 108 | Ok(module) => module, |
| 109 | Err(err) if aot_verify_mode()? == AotVerifyMode::Fast => { |
| 110 | let _phase = timing::phase("aot.rebuild_after_deserialize_failure"); |
| 111 | forget_installed_artifact(artifact_name); |
| 112 | remove_cached_artifact(&artifact.path)?; |
| 113 | let artifact = rebuild_artifact(artifact_name).with_context(|| { |
| 114 | format!("rebuild AOT artifact '{artifact_name}' after deserialize failure") |
| 115 | })?; |
| 116 | deserialize_headless(engine, &artifact.path).with_context(|| { |
| 117 | format!( |
| 118 | "deserialize rebuilt Wasmer AOT artifact '{}' after initial failure: {err:#}", |
| 119 | artifact.path.display() |
| 120 | ) |
| 121 | })? |
| 122 | } |
| 123 | Err(err) => return Err(err), |
| 124 | }; |
| 125 | modules.insert(cache_key, module.clone()); |
| 126 | Ok(module) |
| 127 | } |
| 128 | |
| 129 | #[cfg(feature = "extensions")] |
| 130 | pub(crate) fn load_pg_dump_module(engine: &Engine) -> Result<Module> { |
no test coverage detected