Make it compile.
This commit is contained in:
parent
e167cbcb96
commit
1dad287999
|
@ -13,12 +13,16 @@ exclude = [ "/res/*", "/tests/*", "/fuzz/*", "/benches/*" ]
|
|||
[features]
|
||||
default = ["std"]
|
||||
# Disable for no_std support
|
||||
std = ["parity-wasm/std"]
|
||||
std = [
|
||||
"parity-wasm/std",
|
||||
"wasmi-validation/std",
|
||||
]
|
||||
# Enable for no_std support
|
||||
# hashbrown only works on no_std
|
||||
core = ["hashbrown/nightly", "libm"]
|
||||
|
||||
[dependencies]
|
||||
wasmi-validation = { path = "validation", default-features = false }
|
||||
parity-wasm = { version = "0.31", default-features = false }
|
||||
hashbrown = { version = "0.1.8", optional = true }
|
||||
memory_units = "0.3.0"
|
||||
|
|
|
@ -120,6 +120,8 @@ extern crate hashbrown;
|
|||
extern crate memory_units as memory_units_crate;
|
||||
extern crate parity_wasm;
|
||||
|
||||
extern crate wasmi_validation as validation;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use alloc::prelude::*;
|
||||
use core::fmt;
|
||||
|
@ -392,7 +394,6 @@ mod prepare;
|
|||
mod runner;
|
||||
mod table;
|
||||
mod types;
|
||||
mod validation;
|
||||
mod value;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -108,7 +108,7 @@ impl MemoryInstance {
|
|||
///
|
||||
/// [`LINEAR_MEMORY_PAGE_SIZE`]: constant.LINEAR_MEMORY_PAGE_SIZE.html
|
||||
pub fn alloc(initial: Pages, maximum: Option<Pages>) -> Result<MemoryRef, Error> {
|
||||
validate_memory(initial, maximum).map_err(Error::Memory)?;
|
||||
validation::validate_memory(initial, maximum).map_err(Error::Memory)?;
|
||||
|
||||
let memory = MemoryInstance::new(initial, maximum);
|
||||
Ok(MemoryRef(Rc::new(memory)))
|
||||
|
@ -268,7 +268,7 @@ impl MemoryInstance {
|
|||
}
|
||||
|
||||
let new_size: Pages = size_before_grow + additional;
|
||||
let maximum = self.maximum.unwrap_or(LINEAR_MEMORY_MAX_PAGES);
|
||||
let maximum = self.maximum.unwrap_or(validation::LINEAR_MEMORY_MAX_PAGES);
|
||||
if new_size > maximum {
|
||||
return Err(Error::Memory(format!(
|
||||
"Trying to grow memory by {} pages when already have {}",
|
||||
|
|
|
@ -10,7 +10,7 @@ use hashbrown::HashMap;
|
|||
#[cfg(feature = "std")]
|
||||
use std::collections::HashMap;
|
||||
|
||||
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
|
||||
use validation::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
|
||||
use core::cell::Ref;
|
||||
use func::{FuncBody, FuncInstance, FuncRef};
|
||||
use global::{GlobalInstance, GlobalRef};
|
||||
|
|
|
@ -6,8 +6,8 @@ use validation::func::{
|
|||
};
|
||||
use validation::util::Locals;
|
||||
use validation::{Error, FunctionValidator};
|
||||
use validation::stack::StackWithLimit;
|
||||
|
||||
use common::stack::StackWithLimit;
|
||||
use isa;
|
||||
|
||||
/// Type of block frame.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[allow(unused_imports)]
|
||||
use alloc::prelude::*;
|
||||
use common::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
|
||||
use validation::{DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX};
|
||||
use core::fmt;
|
||||
use core::ops;
|
||||
use core::{u32, usize};
|
||||
|
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
parity-wasm = { version = "0.31", default-features = false }
|
||||
memory_units = "0.3.0"
|
||||
memory_units_crate = { package = "memory_units", version = "0.3.0" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
|
|
@ -30,6 +30,12 @@ use hashbrown::HashSet;
|
|||
#[cfg(feature = "std")]
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// WebAssembly-specific sizes and units.
|
||||
pub mod memory_units {
|
||||
pub use memory_units_crate::wasm32::*;
|
||||
pub use memory_units_crate::{size_of, ByteSize, Bytes, RoundUpTo};
|
||||
}
|
||||
|
||||
use memory_units::Pages;
|
||||
|
||||
use self::context::ModuleContextBuilder;
|
||||
|
@ -437,7 +443,7 @@ fn validate_memory_type(memory_type: &MemoryType) -> Result<(), Error> {
|
|||
}
|
||||
|
||||
/// Maximal number of pages that a wasm instance supports.
|
||||
const LINEAR_MEMORY_MAX_PAGES: Pages = Pages(65536);
|
||||
pub const LINEAR_MEMORY_MAX_PAGES: Pages = Pages(65536);
|
||||
|
||||
pub fn validate_memory(initial: Pages, maximum: Option<Pages>) -> Result<(), String> {
|
||||
if initial > LINEAR_MEMORY_MAX_PAGES {
|
||||
|
|
Loading…
Reference in New Issue