From db45dc6ad6d10808b469d3bbd25de0c4ce821b85 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 15 Dec 2022 13:17:40 +0100 Subject: [PATCH] Rewrite some use statements Smaller diff, and more sensible that way. --- lib/api/src/sys/externals/global.rs | 1 - lib/api/src/sys/externals/memory.rs | 4 +--- lib/api/src/sys/externals/table.rs | 1 - lib/api/src/sys/imports.rs | 6 ++---- lib/api/src/sys/instance.rs | 1 - lib/api/src/sys/value.rs | 4 +--- 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/api/src/sys/externals/global.rs b/lib/api/src/sys/externals/global.rs index e43725ec265..2dfc77ff06d 100644 --- a/lib/api/src/sys/externals/global.rs +++ b/lib/api/src/sys/externals/global.rs @@ -4,7 +4,6 @@ use crate::sys::store::{AsStoreMut, AsStoreRef}; use crate::sys::value::Value; use crate::sys::GlobalType; use crate::sys::Mutability; -#[cfg(feature = "compiler")] use crate::sys::RuntimeError; use wasmer_vm::{InternalStoreHandle, StoreHandle, VMExtern, VMGlobal}; diff --git a/lib/api/src/sys/externals/memory.rs b/lib/api/src/sys/externals/memory.rs index 67cf908d4d9..fddcb2995ab 100644 --- a/lib/api/src/sys/externals/memory.rs +++ b/lib/api/src/sys/externals/memory.rs @@ -11,8 +11,6 @@ use std::slice; #[cfg(feature = "tracing")] use tracing::warn; use wasmer_types::Pages; -#[cfg(feature = "compiler")] -use wasmer_types::WASM_PAGE_SIZE; use wasmer_vm::{InternalStoreHandle, LinearMemory, MemoryError, StoreHandle, VMExtern, VMMemory}; use super::MemoryView; @@ -151,7 +149,7 @@ impl Memory { let new_view_size = new_view.data_size() as usize; if amount > new_view_size { let delta = amount - new_view_size; - let pages = ((delta - 1) / WASM_PAGE_SIZE) + 1; + let pages = ((delta - 1) / wasmer_types::WASM_PAGE_SIZE) + 1; new_memory.grow(new_store, Pages(pages as u32))?; new_view = new_memory.view(&new_store); } diff --git a/lib/api/src/sys/externals/table.rs b/lib/api/src/sys/externals/table.rs index 56031e1d462..52137330846 100644 --- a/lib/api/src/sys/externals/table.rs +++ b/lib/api/src/sys/externals/table.rs @@ -3,7 +3,6 @@ use crate::sys::externals::Extern; use crate::sys::store::{AsStoreMut, AsStoreRef}; use crate::sys::TableType; use crate::Value; -#[cfg(feature = "compiler")] use crate::{sys::RuntimeError, ExternRef, Function}; use wasmer_vm::{InternalStoreHandle, StoreHandle, TableElement, VMExtern, VMTable}; diff --git a/lib/api/src/sys/imports.rs b/lib/api/src/sys/imports.rs index f2ceba1ba31..2730c13735e 100644 --- a/lib/api/src/sys/imports.rs +++ b/lib/api/src/sys/imports.rs @@ -1,8 +1,6 @@ //! The import module contains the implementation data structures and helper functions used to //! manipulate and access a wasm module's imports including memories, tables, globals, and //! functions. -#[cfg(feature = "compiler")] -use crate::{AsStoreMut, Memory}; use crate::{Exports, Extern, Module}; use std::collections::HashMap; use std::fmt; @@ -131,7 +129,7 @@ impl Imports { pub fn import_shared_memory( &mut self, module: &Module, - store: &mut impl AsStoreMut, + store: &mut impl crate::AsStoreMut, ) -> Option { // Determine if shared memory needs to be created and imported let shared_memory = module @@ -148,7 +146,7 @@ impl Imports { self.define( "env", "memory", - Memory::new_from_existing(store, memory.clone().into()), + crate::Memory::new_from_existing(store, memory.clone().into()), ); Some(memory) } else { diff --git a/lib/api/src/sys/instance.rs b/lib/api/src/sys/instance.rs index 4ad4d797096..a3df77d1445 100644 --- a/lib/api/src/sys/instance.rs +++ b/lib/api/src/sys/instance.rs @@ -1,6 +1,5 @@ use crate::sys::exports::Exports; use crate::sys::module::Module; -#[cfg(feature = "compiler")] use crate::sys::{LinkError, RuntimeError}; use std::fmt; use thiserror::Error; diff --git a/lib/api/src/sys/value.rs b/lib/api/src/sys/value.rs index 1c00e4bbcf6..fe4fb5c4b5f 100644 --- a/lib/api/src/sys/value.rs +++ b/lib/api/src/sys/value.rs @@ -9,8 +9,6 @@ use wasmer_vm::{VMExternRef, VMFuncRef}; use crate::ExternRef; use crate::Function; -#[cfg(feature = "compiler")] -use super::store::AsStoreMut; use super::store::AsStoreRef; pub use wasmer_types::RawValue; @@ -113,7 +111,7 @@ impl Value { /// /// # Safety /// - pub unsafe fn from_raw(store: &mut impl AsStoreMut, ty: Type, raw: RawValue) -> Self { + pub unsafe fn from_raw(store: &mut impl crate::AsStoreMut, ty: Type, raw: RawValue) -> Self { match ty { Type::I32 => Self::I32(raw.i32), Type::I64 => Self::I64(raw.i64),