Fix WASM executor without instance reuse; cleanups and refactoring (#10313)

* Fix WASM executor without instance reuse; cleanups and refactoring

* Align to review comments

* Move the functions for reading/writing memory to `util.rs`

* Only `#[ignore]` the test in debug builds

* More review comments and minor extra comments
This commit is contained in:
Koute
2021-11-23 15:35:19 +09:00
committed by GitHub
parent a47f0243e0
commit e5108606eb
7 changed files with 394 additions and 376 deletions
@@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::{
host::HostContext,
runtime::{Store, StoreData},
util,
};
@@ -191,19 +192,7 @@ fn call_static<'a>(
mut caller: Caller<'a, StoreData>,
) -> Result<(), wasmtime::Trap> {
let unwind_result = {
let host_state = caller
.data()
.host_state()
.expect(
"host functions can be called only from wasm instance;
wasm instance is always called initializing context;
therefore host_ctx cannot be None;
qed
",
)
.clone();
let mut host_ctx = host_state.materialize(&mut caller);
let mut host_ctx = HostContext { caller: &mut caller };
// `from_wasmtime_val` panics if it encounters a value that doesn't fit into the values
// available in substrate.