From 14bfd75ac98f389eaa0bc609fb7d47dddd005208 Mon Sep 17 00:00:00 2001 From: losfair Date: Fri, 3 May 2019 00:23:41 +0800 Subject: [PATCH 01/43] Code loader framework. --- lib/runtime-core/src/backend.rs | 3 + lib/runtime-core/src/instance.rs | 34 +++++- lib/runtime-core/src/lib.rs | 1 + lib/runtime-core/src/loader.rs | 130 ++++++++++++++++++++++ lib/runtime-core/src/types.rs | 9 ++ lib/singlepass-backend/src/codegen_x64.rs | 12 ++ src/bin/wasmer.rs | 54 +++++++++ 7 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 lib/runtime-core/src/loader.rs diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index d465cda5834..b43bfa75787 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -80,6 +80,9 @@ pub trait RunnableModule: Send + Sync { fn get_trampoline(&self, info: &ModuleInfo, sig_index: SigIndex) -> Option; unsafe fn do_early_trap(&self, data: Box) -> !; + + fn get_code(&self) -> Option<&[u8]> { None } + fn get_offsets(&self) -> Option> { None } } pub trait CacheGen: Send + Sync { diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index 14d7a0146c0..d826999731f 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -12,6 +12,8 @@ use crate::{ typed_func::{Func, Wasm, WasmTrapInfo, WasmTypeList}, types::{FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex, Type, Value}, vm, + loader::{self, Loader, Instance as _}, + structures::TypedIndex, }; use smallvec::{smallvec, SmallVec}; use std::{mem, ptr::NonNull, sync::Arc}; @@ -38,7 +40,7 @@ impl Drop for InstanceInner { /// /// [`ImportObject`]: struct.ImportObject.html pub struct Instance { - module: Arc, + pub module: Arc, inner: Box, #[allow(dead_code)] import_object: ImportObject, @@ -127,6 +129,10 @@ impl Instance { Ok(instance) } + pub fn load(&self, loader: T) -> ::std::result::Result { + loader.load(&*self.module.runnable_module, &self.module.info, unsafe { &(*self.inner.vmctx).internal }) + } + /// Through generic magic and the awe-inspiring power of traits, we bring you... /// /// # "Func" @@ -214,6 +220,32 @@ impl Instance { } } + pub fn resolve_local_func(&self, name: &str) -> ResolveResult { + let export_index = + self.module + .info + .exports + .get(name) + .ok_or_else(|| ResolveError::ExportNotFound { + name: name.to_string(), + })?; + + if let ExportIndex::Func(func_index) = export_index { + match func_index.local_or_import(&self.module.info) { + LocalOrImport::Local(x) => Ok(x.index()), + LocalOrImport::Import(x) => Err(ResolveError::ExportWrongType { + name: name.to_string(), + } + .into()) + } + } else { + Err(ResolveError::ExportWrongType { + name: name.to_string(), + } + .into()) + } + } + /// This returns the representation of a function that can be called /// safely. /// diff --git a/lib/runtime-core/src/lib.rs b/lib/runtime-core/src/lib.rs index 46c435db598..90517dba53a 100644 --- a/lib/runtime-core/src/lib.rs +++ b/lib/runtime-core/src/lib.rs @@ -33,6 +33,7 @@ pub mod units; pub mod vm; #[doc(hidden)] pub mod vmcalls; +pub mod loader; use self::error::CompileResult; #[doc(inline)] diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs new file mode 100644 index 00000000000..57885891a94 --- /dev/null +++ b/lib/runtime-core/src/loader.rs @@ -0,0 +1,130 @@ +use std::{ + fmt::Debug, + ops::{Deref, DerefMut}, +}; +use crate::{ + backend::RunnableModule, + vm::InternalCtx, + module::ModuleInfo, + types::Value, +}; +use libc::{ + c_char, mmap, mprotect, munmap, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_NONE, PROT_READ, + PROT_WRITE, +}; + +pub trait Loader { + type Instance: Instance; + type Error: Debug; + + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result; +} + +pub trait Instance { + type Error: Debug; + fn call(&mut self, id: usize, args: &[Value]) -> Result; +} + +pub struct LocalLoader; + +impl Loader for LocalLoader { + type Instance = LocalInstance; + type Error = String; + + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result { + let code = rm.get_code().unwrap(); + let mut code_mem = CodeMemory::new(code.len()); + code_mem[..code.len()].copy_from_slice(code); + code_mem.make_executable(); + + Ok(LocalInstance { + code: code_mem, + offsets: rm.get_offsets().unwrap(), + }) + } +} + +pub struct LocalInstance { + code: CodeMemory, + offsets: Vec, +} + +impl Instance for LocalInstance { + type Error = String; + fn call(&mut self, id: usize, args: &[Value]) -> Result { + let offset = self.offsets[id]; + let addr: *const u8 = unsafe { self.code.as_ptr().offset(offset as isize) }; + use std::mem::transmute; + Ok(unsafe { + match args.len() { + 0 => (transmute::<_, extern "C" fn() -> u64>(addr))(), + 1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args[0].to_u64()), + 2 => (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64()), + 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64()), + 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64(), args[3].to_u64()), + 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64(), args[3].to_u64(), args[4].to_u64()), + _ => return Err("too many arguments".into()) + } + }) + } +} + +pub struct CodeMemory { + ptr: *mut u8, + size: usize, +} + +impl CodeMemory { + pub fn new(size: usize) -> CodeMemory { + fn round_up_to_page_size(size: usize) -> usize { + (size + (4096 - 1)) & !(4096 - 1) + } + let size = round_up_to_page_size(size); + let ptr = unsafe { + mmap( + ::std::ptr::null_mut(), + size, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, + -1, + 0, + ) + }; + if ptr as isize == -1 { + panic!("cannot allocate code memory"); + } + CodeMemory { + ptr: ptr as _, + size: size, + } + } + + pub fn make_executable(&mut self) { + if unsafe { mprotect(self.ptr as _, self.size, PROT_READ | PROT_EXEC) } != 0 { + panic!("cannot set code memory to executable"); + } + } +} + +impl Drop for CodeMemory { + fn drop(&mut self) { + unsafe { munmap(self.ptr as _, self.size); } + } +} + +impl Deref for CodeMemory { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + ::std::slice::from_raw_parts(self.ptr, self.size) + } + } +} + +impl DerefMut for CodeMemory { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + ::std::slice::from_raw_parts_mut(self.ptr, self.size) + } + } +} \ No newline at end of file diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index bf5df2183af..62d3235a20c 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -45,6 +45,15 @@ impl Value { Value::F64(_) => Type::F64, } } + + pub fn to_u64(&self) -> u64 { + match *self { + Value::I32(x) => x as u32 as u64, + Value::I64(x) => x as u64, + Value::F32(x) => f32::to_bits(x) as u64, + Value::F64(x) => f64::to_bits(x), + } + } } impl From for Value { diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 783ca13af1e..5f4679cef73 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -159,6 +159,7 @@ pub struct X64ExecutionContext { #[allow(dead_code)] functions: Vec, function_pointers: Vec, + function_offsets: Vec, signatures: Arc>, _br_table_data: Vec>, breakpoints: Arc>>, @@ -270,6 +271,14 @@ impl RunnableModule for X64ExecutionContext { protect_unix::TRAP_EARLY_DATA.with(|x| x.set(Some(data))); protect_unix::trigger_trap(); } + + fn get_code(&self) -> Option<&[u8]> { + Some(&self.code) + } + + fn get_offsets(&self) -> Option> { + Some(self.function_offsets.iter().map(|x| x.0).collect()) + } } #[derive(Debug)] @@ -376,6 +385,7 @@ impl ModuleCodeGenerator self.function_labels.as_ref().unwrap() }; let mut out_labels: Vec = vec![]; + let mut out_offsets: Vec = vec![]; for i in 0..function_labels.len() { let (_, offset) = match function_labels.get(&i) { @@ -395,6 +405,7 @@ impl ModuleCodeGenerator } }; out_labels.push(FuncPtr(output.ptr(*offset) as _)); + out_offsets.push(*offset); } let breakpoints: Arc> = Arc::new( @@ -412,6 +423,7 @@ impl ModuleCodeGenerator breakpoints: breakpoints, func_import_count: self.func_import_count, function_pointers: out_labels, + function_offsets: out_offsets, }) } diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 6774fab58f1..548a64279b1 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -23,6 +23,7 @@ use wasmer_runtime::{ use wasmer_runtime_core::{ self, backend::{Compiler, CompilerConfig}, + loader::{self, Loader, Instance as _, LocalLoader}, }; #[cfg(feature = "backend:singlepass")] use wasmer_singlepass_backend::SinglePassCompiler; @@ -90,6 +91,13 @@ struct Run { #[structopt(long = "dir", multiple = true, group = "wasi")] pre_opened_directories: Vec, + // Custom code loader + #[structopt( + long = "loader", + raw(possible_values = "LoaderName::variants()", case_insensitive = "true") + )] + loader: Option, + #[structopt(long = "command-name", hidden = true)] command_name: Option, @@ -98,6 +106,30 @@ struct Run { args: Vec, } +#[allow(dead_code)] +#[derive(Debug, Copy, Clone)] +enum LoaderName { + Local, +} + +impl LoaderName { + pub fn variants() -> &'static [&'static str] { + &[ + "local", + ] + } +} + +impl FromStr for LoaderName { + type Err = String; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "local" => Ok(LoaderName::Local), + _ => Err(format!("The loader {} doesn't exist", s)), + } + } +} + #[allow(dead_code)] #[derive(Debug)] enum Backend { @@ -303,6 +335,28 @@ fn execute_wasm(options: &Run) -> Result<(), String> { .map_err(|e| format!("Can't compile module: {:?}", e))? }; + if let Some(loader) = options.loader { + let import_object = wasmer_runtime_core::import::ImportObject::new(); + let instance = module + .instantiate(&import_object) + .map_err(|e| format!("Can't instantiate module: {:?}", e))?; + + let args: Vec = options + .args + .iter() + .map(|arg| arg.as_str()) + .map(|x| Value::I32(x.parse().unwrap())) + .collect(); + let index = instance.resolve_local_func("main").unwrap(); + match loader { + LoaderName::Local => { + let mut ins = instance.load(LocalLoader).unwrap(); + println!("{:?}", ins.call(index, &args)); + }, + } + return Ok(()) + } + // TODO: refactor this if wasmer_emscripten::is_emscripten_module(&module) { let mut emscripten_globals = wasmer_emscripten::EmscriptenGlobals::new(&module); From af58ea5642c6a0921354ff45b2857b615a45d035 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Fri, 3 May 2019 23:07:07 -0700 Subject: [PATCH 02/43] Kernel mode code loading. --- Cargo.lock | 9 +++ Cargo.toml | 3 +- lib/kwasm-loader/Cargo.toml | 9 +++ lib/kwasm-loader/src/lib.rs | 70 +++++++++++++++++++++ lib/kwasm-loader/src/service.rs | 106 ++++++++++++++++++++++++++++++++ src/bin/wasmer.rs | 16 ++--- 6 files changed, 205 insertions(+), 8 deletions(-) create mode 100644 lib/kwasm-loader/Cargo.toml create mode 100644 lib/kwasm-loader/src/lib.rs create mode 100644 lib/kwasm-loader/src/service.rs diff --git a/Cargo.lock b/Cargo.lock index ad4e6b3b2ff..6ecc90bd1b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -906,6 +906,14 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "kwasm-loader" +version = "0.1.0" +dependencies = [ + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-runtime-core 0.3.0", +] + [[package]] name = "lazy_static" version = "1.3.0" @@ -2231,6 +2239,7 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "kwasm-loader 0.1.0", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index edd1c5b388c..91628b2ddf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,9 +32,10 @@ wasmer-runtime-core = { path = "lib/runtime-core" } wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } wasmer-wasi = { path = "lib/wasi", optional = true } +kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/lib/kwasm-loader/Cargo.toml b/lib/kwasm-loader/Cargo.toml new file mode 100644 index 00000000000..bc3303aa504 --- /dev/null +++ b/lib/kwasm-loader/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "kwasm-loader" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +[dependencies] +libc = "0.2.49" +wasmer-runtime-core = { path = "../runtime-core", version = "0.3.0" } diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs new file mode 100644 index 00000000000..74e76ed511e --- /dev/null +++ b/lib/kwasm-loader/src/lib.rs @@ -0,0 +1,70 @@ +pub mod service; + +use wasmer_runtime_core::{ + loader::{self, Loader, Instance}, + backend::RunnableModule, + vm::{InternalCtx, LocalGlobal}, + module::ModuleInfo, + types::{Value, LocalMemoryIndex, ImportedMemoryIndex}, + structures::TypedIndex, +}; +use service::{ServiceContext, RunProfile}; + +pub struct KernelLoader; + +impl Loader for KernelLoader { + type Instance = KernelInstance; + type Error = String; + + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result { + let code = rm.get_code().unwrap(); + let memory = if let Some(_) = module.memories.get(LocalMemoryIndex::new(0)) { + Some(unsafe { + ::std::slice::from_raw_parts((**ctx.memories).base, (**ctx.memories).bound) + }.to_vec()) + } else if let Some(_) = module.imported_memories.get(ImportedMemoryIndex::new(0)) { + return Err("imported memory is not supported".into()); + } else { + None + }; + if module.imported_globals.len() > 0 { + return Err("imported globals are not supported".into()); + } + let globals: Vec = unsafe { + let globals: &[*mut LocalGlobal] = ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); + globals.iter().map(|x| (**x).data).collect() + }; + Ok(KernelInstance { + context: ServiceContext::connect().map_err(|x| format!("{:?}", x))?, + code: code.to_vec(), + memory: memory, + globals: globals, + offsets: rm.get_offsets().unwrap(), + }) + } +} + +pub struct KernelInstance { + context: ServiceContext, + code: Vec, + memory: Option>, + globals: Vec, + offsets: Vec, +} + +impl Instance for KernelInstance { + type Error = String; + fn call(&mut self, id: usize, args: &[Value]) -> Result { + let args: Vec = args.iter().map(|x| x.to_u64()).collect(); + + let ret = self.context.run_code(RunProfile { + code: &self.code, + memory: if let Some(ref x) = self.memory { Some(&*x) } else { None }, + memory_max: 0, + globals: &self.globals, + params: &args, + entry_offset: self.offsets[id] as u32, + }).map_err(|x| format!("{:?}", x))?; + Ok(ret as u64) + } +} \ No newline at end of file diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs new file mode 100644 index 00000000000..0517ff1c503 --- /dev/null +++ b/lib/kwasm-loader/src/service.rs @@ -0,0 +1,106 @@ +use std::fs::File; +use std::io; +use std::error::Error; +use std::os::unix::io::AsRawFd; + +macro_rules! impl_debug_display { + ($target:ident) => { + impl ::std::fmt::Display for $target { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::fmt(self, f) + } + } + } +} + +#[repr(i32)] +pub enum Command { + RunCode = 0x1001, +} + +#[derive(Debug)] +pub enum ServiceError { + Io(io::Error), + InvalidInput, + Rejected +} + +pub type ServiceResult = Result; + +impl_debug_display!(ServiceError); + +impl Error for ServiceError { + fn description(&self) -> &str { + "ServiceError" + } +} + +impl From for ServiceError { + fn from(other: io::Error) -> ServiceError { + ServiceError::Io(other) + } +} + +#[repr(C)] +struct RunCodeRequest { + code: *const u8, + code_len: u32, + memory: *const u8, + memory_len: u32, + memory_max: u32, + table: *const u32, + table_count: u32, + globals: *const u64, + global_count: u32, + + entry_offset: u32, + params: *const u64, + param_count: u32, +} + +pub struct RunProfile<'a> { + pub code: &'a [u8], + pub memory: Option<&'a [u8]>, + pub memory_max: usize, + pub globals: &'a [u64], + pub params: &'a [u64], + pub entry_offset: u32, +} + +pub struct ServiceContext { + dev: File +} + +impl ServiceContext { + pub fn connect() -> ServiceResult { + Ok(ServiceContext { + dev: File::open("/dev/wasmctl")? + }) + } + + pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { + let req = RunCodeRequest { + code: run.code.as_ptr(), + code_len: run.code.len() as u32, + memory: run.memory.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), + memory_len: run.memory.map(|x| x.len() as u32).unwrap_or(0), + memory_max: run.memory_max as u32, + table: ::std::ptr::null(), + table_count: 0, + globals: run.globals.as_ptr(), + global_count: run.globals.len() as u32, + params: run.params.as_ptr(), + param_count: run.params.len() as u32, + entry_offset: run.entry_offset, + }; + let fd = self.dev.as_raw_fd(); + let ret = unsafe { + ::libc::ioctl( + fd, + Command::RunCode as i32 as ::libc::c_ulong, + &req as *const _ as ::libc::c_ulong + ) + }; + Ok(ret) + } +} diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 548a64279b1..bf891dcd888 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -23,7 +23,7 @@ use wasmer_runtime::{ use wasmer_runtime_core::{ self, backend::{Compiler, CompilerConfig}, - loader::{self, Loader, Instance as _, LocalLoader}, + loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, }; #[cfg(feature = "backend:singlepass")] use wasmer_singlepass_backend::SinglePassCompiler; @@ -110,12 +110,14 @@ struct Run { #[derive(Debug, Copy, Clone)] enum LoaderName { Local, + Kernel, } impl LoaderName { pub fn variants() -> &'static [&'static str] { &[ "local", + "kernel", ] } } @@ -125,6 +127,7 @@ impl FromStr for LoaderName { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "local" => Ok(LoaderName::Local), + "kernel" => Ok(LoaderName::Kernel), _ => Err(format!("The loader {} doesn't exist", s)), } } @@ -348,12 +351,11 @@ fn execute_wasm(options: &Run) -> Result<(), String> { .map(|x| Value::I32(x.parse().unwrap())) .collect(); let index = instance.resolve_local_func("main").unwrap(); - match loader { - LoaderName::Local => { - let mut ins = instance.load(LocalLoader).unwrap(); - println!("{:?}", ins.call(index, &args)); - }, - } + let mut ins: Box> = match loader { + LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), + LoaderName::Kernel => Box::new(instance.load(::kwasm_loader::KernelLoader).unwrap()), + }; + println!("{:?}", ins.call(index, &args)); return Ok(()) } From 7a4b2172a553b7b860e5efd8aaaa6919c1eb03b2 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 07:25:11 -0700 Subject: [PATCH 03/43] Remove runtime dependence for BrTable --- lib/singlepass-backend/src/codegen_x64.rs | 39 +++++++++-------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 5f4679cef73..1dc932a2037 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -134,7 +134,6 @@ pub struct X64FunctionCode { assembler: Option, function_labels: Option)>>, - br_table_data: Option>>, breakpoints: Option>>, returns: SmallVec<[WpType; 1]>, locals: Vec, @@ -161,7 +160,6 @@ pub struct X64ExecutionContext { function_pointers: Vec, function_offsets: Vec, signatures: Arc>, - _br_table_data: Vec>, breakpoints: Arc>>, func_import_count: usize, } @@ -309,18 +307,16 @@ impl ModuleCodeGenerator } fn next_function(&mut self) -> Result<&mut X64FunctionCode, CodegenError> { - let (mut assembler, mut function_labels, br_table_data, breakpoints) = + let (mut assembler, mut function_labels, breakpoints) = match self.functions.last_mut() { Some(x) => ( x.assembler.take().unwrap(), x.function_labels.take().unwrap(), - x.br_table_data.take().unwrap(), x.breakpoints.take().unwrap(), ), None => ( self.assembler.take().unwrap(), self.function_labels.take().unwrap(), - vec![], HashMap::new(), ), }; @@ -343,7 +339,6 @@ impl ModuleCodeGenerator assembler: Some(assembler), function_labels: Some(function_labels), - br_table_data: Some(br_table_data), breakpoints: Some(breakpoints), returns: smallvec![], locals: vec![], @@ -359,10 +354,9 @@ impl ModuleCodeGenerator } fn finalize(mut self, _: &ModuleInfo) -> Result { - let (assembler, mut br_table_data, breakpoints) = match self.functions.last_mut() { + let (assembler, breakpoints) = match self.functions.last_mut() { Some(x) => ( x.assembler.take().unwrap(), - x.br_table_data.take().unwrap(), x.breakpoints.take().unwrap(), ), None => { @@ -373,12 +367,6 @@ impl ModuleCodeGenerator }; let output = assembler.finalize().unwrap(); - for table in &mut br_table_data { - for entry in table { - *entry = output.ptr(AssemblyOffset(*entry)) as usize; - } - } - let function_labels = if let Some(x) = self.functions.last() { x.function_labels.as_ref().unwrap() } else { @@ -419,7 +407,6 @@ impl ModuleCodeGenerator code: output, functions: self.functions, signatures: self.signatures.as_ref().unwrap().clone(), - _br_table_data: br_table_data, breakpoints: breakpoints, func_import_count: self.func_import_count, function_pointers: out_labels, @@ -4051,7 +4038,8 @@ impl FunctionCodeGenerator for X64FunctionCode { let (targets, default_target) = table.read_table().unwrap(); let cond = get_location_released(a, &mut self.machine, self.value_stack.pop().unwrap()); - let mut table = vec![0usize; targets.len()]; + let mut table_label = a.get_label(); + let mut table: Vec = vec![]; let default_br = a.get_label(); Self::emit_relaxed_binop( a, @@ -4063,19 +4051,19 @@ impl FunctionCodeGenerator for X64FunctionCode { ); a.emit_jmp(Condition::AboveEqual, default_br); - a.emit_mov( - Size::S64, - Location::Imm64(table.as_ptr() as usize as u64), + a.emit_lea_label( + table_label, Location::GPR(GPR::RCX), ); a.emit_mov(Size::S32, cond, Location::GPR(GPR::RDX)); - a.emit_shl(Size::S32, Location::Imm8(3), Location::GPR(GPR::RDX)); + a.emit_imul_imm32_gpr64(5, GPR::RDX); a.emit_add(Size::S64, Location::GPR(GPR::RCX), Location::GPR(GPR::RDX)); - a.emit_jmp_location(Location::Memory(GPR::RDX, 0)); + a.emit_jmp_location(Location::GPR(GPR::RDX)); for (i, target) in targets.iter().enumerate() { - let AssemblyOffset(offset) = a.offset(); - table[i] = offset; + let label = a.get_label(); + a.emit_label(label); + table.push(label); let frame = &self.control_stack[self.control_stack.len() - 1 - (*target as usize)]; if !frame.loop_like && frame.returns.len() > 0 { @@ -4110,7 +4098,10 @@ impl FunctionCodeGenerator for X64FunctionCode { a.emit_jmp(Condition::None, frame.label); } - self.br_table_data.as_mut().unwrap().push(table); + a.emit_label(table_label); + for x in table { + a.emit_jmp(Condition::None, x); + } self.unreachable_depth = 1; } Operator::Drop => { From af0b1476f3a05071101f7e67f3439d3efd9d436f Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 07:25:29 -0700 Subject: [PATCH 04/43] Add emit_u64 to Emitter API --- lib/singlepass-backend/src/emitter_x64.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/singlepass-backend/src/emitter_x64.rs b/lib/singlepass-backend/src/emitter_x64.rs index 889b1099db1..f94de7013b3 100644 --- a/lib/singlepass-backend/src/emitter_x64.rs +++ b/lib/singlepass-backend/src/emitter_x64.rs @@ -89,6 +89,8 @@ pub trait Emitter { fn get_label(&mut self) -> Self::Label; fn get_offset(&mut self) -> Self::Offset; + fn emit_u64(&mut self, x: u64); + fn emit_label(&mut self, label: Self::Label); fn emit_mov(&mut self, sz: Size, src: Location, dst: Location); @@ -490,6 +492,10 @@ impl Emitter for Assembler { self.offset() } + fn emit_u64(&mut self, x: u64) { + self.push_u64(x); + } + fn emit_label(&mut self, label: Self::Label) { dynasm!(self ; => label); } From c4e4efc694ca043aa3c4200f738e6883c854afba Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 08:28:13 -0700 Subject: [PATCH 05/43] kwasm imports --- lib/kwasm-loader/src/lib.rs | 8 ++++++++ lib/kwasm-loader/src/service.rs | 21 +++++++++++++++++++++ lib/runtime-core/src/backing.rs | 15 +++++++++++---- lib/runtime-core/src/import.rs | 4 ++++ src/bin/wasmer.rs | 3 ++- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 74e76ed511e..3213a18e767 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -34,12 +34,18 @@ impl Loader for KernelLoader { let globals: &[*mut LocalGlobal] = ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); globals.iter().map(|x| (**x).data).collect() }; + let mut import_names: Vec = vec![]; + for (_, import) in &module.imported_functions { + let name = format!("{}##{}", module.namespace_table.get(import.namespace_index), module.name_table.get(import.name_index)); + import_names.push(name); + } Ok(KernelInstance { context: ServiceContext::connect().map_err(|x| format!("{:?}", x))?, code: code.to_vec(), memory: memory, globals: globals, offsets: rm.get_offsets().unwrap(), + import_names: import_names, }) } } @@ -50,6 +56,7 @@ pub struct KernelInstance { memory: Option>, globals: Vec, offsets: Vec, + import_names: Vec, } impl Instance for KernelInstance { @@ -64,6 +71,7 @@ impl Instance for KernelInstance { globals: &self.globals, params: &args, entry_offset: self.offsets[id] as u32, + imports: &self.import_names, }).map_err(|x| format!("{:?}", x))?; Ok(ret as u64) } diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index 0517ff1c503..194c639e30f 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -53,11 +53,19 @@ struct RunCodeRequest { globals: *const u64, global_count: u32, + imported_funcs: *const ImportRequest, + imported_func_count: u32, + entry_offset: u32, params: *const u64, param_count: u32, } +#[repr(C)] +struct ImportRequest { + name: [u8; 64], +} + pub struct RunProfile<'a> { pub code: &'a [u8], pub memory: Option<&'a [u8]>, @@ -65,6 +73,7 @@ pub struct RunProfile<'a> { pub globals: &'a [u64], pub params: &'a [u64], pub entry_offset: u32, + pub imports: &'a [String] } pub struct ServiceContext { @@ -79,6 +88,16 @@ impl ServiceContext { } pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { + let imports: Vec = run.imports.iter().map(|x| { + let mut req: ImportRequest = unsafe { ::std::mem::zeroed() }; + let x = x.as_bytes(); + let mut count = req.name.len() - 1; + if x.len() < count { + count = x.len(); + } + req.name[..count].copy_from_slice(&x[..count]); + req + }).collect(); let req = RunCodeRequest { code: run.code.as_ptr(), code_len: run.code.len() as u32, @@ -89,6 +108,8 @@ impl ServiceContext { table_count: 0, globals: run.globals.as_ptr(), global_count: run.globals.len() as u32, + imported_funcs: imports.as_ptr(), + imported_func_count: imports.len() as u32, params: run.params.as_ptr(), param_count: run.params.len() as u32, entry_offset: run.entry_offset, diff --git a/lib/runtime-core/src/backing.rs b/lib/runtime-core/src/backing.rs index b79180ad6d5..23aaf2f8ad8 100644 --- a/lib/runtime-core/src/backing.rs +++ b/lib/runtime-core/src/backing.rs @@ -449,10 +449,17 @@ fn import_functions( }); } None => { - link_errors.push(LinkError::ImportNotFound { - namespace: namespace.to_string(), - name: name.to_string(), - }); + if imports.allow_missing_functions { + functions.push(vm::ImportedFunc { + func: ::std::ptr::null(), + vmctx: ::std::ptr::null_mut(), + }); + } else { + link_errors.push(LinkError::ImportNotFound { + namespace: namespace.to_string(), + name: name.to_string(), + }); + } } } } diff --git a/lib/runtime-core/src/import.rs b/lib/runtime-core/src/import.rs index 14465deedd3..9522b0829fa 100644 --- a/lib/runtime-core/src/import.rs +++ b/lib/runtime-core/src/import.rs @@ -47,6 +47,7 @@ impl IsExport for Export { pub struct ImportObject { map: Rc>>>, state_creator: Option (*mut c_void, fn(*mut c_void))>>, + pub allow_missing_functions: bool, } impl ImportObject { @@ -55,6 +56,7 @@ impl ImportObject { Self { map: Rc::new(RefCell::new(HashMap::new())), state_creator: None, + allow_missing_functions: false, } } @@ -65,6 +67,7 @@ impl ImportObject { Self { map: Rc::new(RefCell::new(HashMap::new())), state_creator: Some(Rc::new(state_creator)), + allow_missing_functions: false, } } @@ -116,6 +119,7 @@ impl ImportObject { Self { map: Rc::clone(&self.map), state_creator: self.state_creator.clone(), + allow_missing_functions: false, } } diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index bf891dcd888..f8f6e71c7c8 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -339,7 +339,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> { }; if let Some(loader) = options.loader { - let import_object = wasmer_runtime_core::import::ImportObject::new(); + let mut import_object = wasmer_runtime_core::import::ImportObject::new(); + import_object.allow_missing_functions = true; // Import initialization might be left to the loader. let instance = module .instantiate(&import_object) .map_err(|e| format!("Can't instantiate module: {:?}", e))?; From a590d7cd078c73fa206a9ac773570601caac3922 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 09:56:52 -0700 Subject: [PATCH 06/43] Tables --- lib/kwasm-loader/src/lib.rs | 40 ++++++++++++++++++++++++++++---- lib/kwasm-loader/src/service.rs | 21 +++++++++++++---- lib/runtime-core/src/instance.rs | 2 +- lib/runtime-core/src/loader.rs | 6 ++--- lib/runtime-core/src/vm.rs | 9 ++++++- 5 files changed, 65 insertions(+), 13 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 3213a18e767..2afea2ce78d 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -3,12 +3,12 @@ pub mod service; use wasmer_runtime_core::{ loader::{self, Loader, Instance}, backend::RunnableModule, - vm::{InternalCtx, LocalGlobal}, + vm::{Ctx, LocalGlobal, SigId, Anyfunc}, module::ModuleInfo, - types::{Value, LocalMemoryIndex, ImportedMemoryIndex}, + types::{Value, LocalMemoryIndex, LocalTableIndex, ImportedMemoryIndex, ImportedTableIndex}, structures::TypedIndex, }; -use service::{ServiceContext, RunProfile}; +use service::{ServiceContext, RunProfile, TableEntryRequest}; pub struct KernelLoader; @@ -16,7 +16,8 @@ impl Loader for KernelLoader { type Instance = KernelInstance; type Error = String; - fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result { + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, full_ctx: &Ctx) -> Result { + let ctx = &full_ctx.internal; let code = rm.get_code().unwrap(); let memory = if let Some(_) = module.memories.get(LocalMemoryIndex::new(0)) { Some(unsafe { @@ -27,6 +28,29 @@ impl Loader for KernelLoader { } else { None }; + let table: Option> = if let Some(_) = module.tables.get(LocalTableIndex::new(0)) { + Some(unsafe { + let table = &**ctx.tables; + let elements: &[Anyfunc] = ::std::slice::from_raw_parts(table.base as *const Anyfunc, table.count); + let base_addr = code.as_ptr() as usize; + let end_addr = base_addr + code.len(); + elements.iter().map(|x| { + let func_addr = x.func as usize; + TableEntryRequest { + offset: if x.func.is_null() || func_addr < base_addr || func_addr >= end_addr { + ::std::usize::MAX + } else { + x.func as usize - base_addr + }, + sig_id: x.sig_id.0, + } + }).collect() + }) + } else if let Some(_) = module.imported_tables.get(ImportedTableIndex::new(0)) { + return Err("imported table is not supported".into()); + } else { + None + }; if module.imported_globals.len() > 0 { return Err("imported globals are not supported".into()); } @@ -43,9 +67,13 @@ impl Loader for KernelLoader { context: ServiceContext::connect().map_err(|x| format!("{:?}", x))?, code: code.to_vec(), memory: memory, + table: table, globals: globals, offsets: rm.get_offsets().unwrap(), import_names: import_names, + dynamic_sigindices: unsafe { + ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) + }.iter().map(|x| x.0).collect(), }) } } @@ -54,9 +82,11 @@ pub struct KernelInstance { context: ServiceContext, code: Vec, memory: Option>, + table: Option>, globals: Vec, offsets: Vec, import_names: Vec, + dynamic_sigindices: Vec, } impl Instance for KernelInstance { @@ -72,6 +102,8 @@ impl Instance for KernelInstance { params: &args, entry_offset: self.offsets[id] as u32, imports: &self.import_names, + dynamic_sigindices: &self.dynamic_sigindices, + table: self.table.as_ref().map(|x| x.as_slice()), }).map_err(|x| format!("{:?}", x))?; Ok(ret as u64) } diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index 194c639e30f..8cac49c8ef5 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -48,7 +48,7 @@ struct RunCodeRequest { memory: *const u8, memory_len: u32, memory_max: u32, - table: *const u32, + table: *const TableEntryRequest, table_count: u32, globals: *const u64, global_count: u32, @@ -56,6 +56,9 @@ struct RunCodeRequest { imported_funcs: *const ImportRequest, imported_func_count: u32, + dynamic_sigindices: *const u32, + dynamic_sigindice_count: u32, + entry_offset: u32, params: *const u64, param_count: u32, @@ -66,6 +69,12 @@ struct ImportRequest { name: [u8; 64], } +#[repr(C)] +pub struct TableEntryRequest { + pub offset: usize, + pub sig_id: u32, +} + pub struct RunProfile<'a> { pub code: &'a [u8], pub memory: Option<&'a [u8]>, @@ -73,7 +82,9 @@ pub struct RunProfile<'a> { pub globals: &'a [u64], pub params: &'a [u64], pub entry_offset: u32, - pub imports: &'a [String] + pub imports: &'a [String], + pub dynamic_sigindices: &'a [u32], + pub table: Option<&'a [TableEntryRequest]>, } pub struct ServiceContext { @@ -104,12 +115,14 @@ impl ServiceContext { memory: run.memory.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), memory_len: run.memory.map(|x| x.len() as u32).unwrap_or(0), memory_max: run.memory_max as u32, - table: ::std::ptr::null(), - table_count: 0, + table: run.table.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), + table_count: run.table.map(|x| x.len() as u32).unwrap_or(0), globals: run.globals.as_ptr(), global_count: run.globals.len() as u32, imported_funcs: imports.as_ptr(), imported_func_count: imports.len() as u32, + dynamic_sigindices: run.dynamic_sigindices.as_ptr(), + dynamic_sigindice_count: run.dynamic_sigindices.len() as u32, params: run.params.as_ptr(), param_count: run.params.len() as u32, entry_offset: run.entry_offset, diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index d826999731f..f6d6a7a0cd2 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -130,7 +130,7 @@ impl Instance { } pub fn load(&self, loader: T) -> ::std::result::Result { - loader.load(&*self.module.runnable_module, &self.module.info, unsafe { &(*self.inner.vmctx).internal }) + loader.load(&*self.module.runnable_module, &self.module.info, unsafe { &*self.inner.vmctx }) } /// Through generic magic and the awe-inspiring power of traits, we bring you... diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index 57885891a94..b109ddb1460 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -4,7 +4,7 @@ use std::{ }; use crate::{ backend::RunnableModule, - vm::InternalCtx, + vm::Ctx, module::ModuleInfo, types::Value, }; @@ -17,7 +17,7 @@ pub trait Loader { type Instance: Instance; type Error: Debug; - fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result; + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &Ctx) -> Result; } pub trait Instance { @@ -31,7 +31,7 @@ impl Loader for LocalLoader { type Instance = LocalInstance; type Error = String; - fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &InternalCtx) -> Result { + fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &Ctx) -> Result { let code = rm.get_code().unwrap(); let mut code_mem = CodeMemory::new(code.len()); code_mem[..code.len()].copy_from_slice(code); diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 7d9039b7d36..2ef51c8690e 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -16,7 +16,7 @@ use hashbrown::HashMap; #[repr(C)] pub struct Ctx { // `internal` must be the first field of `Ctx`. - pub(crate) internal: InternalCtx, + pub internal: InternalCtx, pub(crate) local_functions: *const *const Func, @@ -163,6 +163,13 @@ impl Ctx { pub unsafe fn borrow_symbol_map(&self) -> &Option> { &(*self.module).info.em_symbol_map } + + /// Returns the number of dynamic sigindices. + pub fn dynamic_sigindice_count(&self) -> usize { + unsafe { + (*self.local_backing).dynamic_sigindices.len() + } + } } #[doc(hidden)] From 46e4cb05bc862920e78eff855ea6e52b3292d55d Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 10:33:12 -0700 Subject: [PATCH 07/43] Get memory intrinsics at runtime. --- lib/runtime-core/src/vm.rs | 94 ++++++++++++++++++++++- lib/singlepass-backend/src/codegen_x64.rs | 68 +++++----------- 2 files changed, 111 insertions(+), 51 deletions(-) diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 2ef51c8690e..965e5ef1d10 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -1,9 +1,11 @@ pub use crate::backing::{ImportBacking, LocalBacking}; use crate::{ - memory::Memory, - module::ModuleInner, + memory::{Memory, MemoryType}, + module::{ModuleInfo, ModuleInner}, structures::TypedIndex, - types::{LocalOrImport, MemoryIndex}, + types::{LocalOrImport, MemoryIndex, LocalMemoryIndex}, + units::{Pages}, + vmcalls, }; use std::{ffi::c_void, mem, ptr}; @@ -61,6 +63,77 @@ pub struct InternalCtx { /// signature id. This is used to allow call-indirect to other /// modules safely. pub dynamic_sigindices: *const SigId, + + pub intrinsics: *const Intrinsics, +} + +#[repr(C)] +pub struct Intrinsics { + pub memory_grow: *const Func, + pub memory_size: *const Func, + /*pub memory_grow: unsafe extern "C" fn( + ctx: &mut Ctx, + memory_index: usize, + delta: Pages, + ) -> i32, + pub memory_size: unsafe extern "C" fn( + ctx: &Ctx, + memory_index: usize, + ) -> Pages,*/ +} + +unsafe impl Send for Intrinsics {} +unsafe impl Sync for Intrinsics {} + +impl Intrinsics { + pub fn offset_memory_grow() -> u8 { + (0 * ::std::mem::size_of::()) as u8 + } + pub fn offset_memory_size() -> u8 { + (1 * ::std::mem::size_of::()) as u8 + } +} + +pub static INTRINSICS_LOCAL_STATIC_MEMORY: Intrinsics = Intrinsics { + memory_grow: vmcalls::local_static_memory_grow as _, + memory_size: vmcalls::local_static_memory_size as _, +}; +pub static INTRINSICS_LOCAL_DYNAMIC_MEMORY: Intrinsics = Intrinsics { + memory_grow: vmcalls::local_dynamic_memory_grow as _, + memory_size: vmcalls::local_dynamic_memory_size as _, +}; +pub static INTRINSICS_IMPORTED_STATIC_MEMORY: Intrinsics = Intrinsics { + memory_grow: vmcalls::imported_static_memory_grow as _, + memory_size: vmcalls::imported_static_memory_size as _, +}; +pub static INTRINSICS_IMPORTED_DYNAMIC_MEMORY: Intrinsics = Intrinsics { + memory_grow: vmcalls::imported_dynamic_memory_grow as _, + memory_size: vmcalls::imported_dynamic_memory_size as _, +}; + +fn get_intrinsics_for_module(m: &ModuleInfo) -> *const Intrinsics { + if m.memories.len() == 0 && m.imported_memories.len() == 0 { + ::std::ptr::null() + } else { + match MemoryIndex::new(0).local_or_import(m) { + LocalOrImport::Local(local_mem_index) => { + let mem_desc = &m.memories[local_mem_index]; + match mem_desc.memory_type() { + MemoryType::Dynamic => &INTRINSICS_LOCAL_DYNAMIC_MEMORY, + MemoryType::Static => &INTRINSICS_LOCAL_STATIC_MEMORY, + MemoryType::SharedStatic => unimplemented!(), + } + } + LocalOrImport::Import(import_mem_index) => { + let mem_desc = &m.imported_memories[import_mem_index].1; + match mem_desc.memory_type() { + MemoryType::Dynamic => &INTRINSICS_IMPORTED_DYNAMIC_MEMORY, + MemoryType::Static => &INTRINSICS_IMPORTED_STATIC_MEMORY, + MemoryType::SharedStatic => unimplemented!(), + } + } + } + } } impl Ctx { @@ -82,6 +155,8 @@ impl Ctx { imported_funcs: import_backing.vm_functions.as_mut_ptr(), dynamic_sigindices: local_backing.dynamic_sigindices.as_ptr(), + + intrinsics: get_intrinsics_for_module(&module.info), }, local_functions: local_backing.local_functions.as_ptr(), @@ -114,6 +189,8 @@ impl Ctx { imported_funcs: import_backing.vm_functions.as_mut_ptr(), dynamic_sigindices: local_backing.dynamic_sigindices.as_ptr(), + + intrinsics: get_intrinsics_for_module(&module.info), }, local_functions: local_backing.local_functions.as_ptr(), @@ -207,9 +284,13 @@ impl Ctx { 7 * (mem::size_of::() as u8) } - pub fn offset_local_functions() -> u8 { + pub fn offset_intrinsics() -> u8 { 8 * (mem::size_of::() as u8) } + + pub fn offset_local_functions() -> u8 { + 9 * (mem::size_of::() as u8) + } } enum InnerFunc {} @@ -403,6 +484,11 @@ mod vm_offset_tests { offset_of!(InternalCtx => imported_funcs).get_byte_offset(), ); + assert_eq!( + Ctx::offset_intrinsics() as usize, + offset_of!(InternalCtx => intrinsics).get_byte_offset(), + ); + assert_eq!( Ctx::offset_local_functions() as usize, offset_of!(Ctx => local_functions).get_byte_offset(), diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 1dc932a2037..0697d70e40d 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -3284,33 +3284,20 @@ impl FunctionCodeGenerator for X64FunctionCode { Operator::Nop => {} Operator::MemorySize { reserved } => { let memory_index = MemoryIndex::new(reserved as usize); - let target: usize = match memory_index.local_or_import(module_info) { - LocalOrImport::Local(local_mem_index) => { - let mem_desc = &module_info.memories[local_mem_index]; - match mem_desc.memory_type() { - MemoryType::Dynamic => vmcalls::local_dynamic_memory_size as usize, - MemoryType::Static => vmcalls::local_static_memory_size as usize, - MemoryType::SharedStatic => unimplemented!(), - } - } - LocalOrImport::Import(import_mem_index) => { - let mem_desc = &module_info.imported_memories[import_mem_index].1; - match mem_desc.memory_type() { - MemoryType::Dynamic => vmcalls::imported_dynamic_memory_size as usize, - MemoryType::Static => vmcalls::imported_static_memory_size as usize, - MemoryType::SharedStatic => unimplemented!(), - } - } - }; + a.emit_mov( + Size::S64, + Location::Memory(Machine::get_vmctx_reg(), vm::Ctx::offset_intrinsics() as i32), + Location::GPR(GPR::RAX) + ); + a.emit_mov( + Size::S64, + Location::Memory(GPR::RAX, vm::Intrinsics::offset_memory_size() as i32), + Location::GPR(GPR::RAX) + ); Self::emit_call_sysv( a, &mut self.machine, |a| { - a.emit_mov( - Size::S64, - Location::Imm64(target as u64), - Location::GPR(GPR::RAX), - ); a.emit_call_location(Location::GPR(GPR::RAX)); }, ::std::iter::once(Location::Imm32(memory_index.index() as u32)), @@ -3321,40 +3308,27 @@ impl FunctionCodeGenerator for X64FunctionCode { } Operator::MemoryGrow { reserved } => { let memory_index = MemoryIndex::new(reserved as usize); - let target: usize = match memory_index.local_or_import(module_info) { - LocalOrImport::Local(local_mem_index) => { - let mem_desc = &module_info.memories[local_mem_index]; - match mem_desc.memory_type() { - MemoryType::Dynamic => vmcalls::local_dynamic_memory_grow as usize, - MemoryType::Static => vmcalls::local_static_memory_grow as usize, - MemoryType::SharedStatic => unimplemented!(), - } - } - LocalOrImport::Import(import_mem_index) => { - let mem_desc = &module_info.imported_memories[import_mem_index].1; - match mem_desc.memory_type() { - MemoryType::Dynamic => vmcalls::imported_dynamic_memory_grow as usize, - MemoryType::Static => vmcalls::imported_static_memory_grow as usize, - MemoryType::SharedStatic => unimplemented!(), - } - } - }; - let (param_pages, param_pages_lot) = self.value_stack.pop().unwrap(); if param_pages_lot == LocalOrTemp::Temp { self.machine.release_locations_only_regs(&[param_pages]); } + a.emit_mov( + Size::S64, + Location::Memory(Machine::get_vmctx_reg(), vm::Ctx::offset_intrinsics() as i32), + Location::GPR(GPR::RAX) + ); + a.emit_mov( + Size::S64, + Location::Memory(GPR::RAX, vm::Intrinsics::offset_memory_grow() as i32), + Location::GPR(GPR::RAX) + ); + Self::emit_call_sysv( a, &mut self.machine, |a| { - a.emit_mov( - Size::S64, - Location::Imm64(target as u64), - Location::GPR(GPR::RAX), - ); a.emit_call_location(Location::GPR(GPR::RAX)); }, ::std::iter::once(Location::Imm32(memory_index.index() as u32)) From 3c64bd009ea45c89d105a11ba2ec45bbc4e0e3a7 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sat, 4 May 2019 10:51:12 -0700 Subject: [PATCH 08/43] Kernel mode example. --- Cargo.lock | 4 ++++ Cargo.toml | 2 +- examples/kernel/hello_world/Cargo.toml | 10 ++++++++++ examples/kernel/hello_world/src/lib.rs | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 examples/kernel/hello_world/Cargo.toml create mode 100644 examples/kernel/hello_world/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 6ecc90bd1b6..0064d85532c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,6 +772,10 @@ dependencies = [ "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hello_world" +version = "0.1.0" + [[package]] name = "hex" version = "0.3.2" diff --git a/Cargo.toml b/Cargo.toml index 91628b2ddf1..b34b277152d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/kernel/hello_world/Cargo.toml b/examples/kernel/hello_world/Cargo.toml new file mode 100644 index 00000000000..b6d6f2fde7f --- /dev/null +++ b/examples/kernel/hello_world/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "hello_world" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +[dependencies] diff --git a/examples/kernel/hello_world/src/lib.rs b/examples/kernel/hello_world/src/lib.rs new file mode 100644 index 00000000000..43b7df332b1 --- /dev/null +++ b/examples/kernel/hello_world/src/lib.rs @@ -0,0 +1,14 @@ +extern "C" { + fn print_str(base: *const u8, len: usize) -> i32; +} + +#[no_mangle] +pub extern "C" fn main() -> i32 { + let v: Vec = (0..10).collect(); + let s = format!("Hello world from WebAssembly. Some heap allocated integers: {:?}", v); + let s = s.as_bytes(); + unsafe { + print_str(s.as_ptr(), s.len()); + } + return 0; +} From cc01e40dc52d07cc05fabcf6ecbfb1439bccc3bf Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sun, 5 May 2019 05:03:07 -0700 Subject: [PATCH 09/43] Split load/run --- lib/kwasm-loader/src/lib.rs | 44 +++++++++---------- lib/kwasm-loader/src/service.rs | 75 +++++++++++++++++++++------------ 2 files changed, 68 insertions(+), 51 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 2afea2ce78d..0acd356ffc0 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -8,7 +8,7 @@ use wasmer_runtime_core::{ types::{Value, LocalMemoryIndex, LocalTableIndex, ImportedMemoryIndex, ImportedTableIndex}, structures::TypedIndex, }; -use service::{ServiceContext, RunProfile, TableEntryRequest}; +use service::{ServiceContext, LoadProfile, RunProfile, TableEntryRequest}; pub struct KernelLoader; @@ -22,7 +22,7 @@ impl Loader for KernelLoader { let memory = if let Some(_) = module.memories.get(LocalMemoryIndex::new(0)) { Some(unsafe { ::std::slice::from_raw_parts((**ctx.memories).base, (**ctx.memories).bound) - }.to_vec()) + }) } else if let Some(_) = module.imported_memories.get(ImportedMemoryIndex::new(0)) { return Err("imported memory is not supported".into()); } else { @@ -63,30 +63,31 @@ impl Loader for KernelLoader { let name = format!("{}##{}", module.namespace_table.get(import.namespace_index), module.name_table.get(import.name_index)); import_names.push(name); } - Ok(KernelInstance { - context: ServiceContext::connect().map_err(|x| format!("{:?}", x))?, - code: code.to_vec(), + let dynamic_sigindices: &[u32] = unsafe { + ::std::mem::transmute::<&[SigId], &[u32]>( + ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) + ) + }; + let profile = LoadProfile { + code: code, memory: memory, - table: table, - globals: globals, + memory_max: 0, + globals: &globals, + imports: &import_names, + dynamic_sigindices: dynamic_sigindices, + table: table.as_ref().map(|x| x.as_slice()), + }; + let sc = ServiceContext::new(profile).map_err(|x| format!("{:?}", x))?; + Ok(KernelInstance { + context: sc, offsets: rm.get_offsets().unwrap(), - import_names: import_names, - dynamic_sigindices: unsafe { - ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) - }.iter().map(|x| x.0).collect(), }) } } pub struct KernelInstance { context: ServiceContext, - code: Vec, - memory: Option>, - table: Option>, - globals: Vec, offsets: Vec, - import_names: Vec, - dynamic_sigindices: Vec, } impl Instance for KernelInstance { @@ -95,15 +96,8 @@ impl Instance for KernelInstance { let args: Vec = args.iter().map(|x| x.to_u64()).collect(); let ret = self.context.run_code(RunProfile { - code: &self.code, - memory: if let Some(ref x) = self.memory { Some(&*x) } else { None }, - memory_max: 0, - globals: &self.globals, - params: &args, entry_offset: self.offsets[id] as u32, - imports: &self.import_names, - dynamic_sigindices: &self.dynamic_sigindices, - table: self.table.as_ref().map(|x| x.as_slice()), + params: &args, }).map_err(|x| format!("{:?}", x))?; Ok(ret as u64) } diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index 8cac49c8ef5..eaa8230a9b3 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -15,12 +15,14 @@ macro_rules! impl_debug_display { #[repr(i32)] pub enum Command { - RunCode = 0x1001, + LoadCode = 0x1001, + RunCode = 0x1002, } #[derive(Debug)] pub enum ServiceError { Io(io::Error), + Code(i32), InvalidInput, Rejected } @@ -42,7 +44,7 @@ impl From for ServiceError { } #[repr(C)] -struct RunCodeRequest { +struct LoadCodeRequest { code: *const u8, code_len: u32, memory: *const u8, @@ -58,7 +60,10 @@ struct RunCodeRequest { dynamic_sigindices: *const u32, dynamic_sigindice_count: u32, +} +#[repr(C)] +struct RunCodeRequest { entry_offset: u32, params: *const u64, param_count: u32, @@ -75,31 +80,29 @@ pub struct TableEntryRequest { pub sig_id: u32, } -pub struct RunProfile<'a> { +pub struct LoadProfile<'a> { pub code: &'a [u8], pub memory: Option<&'a [u8]>, pub memory_max: usize, pub globals: &'a [u64], - pub params: &'a [u64], - pub entry_offset: u32, pub imports: &'a [String], pub dynamic_sigindices: &'a [u32], pub table: Option<&'a [TableEntryRequest]>, } +pub struct RunProfile<'a> { + pub entry_offset: u32, + pub params: &'a [u64], +} + pub struct ServiceContext { dev: File } impl ServiceContext { - pub fn connect() -> ServiceResult { - Ok(ServiceContext { - dev: File::open("/dev/wasmctl")? - }) - } - - pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { - let imports: Vec = run.imports.iter().map(|x| { + pub fn new(load: LoadProfile) -> ServiceResult { + let dev = File::open("/dev/wasmctl")?; + let imports: Vec = load.imports.iter().map(|x| { let mut req: ImportRequest = unsafe { ::std::mem::zeroed() }; let x = x.as_bytes(); let mut count = req.name.len() - 1; @@ -109,23 +112,43 @@ impl ServiceContext { req.name[..count].copy_from_slice(&x[..count]); req }).collect(); - let req = RunCodeRequest { - code: run.code.as_ptr(), - code_len: run.code.len() as u32, - memory: run.memory.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), - memory_len: run.memory.map(|x| x.len() as u32).unwrap_or(0), - memory_max: run.memory_max as u32, - table: run.table.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), - table_count: run.table.map(|x| x.len() as u32).unwrap_or(0), - globals: run.globals.as_ptr(), - global_count: run.globals.len() as u32, + let req = LoadCodeRequest { + code: load.code.as_ptr(), + code_len: load.code.len() as u32, + memory: load.memory.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), + memory_len: load.memory.map(|x| x.len() as u32).unwrap_or(0), + memory_max: load.memory_max as u32, + table: load.table.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), + table_count: load.table.map(|x| x.len() as u32).unwrap_or(0), + globals: load.globals.as_ptr(), + global_count: load.globals.len() as u32, imported_funcs: imports.as_ptr(), imported_func_count: imports.len() as u32, - dynamic_sigindices: run.dynamic_sigindices.as_ptr(), - dynamic_sigindice_count: run.dynamic_sigindices.len() as u32, + dynamic_sigindices: load.dynamic_sigindices.as_ptr(), + dynamic_sigindice_count: load.dynamic_sigindices.len() as u32, + }; + let fd = dev.as_raw_fd(); + let ret = unsafe { + ::libc::ioctl( + fd, + Command::LoadCode as i32 as ::libc::c_ulong, + &req as *const _ as ::libc::c_ulong + ) + }; + if ret != 0 { + Err(ServiceError::Code(ret)) + } else { + Ok(ServiceContext { + dev: dev, + }) + } + } + + pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { + let req = RunCodeRequest { + entry_offset: run.entry_offset, params: run.params.as_ptr(), param_count: run.params.len() as u32, - entry_offset: run.entry_offset, }; let fd = self.dev.as_raw_fd(); let ret = unsafe { From 7bc09ee22055ee3add3eb50e86ee960afb6cb99e Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Sun, 5 May 2019 09:32:35 -0700 Subject: [PATCH 10/43] kwasmd. --- Cargo.lock | 1 + Cargo.toml | 1 + lib/kwasm-loader/src/lib.rs | 10 +- lib/kwasm-loader/src/service.rs | 86 +++++++++++++++++- lib/runtime-core/src/loader.rs | 7 ++ src/bin/kwasmd.rs | 156 ++++++++++++++++++++++++++++++++ 6 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 src/bin/kwasmd.rs diff --git a/Cargo.lock b/Cargo.lock index 0064d85532c..cefe24d7f3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2240,6 +2240,7 @@ dependencies = [ name = "wasmer" version = "0.4.0" dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index b34b277152d..b11e133408b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ include = [ ] [dependencies] +byteorder = "1.3.1" errno = "0.2.4" structopt = "0.2.11" wabt = "0.7.2" diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 0acd356ffc0..365013f575d 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -99,6 +99,14 @@ impl Instance for KernelInstance { entry_offset: self.offsets[id] as u32, params: &args, }).map_err(|x| format!("{:?}", x))?; - Ok(ret as u64) + Ok(ret) + } + + fn read_memory(&mut self, offset: u32, len: u32) -> Result, String> { + self.context.read_memory(offset, len).map_err(|x| format!("{:?}", x)) + } + + fn write_memory(&mut self, offset: u32, len: u32, buf: &[u8]) -> Result<(), String> { + self.context.write_memory(offset, len, buf).map_err(|x| format!("{:?}", x)) } } \ No newline at end of file diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index eaa8230a9b3..f169327bf32 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -17,6 +17,8 @@ macro_rules! impl_debug_display { pub enum Command { LoadCode = 0x1001, RunCode = 0x1002, + ReadMemory = 0x1003, + WriteMemory = 0x1004, } #[derive(Debug)] @@ -67,6 +69,27 @@ struct RunCodeRequest { entry_offset: u32, params: *const u64, param_count: u32, + result: *mut RunCodeResult, +} + +#[repr(C)] +struct RunCodeResult { + success: u32, + retval: u64, +} + +#[repr(C)] +struct ReadMemoryRequest { + out: *mut u8, + offset: u32, + len: u32, +} + +#[repr(C)] +struct WriteMemoryRequest { + _in: *const u8, + offset: u32, + len: u32, } #[repr(C)] @@ -144,20 +167,75 @@ impl ServiceContext { } } - pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { - let req = RunCodeRequest { + pub fn run_code(&mut self, run: RunProfile) -> ServiceResult { + let mut result: RunCodeResult = unsafe { ::std::mem::zeroed() }; + let mut req = RunCodeRequest { entry_offset: run.entry_offset, params: run.params.as_ptr(), param_count: run.params.len() as u32, + result: &mut result, }; let fd = self.dev.as_raw_fd(); - let ret = unsafe { + let err = unsafe { ::libc::ioctl( fd, Command::RunCode as i32 as ::libc::c_ulong, + &mut req as *mut _ as ::libc::c_ulong + ) + }; + if err < 0 { + Err(ServiceError::Code(err)) + } else if result.success == 0 { + println!("Rejected {} {}", result.success, result.retval); + Err(ServiceError::Rejected) + } else { + Ok(result.retval) + } + } + + pub fn read_memory(&mut self, offset: u32, len: u32) -> ServiceResult> { + let fd = self.dev.as_raw_fd(); + let mut ret = Vec::with_capacity(len as usize); + unsafe { + ret.set_len(len as usize); + } + let req = ReadMemoryRequest { + out: ret.as_mut_ptr(), + offset: offset, + len: len, + }; + let err = unsafe { + ::libc::ioctl( + fd, + Command::ReadMemory as i32 as ::libc::c_ulong, &req as *const _ as ::libc::c_ulong ) }; - Ok(ret) + if err < 0 { + Err(ServiceError::Code(err)) + } else { + Ok(ret) + } + } + + pub fn write_memory(&mut self, offset: u32, len: u32, buf: &[u8]) -> ServiceResult<()> { + let fd = self.dev.as_raw_fd(); + let req = WriteMemoryRequest { + _in: buf.as_ptr(), + offset: offset, + len: len, + }; + let err = unsafe { + ::libc::ioctl( + fd, + Command::WriteMemory as i32 as ::libc::c_ulong, + &req as *const _ as ::libc::c_ulong + ) + }; + if err < 0 { + Err(ServiceError::Code(err)) + } else { + Ok(()) + } } } diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index b109ddb1460..749508a57e4 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -23,6 +23,13 @@ pub trait Loader { pub trait Instance { type Error: Debug; fn call(&mut self, id: usize, args: &[Value]) -> Result; + fn read_memory(&mut self, offset: u32, len: u32) -> Result, Self::Error> { + unimplemented!() + } + + fn write_memory(&mut self, offset: u32, len: u32, buf: &[u8]) -> Result<(), Self::Error> { + unimplemented!() + } } pub struct LocalLoader; diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs new file mode 100644 index 00000000000..994ae73fff3 --- /dev/null +++ b/src/bin/kwasmd.rs @@ -0,0 +1,156 @@ +extern crate structopt; +extern crate byteorder; + +use std::thread; +use structopt::StructOpt; +use wasmer::*; +use wasmer_runtime::{ + error::RuntimeError, + Func, Value, +}; +use wasmer_runtime_core::{ + self, + backend::{Compiler, CompilerConfig}, + loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, +}; +use wasmer_singlepass_backend::SinglePassCompiler; + +use std::os::unix::net::{UnixStream, UnixListener}; +use std::io::prelude::*; + +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; + +#[derive(Debug, StructOpt)] +#[structopt(name = "kwasmd", about = "Kernel-mode WebAssembly service.")] +enum CLIOptions { + #[structopt(name = "listen")] + Listen(Listen), +} + +#[derive(Debug, StructOpt)] +struct Listen { + #[structopt(long = "socket")] + socket: String, +} + +const CMD_RUN_CODE: u32 = 0x901; +const CMD_READ_MEMORY: u32 = 0x902; +const CMD_WRITE_MEMORY: u32 = 0x903; + +fn handle_client(mut stream: UnixStream) { + let binary_size = stream.read_u32::().unwrap(); + if binary_size > 1048576 * 16 { + println!("binary too large"); + return; + } + let mut wasm_binary: Vec = Vec::with_capacity(binary_size as usize); + unsafe { wasm_binary.set_len(binary_size as usize) }; + stream.read_exact(&mut wasm_binary).unwrap(); + let module = webassembly::compile_with_config_with( + &wasm_binary[..], + CompilerConfig { + symbol_map: None, + }, + &SinglePassCompiler::new(), + ).unwrap(); + + let mut import_object = wasmer_runtime_core::import::ImportObject::new(); + import_object.allow_missing_functions = true; // Import initialization might be left to the loader. + let instance = module.instantiate(&import_object).unwrap(); + let mut ins = instance.load(::kwasm_loader::KernelLoader).unwrap(); + + loop { + let cmd = stream.read_u32::().unwrap(); + match cmd { + CMD_RUN_CODE => { + let func_name_len = stream.read_u32::().unwrap(); + if func_name_len > 32 { + println!("function name too long"); + return; + } + let mut func_name: Vec = Vec::with_capacity(func_name_len as usize); + unsafe { func_name.set_len(func_name_len as usize) }; + stream.read_exact(&mut func_name).unwrap(); + let func_name = ::std::str::from_utf8(&func_name).unwrap(); + let arg_count = stream.read_u32::().unwrap(); + if arg_count > 0 { + println!("Too many arguments"); + return; + } + let mut args: Vec = Vec::with_capacity(arg_count as usize); + for _ in 0..arg_count { + args.push(Value::I64(stream.read_u64::().unwrap() as _)); + } + + let index = instance.resolve_local_func(func_name).unwrap(); + let ret = ins.call(index, &args); + match ret { + Ok(x) => { + stream.write_u32::(1).unwrap(); + stream.write_u64::(x).unwrap(); + }, + Err(e) => { + println!("Execution error: {:?}", e); + stream.write_u32::(0).unwrap(); + }, + } + }, + CMD_READ_MEMORY => { + let offset = stream.read_u32::().unwrap(); + let len = stream.read_u32::().unwrap(); + if len > 1048576 * 16 { + println!("memory size too large"); + return; + } + let buf = ins.read_memory(offset, len).unwrap(); + stream.write_all(&buf).unwrap(); + }, + CMD_WRITE_MEMORY => { + let offset = stream.read_u32::().unwrap(); + let len = stream.read_u32::().unwrap(); + if len > 1048576 * 16 { + println!("memory size too large"); + return; + } + let mut buf: Vec = Vec::with_capacity(len as usize); + unsafe { buf.set_len(len as usize) }; + stream.read_exact(&mut buf).unwrap(); + ins.write_memory(offset, len, &buf).unwrap(); + }, + _ => { + println!("Unknown command"); + return; + } + } + } +} + +fn run_listen(opts: Listen) { + let listener = UnixListener::bind(&opts.socket).unwrap(); + for stream in listener.incoming() { + match stream { + Ok(stream) => { + thread::spawn(|| { + match ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { + handle_client(stream); + })) { + Ok(()) => {}, + Err(_) => {} + } + }); + } + Err(err) => { + panic!("{:?}", err); + } + } + } +} + +fn main() { + let options = CLIOptions::from_args(); + match options { + CLIOptions::Listen(listen) => { + run_listen(listen); + } + } +} From 61510f81169edc9c87b6ad03c1e5449de0df1c15 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 6 May 2019 07:15:30 -0700 Subject: [PATCH 11/43] Enforce runtime memory and stack bound check when using kernel loader. --- Cargo.lock | 6 +- lib/runtime-core/src/backend.rs | 9 +-- lib/runtime-core/src/codegen.rs | 2 + lib/runtime-core/src/parse.rs | 2 + lib/runtime-core/src/vm.rs | 17 +++++- lib/singlepass-backend/Cargo.toml | 2 +- lib/singlepass-backend/src/codegen_x64.rs | 69 +++++++++++++++++++++-- src/bin/kwasmd.rs | 2 + src/bin/wasmer.rs | 37 ++++++++---- 9 files changed, 121 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cefe24d7f3d..820dafb0cb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -530,7 +530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "dynasm" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2399,7 +2399,7 @@ name = "wasmer-singlepass-backend" version = "0.3.0" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dynasm 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2645,7 +2645,7 @@ dependencies = [ "checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b77e128faecc4d16cff7cae96c0c9e809f687f748a0dbc4d017996e48240a991" +"checksum dynasm 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f36d49ab6f8ecc642d2c6ee10fda04ba68003ef0277300866745cdde160e6b40" "checksum dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c408a211e7f5762829f5e46bdff0c14bc3b1517a21a4bb781c716bf88b0c68" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index b43bfa75787..b4875b8ae36 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -40,15 +40,12 @@ impl Token { } /// Configuration data for the compiler +#[derive(Default)] pub struct CompilerConfig { /// Symbol information generated from emscripten; used for more detailed debug messages pub symbol_map: Option>, -} - -impl Default for CompilerConfig { - fn default() -> CompilerConfig { - CompilerConfig { symbol_map: None } - } + pub enforce_memory_bound_check: bool, + pub enforce_stack_check: bool, } pub trait Compiler { diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 210a105bede..1b96a942a73 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -43,6 +43,8 @@ pub trait ModuleCodeGenerator, RM: RunnableModule, /// Adds an import function. fn feed_import_function(&mut self) -> Result<(), E>; + + fn feed_compiler_config(&mut self, config: &CompilerConfig) -> Result<(), E> { Ok(()) } } pub struct StreamingCompiler< diff --git a/lib/runtime-core/src/parse.rs b/lib/runtime-core/src/parse.rs index e8fabf1947c..479e25cf7c4 100644 --- a/lib/runtime-core/src/parse.rs +++ b/lib/runtime-core/src/parse.rs @@ -53,6 +53,8 @@ pub fn read_module< middlewares: &mut MiddlewareChain, compiler_config: &CompilerConfig, ) -> Result { + mcg.feed_compiler_config(compiler_config) + .map_err(|x| LoadError::Codegen(format!("{:?}", x)))?; let mut info = ModuleInfo { memories: Map::new(), globals: Map::new(), diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 965e5ef1d10..3e13eaa90de 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -65,6 +65,8 @@ pub struct InternalCtx { pub dynamic_sigindices: *const SigId, pub intrinsics: *const Intrinsics, + + pub stack_lower_bound: *mut u8, } #[repr(C)] @@ -157,6 +159,8 @@ impl Ctx { dynamic_sigindices: local_backing.dynamic_sigindices.as_ptr(), intrinsics: get_intrinsics_for_module(&module.info), + + stack_lower_bound: ::std::ptr::null_mut(), }, local_functions: local_backing.local_functions.as_ptr(), @@ -191,6 +195,8 @@ impl Ctx { dynamic_sigindices: local_backing.dynamic_sigindices.as_ptr(), intrinsics: get_intrinsics_for_module(&module.info), + + stack_lower_bound: ::std::ptr::null_mut(), }, local_functions: local_backing.local_functions.as_ptr(), @@ -288,9 +294,13 @@ impl Ctx { 8 * (mem::size_of::() as u8) } - pub fn offset_local_functions() -> u8 { + pub fn offset_stack_lower_bound() -> u8 { 9 * (mem::size_of::() as u8) } + + pub fn offset_local_functions() -> u8 { + 10 * (mem::size_of::() as u8) + } } enum InnerFunc {} @@ -489,6 +499,11 @@ mod vm_offset_tests { offset_of!(InternalCtx => intrinsics).get_byte_offset(), ); + assert_eq!( + Ctx::offset_stack_lower_bound() as usize, + offset_of!(InternalCtx => stack_lower_bound).get_byte_offset(), + ); + assert_eq!( Ctx::offset_local_functions() as usize, offset_of!(Ctx => local_functions).get_byte_offset(), diff --git a/lib/singlepass-backend/Cargo.toml b/lib/singlepass-backend/Cargo.toml index b4046e76c47..f9d7558eb3a 100644 --- a/lib/singlepass-backend/Cargo.toml +++ b/lib/singlepass-backend/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" [dependencies] wasmer-runtime-core = { path = "../runtime-core", version = "0.3.0" } wasmparser = "0.29.2" -dynasm = "0.3.1" +dynasm = "0.3.2" dynasmrt = "0.3.1" lazy_static = "1.2.0" byteorder = "1" diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 0697d70e40d..4f07aaf31d1 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -10,7 +10,7 @@ use smallvec::SmallVec; use std::ptr::NonNull; use std::{any::Any, collections::HashMap, sync::Arc}; use wasmer_runtime_core::{ - backend::{Backend, RunnableModule}, + backend::{Backend, RunnableModule, CompilerConfig}, codegen::*, memory::MemoryType, module::ModuleInfo, @@ -120,6 +120,8 @@ pub struct X64ModuleCodeGenerator { function_labels: Option)>>, assembler: Option, func_import_count: usize, + + config: Option>, } #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -143,6 +145,8 @@ pub struct X64FunctionCode { control_stack: Vec, machine: Machine, unreachable_depth: usize, + + config: Arc, } enum FuncPtrInner {} @@ -284,6 +288,12 @@ pub struct CodegenError { pub message: &'static str, } +#[derive(Copy, Clone, Debug)] +struct CodegenConfig { + enforce_memory_bound_check: bool, + enforce_stack_check: bool, +} + impl ModuleCodeGenerator for X64ModuleCodeGenerator { @@ -295,6 +305,7 @@ impl ModuleCodeGenerator function_labels: Some(HashMap::new()), assembler: Some(Assembler::new().unwrap()), func_import_count: 0, + config: None, } } @@ -348,6 +359,7 @@ impl ModuleCodeGenerator control_stack: vec![], machine: Machine::new(), unreachable_depth: 0, + config: self.config.as_ref().unwrap().clone(), }; self.functions.push(code); Ok(self.functions.last_mut().unwrap()) @@ -460,6 +472,14 @@ impl ModuleCodeGenerator Ok(()) } + + fn feed_compiler_config(&mut self, config: &CompilerConfig) -> Result<(), CodegenError> { + self.config = Some(Arc::new(CodegenConfig { + enforce_memory_bound_check: config.enforce_memory_bound_check, + enforce_stack_check: config.enforce_stack_check, + })); + Ok(()) + } } impl X64FunctionCode { @@ -1173,6 +1193,7 @@ impl X64FunctionCode { /// Emits a memory operation. fn emit_memory_op( module_info: &ModuleInfo, + config: &CodegenConfig, a: &mut Assembler, m: &mut Machine, addr: Location, @@ -1222,9 +1243,13 @@ impl X64FunctionCode { &module_info.imported_memories[import_mem_index].1 } }; - let need_check = match mem_desc.memory_type() { - MemoryType::Dynamic => true, - MemoryType::Static | MemoryType::SharedStatic => false, + let need_check = if config.enforce_memory_bound_check { + true + } else { + match mem_desc.memory_type() { + MemoryType::Dynamic => true, + MemoryType::Static | MemoryType::SharedStatic => false, + } }; if need_check { @@ -1391,6 +1416,19 @@ impl FunctionCodeGenerator for X64FunctionCode { a.emit_push(Size::S64, Location::GPR(GPR::RBP)); a.emit_mov(Size::S64, Location::GPR(GPR::RSP), Location::GPR(GPR::RBP)); + // Stack check. + if self.config.enforce_stack_check { + a.emit_cmp( + Size::S64, + Location::Memory( + GPR::RDI, // first parameter is vmctx + vm::Ctx::offset_stack_lower_bound() as i32, + ), + Location::GPR(GPR::RSP) + ); + a.emit_conditional_trap(Condition::Below); + } + self.locals = self .machine .init_locals(a, self.num_locals, self.num_params); @@ -3351,6 +3389,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3376,6 +3415,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3401,6 +3441,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3427,6 +3468,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3453,6 +3495,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3479,6 +3522,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3505,6 +3549,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3530,6 +3575,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3555,6 +3601,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3580,6 +3627,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3605,6 +3653,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3630,6 +3679,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3655,6 +3705,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3681,6 +3732,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3707,6 +3759,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3733,6 +3786,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3759,6 +3813,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3790,6 +3845,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target, @@ -3816,6 +3872,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3841,6 +3898,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3866,6 +3924,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3891,6 +3950,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, @@ -3916,6 +3976,7 @@ impl FunctionCodeGenerator for X64FunctionCode { Self::emit_memory_op( module_info, + &self.config, a, &mut self.machine, target_addr, diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 994ae73fff3..3fd745fc6dd 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -50,6 +50,8 @@ fn handle_client(mut stream: UnixStream) { &wasm_binary[..], CompilerConfig { symbol_map: None, + enforce_memory_bound_check: true, + enforce_stack_check: true, }, &SinglePassCompiler::new(), ).unwrap(); diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index f8f6e71c7c8..efe30cf8ee2 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -287,7 +287,32 @@ fn execute_wasm(options: &Run) -> Result<(), String> { Backend::LLVM => return Err("the llvm backend is not enabled".to_string()), }; - let module = if !disable_cache { + let is_kernel_loader = if let Some(LoaderName::Kernel) = options.loader { + true + } else { + false + }; + + let module = if is_kernel_loader { + webassembly::compile_with_config_with( + &wasm_binary[..], + CompilerConfig { + symbol_map: em_symbol_map, + enforce_memory_bound_check: true, + enforce_stack_check: true, + }, + &*compiler, + ).map_err(|e| format!("Can't compile module: {:?}", e))? + } else if disable_cache { + webassembly::compile_with_config_with( + &wasm_binary[..], + CompilerConfig { + symbol_map: em_symbol_map, + ..Default::default() + }, + &*compiler, + ).map_err(|e| format!("Can't compile module: {:?}", e))? + } else { // If we have cache enabled // We generate a hash for the given binary, so we can use it as key @@ -316,6 +341,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { &wasm_binary[..], CompilerConfig { symbol_map: em_symbol_map, + ..Default::default() }, &*compiler, ) @@ -327,15 +353,6 @@ fn execute_wasm(options: &Run) -> Result<(), String> { } }; module - } else { - webassembly::compile_with_config_with( - &wasm_binary[..], - CompilerConfig { - symbol_map: em_symbol_map, - }, - &*compiler, - ) - .map_err(|e| format!("Can't compile module: {:?}", e))? }; if let Some(loader) = options.loader { From b343fd40bce650c7f83a4eb6e368ee2a686266cd Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 6 May 2019 08:28:12 -0700 Subject: [PATCH 12/43] Pass in param count for import functions in kernel loader. --- lib/kwasm-loader/src/lib.rs | 16 +++++++++++----- lib/kwasm-loader/src/service.rs | 21 +++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 365013f575d..cce0a995485 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -5,10 +5,10 @@ use wasmer_runtime_core::{ backend::RunnableModule, vm::{Ctx, LocalGlobal, SigId, Anyfunc}, module::ModuleInfo, - types::{Value, LocalMemoryIndex, LocalTableIndex, ImportedMemoryIndex, ImportedTableIndex}, + types::{Value, LocalMemoryIndex, LocalTableIndex, ImportedMemoryIndex, ImportedTableIndex, FuncIndex}, structures::TypedIndex, }; -use service::{ServiceContext, LoadProfile, RunProfile, TableEntryRequest}; +use service::{ServiceContext, LoadProfile, RunProfile, TableEntryRequest, ImportInfo}; pub struct KernelLoader; @@ -58,10 +58,16 @@ impl Loader for KernelLoader { let globals: &[*mut LocalGlobal] = ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); globals.iter().map(|x| (**x).data).collect() }; - let mut import_names: Vec = vec![]; - for (_, import) in &module.imported_functions { + let mut import_names: Vec = vec![]; + for (idx, import) in &module.imported_functions { let name = format!("{}##{}", module.namespace_table.get(import.namespace_index), module.name_table.get(import.name_index)); - import_names.push(name); + let sig = module.signatures.get( + *module.func_assoc.get(FuncIndex::new(idx.index())).unwrap() + ).unwrap(); + import_names.push(ImportInfo { + name: name, + param_count: sig.params().len(), + }); } let dynamic_sigindices: &[u32] = unsafe { ::std::mem::transmute::<&[SigId], &[u32]>( diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index f169327bf32..7be3370b95a 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -95,6 +95,7 @@ struct WriteMemoryRequest { #[repr(C)] struct ImportRequest { name: [u8; 64], + param_count: u32, } #[repr(C)] @@ -108,11 +109,16 @@ pub struct LoadProfile<'a> { pub memory: Option<&'a [u8]>, pub memory_max: usize, pub globals: &'a [u64], - pub imports: &'a [String], + pub imports: &'a [ImportInfo], pub dynamic_sigindices: &'a [u32], pub table: Option<&'a [TableEntryRequest]>, } +pub struct ImportInfo { + pub name: String, + pub param_count: usize, +} + pub struct RunProfile<'a> { pub entry_offset: u32, pub params: &'a [u64], @@ -126,13 +132,16 @@ impl ServiceContext { pub fn new(load: LoadProfile) -> ServiceResult { let dev = File::open("/dev/wasmctl")?; let imports: Vec = load.imports.iter().map(|x| { - let mut req: ImportRequest = unsafe { ::std::mem::zeroed() }; - let x = x.as_bytes(); + let mut req = ImportRequest { + name: [0u8; 64], + param_count: x.param_count as u32, + }; + let name = x.name.as_bytes(); let mut count = req.name.len() - 1; - if x.len() < count { - count = x.len(); + if name.len() < count { + count = name.len(); } - req.name[..count].copy_from_slice(&x[..count]); + req.name[..count].copy_from_slice(&name[..count]); req }).collect(); let req = LoadCodeRequest { From 0895dc60c263039fe225cc066351d33243167188 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 6 May 2019 09:19:56 -0700 Subject: [PATCH 13/43] Check param count. --- lib/kwasm-loader/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index cce0a995485..3e98175dbd5 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -74,6 +74,9 @@ impl Loader for KernelLoader { ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) ) }; + let local_param_counts: Vec = (module.imported_functions.len()..module.func_assoc.len()) + .map(|x| module.signatures.get(*module.func_assoc.get(FuncIndex::new(x)).unwrap()).unwrap().params().len()) + .collect(); let profile = LoadProfile { code: code, memory: memory, @@ -87,6 +90,7 @@ impl Loader for KernelLoader { Ok(KernelInstance { context: sc, offsets: rm.get_offsets().unwrap(), + param_counts: local_param_counts, }) } } @@ -94,11 +98,15 @@ impl Loader for KernelLoader { pub struct KernelInstance { context: ServiceContext, offsets: Vec, + param_counts: Vec, // FIXME: Full signature check } impl Instance for KernelInstance { type Error = String; fn call(&mut self, id: usize, args: &[Value]) -> Result { + if args.len() != self.param_counts[id] { + return Err("param count mismatch".into()); + } let args: Vec = args.iter().map(|x| x.to_u64()).collect(); let ret = self.context.run_code(RunProfile { From 0bbd6e69702a017b5f0a58e79ef2828042105b11 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Tue, 7 May 2019 08:25:46 -0700 Subject: [PATCH 14/43] Fix function offset. --- lib/kwasm-loader/src/lib.rs | 4 ++-- lib/runtime-core/src/instance.rs | 10 ++-------- src/bin/kwasmd.rs | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 3e98175dbd5..5d548980543 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -74,7 +74,7 @@ impl Loader for KernelLoader { ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) ) }; - let local_param_counts: Vec = (module.imported_functions.len()..module.func_assoc.len()) + let param_counts: Vec = (0..module.func_assoc.len()) .map(|x| module.signatures.get(*module.func_assoc.get(FuncIndex::new(x)).unwrap()).unwrap().params().len()) .collect(); let profile = LoadProfile { @@ -90,7 +90,7 @@ impl Loader for KernelLoader { Ok(KernelInstance { context: sc, offsets: rm.get_offsets().unwrap(), - param_counts: local_param_counts, + param_counts: param_counts, }) } } diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index f6d6a7a0cd2..f87c628104f 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -220,7 +220,7 @@ impl Instance { } } - pub fn resolve_local_func(&self, name: &str) -> ResolveResult { + pub fn resolve_func(&self, name: &str) -> ResolveResult { let export_index = self.module .info @@ -231,13 +231,7 @@ impl Instance { })?; if let ExportIndex::Func(func_index) = export_index { - match func_index.local_or_import(&self.module.info) { - LocalOrImport::Local(x) => Ok(x.index()), - LocalOrImport::Import(x) => Err(ResolveError::ExportWrongType { - name: name.to_string(), - } - .into()) - } + Ok(func_index.index()) } else { Err(ResolveError::ExportWrongType { name: name.to_string(), diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 3fd745fc6dd..5a7c327ca4b 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -84,7 +84,7 @@ fn handle_client(mut stream: UnixStream) { args.push(Value::I64(stream.read_u64::().unwrap() as _)); } - let index = instance.resolve_local_func(func_name).unwrap(); + let index = instance.resolve_func(func_name).unwrap(); let ret = ins.call(index, &args); match ret { Ok(x) => { From accb80bca23448d980ce6b4a42d9c6191606b6ea Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Tue, 7 May 2019 10:48:50 -0700 Subject: [PATCH 15/43] Pipe example --- Cargo.lock | 4 ++++ Cargo.toml | 2 +- examples/pipe/Cargo.toml | 7 +++++++ examples/pipe/src/main.rs | 13 +++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 examples/pipe/Cargo.toml create mode 100644 examples/pipe/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 820dafb0cb6..3b23fd68337 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,6 +1319,10 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pipe" +version = "0.1.0" + [[package]] name = "pkg-config" version = "0.3.14" diff --git a/Cargo.toml b/Cargo.toml index b11e133408b..8849a491868 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/pipe", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/pipe/Cargo.toml b/examples/pipe/Cargo.toml new file mode 100644 index 00000000000..50702bbb159 --- /dev/null +++ b/examples/pipe/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "pipe" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +[dependencies] diff --git a/examples/pipe/src/main.rs b/examples/pipe/src/main.rs new file mode 100644 index 00000000000..5192c539ae3 --- /dev/null +++ b/examples/pipe/src/main.rs @@ -0,0 +1,13 @@ +use std::io::{Read, Write}; + +fn main() { + let mut stdin = ::std::io::stdin(); + let mut stdout = ::std::io::stdout(); + let mut buf: Vec = vec![0; 512]; + let mut total: u64 = 0; + while total < 1048576u64 * 2048 { + let n = stdin.read(&mut buf).unwrap(); + stdout.write_all(&buf[..n]).unwrap(); + total += n as u64; + } +} From 620a6ddd85cc18dcacbf641b2338d4b909af6126 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Wed, 8 May 2019 10:25:29 -0700 Subject: [PATCH 16/43] Disable memory bound checking for kernel loader. --- lib/runtime-core/src/backend.rs | 15 ++++++++++++++- lib/singlepass-backend/src/codegen_x64.rs | 16 ++++++++-------- src/bin/kwasmd.rs | 4 ++-- src/bin/wasmer.rs | 6 +++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index b4875b8ae36..c86c9569df2 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -39,12 +39,25 @@ impl Token { } } +#[derive(Copy, Clone, Debug)] +pub enum MemoryBoundCheckMode { + Default, + Enable, + Disable, +} + +impl Default for MemoryBoundCheckMode { + fn default() -> MemoryBoundCheckMode { + MemoryBoundCheckMode::Default + } +} + /// Configuration data for the compiler #[derive(Default)] pub struct CompilerConfig { /// Symbol information generated from emscripten; used for more detailed debug messages pub symbol_map: Option>, - pub enforce_memory_bound_check: bool, + pub memory_bound_check_mode: MemoryBoundCheckMode, pub enforce_stack_check: bool, } diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 4f07aaf31d1..5f193e563f2 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -10,7 +10,7 @@ use smallvec::SmallVec; use std::ptr::NonNull; use std::{any::Any, collections::HashMap, sync::Arc}; use wasmer_runtime_core::{ - backend::{Backend, RunnableModule, CompilerConfig}, + backend::{Backend, RunnableModule, CompilerConfig, MemoryBoundCheckMode}, codegen::*, memory::MemoryType, module::ModuleInfo, @@ -290,7 +290,7 @@ pub struct CodegenError { #[derive(Copy, Clone, Debug)] struct CodegenConfig { - enforce_memory_bound_check: bool, + memory_bound_check_mode: MemoryBoundCheckMode, enforce_stack_check: bool, } @@ -475,7 +475,7 @@ impl ModuleCodeGenerator fn feed_compiler_config(&mut self, config: &CompilerConfig) -> Result<(), CodegenError> { self.config = Some(Arc::new(CodegenConfig { - enforce_memory_bound_check: config.enforce_memory_bound_check, + memory_bound_check_mode: config.memory_bound_check_mode, enforce_stack_check: config.enforce_stack_check, })); Ok(()) @@ -1243,13 +1243,13 @@ impl X64FunctionCode { &module_info.imported_memories[import_mem_index].1 } }; - let need_check = if config.enforce_memory_bound_check { - true - } else { - match mem_desc.memory_type() { + let need_check = match config.memory_bound_check_mode { + MemoryBoundCheckMode::Default => match mem_desc.memory_type() { MemoryType::Dynamic => true, MemoryType::Static | MemoryType::SharedStatic => false, - } + }, + MemoryBoundCheckMode::Enable => true, + MemoryBoundCheckMode::Disable => false, }; if need_check { diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 5a7c327ca4b..214af6017bd 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -10,7 +10,7 @@ use wasmer_runtime::{ }; use wasmer_runtime_core::{ self, - backend::{Compiler, CompilerConfig}, + backend::{Compiler, CompilerConfig, MemoryBoundCheckMode}, loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, }; use wasmer_singlepass_backend::SinglePassCompiler; @@ -50,7 +50,7 @@ fn handle_client(mut stream: UnixStream) { &wasm_binary[..], CompilerConfig { symbol_map: None, - enforce_memory_bound_check: true, + memory_bound_check_mode: MemoryBoundCheckMode::Disable, enforce_stack_check: true, }, &SinglePassCompiler::new(), diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index efe30cf8ee2..9af165011d8 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -22,7 +22,7 @@ use wasmer_runtime::{ }; use wasmer_runtime_core::{ self, - backend::{Compiler, CompilerConfig}, + backend::{Compiler, CompilerConfig, MemoryBoundCheckMode}, loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, }; #[cfg(feature = "backend:singlepass")] @@ -298,7 +298,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { &wasm_binary[..], CompilerConfig { symbol_map: em_symbol_map, - enforce_memory_bound_check: true, + memory_bound_check_mode: MemoryBoundCheckMode::Disable, enforce_stack_check: true, }, &*compiler, @@ -368,7 +368,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { .map(|arg| arg.as_str()) .map(|x| Value::I32(x.parse().unwrap())) .collect(); - let index = instance.resolve_local_func("main").unwrap(); + let index = instance.resolve_func("_start").unwrap(); let mut ins: Box> = match loader { LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), LoaderName::Kernel => Box::new(instance.load(::kwasm_loader::KernelLoader).unwrap()), From af1ac9af965725ed24049766063b3a2b1c919c9e Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 13 May 2019 05:11:08 -0700 Subject: [PATCH 17/43] Improve performance of memory access. --- lib/runtime-core/src/vm.rs | 49 ++++++++++++++++++- lib/runtime-core/src/vmcalls.rs | 36 +++++++++++--- lib/singlepass-backend/src/codegen_x64.rs | 59 +++++++++-------------- 3 files changed, 100 insertions(+), 44 deletions(-) diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 3e13eaa90de..1c7c07d83d2 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -67,6 +67,9 @@ pub struct InternalCtx { pub intrinsics: *const Intrinsics, pub stack_lower_bound: *mut u8, + + pub memory_base: *mut u8, + pub memory_bound: usize, } #[repr(C)] @@ -145,6 +148,16 @@ impl Ctx { import_backing: &mut ImportBacking, module: &ModuleInner, ) -> Self { + let (mem_base, mem_bound): (*mut u8, usize) = + if module.info.memories.len() == 0 && module.info.imported_memories.len() == 0 { + (::std::ptr::null_mut(), 0) + } else { + let mem = match MemoryIndex::new(0).local_or_import(&module.info) { + LocalOrImport::Local(index) => local_backing.vm_memories[index], + LocalOrImport::Import(index) => import_backing.vm_memories[index], + }; + ((*mem).base, (*mem).bound) + }; Self { internal: InternalCtx { memories: local_backing.vm_memories.as_mut_ptr(), @@ -161,6 +174,9 @@ impl Ctx { intrinsics: get_intrinsics_for_module(&module.info), stack_lower_bound: ::std::ptr::null_mut(), + + memory_base: mem_base, + memory_bound: mem_bound, }, local_functions: local_backing.local_functions.as_ptr(), @@ -181,6 +197,16 @@ impl Ctx { data: *mut c_void, data_finalizer: fn(*mut c_void), ) -> Self { + let (mem_base, mem_bound): (*mut u8, usize) = + if module.info.memories.len() == 0 && module.info.imported_memories.len() == 0 { + (::std::ptr::null_mut(), 0) + } else { + let mem = match MemoryIndex::new(0).local_or_import(&module.info) { + LocalOrImport::Local(index) => local_backing.vm_memories[index], + LocalOrImport::Import(index) => import_backing.vm_memories[index], + }; + ((*mem).base, (*mem).bound) + }; Self { internal: InternalCtx { memories: local_backing.vm_memories.as_mut_ptr(), @@ -197,6 +223,9 @@ impl Ctx { intrinsics: get_intrinsics_for_module(&module.info), stack_lower_bound: ::std::ptr::null_mut(), + + memory_base: mem_base, + memory_bound: mem_bound, }, local_functions: local_backing.local_functions.as_ptr(), @@ -298,9 +327,17 @@ impl Ctx { 9 * (mem::size_of::() as u8) } - pub fn offset_local_functions() -> u8 { + pub fn offset_memory_base() -> u8 { 10 * (mem::size_of::() as u8) } + + pub fn offset_memory_bound() -> u8 { + 11 * (mem::size_of::() as u8) + } + + pub fn offset_local_functions() -> u8 { + 12 * (mem::size_of::() as u8) + } } enum InnerFunc {} @@ -504,6 +541,16 @@ mod vm_offset_tests { offset_of!(InternalCtx => stack_lower_bound).get_byte_offset(), ); + assert_eq!( + Ctx::offset_memory_base() as usize, + offset_of!(InternalCtx => memory_base).get_byte_offset(), + ); + + assert_eq!( + Ctx::offset_memory_bound() as usize, + offset_of!(InternalCtx => memory_bound).get_byte_offset(), + ); + assert_eq!( Ctx::offset_local_functions() as usize, offset_of!(Ctx => local_functions).get_byte_offset(), diff --git a/lib/runtime-core/src/vmcalls.rs b/lib/runtime-core/src/vmcalls.rs index 4126024bf83..5205a0d6901 100644 --- a/lib/runtime-core/src/vmcalls.rs +++ b/lib/runtime-core/src/vmcalls.rs @@ -20,10 +20,15 @@ pub unsafe extern "C" fn local_static_memory_grow( let local_memory = *ctx.internal.memories.add(memory_index.index()); let memory = (*local_memory).memory as *mut StaticMemory; - match (*memory).grow(delta, &mut *local_memory) { + let ret = match (*memory).grow(delta, &mut *local_memory) { Ok(old) => old.0 as i32, Err(_) => -1, - } + }; + + ctx.internal.memory_base = (*local_memory).base; + ctx.internal.memory_bound = (*local_memory).bound; + + ret } pub unsafe extern "C" fn local_static_memory_size( @@ -44,10 +49,15 @@ pub unsafe extern "C" fn local_dynamic_memory_grow( let local_memory = *ctx.internal.memories.add(memory_index.index()); let memory = (*local_memory).memory as *mut DynamicMemory; - match (*memory).grow(delta, &mut *local_memory) { + let ret = match (*memory).grow(delta, &mut *local_memory) { Ok(old) => old.0 as i32, Err(_) => -1, - } + }; + + ctx.internal.memory_base = (*local_memory).base; + ctx.internal.memory_bound = (*local_memory).bound; + + ret } pub unsafe extern "C" fn local_dynamic_memory_size( @@ -75,10 +85,15 @@ pub unsafe extern "C" fn imported_static_memory_grow( .add(import_memory_index.index()); let memory = (*local_memory).memory as *mut StaticMemory; - match (*memory).grow(delta, &mut *local_memory) { + let ret = match (*memory).grow(delta, &mut *local_memory) { Ok(old) => old.0 as i32, Err(_) => -1, - } + }; + + ctx.internal.memory_base = (*local_memory).base; + ctx.internal.memory_bound = (*local_memory).bound; + + ret } pub unsafe extern "C" fn imported_static_memory_size( @@ -102,10 +117,15 @@ pub unsafe extern "C" fn imported_dynamic_memory_grow( let local_memory = *ctx.internal.imported_memories.add(memory_index.index()); let memory = (*local_memory).memory as *mut DynamicMemory; - match (*memory).grow(delta, &mut *local_memory) { + let ret = match (*memory).grow(delta, &mut *local_memory) { Ok(old) => old.0 as i32, Err(_) => -1, - } + }; + + ctx.internal.memory_base = (*local_memory).base; + ctx.internal.memory_bound = (*local_memory).bound; + + ret } pub unsafe extern "C" fn imported_dynamic_memory_size( diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index 5f193e563f2..4e9e2859183 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -1201,41 +1201,6 @@ impl X64FunctionCode { value_size: usize, cb: F, ) { - let tmp_addr = m.acquire_temp_gpr().unwrap(); - let tmp_base = m.acquire_temp_gpr().unwrap(); - let tmp_bound = m.acquire_temp_gpr().unwrap(); - - // Loads both base and bound into temporary registers. - a.emit_mov( - Size::S64, - Location::Memory( - Machine::get_vmctx_reg(), - match MemoryIndex::new(0).local_or_import(module_info) { - LocalOrImport::Local(_) => vm::Ctx::offset_memories(), - LocalOrImport::Import(_) => vm::Ctx::offset_imported_memories(), - } as i32, - ), - Location::GPR(tmp_base), - ); - a.emit_mov( - Size::S64, - Location::Memory(tmp_base, 0), - Location::GPR(tmp_base), - ); - a.emit_mov( - Size::S32, - Location::Memory(tmp_base, LocalMemory::offset_bound() as i32), - Location::GPR(tmp_bound), - ); - a.emit_mov( - Size::S64, - Location::Memory(tmp_base, LocalMemory::offset_base() as i32), - Location::GPR(tmp_base), - ); - - // Adds base to bound so `tmp_bound` now holds the end of linear memory. - a.emit_add(Size::S64, Location::GPR(tmp_base), Location::GPR(tmp_bound)); - // If the memory is dynamic, we need to do bound checking at runtime. let mem_desc = match MemoryIndex::new(0).local_or_import(module_info) { LocalOrImport::Local(local_mem_index) => &module_info.memories[local_mem_index], @@ -1251,8 +1216,32 @@ impl X64FunctionCode { MemoryBoundCheckMode::Enable => true, MemoryBoundCheckMode::Disable => false, }; + + let tmp_addr = m.acquire_temp_gpr().unwrap(); + let tmp_base = m.acquire_temp_gpr().unwrap(); + let tmp_bound = m.acquire_temp_gpr().unwrap(); + + // Load base into temporary register. + a.emit_mov( + Size::S64, + Location::Memory( + Machine::get_vmctx_reg(), + vm::Ctx::offset_memory_base() as i32, + ), + Location::GPR(tmp_base), + ); if need_check { + a.emit_mov( + Size::S64, + Location::Memory( + Machine::get_vmctx_reg(), + vm::Ctx::offset_memory_bound() as i32, + ), + Location::GPR(tmp_bound), + ); + // Adds base to bound so `tmp_bound` now holds the end of linear memory. + a.emit_add(Size::S64, Location::GPR(tmp_base), Location::GPR(tmp_bound)); a.emit_mov(Size::S32, addr, Location::GPR(tmp_addr)); // This branch is used for emitting "faster" code for the special case of (offset + value_size) not exceeding u32 range. From 3bcdfb42634854a56347dfbaf62434ce0172a8f2 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 13 May 2019 06:14:28 -0700 Subject: [PATCH 18/43] Asynchronous networking extension. --- Cargo.lock | 83 ++-- Cargo.toml | 2 +- examples/kernel/hello_world/src/lib.rs | 14 - .../Cargo.toml | 6 +- examples/wasi-networking/src/main.rs | 56 +++ lib/kwasm-net/Cargo.toml | 9 + lib/kwasm-net/src/lib.rs | 420 ++++++++++++++++++ 7 files changed, 533 insertions(+), 57 deletions(-) delete mode 100644 examples/kernel/hello_world/src/lib.rs rename examples/{kernel/hello_world => wasi-networking}/Cargo.toml (62%) create mode 100644 examples/wasi-networking/src/main.rs create mode 100644 lib/kwasm-net/Cargo.toml create mode 100644 lib/kwasm-net/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 3b23fd68337..04a7da8cc23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,8 +117,8 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -213,12 +213,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -537,9 +537,9 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -619,9 +619,9 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -772,10 +772,6 @@ dependencies = [ "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hello_world" -version = "0.1.0" - [[package]] name = "hex" version = "0.3.2" @@ -875,8 +871,8 @@ name = "inkwell_internal_macros" version = "0.1.0" source = "git+https://github.com/wasmerio/inkwell?branch=llvm7-0#a14e62977504ef574dc2e933edc559cc79781ca7" dependencies = [ - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -918,6 +914,10 @@ dependencies = [ "wasmer-runtime-core 0.3.0", ] +[[package]] +name = "kwasm-net" +version = "0.1.0" + [[package]] name = "lazy_static" version = "1.3.0" @@ -1344,7 +1344,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.27" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1362,10 +1362,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1667,9 +1667,9 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1736,9 +1736,9 @@ name = "serde_derive" version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1815,9 +1815,9 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1832,11 +1832,11 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.30" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1853,9 +1853,9 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2240,6 +2240,13 @@ dependencies = [ "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasi-networking" +version = "0.1.0" +dependencies = [ + "kwasm-net 0.1.0", +] + [[package]] name = "wasmer" version = "0.4.0" @@ -2740,10 +2747,10 @@ dependencies = [ "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" +"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" @@ -2796,7 +2803,7 @@ dependencies = [ "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" diff --git a/Cargo.toml b/Cargo.toml index 8849a491868..4b11cc7db23 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/pipe", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/pipe", "examples/wasi-networking", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/kernel/hello_world/src/lib.rs b/examples/kernel/hello_world/src/lib.rs deleted file mode 100644 index 43b7df332b1..00000000000 --- a/examples/kernel/hello_world/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -extern "C" { - fn print_str(base: *const u8, len: usize) -> i32; -} - -#[no_mangle] -pub extern "C" fn main() -> i32 { - let v: Vec = (0..10).collect(); - let s = format!("Hello world from WebAssembly. Some heap allocated integers: {:?}", v); - let s = s.as_bytes(); - unsafe { - print_str(s.as_ptr(), s.len()); - } - return 0; -} diff --git a/examples/kernel/hello_world/Cargo.toml b/examples/wasi-networking/Cargo.toml similarity index 62% rename from examples/kernel/hello_world/Cargo.toml rename to examples/wasi-networking/Cargo.toml index b6d6f2fde7f..8057f959230 100644 --- a/examples/kernel/hello_world/Cargo.toml +++ b/examples/wasi-networking/Cargo.toml @@ -1,10 +1,8 @@ [package] -name = "hello_world" +name = "wasi-networking" version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" -[lib] -crate-type = ["cdylib"] - [dependencies] +kwasm-net = { path = "../../lib/kwasm-net" } \ No newline at end of file diff --git a/examples/wasi-networking/src/main.rs b/examples/wasi-networking/src/main.rs new file mode 100644 index 00000000000..84a8bcf467f --- /dev/null +++ b/examples/wasi-networking/src/main.rs @@ -0,0 +1,56 @@ +#![feature(wasi_ext)] + +use kwasm_net::{Epoll, Tcp4Listener, TcpStream, schedule}; +use std::io::{Read, Write}; +use std::sync::Arc; + +fn do_echo(stream: Arc, buf: Vec) { + let stream2 = stream.clone(); + stream.read_async(buf, move |result| { + match result { + Ok(buf) => { + if buf.len() == 0 { + return; + } + let stream = stream2.clone(); + stream2.write_all_async(buf, move |result| { + match result { + Ok(buf) => { + schedule(|| { + do_echo(stream, buf); + }); + }, + Err(code) => { + println!("failed to write; code = {}", code); + } + } + }); + }, + Err(code) => { + println!("failed to read; code = {}", code); + } + } + }); +} + +fn main() { + let epoll = Arc::new(Epoll::new()); + let listener = Arc::new(Tcp4Listener::new("0.0.0.0", 2001, 128).unwrap()); + + listener.accept_async(epoll.clone(), |stream| { + match stream { + Ok(stream) => { + do_echo(stream, Vec::with_capacity(4096 * 4)); + Ok(()) + }, + Err(code) => { + println!("failed to accept; code = {}", code); + Err(()) + } + } + }); + println!("start epoll"); + unsafe { + epoll.run(); + } +} diff --git a/lib/kwasm-net/Cargo.toml b/lib/kwasm-net/Cargo.toml new file mode 100644 index 00000000000..135a07c7655 --- /dev/null +++ b/lib/kwasm-net/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "kwasm-net" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +[dependencies] +#runtime = "0.3.0-alpha.4" +#runtime-raw = "0.3.0-alpha.3" diff --git a/lib/kwasm-net/src/lib.rs b/lib/kwasm-net/src/lib.rs new file mode 100644 index 00000000000..e6f7791903b --- /dev/null +++ b/lib/kwasm-net/src/lib.rs @@ -0,0 +1,420 @@ +#![feature(wasi_ext)] + +use std::fs::File; +use std::os::wasi::io::FromRawFd; +use std::io::{Read, Write}; +use std::net::{Ipv4Addr, AddrParseError}; +use std::ops::{Deref, DerefMut}; +use std::task::{Waker, RawWaker, RawWakerVTable, Poll}; +use std::future::Future; +use std::sync::{Arc, Mutex}; +use std::cell::RefCell; + +const AF_INET: i32 = 2; +const SOCK_STREAM: i32 = 1; +const O_NONBLOCK: u32 = 2048; +const F_GETFL: i32 = 3; +const F_SETFL: i32 = 4; +const EPOLLIN: u32 = 1u32; +const EPOLLOUT: u32 = 4u32; +const EPOLLONESHOT: u32 = 1u32 << 30; +const EPOLLET: u32 = 1u32 << 31; +const EAGAIN: i32 = 11; +const EWOULDBLOCK: i32 = EAGAIN; +const EPOLL_CTL_ADD: i32 = 1; +const EPOLL_CTL_DEL: i32 = 2; + +#[link(wasm_import_module = "net")] +extern "C" { + fn _socket(family: i32, _type: i32, proto: i32) -> i32; + fn _bind(fd: i32, sa: *const SockaddrIn, sa_len: usize) -> i32; + fn _listen(fd: i32, backlog: i32) -> i32; + fn _accept4(fd: i32, sa: *mut SockaddrIn, sa_len: *mut usize, flags: u32) -> i32; + fn _sendto(fd: i32, buf: *const u8, buf_len: usize, flags: u32, addr: *const SockaddrIn, addr_len: usize) -> i32; + fn _recvfrom(fd: i32, buf: *mut u8, buf_len: usize, flags: u32, addr: *mut SockaddrIn, addr_len: *mut usize) -> i32; + fn _get_immediate_fd() -> i32; + fn _epoll_create() -> i32; + fn _epoll_ctl( + epfd: i32, + op: i32, + fd: i32, + event: *const EpollEvent, + ) -> i32; + fn _epoll_wait( + epfd: i32, + events: *mut EpollEvent, + maxevents: usize, + timeout: i32, + ) -> i32; + fn _fcntl( + fd: i32, + cmd: i32, + arg: u32, + ) -> i32; +} + +thread_local! { + static GLOBAL_EPOLL: RefCell>> = RefCell::new(None); +} + +struct AsyncState { + callback: Box, + _epoll: Arc, +} + +pub struct Epoll { + fd: i32, +} + +impl Epoll { + pub fn new() -> Epoll { + let fd = unsafe { + _epoll_create() + }; + assert!(fd >= 0); + Epoll { + fd: fd, + } + } + + pub unsafe fn run(self: Arc) -> ! { + GLOBAL_EPOLL.with(|x| { + *x.borrow_mut() = Some(self.clone()); + }); + let mut events: Vec = vec! [ EpollEvent::default(); 16 ]; + loop { + let events_len = events.len(); + let n_ready = unsafe { + _epoll_wait(self.fd, events.as_mut_ptr(), events_len, -1) + }; + assert!(n_ready >= 0); + //println!("n_ready = {}", n_ready); + for ev in &events[..n_ready as usize] { + if ev.events & (EPOLLIN | EPOLLOUT) != 0 { + //println!("Free event {:x} {:?}", ev.events, ev.data as usize as *mut AsyncState); + let state = unsafe { + Box::from_raw(ev.data as usize as *mut AsyncState) + }; + (state.callback)(); + //println!("After callback"); + } else { + println!("unknown event(s): 0x{:x}", ev.events); + } + } + } + } +} + +impl Drop for Epoll { + fn drop(&mut self) { + unsafe { + File::from_raw_fd(self.fd as _); + } + } +} + +#[derive(Copy, Clone, Debug)] +pub enum EpollDirection { + In, + Out +} + +pub fn schedule(f: F) { + let epoll = GLOBAL_EPOLL.with(|x| x.borrow().as_ref().unwrap().clone()); + let epfd = epoll.fd; + let imm_fd = unsafe { _get_immediate_fd() }; + assert!(imm_fd >= 0); + + let state = Box::new(AsyncState { + callback: Box::new(move || { + assert!(unsafe { + _epoll_ctl(epfd, EPOLL_CTL_DEL, imm_fd, ::std::ptr::null()) + } >= 0); + unsafe { File::from_raw_fd(imm_fd as _) }; + f(); + }), + _epoll: epoll, + }); + let ev = EpollEvent { + events: EPOLLIN | EPOLLET | EPOLLONESHOT, + data: Box::into_raw(state) as usize as _, + }; + let ret = unsafe { _epoll_ctl(epfd, EPOLL_CTL_ADD, imm_fd, &ev) }; + assert!(ret >= 0); +} + +fn get_async_io_payload Result + 'static, F: FnOnce(Result) + 'static>( + epoll: Arc, + fd: i32, + direction: EpollDirection, + poll_action: P, + on_ready: F, +) -> Box { + __get_async_io_payload(epoll, fd, direction, poll_action, on_ready, false) +} + +fn __get_async_io_payload Result + 'static, F: FnOnce(Result) + 'static>( + epoll: Arc, + fd: i32, + direction: EpollDirection, + mut poll_action: P, + on_ready: F, + registered: bool, +) -> Box { + let epfd = epoll.fd; + Box::new(move || { + //println!("async io payload"); + let ret = poll_action(fd); + //println!("async io payload (after poll_action)"); + match ret { + Err(x) if x == -EAGAIN || x == -EWOULDBLOCK => { + let state = Box::new(AsyncState { + callback: __get_async_io_payload(epoll.clone(), fd, direction, poll_action, on_ready, true), + _epoll: epoll, + }); + let direction_flag = match direction { + EpollDirection::In => EPOLLIN, + EpollDirection::Out => EPOLLOUT, + }; + let ev = EpollEvent { + events: direction_flag | EPOLLET | EPOLLONESHOT, + data: Box::into_raw(state) as usize as _, + }; + //println!("Alloc event {:?}", ev.data as usize as *mut AsyncState); + let ret = unsafe { _epoll_ctl( + epfd, + EPOLL_CTL_ADD, + fd, + &ev + ) }; + assert!(ret >= 0); + }, + x => { + if registered { + assert!(unsafe { _epoll_ctl( + epfd, + EPOLL_CTL_DEL, + fd, + ::std::ptr::null(), + ) } >= 0); + } + on_ready(x); // fast path + } + } + }) +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct SockaddrIn { + sin_family: u16, // e.g. AF_INET + sin_port: u16, // e.g. htons(3490) + sin_addr: InAddr, + sin_zero: [u8; 8], +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct InAddr { + s_addr: u32, +} + +#[repr(C)] +#[derive(Copy, Clone, Default)] +struct EpollEvent { + events: u32, + data: u64, +} + +fn invert_byteorder_u16(x: u16) -> u16 { + unsafe { + use std::mem::transmute; + let buf: [u8; 2] = transmute(x); + let out: [u8; 2] = [buf[1], buf[0]]; + transmute(out) + } +} + +#[derive(Debug)] +pub enum SocketError { + AddrParse(AddrParseError), + SocketCreate, + Bind, + Listen, + Accept, + Message(String), +} + +pub struct Tcp4Listener { + addr: Ipv4Addr, + port: u16, + fd: i32, +} + +impl Tcp4Listener { + pub fn new>( + addr: A, + port: u16, + backlog: u32, + ) -> Result { + let addr: Ipv4Addr = addr.as_ref().parse().map_err(SocketError::AddrParse)?; + let sa = SockaddrIn { + sin_family: AF_INET as _, + sin_port: invert_byteorder_u16(port), + sin_addr: InAddr { s_addr: unsafe { ::std::mem::transmute(addr.octets()) } }, + sin_zero: [0; 8], + }; + let fd = unsafe { + _socket(AF_INET, SOCK_STREAM, 0) + }; + if fd < 0 { + return Err(SocketError::SocketCreate); + } + if(unsafe { + _bind(fd, &sa, ::std::mem::size_of::()) + } < 0) { + return Err(SocketError::Bind); + } + if(unsafe { + _listen(fd, backlog as _) + } < 0) { + return Err(SocketError::Listen); + } + + unsafe { + let mut socket_flags = _fcntl(fd, F_GETFL, 0) as u32; + socket_flags |= O_NONBLOCK; + assert!(_fcntl(fd, F_SETFL, socket_flags) >= 0); + } + + Ok(Tcp4Listener { + addr: addr, + port: port, + fd: fd, + }) + } + + pub fn accept_async, i32>) -> Result<(), ()> + 'static>(self: Arc, ep: Arc, cb: F) { + let ep2 = ep.clone(); + (get_async_io_payload(ep.clone(), self.fd, EpollDirection::In, move |fd| -> Result, i32> { + let mut incoming_sa: SockaddrIn = unsafe { ::std::mem::uninitialized() }; + let mut real_len: usize = ::std::mem::size_of::(); + let conn = unsafe { + _accept4(fd, &mut incoming_sa, &mut real_len, O_NONBLOCK) + }; + if conn >= 0 { + unsafe { + let mut socket_flags = _fcntl(conn, F_GETFL, 0) as u32; + socket_flags |= O_NONBLOCK; + assert!(_fcntl(conn, F_SETFL, socket_flags) >= 0); + } + Ok(Arc::new(TcpStream { + fd: conn, + epoll: ep.clone(), + })) + } else { + Err(conn) + } + }, move |x| { + if let Ok(()) = cb(x) { + self.accept_async(ep2, cb); + } + }))(); + } +} + +pub struct TcpStream { + fd: i32, + epoll: Arc, +} + +impl TcpStream { + pub fn __write_async(self: Arc, data: Vec, offset: usize, cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static) { + let mut data = Some(data); + + (get_async_io_payload( + self.epoll.clone(), + self.fd, + EpollDirection::Out, + move |fd| -> Result<(usize, Vec), i32> { + let _data = data.as_ref().unwrap(); + let _data = &_data[offset..]; + let ret = unsafe { + _sendto(fd, _data.as_ptr(), _data.len(), 0, ::std::ptr::null(), 0) + }; + if ret >= 0 { + Ok((ret as usize, data.take().unwrap())) + } else { + Err(ret) + } + }, + move |x| { + drop(self); + cb(x); + } + ))(); + } + + pub fn write_async(self: Arc, data: Vec, cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static) { + self.__write_async(data, 0, cb) + } + + pub fn write_all_async(self: Arc, data: Vec, cb: impl FnOnce(Result, i32>) + 'static) { + fn inner(me: Arc, data: Vec, offset: usize, cb: impl FnOnce(Result, i32>) + 'static) { + let me2 = me.clone(); + me.__write_async(data, offset, move |result| { + match result { + Ok((len, data)) => { + let new_offset = offset + len; + if new_offset == data.len() { + cb(Ok(data)); + } else { + inner(me2, data, new_offset, cb); + } + } + Err(code) => { + cb(Err(code)); + } + } + }) + } + inner(self, data, 0, cb); + } + + pub fn read_async(self: Arc, out: Vec, cb: impl FnOnce(Result, i32>) + 'static) { + let mut out = Some(out); + (get_async_io_payload( + self.epoll.clone(), + self.fd, + EpollDirection::In, + move |fd| -> Result, i32> { + let _out = out.as_mut().unwrap(); + let out_cap = _out.capacity(); + let ret = unsafe { + _recvfrom(fd, _out.as_mut_ptr(), out_cap, 0, ::std::ptr::null_mut(), ::std::ptr::null_mut()) + }; + if ret >= 0 { + assert!(ret as usize <= out_cap); + unsafe { + _out.set_len(ret as usize); + } + Ok(out.take().unwrap()) + } else { + Err(ret) + } + }, + move |x| { + drop(self); + cb(x); + } + ))(); + } +} + +impl Drop for TcpStream { + fn drop(&mut self) { + unsafe { + File::from_raw_fd(self.fd as _); + } + } +} From 884a7e1713def954cd5164749a9b3027b998e6f1 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 13 May 2019 10:15:03 -0700 Subject: [PATCH 19/43] kwasm-net fixes and optimizations. --- examples/wasi-networking/src/main.rs | 3 +- lib/kwasm-net/src/lib.rs | 92 +++++++++++++++------------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/examples/wasi-networking/src/main.rs b/examples/wasi-networking/src/main.rs index 84a8bcf467f..d73f7961eba 100644 --- a/examples/wasi-networking/src/main.rs +++ b/examples/wasi-networking/src/main.rs @@ -1,7 +1,6 @@ #![feature(wasi_ext)] use kwasm_net::{Epoll, Tcp4Listener, TcpStream, schedule}; -use std::io::{Read, Write}; use std::sync::Arc; fn do_echo(stream: Arc, buf: Vec) { @@ -40,7 +39,7 @@ fn main() { listener.accept_async(epoll.clone(), |stream| { match stream { Ok(stream) => { - do_echo(stream, Vec::with_capacity(4096 * 4)); + do_echo(stream, Vec::with_capacity(16384)); Ok(()) }, Err(code) => { diff --git a/lib/kwasm-net/src/lib.rs b/lib/kwasm-net/src/lib.rs index e6f7791903b..22ec413e5ec 100644 --- a/lib/kwasm-net/src/lib.rs +++ b/lib/kwasm-net/src/lib.rs @@ -2,12 +2,8 @@ use std::fs::File; use std::os::wasi::io::FromRawFd; -use std::io::{Read, Write}; use std::net::{Ipv4Addr, AddrParseError}; -use std::ops::{Deref, DerefMut}; -use std::task::{Waker, RawWaker, RawWakerVTable, Poll}; -use std::future::Future; -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use std::cell::RefCell; const AF_INET: i32 = 2; @@ -55,11 +51,13 @@ extern "C" { thread_local! { static GLOBAL_EPOLL: RefCell>> = RefCell::new(None); + static ASYNC_STATE_POOL: RefCell>> = RefCell::new(Vec::new()); } +#[derive(Default)] struct AsyncState { - callback: Box, - _epoll: Arc, + callback: Option>, + _epoll: Option>, } pub struct Epoll { @@ -81,21 +79,20 @@ impl Epoll { GLOBAL_EPOLL.with(|x| { *x.borrow_mut() = Some(self.clone()); }); - let mut events: Vec = vec! [ EpollEvent::default(); 16 ]; + let mut events: Vec = vec! [ EpollEvent::default(); 32 ]; loop { let events_len = events.len(); - let n_ready = unsafe { - _epoll_wait(self.fd, events.as_mut_ptr(), events_len, -1) - }; + let n_ready = _epoll_wait(self.fd, events.as_mut_ptr(), events_len, -1); assert!(n_ready >= 0); - //println!("n_ready = {}", n_ready); + /*if n_ready > 1 { + println!("n_ready = {}", n_ready); + }*/ for ev in &events[..n_ready as usize] { if ev.events & (EPOLLIN | EPOLLOUT) != 0 { //println!("Free event {:x} {:?}", ev.events, ev.data as usize as *mut AsyncState); - let state = unsafe { - Box::from_raw(ev.data as usize as *mut AsyncState) - }; - (state.callback)(); + let mut state = Box::from_raw(ev.data as usize as *mut AsyncState); + (state.callback.take().unwrap())(); + put_async_state(state); //println!("After callback"); } else { println!("unknown event(s): 0x{:x}", ev.events); @@ -119,22 +116,32 @@ pub enum EpollDirection { Out } +fn get_async_state() -> Box { + ASYNC_STATE_POOL.with(|pool| pool.borrow_mut().pop().unwrap_or_else(|| Box::new(AsyncState::default()))) +} + +fn put_async_state(mut x: Box) { + x.callback = None; + x._epoll = None; + ASYNC_STATE_POOL.with(|pool| pool.borrow_mut().push(x)); +} + pub fn schedule(f: F) { let epoll = GLOBAL_EPOLL.with(|x| x.borrow().as_ref().unwrap().clone()); let epfd = epoll.fd; let imm_fd = unsafe { _get_immediate_fd() }; assert!(imm_fd >= 0); - let state = Box::new(AsyncState { - callback: Box::new(move || { - assert!(unsafe { - _epoll_ctl(epfd, EPOLL_CTL_DEL, imm_fd, ::std::ptr::null()) - } >= 0); - unsafe { File::from_raw_fd(imm_fd as _) }; - f(); - }), - _epoll: epoll, - }); + let mut state = get_async_state(); + state.callback = Some(Box::new(move || { + assert!(unsafe { + _epoll_ctl(epfd, EPOLL_CTL_DEL, imm_fd, ::std::ptr::null()) + } >= 0); + unsafe { File::from_raw_fd(imm_fd as _) }; + f(); + })); + state._epoll = Some(epoll); + let ev = EpollEvent { events: EPOLLIN | EPOLLET | EPOLLONESHOT, data: Box::into_raw(state) as usize as _, @@ -168,10 +175,9 @@ fn __get_async_io_payload Result + 'static, //println!("async io payload (after poll_action)"); match ret { Err(x) if x == -EAGAIN || x == -EWOULDBLOCK => { - let state = Box::new(AsyncState { - callback: __get_async_io_payload(epoll.clone(), fd, direction, poll_action, on_ready, true), - _epoll: epoll, - }); + let mut state = get_async_state(); + state.callback = Some(__get_async_io_payload(epoll.clone(), fd, direction, poll_action, on_ready, true)); + state._epoll = Some(epoll); let direction_flag = match direction { EpollDirection::In => EPOLLIN, EpollDirection::Out => EPOLLOUT, @@ -219,7 +225,7 @@ struct InAddr { s_addr: u32, } -#[repr(C)] +#[repr(C, packed)] #[derive(Copy, Clone, Default)] struct EpollEvent { events: u32, @@ -246,8 +252,8 @@ pub enum SocketError { } pub struct Tcp4Listener { - addr: Ipv4Addr, - port: u16, + _addr: Ipv4Addr, + _port: u16, fd: i32, } @@ -270,14 +276,14 @@ impl Tcp4Listener { if fd < 0 { return Err(SocketError::SocketCreate); } - if(unsafe { + if unsafe { _bind(fd, &sa, ::std::mem::size_of::()) - } < 0) { + } < 0 { return Err(SocketError::Bind); } - if(unsafe { + if unsafe { _listen(fd, backlog as _) - } < 0) { + } < 0 { return Err(SocketError::Listen); } @@ -288,8 +294,8 @@ impl Tcp4Listener { } Ok(Tcp4Listener { - addr: addr, - port: port, + _addr: addr, + _port: port, fd: fd, }) } @@ -316,9 +322,11 @@ impl Tcp4Listener { Err(conn) } }, move |x| { - if let Ok(()) = cb(x) { - self.accept_async(ep2, cb); - } + schedule(|| { + if let Ok(()) = cb(x) { + self.accept_async(ep2, cb); + } + }); }))(); } } From 4f77f4d024e474b23809e5ab253f9ee0ba977839 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Mon, 13 May 2019 18:37:22 -0700 Subject: [PATCH 20/43] HTTP server example. --- Cargo.lock | 7 ++++ Cargo.toml | 2 +- examples/http-server/Cargo.toml | 10 +++++ examples/http-server/src/main.rs | 68 ++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 examples/http-server/Cargo.toml create mode 100644 examples/http-server/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 04a7da8cc23..f556254dfcf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -787,6 +787,13 @@ dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http-server" +version = "0.1.0" +dependencies = [ + "kwasm-net 0.1.0", +] + [[package]] name = "httparse" version = "1.3.3" diff --git a/Cargo.toml b/Cargo.toml index 4b11cc7db23..cc9e63a9a60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/pipe", "examples/wasi-networking", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/pipe", "examples/wasi-networking", "examples/http-server", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml new file mode 100644 index 00000000000..3d6f23502ee --- /dev/null +++ b/examples/http-server/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "http-server" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +kwasm-net = { path = "../../lib/kwasm-net" } diff --git a/examples/http-server/src/main.rs b/examples/http-server/src/main.rs new file mode 100644 index 00000000000..3ace473774e --- /dev/null +++ b/examples/http-server/src/main.rs @@ -0,0 +1,68 @@ +#![feature(wasi_ext)] + +use kwasm_net::{Epoll, Tcp4Listener, TcpStream, schedule}; +use std::sync::Arc; + +fn serve(stream: Arc, mut all: Vec) { + let stream2 = stream.clone(); + stream.read_async( + Vec::with_capacity(512), + move |result| { + match result { + Ok(buf) => { + if buf.len() == 0 { + return; + } + all.extend_from_slice(&buf); + if all.len() > 4096 { + println!("header too large"); + return; + } + let s = match ::std::str::from_utf8(&all) { + Ok(x) => x, + Err(e) => { + println!("not utf8: {:?}", e); + return; + } + }; + if let Some(pos) = s.find("\r\n\r\n") { + stream2.write_all_async( + format!( + "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nYour headers: \n\n{}\n", + ::std::str::from_utf8(&all[..pos]).unwrap() + ).into_bytes(), + |result| {} + ); + } else { + schedule(|| serve(stream2, all)); + } + } + Err(code) => { + println!("failed to read; code = {}", code); + } + } + } + ); +} + +fn main() { + let epoll = Arc::new(Epoll::new()); + let listener = Arc::new(Tcp4Listener::new("0.0.0.0", 2011, 128).unwrap()); + + listener.accept_async(epoll.clone(), |stream| { + match stream { + Ok(stream) => { + serve(stream, vec![]); + Ok(()) + }, + Err(code) => { + println!("failed to accept; code = {}", code); + Err(()) + } + } + }); + println!("start epoll"); + unsafe { + epoll.run(); + } +} From 2963b0a2eb679bc38d3710831538617e8a0bfe6a Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Tue, 14 May 2019 00:04:32 -0700 Subject: [PATCH 21/43] Make `schedule()` faster. --- lib/kwasm-net/src/lib.rs | 41 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/lib/kwasm-net/src/lib.rs b/lib/kwasm-net/src/lib.rs index 22ec413e5ec..2cfce862464 100644 --- a/lib/kwasm-net/src/lib.rs +++ b/lib/kwasm-net/src/lib.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::os::wasi::io::FromRawFd; use std::net::{Ipv4Addr, AddrParseError}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use std::cell::RefCell; const AF_INET: i32 = 2; @@ -28,7 +28,7 @@ extern "C" { fn _accept4(fd: i32, sa: *mut SockaddrIn, sa_len: *mut usize, flags: u32) -> i32; fn _sendto(fd: i32, buf: *const u8, buf_len: usize, flags: u32, addr: *const SockaddrIn, addr_len: usize) -> i32; fn _recvfrom(fd: i32, buf: *mut u8, buf_len: usize, flags: u32, addr: *mut SockaddrIn, addr_len: *mut usize) -> i32; - fn _get_immediate_fd() -> i32; + fn _eventfd_sem(initial: u32) -> i32; fn _epoll_create() -> i32; fn _epoll_ctl( epfd: i32, @@ -62,6 +62,7 @@ struct AsyncState { pub struct Epoll { fd: i32, + imm_queue: Mutex>>, } impl Epoll { @@ -72,15 +73,29 @@ impl Epoll { assert!(fd >= 0); Epoll { fd: fd, + imm_queue: Mutex::new(Vec::new()), } } + pub fn schedule(&self, f: F) { + self.imm_queue.lock().unwrap().push(Box::new(f)); + } + pub unsafe fn run(self: Arc) -> ! { GLOBAL_EPOLL.with(|x| { *x.borrow_mut() = Some(self.clone()); }); let mut events: Vec = vec! [ EpollEvent::default(); 32 ]; loop { + loop { + let imm_queue = ::std::mem::replace(&mut *self.imm_queue.lock().unwrap(), Vec::new()); + if imm_queue.len() == 0 { + break; + } + for f in imm_queue { + f(); + } + } let events_len = events.len(); let n_ready = _epoll_wait(self.fd, events.as_mut_ptr(), events_len, -1); assert!(n_ready >= 0); @@ -127,27 +142,9 @@ fn put_async_state(mut x: Box) { } pub fn schedule(f: F) { + //println!("schedule"); let epoll = GLOBAL_EPOLL.with(|x| x.borrow().as_ref().unwrap().clone()); - let epfd = epoll.fd; - let imm_fd = unsafe { _get_immediate_fd() }; - assert!(imm_fd >= 0); - - let mut state = get_async_state(); - state.callback = Some(Box::new(move || { - assert!(unsafe { - _epoll_ctl(epfd, EPOLL_CTL_DEL, imm_fd, ::std::ptr::null()) - } >= 0); - unsafe { File::from_raw_fd(imm_fd as _) }; - f(); - })); - state._epoll = Some(epoll); - - let ev = EpollEvent { - events: EPOLLIN | EPOLLET | EPOLLONESHOT, - data: Box::into_raw(state) as usize as _, - }; - let ret = unsafe { _epoll_ctl(epfd, EPOLL_CTL_ADD, imm_fd, &ev) }; - assert!(ret >= 0); + epoll.schedule(f); } fn get_async_io_payload Result + 'static, F: FnOnce(Result) + 'static>( From 9df3e4af88cad23c603fb853c83f9ac275d68108 Mon Sep 17 00:00:00 2001 From: Heyang Zhou Date: Tue, 14 May 2019 00:05:05 -0700 Subject: [PATCH 22/43] Fix http server example. --- examples/http-server/src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/http-server/src/main.rs b/examples/http-server/src/main.rs index 3ace473774e..22727cd6ea9 100644 --- a/examples/http-server/src/main.rs +++ b/examples/http-server/src/main.rs @@ -25,13 +25,19 @@ fn serve(stream: Arc, mut all: Vec) { return; } }; - if let Some(pos) = s.find("\r\n\r\n") { + if let Some(_pos) = s.find("\r\n\r\n") { + let body = format!( + "Hello, world!\n", + ).into_bytes(); + let stream = stream2.clone(); stream2.write_all_async( format!( - "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\n\r\nYour headers: \n\n{}\n", - ::std::str::from_utf8(&all[..pos]).unwrap() + "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nConnection: close\r\nContent-Length: {}\r\n\r\n", + body.len() ).into_bytes(), - |result| {} + |_| { + stream.write_all_async(body, |_| {}); + } ); } else { schedule(|| serve(stream2, all)); From 2a160c74ad0a33edd73414e5075c37c45fe04ac7 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 15:47:19 +0800 Subject: [PATCH 23/43] Fix wasmer-runtime-core dependency version. --- lib/kwasm-loader/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kwasm-loader/Cargo.toml b/lib/kwasm-loader/Cargo.toml index bc3303aa504..abf2fa8f25d 100644 --- a/lib/kwasm-loader/Cargo.toml +++ b/lib/kwasm-loader/Cargo.toml @@ -6,4 +6,4 @@ edition = "2018" [dependencies] libc = "0.2.49" -wasmer-runtime-core = { path = "../runtime-core", version = "0.3.0" } +wasmer-runtime-core = { path = "../runtime-core" } From 722ea3987765eaecdf8c52c2e47b1ef5c03a870c Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:02:27 +0800 Subject: [PATCH 24/43] Cleanup loader code. --- Cargo.lock | 634 ++++++++++++++++++--------------- Cargo.toml | 3 +- lib/runtime-core/src/loader.rs | 14 + src/bin/kwasmd.rs | 15 +- src/bin/wasmer.rs | 10 +- 5 files changed, 378 insertions(+), 298 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35daf0b07ea..0d2ad8eb84a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,13 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "MacTypes-sys" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "adler32" version = "1.0.3" @@ -62,8 +54,8 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -80,8 +72,8 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -90,8 +82,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -111,7 +103,7 @@ dependencies = [ "cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -119,7 +111,7 @@ dependencies = [ "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -139,15 +131,6 @@ dependencies = [ "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "blob" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "build_const" version = "0.2.1" @@ -173,7 +156,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bzip2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -181,8 +164,8 @@ name = "bzip2-sys" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -198,7 +181,7 @@ name = "capstone-sys" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,15 +191,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cbindgen" -version = "0.8.3" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -225,7 +208,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -250,20 +233,20 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clap" -version = "2.32.0" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -278,10 +261,10 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.38" +version = "0.1.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -290,22 +273,47 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "core-foundation" -version = "0.5.1" +name = "cookie" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "core-foundation-sys" +name = "cookie_store" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "core-foundation-sys" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cranelift-bforest" version = "0.30.0" @@ -394,23 +402,25 @@ dependencies = [ [[package]] name = "criterion" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion-plot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "csv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -418,7 +428,7 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -498,13 +508,13 @@ dependencies = [ [[package]] name = "csv" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -525,7 +535,7 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -582,7 +592,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -592,7 +602,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -602,7 +612,16 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "error-chain" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -632,12 +651,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "filetime" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -646,7 +665,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -689,7 +708,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -697,7 +716,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -739,13 +758,13 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -761,7 +780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -784,7 +803,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -809,27 +828,27 @@ dependencies = [ [[package]] name = "hyper" -version = "0.12.25" +version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -840,9 +859,9 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.25 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -869,7 +888,7 @@ dependencies = [ "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "enum-methods 0.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -887,7 +906,7 @@ name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -901,7 +920,7 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -917,8 +936,8 @@ dependencies = [ name = "kwasm-loader" version = "0.1.0" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-runtime-core 0.3.0", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-runtime-core 0.4.1", ] [[package]] @@ -937,12 +956,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.51" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libflate" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -955,7 +974,7 @@ name = "libloading" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -964,8 +983,8 @@ name = "linked-hash-map" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_test 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_test 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -973,10 +992,10 @@ name = "llvm-sys" version = "70.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1002,7 +1021,7 @@ name = "lz4" version = "1.23.1" source = "git+https://github.com/zboxfs/lz4-rs.git#4704144553d827a96d4fedeb683dbde1360e06e3" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "lz4-sys 1.8.3 (git+https://github.com/zboxfs/lz4-rs.git)", ] @@ -1011,8 +1030,8 @@ name = "lz4-sys" version = "1.8.3" source = "git+https://github.com/zboxfs/lz4-rs.git#4704144553d827a96d4fedeb683dbde1360e06e3" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1025,7 +1044,7 @@ name = "memchr" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1033,7 +1052,7 @@ name = "memmap" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1042,7 +1061,7 @@ name = "memmap" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1056,7 +1075,7 @@ name = "mime" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1083,9 +1102,9 @@ name = "miniz_oxide_c_api" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1099,7 +1118,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1120,18 +1139,18 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1141,7 +1160,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1151,9 +1170,9 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1163,9 +1182,9 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1201,20 +1220,25 @@ name = "num_cpus" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "openssl" -version = "0.10.20" +version = "0.10.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1224,13 +1248,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.43" +version = "0.9.46" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1256,7 +1280,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1274,7 +1298,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1357,6 +1381,18 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "publicsuffix" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -1381,7 +1417,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1393,12 +1429,12 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1445,10 +1481,10 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1460,7 +1496,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1498,7 +1534,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1519,7 +1555,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1533,7 +1569,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1541,12 +1577,12 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1574,28 +1610,31 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.9.13" +version = "0.9.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.25 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1617,12 +1656,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1635,7 +1674,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1681,23 +1720,21 @@ dependencies = [ [[package]] name = "security-framework" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "security-framework-sys" -version = "0.2.3" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1715,10 +1752,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1727,7 +1764,7 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1735,12 +1772,12 @@ name = "serde_bytes" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1753,27 +1790,27 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_test" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_urlencoded" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1804,7 +1841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1812,7 +1849,7 @@ name = "structopt" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1873,12 +1910,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "tar" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1907,9 +1944,9 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1924,17 +1961,18 @@ dependencies = [ [[package]] name = "termion" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "textwrap" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1953,8 +1991,8 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1963,24 +2001,25 @@ name = "tinytemplate" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1990,7 +2029,7 @@ name = "tokio-current-thread" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2000,7 +2039,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2009,7 +2048,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2019,7 +2058,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2028,16 +2067,16 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-sync" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2046,7 +2085,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2055,13 +2094,13 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2075,7 +2114,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2093,7 +2132,7 @@ name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2101,6 +2140,14 @@ name = "try-lock" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "try_from" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "typenum" version = "1.10.0" @@ -2121,7 +2168,7 @@ dependencies = [ [[package]] name = "unicase" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2211,8 +2258,8 @@ name = "wabt" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2222,8 +2269,8 @@ name = "wabt-sys" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2242,7 +2289,7 @@ name = "want" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2287,13 +2334,13 @@ dependencies = [ "cranelift-native 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-wasm 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde-bench 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.4.1", "wasmer-win-exception-handler 0.4.1", @@ -2308,7 +2355,7 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2323,14 +2370,14 @@ name = "wasmer-llvm-backend" version = "0.4.1" dependencies = [ "capstone 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "inkwell 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2350,7 +2397,7 @@ dependencies = [ name = "wasmer-runtime" version = "0.4.1" dependencies = [ - "criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2367,21 +2414,21 @@ version = "0.4.1" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.4.1", "wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)", "zbox 0.6.1 (git+https://github.com/wasmerio/zbox?branch=bundle-libsodium)", - "zstd 0.4.22+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "zstd 0.4.24+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasmer-runtime-c-api" version = "0.4.1" dependencies = [ - "cbindgen 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime 0.4.1", "wasmer-runtime-core 0.4.1", ] @@ -2398,15 +2445,15 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde-bench 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2421,7 +2468,7 @@ dependencies = [ "dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.4.1", @@ -2446,7 +2493,7 @@ dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "generational-arena 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.4.1", @@ -2457,9 +2504,9 @@ name = "wasmer-win-exception-handler" version = "0.4.1" dependencies = [ "bindgen 0.46.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-runtime-core 0.4.1", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2475,7 +2522,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2538,74 +2585,72 @@ name = "xattr" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zbox" version = "0.6.1" -source = "git+https://github.com/wasmerio/zbox?branch=bundle-libsodium#113c62bf3f94124c4978959043efcf98222fa626" +source = "git+https://github.com/wasmerio/zbox?branch=bundle-libsodium#2636be2907eddfdaa23e1cd385416e804663a2dd" dependencies = [ "android_logger 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libflate 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lz4 1.23.1 (git+https://github.com/zboxfs/lz4-rs.git)", "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "reqwest 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)", "rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "tar 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "zip 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "zip 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zip" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "libflate 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zstd" -version = "0.4.22+zstd.1.3.8" +version = "0.4.24+zstd.1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "zstd-safe 1.4.7+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "zstd-safe 1.4.9+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zstd-safe" -version = "1.4.7+zstd.1.3.8" +version = "1.4.9+zstd.1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "zstd-sys 1.4.8+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "zstd-sys 1.4.10+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zstd-sys" -version = "1.4.8+zstd.1.3.8" +version = "1.4.10+zstd.1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "blob 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum MacTypes-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f0d0b1cc33a4d2aee14fb4b2eac03462ef4db29c8ac4057327d8a71ad86f" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" @@ -2621,7 +2666,6 @@ dependencies = [ "checksum bindgen 0.46.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f7f7f0701772b17de73e4f5cbcb1dd6926f4706cba4c1ab62c5367f8bdc94e1" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2b_simd 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce2571a6cd634670daa2977cc894c1cc2ba57c563c498e5a82c35446f34d056e" -"checksum blob 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "19803aa44ff8b43123bbe369efaddcb638ea7dc332e543972dd95ac7cb148b92" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" @@ -2630,17 +2674,19 @@ dependencies = [ "checksum capstone 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00be9d203fa0e078b93b24603633fb081851dfe0c1086364431f52587a47157e" "checksum capstone-sys 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2dc8d32bc5c1e6d0fcde10af411c98b07d93498d51654f678757f08fa2acd6a6" "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" -"checksum cbindgen 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "31f70db109be74a3dfcb0af4d0d191e52230351477f14c2ed10707c2b0dcfa2e" -"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd" +"checksum cbindgen 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1f861ef68cabbb271d373a7795014052bff37edce22c620d95e395e8719d7dc5" +"checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d" "checksum cexpr 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7fa24eb00d5ffab90eaeaf1092ac85c04c64aaf358ea6f84505b8116d24c6af" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "96210eec534fc3fbfc0452a63769424eaa80205fda6cea98e5b61cb3d97bcec8" +"checksum cmake 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "d9fc5523427cb1451da064f7db483d18bf8957e471baabf140ff683c37a86536" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" -"checksum core-foundation 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "286e0b41c3a20da26536c6000a280585d519fd07b3956b43aed8a79e9edce980" -"checksum core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "716c271e8613ace48344f723b60b900a93150271e5be206212d052bbc0883efa" +"checksum cookie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99be24cfcf40d56ed37fd11c2123be833959bbc5bddecb46e1c2e442e15fa3e0" +"checksum cookie_store 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b0d2f2ecb21dce00e2453268370312978af9b8024020c7a37ae2cc6dbbe64685" +"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" +"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" "checksum cranelift-bforest 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5a357d20666bf4a8c2d626a19f1b59dbca66cd844fb1e66c5612254fd0f7505" "checksum cranelift-codegen 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab00cb149a5bb0f7e6dd391357356a5d71c335a431e8eece94f32da2d5a043f7" "checksum cranelift-codegen-meta 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3797a2f450ac71297e083dd440d0cdd0d3bceabe4a3ca6bcb9e4077e9c0327d" @@ -2650,8 +2696,8 @@ dependencies = [ "checksum cranelift-wasm 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740ebfba28c8433f06750f84819f1eb663ea9f5e4b9a81c01f4e52262d868b56" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "1c6e5ee5b9652d4f851418c448af105642e1f99e9a2741a8ff45c0d2c911b1e0" -"checksum criterion-plot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4107e4a5abb94267e0149922b8ff49dc70a87cc202820fdbfc0d3e1edbdc4b16" +"checksum criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0363053954f3e679645fc443321ca128b7b950a6fe288cf5f9335cc22ee58394" +"checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" @@ -2659,10 +2705,10 @@ dependencies = [ "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f8306fcef4a7b563b76b7dd949ca48f52bc1141aa067d2ea09565f3e2652aa5c" -"checksum csv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f0782c7154d8dd08f4adeb5aa22ab178c10281915f7da68d10bb646f03aaee73" +"checksum csv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9044e25afb0924b5a5fc5511689b0918629e85d68ea591e5e87fbf1e85ea1b3b" "checksum csv-core 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa5cdef62f37e6ffe7d1f07a381bc0db32b7a3ff1cac0de56cb0d81e71f53d65" "checksum digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05f47366984d3ad862010e22c7ce81a7dbcaebbdfb37241a620f8b6596ee135c" -"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" +"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e" "checksum dynasm 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f36d49ab6f8ecc642d2c6ee10fda04ba68003ef0277300866745cdde160e6b40" "checksum dynasmrt 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c408a211e7f5762829f5e46bdff0c14bc3b1517a21a4bb781c716bf88b0c68" "checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b" @@ -2671,10 +2717,11 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum field-offset 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64e9bc339e426139e02601fa69d101e96a92aee71b58bc01697ec2a63a5c9e68" -"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646" +"checksum filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" "checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" @@ -2682,21 +2729,21 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "62941eff9507c8177d448bd83a44d9b9760856e184081d8cd79ba9f03dd24981" +"checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generational-arena 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4024f96ffa0ebaaf36aa589cd41f2fd69f3a5e6fd02c86e11e12cdf41d5b46a3" "checksum generic-array 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c0f28c2f5bfb5960175af447a2da7c18900693738343dc896ffbcabd9839592" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum goblin 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "84473a5302fa5094d3d9911c2f312f522f9a37462a777f195f63fae1bf7faf4d" -"checksum h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "910a5e7be6283a9c91b3982fa5188368c8719cce2a3cf3b86048673bf9d9c36b" +"checksum h2 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "85ab6286db06040ddefb71641b50017c06874614001a134b423783e2db2920bd" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" -"checksum hyper 0.12.25 (registry+https://github.com/rust-lang/crates.io-index)" = "7d5b6658b016965ae301fa995306db965c93677880ea70765a84235a96eae896" +"checksum hyper 0.12.28 (registry+https://github.com/rust-lang/crates.io-index)" = "e8e4606fed1c162e3a63d408c07584429f49a4f34c7176cb6cbee60e78f2372c" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -2704,12 +2751,12 @@ dependencies = [ "checksum inkwell_internal_macros 0.1.0 (git+https://github.com/wasmerio/inkwell?branch=llvm7-0)" = "" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" -"checksum libflate 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "7346a83e8a2c3958d44d24225d905385dc31fc16e89dffb356c457b278914d20" +"checksum libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c6785aa7dd976f5fbf3b71cfd9cd49d7f783c1ff565a858d71031c6c313aa5c6" +"checksum libflate 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c52384aeb22d0ce82a10d8ddf35f7fb4717d1b23eac5b94cd38d2050fb53766a" "checksum libloading 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3ad660d7cb8c5822cd83d10897b0f1f1526792737a179e73896152f85b88c2" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum llvm-sys 70.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60a9ee82fe0fa72ae6ef6d018b407296085863836451c7a97384f84ed7e26b9f" @@ -2728,7 +2775,7 @@ dependencies = [ "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum native-tls 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8e08de0070bbf4c31f452ea2a70db092f36f6f2e4d897adf5674477d488fb2" +"checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" "checksum nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "921f61dc817b379d0834e45d5ec45beaacfae97082090a49c2cf30dcbc30206f" "checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" @@ -2737,9 +2784,10 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum openssl 0.10.20 (registry+https://github.com/rust-lang/crates.io-index)" = "5a0d6b781aac4ac1bd6cafe2a2f0ad8c16ae8e1dd5184822a16c50139f8838d9" +"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" +"checksum openssl 0.10.22 (registry+https://github.com/rust-lang/crates.io-index)" = "a51f452b82d622fc8dd973d7266e9055ac64af25b957d9ced3989142dc61cb6b" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.43 (registry+https://github.com/rust-lang/crates.io-index)" = "33c86834957dd5b915623e94f2f4ab2c70dd8f6b70679824155d5ae21dbd495d" +"checksum openssl-sys 0.9.46 (registry+https://github.com/rust-lang/crates.io-index)" = "05636e06b4f8762d4b81d24a351f3966f38bd25ccbcfd235606c91fdb82cc60f" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f89ef58b3d32420dbd1a43d2f38ae92f6239ef12bb556ab09ca55445f5a67242" @@ -2755,6 +2803,7 @@ dependencies = [ "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum publicsuffix 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5afecba86dcf1e4fd610246f89899d1924fe12e1e89f555eb7c7f710f3c5ad1d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" @@ -2765,7 +2814,7 @@ dependencies = [ "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" @@ -2774,39 +2823,39 @@ dependencies = [ "checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)" = "d32b3053e5ced86e4bc0411fec997389532bf56b000e66cb4884eeeb41413d69" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum reqwest 0.9.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3c4ef83e0beb14bfe38b9f01330a5bc8e965a9f9628690aa28383746dac1e925" +"checksum reqwest 0.9.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ddcfd2c13c6af0f9c45a1086be3b9c68af79e4430b42790759e2d34cce2a6c60" "checksum rmp 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a3d45d7afc9b132b34a2479648863aa95c5c88e98b32285326a6ebadc80ec5c9" "checksum rmp-serde 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" -"checksum security-framework 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfab8dda0e7a327c696d893df9ffa19cadc4bd195797997f5223cf5831beaf05" -"checksum security-framework-sys 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6696852716b589dff9e886ff83778bb635150168e83afa8ac6b8a78cb82abc" +"checksum security-framework 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eee63d0f4a9ec776eeb30e220f0bc1e092c3ad744b2a379e3993070364d3adc2" +"checksum security-framework-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9636f8989cbf61385ae4824b98c1aaa54c994d7d8b41f11c601ed799f0549a56" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" "checksum serde-bench 0.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd" "checksum serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "defbb8a83d7f34cc8380751eeb892b825944222888aff18996ea7901f24aec88" -"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" +"checksum serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "101b495b109a3e3ca8c4cbe44cf62391527cdfb6ba15821c5ce80bcd5ea23f9f" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum serde_test 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce17ed207fa61e7f4701a778a6c111da84a441ca9a8f50b92808f4223dd240b" -"checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2" +"checksum serde_test 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "164b351e29d8a2230b77c27e47dda5603be39a2d35db38f440f0b78946ce37c7" +"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b639411d0b9c738748b5397d5ceba08e648f4f1992231aa859af1a017f31f60b" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" @@ -2814,32 +2863,33 @@ dependencies = [ "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" -"checksum tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2167ff53da2a661702b3299f71a91b61b1dffef36b4b2884b1f9c67254c0133" +"checksum tar 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "7201214ded95b34e3bc00c9557b6dcec34fd1af428d343143f5db67c661762f0" "checksum target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6923974ce4eb5bd28814756256d8ab71c28dd6e7483313fe7ab6614306bf633" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tinytemplate 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7655088894274afb52b807bd3c87072daa1fedd155068b8705cabfd628956115" -"checksum tokio 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "65641e515a437b308ab131a82ce3042ff9795bef5d6c5a9be4eb24195c417fd9" +"checksum tokio 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "cec6c34409089be085de9403ba2010b80e36938c9ca992c4f67f407bb13db0b1" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-executor 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "83ea44c6c0773cc034771693711c35c677b4b5a4b21b9e7071704c54de7d555e" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-reactor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6af16bfac7e112bea8b0442542161bfc41cbfa4466b580bdda7d18cb88b911ce" -"checksum tokio-sync 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "fda385df506bf7546e70872767f71e81640f1f251bdf2fd8eb81a0eaec5fe022" +"checksum tokio-sync 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5b2f843ffdf8d6e1f90bddd48da43f99ab071660cd92b7ec560ef3cdfd7a409a" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ec5759cf26cf9659555f36c431b515e3d05f66831741c85b4b5d5dfb9cf1323c" +"checksum tokio-threadpool 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72558af20be886ea124595ea0f806dd5703b8958e4705429dd58b3d8231f72f2" "checksum tokio-timer 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2910970404ba6fa78c5539126a9ae2045d62e3713041e447f695f41405a120c6" "checksum tokio-trace-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "350c9edade9830dc185ae48ba45667a445ab59f6167ef6d0254ec9d2430d9dd3" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +"checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicase 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41d17211f887da8e4a70a45b9536f26fc5de166b81e2d5d80de4a17fd22553bd" +"checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" @@ -2869,7 +2919,7 @@ dependencies = [ "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" "checksum zbox 0.6.1 (git+https://github.com/wasmerio/zbox?branch=bundle-libsodium)" = "" -"checksum zip 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1cbbddef6339155bc4fa8e2609040078ff18f3011117b55caa9f0516d544a357" -"checksum zstd 0.4.22+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6f042dd18d52854d302d3d92f66d0a63c2d520d7b7034a9d43cde7441d1b4ddd" -"checksum zstd-safe 1.4.7+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "63febf0b0dcd076db81e6b3110ed254cfb8ed54378a4c3cfbb68956e839d4f59" -"checksum zstd-sys 1.4.8+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "4cb187d624025a7d9878ecf13437491869423426183ded2fa40d4651b85f7ae7" +"checksum zip 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c18fc320faf909036e46ac785ea827f72e485304877faf1a3a39538d3714dbc3" +"checksum zstd 0.4.24+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c5a6414958b49ee80f2dd0042023ac8f37cfe1d31fbeec0b9749cf6f2c03683" +"checksum zstd-safe 1.4.9+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d98332212af687878b146a6549c188e9b72971972d23089c831472f938e6272" +"checksum zstd-sys 1.4.10+zstd.1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f433134fbd0c37c9eb5929733df5f34bcdff464722eb93155fcee93eb57652" diff --git a/Cargo.toml b/Cargo.toml index 5b1457bb8ac..3f8c8a47695 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ wasmer-runtime-core = { path = "lib/runtime-core" } wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } wasmer-wasi = { path = "lib/wasi", optional = true } -kwasm-loader = { path = "lib/kwasm-loader" } +kwasm-loader = { path = "lib/kwasm-loader", optional = true } [workspace] members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/pipe", "examples/wasi-networking", "examples/http-server", "examples/plugin-for-example"] @@ -45,6 +45,7 @@ rustc_version = "0.2.3" [features] default = ["fast-tests", "wasi"] +"loader:kwasm" = ["kwasm-loader"] debug = ["wasmer-runtime-core/debug"] extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] # This feature will allow cargo test to run much faster diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index 0982c75f971..6b970aa9509 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -8,6 +8,7 @@ use crate::{ module::ModuleInfo, types::Value, }; +#[cfg(unix)] use libc::{ mmap, mprotect, munmap, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_READ, PROT_WRITE, @@ -81,6 +82,18 @@ pub struct CodeMemory { size: usize, } +#[cfg(not(unix))] +impl CodeMemory { + pub fn new(_size: usize) -> CodeMemory { + unimplemented!(); + } + + pub fn make_executable(&mut self) { + unimplemented!(); + } +} + +#[cfg(unix)] impl CodeMemory { pub fn new(size: usize) -> CodeMemory { fn round_up_to_page_size(size: usize) -> usize { @@ -113,6 +126,7 @@ impl CodeMemory { } } +#[cfg(unix)] impl Drop for CodeMemory { fn drop(&mut self) { unsafe { munmap(self.ptr as _, self.size); } diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 214af6017bd..509167008a5 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -5,13 +5,12 @@ use std::thread; use structopt::StructOpt; use wasmer::*; use wasmer_runtime::{ - error::RuntimeError, - Func, Value, + Value, }; use wasmer_runtime_core::{ self, - backend::{Compiler, CompilerConfig, MemoryBoundCheckMode}, - loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, + backend::{CompilerConfig, MemoryBoundCheckMode}, + loader::{Instance as LoadedInstance}, }; use wasmer_singlepass_backend::SinglePassCompiler; @@ -37,6 +36,7 @@ const CMD_RUN_CODE: u32 = 0x901; const CMD_READ_MEMORY: u32 = 0x902; const CMD_WRITE_MEMORY: u32 = 0x903; +#[cfg(feature = "loader:kwasm")] fn handle_client(mut stream: UnixStream) { let binary_size = stream.read_u32::().unwrap(); if binary_size > 1048576 * 16 { @@ -127,6 +127,7 @@ fn handle_client(mut stream: UnixStream) { } } +#[cfg(feature = "loader:kwasm")] fn run_listen(opts: Listen) { let listener = UnixListener::bind(&opts.socket).unwrap(); for stream in listener.incoming() { @@ -148,6 +149,7 @@ fn run_listen(opts: Listen) { } } +#[cfg(feature = "loader:kwasm")] fn main() { let options = CLIOptions::from_args(); match options { @@ -156,3 +158,8 @@ fn main() { } } } + +#[cfg(not(feature = "loader:kwasm"))] +fn main() { + panic!("Kwasm loader is not enabled during compilation."); +} \ No newline at end of file diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 4cf4d95e71a..e5c50e22cdb 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -25,7 +25,7 @@ use wasmer_runtime::{ use wasmer_runtime_core::{ self, backend::{Compiler, CompilerConfig, MemoryBoundCheckMode}, - loader::{self, Loader, Instance as LoadedInstance, LocalLoader}, + loader::{Instance as LoadedInstance, LocalLoader}, }; #[cfg(feature = "backend:singlepass")] use wasmer_singlepass_backend::SinglePassCompiler; @@ -116,6 +116,7 @@ struct Run { #[derive(Debug, Copy, Clone)] enum LoaderName { Local, + #[cfg(feature = "loader:kwasm")] Kernel, } @@ -123,6 +124,7 @@ impl LoaderName { pub fn variants() -> &'static [&'static str] { &[ "local", + #[cfg(feature = "loader:kwasm")] "kernel", ] } @@ -133,6 +135,7 @@ impl FromStr for LoaderName { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "local" => Ok(LoaderName::Local), + #[cfg(feature = "loader:kwasm")] "kernel" => Ok(LoaderName::Kernel), _ => Err(format!("The loader {} doesn't exist", s)), } @@ -293,12 +296,16 @@ fn execute_wasm(options: &Run) -> Result<(), String> { Backend::LLVM => return Err("the llvm backend is not enabled".to_string()), }; + #[cfg(feature = "loader:kwasm")] let is_kernel_loader = if let Some(LoaderName::Kernel) = options.loader { true } else { false }; + #[cfg(not(feature = "loader:kwasm"))] + let is_kernel_loader = false; + let module = if is_kernel_loader { webassembly::compile_with_config_with( &wasm_binary[..], @@ -377,6 +384,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { let index = instance.resolve_func("_start").unwrap(); let mut ins: Box> = match loader { LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), + #[cfg(feature = "loader:kwasm")] LoaderName::Kernel => Box::new(instance.load(::kwasm_loader::KernelLoader).unwrap()), }; println!("{:?}", ins.call(index, &args)); From 32f9aee6feaa6b724f9b05c765910e5e20d6c8f8 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:04:08 +0800 Subject: [PATCH 25/43] Cargo fmt --- examples/http-server/src/main.rs | 20 +- examples/wasi-networking/src/main.rs | 60 +++--- lib/kwasm-loader/src/lib.rs | 125 +++++++---- lib/kwasm-loader/src/service.rs | 55 ++--- lib/kwasm-net/src/lib.rs | 248 +++++++++++++--------- lib/runtime-core/src/backend.rs | 8 +- lib/runtime-core/src/codegen.rs | 4 +- lib/runtime-core/src/instance.rs | 8 +- lib/runtime-core/src/lib.rs | 2 +- lib/runtime-core/src/loader.rs | 70 +++--- lib/runtime-core/src/vm.rs | 4 +- lib/singlepass-backend/src/codegen_x64.rs | 66 +++--- src/bin/kwasmd.rs | 27 ++- src/bin/wasmer.rs | 8 +- 14 files changed, 404 insertions(+), 301 deletions(-) diff --git a/examples/http-server/src/main.rs b/examples/http-server/src/main.rs index 22727cd6ea9..5d1125e93af 100644 --- a/examples/http-server/src/main.rs +++ b/examples/http-server/src/main.rs @@ -1,6 +1,6 @@ #![feature(wasi_ext)] -use kwasm_net::{Epoll, Tcp4Listener, TcpStream, schedule}; +use kwasm_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn serve(stream: Arc, mut all: Vec) { @@ -55,16 +55,14 @@ fn main() { let epoll = Arc::new(Epoll::new()); let listener = Arc::new(Tcp4Listener::new("0.0.0.0", 2011, 128).unwrap()); - listener.accept_async(epoll.clone(), |stream| { - match stream { - Ok(stream) => { - serve(stream, vec![]); - Ok(()) - }, - Err(code) => { - println!("failed to accept; code = {}", code); - Err(()) - } + listener.accept_async(epoll.clone(), |stream| match stream { + Ok(stream) => { + serve(stream, vec![]); + Ok(()) + } + Err(code) => { + println!("failed to accept; code = {}", code); + Err(()) } }); println!("start epoll"); diff --git a/examples/wasi-networking/src/main.rs b/examples/wasi-networking/src/main.rs index d73f7961eba..65504bde8a9 100644 --- a/examples/wasi-networking/src/main.rs +++ b/examples/wasi-networking/src/main.rs @@ -1,33 +1,29 @@ #![feature(wasi_ext)] -use kwasm_net::{Epoll, Tcp4Listener, TcpStream, schedule}; +use kwasm_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn do_echo(stream: Arc, buf: Vec) { let stream2 = stream.clone(); - stream.read_async(buf, move |result| { - match result { - Ok(buf) => { - if buf.len() == 0 { - return; - } - let stream = stream2.clone(); - stream2.write_all_async(buf, move |result| { - match result { - Ok(buf) => { - schedule(|| { - do_echo(stream, buf); - }); - }, - Err(code) => { - println!("failed to write; code = {}", code); - } - } - }); - }, - Err(code) => { - println!("failed to read; code = {}", code); + stream.read_async(buf, move |result| match result { + Ok(buf) => { + if buf.len() == 0 { + return; } + let stream = stream2.clone(); + stream2.write_all_async(buf, move |result| match result { + Ok(buf) => { + schedule(|| { + do_echo(stream, buf); + }); + } + Err(code) => { + println!("failed to write; code = {}", code); + } + }); + } + Err(code) => { + println!("failed to read; code = {}", code); } }); } @@ -36,16 +32,14 @@ fn main() { let epoll = Arc::new(Epoll::new()); let listener = Arc::new(Tcp4Listener::new("0.0.0.0", 2001, 128).unwrap()); - listener.accept_async(epoll.clone(), |stream| { - match stream { - Ok(stream) => { - do_echo(stream, Vec::with_capacity(16384)); - Ok(()) - }, - Err(code) => { - println!("failed to accept; code = {}", code); - Err(()) - } + listener.accept_async(epoll.clone(), |stream| match stream { + Ok(stream) => { + do_echo(stream, Vec::with_capacity(16384)); + Ok(()) + } + Err(code) => { + println!("failed to accept; code = {}", code); + Err(()) } }); println!("start epoll"); diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index 5d548980543..d9b51f2e3f3 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -1,14 +1,17 @@ pub mod service; +use service::{ImportInfo, LoadProfile, RunProfile, ServiceContext, TableEntryRequest}; use wasmer_runtime_core::{ - loader::{self, Loader, Instance}, backend::RunnableModule, - vm::{Ctx, LocalGlobal, SigId, Anyfunc}, + loader::{self, Instance, Loader}, module::ModuleInfo, - types::{Value, LocalMemoryIndex, LocalTableIndex, ImportedMemoryIndex, ImportedTableIndex, FuncIndex}, structures::TypedIndex, + types::{ + FuncIndex, ImportedMemoryIndex, ImportedTableIndex, LocalMemoryIndex, LocalTableIndex, + Value, + }, + vm::{Anyfunc, Ctx, LocalGlobal, SigId}, }; -use service::{ServiceContext, LoadProfile, RunProfile, TableEntryRequest, ImportInfo}; pub struct KernelLoader; @@ -16,7 +19,12 @@ impl Loader for KernelLoader { type Instance = KernelInstance; type Error = String; - fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, full_ctx: &Ctx) -> Result { + fn load( + &self, + rm: &dyn RunnableModule, + module: &ModuleInfo, + full_ctx: &Ctx, + ) -> Result { let ctx = &full_ctx.internal; let code = rm.get_code().unwrap(); let memory = if let Some(_) = module.memories.get(LocalMemoryIndex::new(0)) { @@ -28,54 +36,76 @@ impl Loader for KernelLoader { } else { None }; - let table: Option> = if let Some(_) = module.tables.get(LocalTableIndex::new(0)) { - Some(unsafe { - let table = &**ctx.tables; - let elements: &[Anyfunc] = ::std::slice::from_raw_parts(table.base as *const Anyfunc, table.count); - let base_addr = code.as_ptr() as usize; - let end_addr = base_addr + code.len(); - elements.iter().map(|x| { - let func_addr = x.func as usize; - TableEntryRequest { - offset: if x.func.is_null() || func_addr < base_addr || func_addr >= end_addr { - ::std::usize::MAX - } else { - x.func as usize - base_addr - }, - sig_id: x.sig_id.0, - } - }).collect() - }) - } else if let Some(_) = module.imported_tables.get(ImportedTableIndex::new(0)) { - return Err("imported table is not supported".into()); - } else { - None - }; + let table: Option> = + if let Some(_) = module.tables.get(LocalTableIndex::new(0)) { + Some(unsafe { + let table = &**ctx.tables; + let elements: &[Anyfunc] = + ::std::slice::from_raw_parts(table.base as *const Anyfunc, table.count); + let base_addr = code.as_ptr() as usize; + let end_addr = base_addr + code.len(); + elements + .iter() + .map(|x| { + let func_addr = x.func as usize; + TableEntryRequest { + offset: if x.func.is_null() + || func_addr < base_addr + || func_addr >= end_addr + { + ::std::usize::MAX + } else { + x.func as usize - base_addr + }, + sig_id: x.sig_id.0, + } + }) + .collect() + }) + } else if let Some(_) = module.imported_tables.get(ImportedTableIndex::new(0)) { + return Err("imported table is not supported".into()); + } else { + None + }; if module.imported_globals.len() > 0 { return Err("imported globals are not supported".into()); } let globals: Vec = unsafe { - let globals: &[*mut LocalGlobal] = ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); + let globals: &[*mut LocalGlobal] = + ::std::slice::from_raw_parts(ctx.globals, module.globals.len()); globals.iter().map(|x| (**x).data).collect() }; let mut import_names: Vec = vec![]; for (idx, import) in &module.imported_functions { - let name = format!("{}##{}", module.namespace_table.get(import.namespace_index), module.name_table.get(import.name_index)); - let sig = module.signatures.get( - *module.func_assoc.get(FuncIndex::new(idx.index())).unwrap() - ).unwrap(); + let name = format!( + "{}##{}", + module.namespace_table.get(import.namespace_index), + module.name_table.get(import.name_index) + ); + let sig = module + .signatures + .get(*module.func_assoc.get(FuncIndex::new(idx.index())).unwrap()) + .unwrap(); import_names.push(ImportInfo { name: name, param_count: sig.params().len(), }); } let dynamic_sigindices: &[u32] = unsafe { - ::std::mem::transmute::<&[SigId], &[u32]>( - ::std::slice::from_raw_parts(ctx.dynamic_sigindices, full_ctx.dynamic_sigindice_count()) - ) + ::std::mem::transmute::<&[SigId], &[u32]>(::std::slice::from_raw_parts( + ctx.dynamic_sigindices, + full_ctx.dynamic_sigindice_count(), + )) }; let param_counts: Vec = (0..module.func_assoc.len()) - .map(|x| module.signatures.get(*module.func_assoc.get(FuncIndex::new(x)).unwrap()).unwrap().params().len()) + .map(|x| { + module + .signatures + .get(*module.func_assoc.get(FuncIndex::new(x)).unwrap()) + .unwrap() + .params() + .len() + }) .collect(); let profile = LoadProfile { code: code, @@ -109,18 +139,25 @@ impl Instance for KernelInstance { } let args: Vec = args.iter().map(|x| x.to_u64()).collect(); - let ret = self.context.run_code(RunProfile { - entry_offset: self.offsets[id] as u32, - params: &args, - }).map_err(|x| format!("{:?}", x))?; + let ret = self + .context + .run_code(RunProfile { + entry_offset: self.offsets[id] as u32, + params: &args, + }) + .map_err(|x| format!("{:?}", x))?; Ok(ret) } fn read_memory(&mut self, offset: u32, len: u32) -> Result, String> { - self.context.read_memory(offset, len).map_err(|x| format!("{:?}", x)) + self.context + .read_memory(offset, len) + .map_err(|x| format!("{:?}", x)) } fn write_memory(&mut self, offset: u32, len: u32, buf: &[u8]) -> Result<(), String> { - self.context.write_memory(offset, len, buf).map_err(|x| format!("{:?}", x)) + self.context + .write_memory(offset, len, buf) + .map_err(|x| format!("{:?}", x)) } -} \ No newline at end of file +} diff --git a/lib/kwasm-loader/src/service.rs b/lib/kwasm-loader/src/service.rs index 7be3370b95a..45ccdd869be 100644 --- a/lib/kwasm-loader/src/service.rs +++ b/lib/kwasm-loader/src/service.rs @@ -1,6 +1,6 @@ +use std::error::Error; use std::fs::File; use std::io; -use std::error::Error; use std::os::unix::io::AsRawFd; macro_rules! impl_debug_display { @@ -10,7 +10,7 @@ macro_rules! impl_debug_display { ::fmt(self, f) } } - } + }; } #[repr(i32)] @@ -26,7 +26,7 @@ pub enum ServiceError { Io(io::Error), Code(i32), InvalidInput, - Rejected + Rejected, } pub type ServiceResult = Result; @@ -125,29 +125,36 @@ pub struct RunProfile<'a> { } pub struct ServiceContext { - dev: File + dev: File, } impl ServiceContext { pub fn new(load: LoadProfile) -> ServiceResult { let dev = File::open("/dev/wasmctl")?; - let imports: Vec = load.imports.iter().map(|x| { - let mut req = ImportRequest { - name: [0u8; 64], - param_count: x.param_count as u32, - }; - let name = x.name.as_bytes(); - let mut count = req.name.len() - 1; - if name.len() < count { - count = name.len(); - } - req.name[..count].copy_from_slice(&name[..count]); - req - }).collect(); + let imports: Vec = load + .imports + .iter() + .map(|x| { + let mut req = ImportRequest { + name: [0u8; 64], + param_count: x.param_count as u32, + }; + let name = x.name.as_bytes(); + let mut count = req.name.len() - 1; + if name.len() < count { + count = name.len(); + } + req.name[..count].copy_from_slice(&name[..count]); + req + }) + .collect(); let req = LoadCodeRequest { code: load.code.as_ptr(), code_len: load.code.len() as u32, - memory: load.memory.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), + memory: load + .memory + .map(|x| x.as_ptr()) + .unwrap_or(::std::ptr::null()), memory_len: load.memory.map(|x| x.len() as u32).unwrap_or(0), memory_max: load.memory_max as u32, table: load.table.map(|x| x.as_ptr()).unwrap_or(::std::ptr::null()), @@ -164,15 +171,13 @@ impl ServiceContext { ::libc::ioctl( fd, Command::LoadCode as i32 as ::libc::c_ulong, - &req as *const _ as ::libc::c_ulong + &req as *const _ as ::libc::c_ulong, ) }; if ret != 0 { Err(ServiceError::Code(ret)) } else { - Ok(ServiceContext { - dev: dev, - }) + Ok(ServiceContext { dev: dev }) } } @@ -189,7 +194,7 @@ impl ServiceContext { ::libc::ioctl( fd, Command::RunCode as i32 as ::libc::c_ulong, - &mut req as *mut _ as ::libc::c_ulong + &mut req as *mut _ as ::libc::c_ulong, ) }; if err < 0 { @@ -217,7 +222,7 @@ impl ServiceContext { ::libc::ioctl( fd, Command::ReadMemory as i32 as ::libc::c_ulong, - &req as *const _ as ::libc::c_ulong + &req as *const _ as ::libc::c_ulong, ) }; if err < 0 { @@ -238,7 +243,7 @@ impl ServiceContext { ::libc::ioctl( fd, Command::WriteMemory as i32 as ::libc::c_ulong, - &req as *const _ as ::libc::c_ulong + &req as *const _ as ::libc::c_ulong, ) }; if err < 0 { diff --git a/lib/kwasm-net/src/lib.rs b/lib/kwasm-net/src/lib.rs index 2cfce862464..fd4108162ce 100644 --- a/lib/kwasm-net/src/lib.rs +++ b/lib/kwasm-net/src/lib.rs @@ -1,10 +1,10 @@ #![feature(wasi_ext)] +use std::cell::RefCell; use std::fs::File; +use std::net::{AddrParseError, Ipv4Addr}; use std::os::wasi::io::FromRawFd; -use std::net::{Ipv4Addr, AddrParseError}; use std::sync::{Arc, Mutex}; -use std::cell::RefCell; const AF_INET: i32 = 2; const SOCK_STREAM: i32 = 1; @@ -26,27 +26,27 @@ extern "C" { fn _bind(fd: i32, sa: *const SockaddrIn, sa_len: usize) -> i32; fn _listen(fd: i32, backlog: i32) -> i32; fn _accept4(fd: i32, sa: *mut SockaddrIn, sa_len: *mut usize, flags: u32) -> i32; - fn _sendto(fd: i32, buf: *const u8, buf_len: usize, flags: u32, addr: *const SockaddrIn, addr_len: usize) -> i32; - fn _recvfrom(fd: i32, buf: *mut u8, buf_len: usize, flags: u32, addr: *mut SockaddrIn, addr_len: *mut usize) -> i32; - fn _eventfd_sem(initial: u32) -> i32; - fn _epoll_create() -> i32; - fn _epoll_ctl( - epfd: i32, - op: i32, + fn _sendto( fd: i32, - event: *const EpollEvent, - ) -> i32; - fn _epoll_wait( - epfd: i32, - events: *mut EpollEvent, - maxevents: usize, - timeout: i32, + buf: *const u8, + buf_len: usize, + flags: u32, + addr: *const SockaddrIn, + addr_len: usize, ) -> i32; - fn _fcntl( + fn _recvfrom( fd: i32, - cmd: i32, - arg: u32, + buf: *mut u8, + buf_len: usize, + flags: u32, + addr: *mut SockaddrIn, + addr_len: *mut usize, ) -> i32; + fn _eventfd_sem(initial: u32) -> i32; + fn _epoll_create() -> i32; + fn _epoll_ctl(epfd: i32, op: i32, fd: i32, event: *const EpollEvent) -> i32; + fn _epoll_wait(epfd: i32, events: *mut EpollEvent, maxevents: usize, timeout: i32) -> i32; + fn _fcntl(fd: i32, cmd: i32, arg: u32) -> i32; } thread_local! { @@ -67,9 +67,7 @@ pub struct Epoll { impl Epoll { pub fn new() -> Epoll { - let fd = unsafe { - _epoll_create() - }; + let fd = unsafe { _epoll_create() }; assert!(fd >= 0); Epoll { fd: fd, @@ -85,10 +83,11 @@ impl Epoll { GLOBAL_EPOLL.with(|x| { *x.borrow_mut() = Some(self.clone()); }); - let mut events: Vec = vec! [ EpollEvent::default(); 32 ]; + let mut events: Vec = vec![EpollEvent::default(); 32]; loop { loop { - let imm_queue = ::std::mem::replace(&mut *self.imm_queue.lock().unwrap(), Vec::new()); + let imm_queue = + ::std::mem::replace(&mut *self.imm_queue.lock().unwrap(), Vec::new()); if imm_queue.len() == 0 { break; } @@ -108,7 +107,7 @@ impl Epoll { let mut state = Box::from_raw(ev.data as usize as *mut AsyncState); (state.callback.take().unwrap())(); put_async_state(state); - //println!("After callback"); + //println!("After callback"); } else { println!("unknown event(s): 0x{:x}", ev.events); } @@ -128,11 +127,15 @@ impl Drop for Epoll { #[derive(Copy, Clone, Debug)] pub enum EpollDirection { In, - Out + Out, } fn get_async_state() -> Box { - ASYNC_STATE_POOL.with(|pool| pool.borrow_mut().pop().unwrap_or_else(|| Box::new(AsyncState::default()))) + ASYNC_STATE_POOL.with(|pool| { + pool.borrow_mut() + .pop() + .unwrap_or_else(|| Box::new(AsyncState::default())) + }) } fn put_async_state(mut x: Box) { @@ -147,7 +150,11 @@ pub fn schedule(f: F) { epoll.schedule(f); } -fn get_async_io_payload Result + 'static, F: FnOnce(Result) + 'static>( +fn get_async_io_payload< + T: 'static, + P: FnMut(i32) -> Result + 'static, + F: FnOnce(Result) + 'static, +>( epoll: Arc, fd: i32, direction: EpollDirection, @@ -157,7 +164,11 @@ fn get_async_io_payload Result + 'static, F __get_async_io_payload(epoll, fd, direction, poll_action, on_ready, false) } -fn __get_async_io_payload Result + 'static, F: FnOnce(Result) + 'static>( +fn __get_async_io_payload< + T: 'static, + P: FnMut(i32) -> Result + 'static, + F: FnOnce(Result) + 'static, +>( epoll: Arc, fd: i32, direction: EpollDirection, @@ -173,7 +184,14 @@ fn __get_async_io_payload Result + 'static, match ret { Err(x) if x == -EAGAIN || x == -EWOULDBLOCK => { let mut state = get_async_state(); - state.callback = Some(__get_async_io_payload(epoll.clone(), fd, direction, poll_action, on_ready, true)); + state.callback = Some(__get_async_io_payload( + epoll.clone(), + fd, + direction, + poll_action, + on_ready, + true, + )); state._epoll = Some(epoll); let direction_flag = match direction { EpollDirection::In => EPOLLIN, @@ -184,22 +202,14 @@ fn __get_async_io_payload Result + 'static, data: Box::into_raw(state) as usize as _, }; //println!("Alloc event {:?}", ev.data as usize as *mut AsyncState); - let ret = unsafe { _epoll_ctl( - epfd, - EPOLL_CTL_ADD, - fd, - &ev - ) }; + let ret = unsafe { _epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev) }; assert!(ret >= 0); - }, + } x => { if registered { - assert!(unsafe { _epoll_ctl( - epfd, - EPOLL_CTL_DEL, - fd, - ::std::ptr::null(), - ) } >= 0); + assert!( + unsafe { _epoll_ctl(epfd, EPOLL_CTL_DEL, fd, ::std::ptr::null(),) } >= 0 + ); } on_ready(x); // fast path } @@ -210,8 +220,8 @@ fn __get_async_io_payload Result + 'static, #[repr(C)] #[derive(Copy, Clone)] struct SockaddrIn { - sin_family: u16, // e.g. AF_INET - sin_port: u16, // e.g. htons(3490) + sin_family: u16, // e.g. AF_INET + sin_port: u16, // e.g. htons(3490) sin_addr: InAddr, sin_zero: [u8; 8], } @@ -264,23 +274,19 @@ impl Tcp4Listener { let sa = SockaddrIn { sin_family: AF_INET as _, sin_port: invert_byteorder_u16(port), - sin_addr: InAddr { s_addr: unsafe { ::std::mem::transmute(addr.octets()) } }, + sin_addr: InAddr { + s_addr: unsafe { ::std::mem::transmute(addr.octets()) }, + }, sin_zero: [0; 8], }; - let fd = unsafe { - _socket(AF_INET, SOCK_STREAM, 0) - }; + let fd = unsafe { _socket(AF_INET, SOCK_STREAM, 0) }; if fd < 0 { return Err(SocketError::SocketCreate); } - if unsafe { - _bind(fd, &sa, ::std::mem::size_of::()) - } < 0 { + if unsafe { _bind(fd, &sa, ::std::mem::size_of::()) } < 0 { return Err(SocketError::Bind); } - if unsafe { - _listen(fd, backlog as _) - } < 0 { + if unsafe { _listen(fd, backlog as _) } < 0 { return Err(SocketError::Listen); } @@ -297,34 +303,42 @@ impl Tcp4Listener { }) } - pub fn accept_async, i32>) -> Result<(), ()> + 'static>(self: Arc, ep: Arc, cb: F) { + pub fn accept_async, i32>) -> Result<(), ()> + 'static>( + self: Arc, + ep: Arc, + cb: F, + ) { let ep2 = ep.clone(); - (get_async_io_payload(ep.clone(), self.fd, EpollDirection::In, move |fd| -> Result, i32> { - let mut incoming_sa: SockaddrIn = unsafe { ::std::mem::uninitialized() }; - let mut real_len: usize = ::std::mem::size_of::(); - let conn = unsafe { - _accept4(fd, &mut incoming_sa, &mut real_len, O_NONBLOCK) - }; - if conn >= 0 { - unsafe { - let mut socket_flags = _fcntl(conn, F_GETFL, 0) as u32; - socket_flags |= O_NONBLOCK; - assert!(_fcntl(conn, F_SETFL, socket_flags) >= 0); - } - Ok(Arc::new(TcpStream { - fd: conn, - epoll: ep.clone(), - })) - } else { - Err(conn) - } - }, move |x| { - schedule(|| { - if let Ok(()) = cb(x) { - self.accept_async(ep2, cb); + (get_async_io_payload( + ep.clone(), + self.fd, + EpollDirection::In, + move |fd| -> Result, i32> { + let mut incoming_sa: SockaddrIn = unsafe { ::std::mem::uninitialized() }; + let mut real_len: usize = ::std::mem::size_of::(); + let conn = unsafe { _accept4(fd, &mut incoming_sa, &mut real_len, O_NONBLOCK) }; + if conn >= 0 { + unsafe { + let mut socket_flags = _fcntl(conn, F_GETFL, 0) as u32; + socket_flags |= O_NONBLOCK; + assert!(_fcntl(conn, F_SETFL, socket_flags) >= 0); + } + Ok(Arc::new(TcpStream { + fd: conn, + epoll: ep.clone(), + })) + } else { + Err(conn) } - }); - }))(); + }, + move |x| { + schedule(|| { + if let Ok(()) = cb(x) { + self.accept_async(ep2, cb); + } + }); + }, + ))(); } } @@ -334,7 +348,12 @@ pub struct TcpStream { } impl TcpStream { - pub fn __write_async(self: Arc, data: Vec, offset: usize, cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static) { + pub fn __write_async( + self: Arc, + data: Vec, + offset: usize, + cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static, + ) { let mut data = Some(data); (get_async_io_payload( @@ -344,9 +363,8 @@ impl TcpStream { move |fd| -> Result<(usize, Vec), i32> { let _data = data.as_ref().unwrap(); let _data = &_data[offset..]; - let ret = unsafe { - _sendto(fd, _data.as_ptr(), _data.len(), 0, ::std::ptr::null(), 0) - }; + let ret = + unsafe { _sendto(fd, _data.as_ptr(), _data.len(), 0, ::std::ptr::null(), 0) }; if ret >= 0 { Ok((ret as usize, data.take().unwrap())) } else { @@ -356,37 +374,52 @@ impl TcpStream { move |x| { drop(self); cb(x); - } + }, ))(); } - pub fn write_async(self: Arc, data: Vec, cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static) { + pub fn write_async( + self: Arc, + data: Vec, + cb: impl FnOnce(Result<(usize, Vec), i32>) + 'static, + ) { self.__write_async(data, 0, cb) } - pub fn write_all_async(self: Arc, data: Vec, cb: impl FnOnce(Result, i32>) + 'static) { - fn inner(me: Arc, data: Vec, offset: usize, cb: impl FnOnce(Result, i32>) + 'static) { + pub fn write_all_async( + self: Arc, + data: Vec, + cb: impl FnOnce(Result, i32>) + 'static, + ) { + fn inner( + me: Arc, + data: Vec, + offset: usize, + cb: impl FnOnce(Result, i32>) + 'static, + ) { let me2 = me.clone(); - me.__write_async(data, offset, move |result| { - match result { - Ok((len, data)) => { - let new_offset = offset + len; - if new_offset == data.len() { - cb(Ok(data)); - } else { - inner(me2, data, new_offset, cb); - } - } - Err(code) => { - cb(Err(code)); + me.__write_async(data, offset, move |result| match result { + Ok((len, data)) => { + let new_offset = offset + len; + if new_offset == data.len() { + cb(Ok(data)); + } else { + inner(me2, data, new_offset, cb); } } + Err(code) => { + cb(Err(code)); + } }) } inner(self, data, 0, cb); } - pub fn read_async(self: Arc, out: Vec, cb: impl FnOnce(Result, i32>) + 'static) { + pub fn read_async( + self: Arc, + out: Vec, + cb: impl FnOnce(Result, i32>) + 'static, + ) { let mut out = Some(out); (get_async_io_payload( self.epoll.clone(), @@ -396,7 +429,14 @@ impl TcpStream { let _out = out.as_mut().unwrap(); let out_cap = _out.capacity(); let ret = unsafe { - _recvfrom(fd, _out.as_mut_ptr(), out_cap, 0, ::std::ptr::null_mut(), ::std::ptr::null_mut()) + _recvfrom( + fd, + _out.as_mut_ptr(), + out_cap, + 0, + ::std::ptr::null_mut(), + ::std::ptr::null_mut(), + ) }; if ret >= 0 { assert!(ret as usize <= out_cap); @@ -411,7 +451,7 @@ impl TcpStream { move |x| { drop(self); cb(x); - } + }, ))(); } } diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index c86c9569df2..51d27f964a6 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -91,8 +91,12 @@ pub trait RunnableModule: Send + Sync { unsafe fn do_early_trap(&self, data: Box) -> !; - fn get_code(&self) -> Option<&[u8]> { None } - fn get_offsets(&self) -> Option> { None } + fn get_code(&self) -> Option<&[u8]> { + None + } + fn get_offsets(&self) -> Option> { + None + } } pub trait CacheGen: Send + Sync { diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index 2f7c2d90002..f941fc882d4 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -57,7 +57,9 @@ pub trait ModuleCodeGenerator, RM: RunnableModule, /// Adds an import function. fn feed_import_function(&mut self) -> Result<(), E>; - fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> { Ok(()) } + fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> { + Ok(()) + } unsafe fn from_cache(cache: Artifact, _: Token) -> Result; } diff --git a/lib/runtime-core/src/instance.rs b/lib/runtime-core/src/instance.rs index 347ec37f0d8..69a8884c3af 100644 --- a/lib/runtime-core/src/instance.rs +++ b/lib/runtime-core/src/instance.rs @@ -5,15 +5,15 @@ use crate::{ export::{Context, Export, ExportIter, FuncPointer}, global::Global, import::{ImportObject, LikeNamespace}, + loader::Loader, memory::Memory, module::{ExportIndex, Module, ModuleInfo, ModuleInner}, sig_registry::SigRegistry, + structures::TypedIndex, table::Table, typed_func::{Func, Wasm, WasmTrapInfo, WasmTypeList}, types::{FuncIndex, FuncSig, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex, Type, Value}, vm, - loader::Loader, - structures::TypedIndex, }; use smallvec::{smallvec, SmallVec}; use std::{mem, ptr::NonNull, sync::Arc}; @@ -130,7 +130,9 @@ impl Instance { } pub fn load(&self, loader: T) -> ::std::result::Result { - loader.load(&*self.module.runnable_module, &self.module.info, unsafe { &*self.inner.vmctx }) + loader.load(&*self.module.runnable_module, &self.module.info, unsafe { + &*self.inner.vmctx + }) } /// Through generic magic and the awe-inspiring power of traits, we bring you... diff --git a/lib/runtime-core/src/lib.rs b/lib/runtime-core/src/lib.rs index 26d153d12f9..20708c17a5e 100644 --- a/lib/runtime-core/src/lib.rs +++ b/lib/runtime-core/src/lib.rs @@ -21,6 +21,7 @@ pub mod export; pub mod global; pub mod import; pub mod instance; +pub mod loader; pub mod memory; pub mod module; pub mod parse; @@ -34,7 +35,6 @@ pub mod units; pub mod vm; #[doc(hidden)] pub mod vmcalls; -pub mod loader; use self::error::CompileResult; #[doc(inline)] diff --git a/lib/runtime-core/src/loader.rs b/lib/runtime-core/src/loader.rs index 6b970aa9509..5ef127ec728 100644 --- a/lib/runtime-core/src/loader.rs +++ b/lib/runtime-core/src/loader.rs @@ -1,24 +1,21 @@ +use crate::{backend::RunnableModule, module::ModuleInfo, types::Value, vm::Ctx}; +#[cfg(unix)] +use libc::{mmap, mprotect, munmap, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_READ, PROT_WRITE}; use std::{ fmt::Debug, ops::{Deref, DerefMut}, }; -use crate::{ - backend::RunnableModule, - vm::Ctx, - module::ModuleInfo, - types::Value, -}; -#[cfg(unix)] -use libc::{ - mmap, mprotect, munmap, MAP_ANON, MAP_PRIVATE, PROT_EXEC, PROT_READ, - PROT_WRITE, -}; pub trait Loader { type Instance: Instance; type Error: Debug; - fn load(&self, rm: &dyn RunnableModule, module: &ModuleInfo, ctx: &Ctx) -> Result; + fn load( + &self, + rm: &dyn RunnableModule, + module: &ModuleInfo, + ctx: &Ctx, + ) -> Result; } pub trait Instance { @@ -39,7 +36,12 @@ impl Loader for LocalLoader { type Instance = LocalInstance; type Error = String; - fn load(&self, rm: &dyn RunnableModule, _module: &ModuleInfo, _ctx: &Ctx) -> Result { + fn load( + &self, + rm: &dyn RunnableModule, + _module: &ModuleInfo, + _ctx: &Ctx, + ) -> Result { let code = rm.get_code().unwrap(); let mut code_mem = CodeMemory::new(code.len()); code_mem[..code.len()].copy_from_slice(code); @@ -67,11 +69,29 @@ impl Instance for LocalInstance { match args.len() { 0 => (transmute::<_, extern "C" fn() -> u64>(addr))(), 1 => (transmute::<_, extern "C" fn(u64) -> u64>(addr))(args[0].to_u64()), - 2 => (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64()), - 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64()), - 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64(), args[3].to_u64()), - 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))(args[0].to_u64(), args[1].to_u64(), args[2].to_u64(), args[3].to_u64(), args[4].to_u64()), - _ => return Err("too many arguments".into()) + 2 => (transmute::<_, extern "C" fn(u64, u64) -> u64>(addr))( + args[0].to_u64(), + args[1].to_u64(), + ), + 3 => (transmute::<_, extern "C" fn(u64, u64, u64) -> u64>(addr))( + args[0].to_u64(), + args[1].to_u64(), + args[2].to_u64(), + ), + 4 => (transmute::<_, extern "C" fn(u64, u64, u64, u64) -> u64>(addr))( + args[0].to_u64(), + args[1].to_u64(), + args[2].to_u64(), + args[3].to_u64(), + ), + 5 => (transmute::<_, extern "C" fn(u64, u64, u64, u64, u64) -> u64>(addr))( + args[0].to_u64(), + args[1].to_u64(), + args[2].to_u64(), + args[3].to_u64(), + args[4].to_u64(), + ), + _ => return Err("too many arguments".into()), } }) } @@ -129,23 +149,21 @@ impl CodeMemory { #[cfg(unix)] impl Drop for CodeMemory { fn drop(&mut self) { - unsafe { munmap(self.ptr as _, self.size); } + unsafe { + munmap(self.ptr as _, self.size); + } } } impl Deref for CodeMemory { type Target = [u8]; fn deref(&self) -> &[u8] { - unsafe { - ::std::slice::from_raw_parts(self.ptr, self.size) - } + unsafe { ::std::slice::from_raw_parts(self.ptr, self.size) } } } impl DerefMut for CodeMemory { fn deref_mut(&mut self) -> &mut [u8] { - unsafe { - ::std::slice::from_raw_parts_mut(self.ptr, self.size) - } + unsafe { ::std::slice::from_raw_parts_mut(self.ptr, self.size) } } -} \ No newline at end of file +} diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 3562169ad35..8e3ad4be8d2 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -300,9 +300,7 @@ impl Ctx { /// Returns the number of dynamic sigindices. pub fn dynamic_sigindice_count(&self) -> usize { - unsafe { - (*self.local_backing).dynamic_sigindices.len() - } + unsafe { (*self.local_backing).dynamic_sigindices.len() } } } diff --git a/lib/singlepass-backend/src/codegen_x64.rs b/lib/singlepass-backend/src/codegen_x64.rs index c67dde3f5a7..7d4d0de5cc1 100644 --- a/lib/singlepass-backend/src/codegen_x64.rs +++ b/lib/singlepass-backend/src/codegen_x64.rs @@ -10,7 +10,9 @@ use smallvec::SmallVec; use std::ptr::NonNull; use std::{any::Any, collections::HashMap, sync::Arc}; use wasmer_runtime_core::{ - backend::{sys::Memory, Backend, CacheGen, Token, RunnableModule, CompilerConfig, MemoryBoundCheckMode}, + backend::{ + sys::Memory, Backend, CacheGen, CompilerConfig, MemoryBoundCheckMode, RunnableModule, Token, + }, cache::{Artifact, Error as CacheError}, codegen::*, memory::MemoryType, @@ -318,19 +320,18 @@ impl ModuleCodeGenerator } fn next_function(&mut self) -> Result<&mut X64FunctionCode, CodegenError> { - let (mut assembler, mut function_labels, breakpoints) = - match self.functions.last_mut() { - Some(x) => ( - x.assembler.take().unwrap(), - x.function_labels.take().unwrap(), - x.breakpoints.take().unwrap(), - ), - None => ( - self.assembler.take().unwrap(), - self.function_labels.take().unwrap(), - HashMap::new(), - ), - }; + let (mut assembler, mut function_labels, breakpoints) = match self.functions.last_mut() { + Some(x) => ( + x.assembler.take().unwrap(), + x.function_labels.take().unwrap(), + x.breakpoints.take().unwrap(), + ), + None => ( + self.assembler.take().unwrap(), + self.function_labels.take().unwrap(), + HashMap::new(), + ), + }; let begin_offset = assembler.offset(); let begin_label_info = function_labels .entry(self.functions.len() + self.func_import_count) @@ -365,12 +366,12 @@ impl ModuleCodeGenerator Ok(self.functions.last_mut().unwrap()) } - fn finalize(mut self, _: &ModuleInfo) -> Result<(X64ExecutionContext, Box), CodegenError> { + fn finalize( + mut self, + _: &ModuleInfo, + ) -> Result<(X64ExecutionContext, Box), CodegenError> { let (assembler, breakpoints) = match self.functions.last_mut() { - Some(x) => ( - x.assembler.take().unwrap(), - x.breakpoints.take().unwrap(), - ), + Some(x) => (x.assembler.take().unwrap(), x.breakpoints.take().unwrap()), None => { return Err(CodegenError { message: "no function", @@ -1232,7 +1233,7 @@ impl X64FunctionCode { MemoryBoundCheckMode::Enable => true, MemoryBoundCheckMode::Disable => false, }; - + let tmp_addr = m.acquire_temp_gpr().unwrap(); let tmp_base = m.acquire_temp_gpr().unwrap(); let tmp_bound = m.acquire_temp_gpr().unwrap(); @@ -1429,7 +1430,7 @@ impl FunctionCodeGenerator for X64FunctionCode { GPR::RDI, // first parameter is vmctx vm::Ctx::offset_stack_lower_bound() as i32, ), - Location::GPR(GPR::RSP) + Location::GPR(GPR::RSP), ); a.emit_conditional_trap(Condition::Below); } @@ -3329,13 +3330,16 @@ impl FunctionCodeGenerator for X64FunctionCode { let memory_index = MemoryIndex::new(reserved as usize); a.emit_mov( Size::S64, - Location::Memory(Machine::get_vmctx_reg(), vm::Ctx::offset_intrinsics() as i32), - Location::GPR(GPR::RAX) + Location::Memory( + Machine::get_vmctx_reg(), + vm::Ctx::offset_intrinsics() as i32, + ), + Location::GPR(GPR::RAX), ); a.emit_mov( Size::S64, Location::Memory(GPR::RAX, vm::Intrinsics::offset_memory_size() as i32), - Location::GPR(GPR::RAX) + Location::GPR(GPR::RAX), ); Self::emit_call_sysv( a, @@ -3359,13 +3363,16 @@ impl FunctionCodeGenerator for X64FunctionCode { a.emit_mov( Size::S64, - Location::Memory(Machine::get_vmctx_reg(), vm::Ctx::offset_intrinsics() as i32), - Location::GPR(GPR::RAX) + Location::Memory( + Machine::get_vmctx_reg(), + vm::Ctx::offset_intrinsics() as i32, + ), + Location::GPR(GPR::RAX), ); a.emit_mov( Size::S64, Location::Memory(GPR::RAX, vm::Intrinsics::offset_memory_grow() as i32), - Location::GPR(GPR::RAX) + Location::GPR(GPR::RAX), ); Self::emit_call_sysv( @@ -4091,10 +4098,7 @@ impl FunctionCodeGenerator for X64FunctionCode { ); a.emit_jmp(Condition::AboveEqual, default_br); - a.emit_lea_label( - table_label, - Location::GPR(GPR::RCX), - ); + a.emit_lea_label(table_label, Location::GPR(GPR::RCX)); a.emit_mov(Size::S32, cond, Location::GPR(GPR::RDX)); a.emit_imul_imm32_gpr64(5, GPR::RDX); a.emit_add(Size::S64, Location::GPR(GPR::RCX), Location::GPR(GPR::RDX)); diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 509167008a5..b4a425061f5 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -1,21 +1,19 @@ -extern crate structopt; extern crate byteorder; +extern crate structopt; use std::thread; use structopt::StructOpt; use wasmer::*; -use wasmer_runtime::{ - Value, -}; +use wasmer_runtime::Value; use wasmer_runtime_core::{ self, backend::{CompilerConfig, MemoryBoundCheckMode}, - loader::{Instance as LoadedInstance}, + loader::Instance as LoadedInstance, }; use wasmer_singlepass_backend::SinglePassCompiler; -use std::os::unix::net::{UnixStream, UnixListener}; use std::io::prelude::*; +use std::os::unix::net::{UnixListener, UnixStream}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -54,7 +52,8 @@ fn handle_client(mut stream: UnixStream) { enforce_stack_check: true, }, &SinglePassCompiler::new(), - ).unwrap(); + ) + .unwrap(); let mut import_object = wasmer_runtime_core::import::ImportObject::new(); import_object.allow_missing_functions = true; // Import initialization might be left to the loader. @@ -90,13 +89,13 @@ fn handle_client(mut stream: UnixStream) { Ok(x) => { stream.write_u32::(1).unwrap(); stream.write_u64::(x).unwrap(); - }, + } Err(e) => { println!("Execution error: {:?}", e); stream.write_u32::(0).unwrap(); - }, + } } - }, + } CMD_READ_MEMORY => { let offset = stream.read_u32::().unwrap(); let len = stream.read_u32::().unwrap(); @@ -106,7 +105,7 @@ fn handle_client(mut stream: UnixStream) { } let buf = ins.read_memory(offset, len).unwrap(); stream.write_all(&buf).unwrap(); - }, + } CMD_WRITE_MEMORY => { let offset = stream.read_u32::().unwrap(); let len = stream.read_u32::().unwrap(); @@ -118,7 +117,7 @@ fn handle_client(mut stream: UnixStream) { unsafe { buf.set_len(len as usize) }; stream.read_exact(&mut buf).unwrap(); ins.write_memory(offset, len, &buf).unwrap(); - }, + } _ => { println!("Unknown command"); return; @@ -137,7 +136,7 @@ fn run_listen(opts: Listen) { match ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { handle_client(stream); })) { - Ok(()) => {}, + Ok(()) => {} Err(_) => {} } }); @@ -162,4 +161,4 @@ fn main() { #[cfg(not(feature = "loader:kwasm"))] fn main() { panic!("Kwasm loader is not enabled during compilation."); -} \ No newline at end of file +} diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index e5c50e22cdb..1fa00afd227 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -315,7 +315,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> { enforce_stack_check: true, }, &*compiler, - ).map_err(|e| format!("Can't compile module: {:?}", e))? + ) + .map_err(|e| format!("Can't compile module: {:?}", e))? } else if disable_cache { webassembly::compile_with_config_with( &wasm_binary[..], @@ -324,7 +325,8 @@ fn execute_wasm(options: &Run) -> Result<(), String> { ..Default::default() }, &*compiler, - ).map_err(|e| format!("Can't compile module: {:?}", e))? + ) + .map_err(|e| format!("Can't compile module: {:?}", e))? } else { // If we have cache enabled @@ -388,7 +390,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { LoaderName::Kernel => Box::new(instance.load(::kwasm_loader::KernelLoader).unwrap()), }; println!("{:?}", ins.call(index, &args)); - return Ok(()) + return Ok(()); } // TODO: refactor this From 1e7a928d6422320c4bc20c0e8c8917614d46863e Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:13:42 +0800 Subject: [PATCH 26/43] Add comments. --- lib/runtime-core/src/backend.rs | 3 +++ lib/runtime-core/src/codegen.rs | 27 ++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/runtime-core/src/backend.rs b/lib/runtime-core/src/backend.rs index 51d27f964a6..1d493c31475 100644 --- a/lib/runtime-core/src/backend.rs +++ b/lib/runtime-core/src/backend.rs @@ -91,9 +91,12 @@ pub trait RunnableModule: Send + Sync { unsafe fn do_early_trap(&self, data: Box) -> !; + /// Returns the machine code associated with this module. fn get_code(&self) -> Option<&[u8]> { None } + + /// Returns the beginning offsets of all functions, including import trampolines. fn get_offsets(&self) -> Option> { None } diff --git a/lib/runtime-core/src/codegen.rs b/lib/runtime-core/src/codegen.rs index f941fc882d4..1d9f30f1a4e 100644 --- a/lib/runtime-core/src/codegen.rs +++ b/lib/runtime-core/src/codegen.rs @@ -42,24 +42,29 @@ impl fmt::Debug for InternalEvent { pub struct BkptInfo {} pub trait ModuleCodeGenerator, RM: RunnableModule, E: Debug> { + /// Creates a new module code generator. fn new() -> Self; + + /// Returns the backend id associated with this MCG. fn backend_id() -> Backend; - fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>; - /// Creates a new function and returns the function-scope code generator for it. - fn next_function(&mut self) -> Result<&mut FCG, E>; - fn finalize(self, module_info: &ModuleInfo) -> Result<(RM, Box), E>; + /// Feeds the compiler config. + fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> { + Ok(()) + } + /// Adds an import function. + fn feed_import_function(&mut self) -> Result<(), E>; fn feed_signatures(&mut self, signatures: Map) -> Result<(), E>; - /// Sets function signatures. fn feed_function_signatures(&mut self, assoc: Map) -> Result<(), E>; + /// Checks the precondition for a module. + fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>; + /// Creates a new function and returns the function-scope code generator for it. + fn next_function(&mut self) -> Result<&mut FCG, E>; + /// Finalizes this module. + fn finalize(self, module_info: &ModuleInfo) -> Result<(RM, Box), E>; - /// Adds an import function. - fn feed_import_function(&mut self) -> Result<(), E>; - - fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> { - Ok(()) - } + /// Creates a module from cache. unsafe fn from_cache(cache: Artifact, _: Token) -> Result; } From d60e2377c116b1f09a7cba4947c883cd25963a4c Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:45:26 +0800 Subject: [PATCH 27/43] Only compile kwasm-net for wasm32-wasi. --- lib/kwasm-net/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/kwasm-net/src/lib.rs b/lib/kwasm-net/src/lib.rs index fd4108162ce..98746a68f95 100644 --- a/lib/kwasm-net/src/lib.rs +++ b/lib/kwasm-net/src/lib.rs @@ -1,3 +1,4 @@ +#![cfg(all(target_arch = "wasm32", target_os = "wasi"))] #![feature(wasi_ext)] use std::cell::RefCell; From 98dd2c0289229735f184cc8515f970e80cb2a585 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:52:09 +0800 Subject: [PATCH 28/43] Fix wasm example crates. --- Cargo.toml | 2 +- examples/http-server/Cargo.lock | 13 +++++++++++++ examples/http-server/Cargo.toml | 2 ++ examples/pipe/Cargo.toml | 2 ++ examples/wasi-networking/Cargo.toml | 2 ++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 examples/http-server/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml index 3f8c8a47695..982535c0095 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader", optional = true } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/pipe", "examples/wasi-networking", "examples/http-server", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/http-server/Cargo.lock b/examples/http-server/Cargo.lock new file mode 100644 index 00000000000..da2847543ae --- /dev/null +++ b/examples/http-server/Cargo.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "http-server" +version = "0.1.0" +dependencies = [ + "kwasm-net 0.1.0", +] + +[[package]] +name = "kwasm-net" +version = "0.1.0" + diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index 3d6f23502ee..daa66555cdc 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -6,5 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[workspace] + [dependencies] kwasm-net = { path = "../../lib/kwasm-net" } diff --git a/examples/pipe/Cargo.toml b/examples/pipe/Cargo.toml index 50702bbb159..3dec721486a 100644 --- a/examples/pipe/Cargo.toml +++ b/examples/pipe/Cargo.toml @@ -4,4 +4,6 @@ version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" +[workspace] + [dependencies] diff --git a/examples/wasi-networking/Cargo.toml b/examples/wasi-networking/Cargo.toml index 8057f959230..fe6712c171f 100644 --- a/examples/wasi-networking/Cargo.toml +++ b/examples/wasi-networking/Cargo.toml @@ -4,5 +4,7 @@ version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" +[workspace] + [dependencies] kwasm-net = { path = "../../lib/kwasm-net" } \ No newline at end of file From ee09209bfbe5f567e9ef3737f007b5d3c14ae59b Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 16:59:18 +0800 Subject: [PATCH 29/43] Fix clippy error. --- lib/runtime-core/src/vm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/runtime-core/src/vm.rs b/lib/runtime-core/src/vm.rs index 8e3ad4be8d2..323e40c219b 100644 --- a/lib/runtime-core/src/vm.rs +++ b/lib/runtime-core/src/vm.rs @@ -113,6 +113,7 @@ unsafe impl Send for Intrinsics {} unsafe impl Sync for Intrinsics {} impl Intrinsics { + #[allow(clippy::erasing_op)] pub fn offset_memory_grow() -> u8 { (0 * ::std::mem::size_of::()) as u8 } From d641909c637e316b5edad98db5ebb14214d26439 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 17:13:17 +0800 Subject: [PATCH 30/43] Fix clippy error --- lib/kwasm-loader/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kwasm-loader/src/lib.rs index d9b51f2e3f3..0224f8abfc4 100644 --- a/lib/kwasm-loader/src/lib.rs +++ b/lib/kwasm-loader/src/lib.rs @@ -40,8 +40,13 @@ impl Loader for KernelLoader { if let Some(_) = module.tables.get(LocalTableIndex::new(0)) { Some(unsafe { let table = &**ctx.tables; - let elements: &[Anyfunc] = - ::std::slice::from_raw_parts(table.base as *const Anyfunc, table.count); + let elements: &[Anyfunc]; + #[allow(clippy::cast_ptr_alignment)] + { + elements = + ::std::slice::from_raw_parts(table.base as *const Anyfunc, table.count); + } + let base_addr = code.as_ptr() as usize; let end_addr = base_addr + code.len(); elements From 5ec931ef8348e616539628fb5c2d6473eb3e4e45 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 17:26:46 +0800 Subject: [PATCH 31/43] Fix kwasmd compilation --- src/bin/kwasmd.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index b4a425061f5..559b3971f99 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -10,6 +10,7 @@ use wasmer_runtime_core::{ backend::{CompilerConfig, MemoryBoundCheckMode}, loader::Instance as LoadedInstance, }; +#[cfg(feature = "loader:kwasm")] use wasmer_singlepass_backend::SinglePassCompiler; use std::io::prelude::*; From fac4c452c656583661c115d979d76b7cf5511da3 Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 18:49:02 +0800 Subject: [PATCH 32/43] Fix LLVM backend. --- lib/llvm-backend/src/code.rs | 38 ++++++++++++++-- lib/llvm-backend/src/intrinsics.rs | 70 +++++++++++++++++++++++++----- 2 files changed, 95 insertions(+), 13 deletions(-) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 028207a8c4f..8514208ad54 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -285,13 +285,16 @@ fn resolve_memory_ptr( ctx: &mut CtxType, memarg: &MemoryImmediate, ptr_ty: PointerType, + value_size: usize, ) -> Result { // Ignore alignment hint for the time being. let imm_offset = intrinsics.i64_ty.const_int(memarg.offset as u64, false); + let value_size_v = intrinsics.i64_ty.const_int(value_size as u64, false); let var_offset_i32 = state.pop1()?.into_int_value(); let var_offset = builder.build_int_z_extend(var_offset_i32, intrinsics.i64_ty, &state.var_name()); let effective_offset = builder.build_int_add(var_offset, imm_offset, &state.var_name()); + let end_offset = builder.build_int_add(effective_offset, value_size_v, &state.var_name()); let memory_cache = ctx.memory(MemoryIndex::new(0), intrinsics); let mem_base_int = match memory_cache { @@ -306,12 +309,20 @@ fn resolve_memory_ptr( let base_as_int = builder.build_ptr_to_int(base, intrinsics.i64_ty, "base_as_int"); - let base_in_bounds = builder.build_int_compare( + let base_in_bounds_1 = builder.build_int_compare( + IntPredicate::ULE, + end_offset, + bounds, + "base_in_bounds_1", + ); + let base_in_bounds_2 = builder.build_int_compare( IntPredicate::ULT, effective_offset, - bounds, - "base_in_bounds", + end_offset, + "base_in_bounds_2", ); + let base_in_bounds = + builder.build_and(base_in_bounds_1, base_in_bounds_2, "base_in_bounds"); let base_in_bounds = builder .build_call( @@ -2000,6 +2011,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i32_ptr_ty, + 4, )?; let result = builder.build_load(effective_address, &state.var_name()); state.push1(result); @@ -2014,6 +2026,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i64_ptr_ty, + 8, )?; let result = builder.build_load(effective_address, &state.var_name()); state.push1(result); @@ -2028,6 +2041,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.f32_ptr_ty, + 4, )?; let result = builder.build_load(effective_address, &state.var_name()); state.push1(result); @@ -2042,6 +2056,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.f64_ptr_ty, + 8, )?; let result = builder.build_load(effective_address, &state.var_name()); state.push1(result); @@ -2058,6 +2073,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i32_ptr_ty, + 4, )?; builder.build_store(effective_address, value); } @@ -2072,6 +2088,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i64_ptr_ty, + 8, )?; builder.build_store(effective_address, value); } @@ -2086,6 +2103,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.f32_ptr_ty, + 4, )?; builder.build_store(effective_address, value); } @@ -2100,6 +2118,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.f64_ptr_ty, + 8, )?; builder.build_store(effective_address, value); } @@ -2114,6 +2133,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i8_ptr_ty, + 1, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2132,6 +2152,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i16_ptr_ty, + 2, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2150,6 +2171,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i8_ptr_ty, + 1, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2168,6 +2190,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i16_ptr_ty, + 2, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2186,6 +2209,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i32_ptr_ty, + 4, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2205,6 +2229,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i8_ptr_ty, + 1, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2223,6 +2248,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i16_ptr_ty, + 2, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2241,6 +2267,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i8_ptr_ty, + 1, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2259,6 +2286,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i16_ptr_ty, + 2, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2277,6 +2305,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i32_ptr_ty, + 4, )?; let narrow_result = builder .build_load(effective_address, &state.var_name()) @@ -2297,6 +2326,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i8_ptr_ty, + 1, )?; let narrow_value = builder.build_int_truncate(value, intrinsics.i8_ty, &state.var_name()); @@ -2313,6 +2343,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i16_ptr_ty, + 2, )?; let narrow_value = builder.build_int_truncate(value, intrinsics.i16_ty, &state.var_name()); @@ -2329,6 +2360,7 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { &mut ctx, memarg, intrinsics.i32_ptr_ty, + 4, )?; let narrow_value = builder.build_int_truncate(value, intrinsics.i32_ty, &state.var_name()); diff --git a/lib/llvm-backend/src/intrinsics.rs b/lib/llvm-backend/src/intrinsics.rs index 6250fd4fd44..ebee5a3882d 100644 --- a/lib/llvm-backend/src/intrinsics.rs +++ b/lib/llvm-backend/src/intrinsics.rs @@ -16,6 +16,7 @@ use wasmer_runtime_core::{ GlobalIndex, ImportedFuncIndex, LocalFuncIndex, LocalOrImport, MemoryIndex, SigIndex, TableIndex, Type, }, + vm::Ctx, }; fn type_to_llvm_ptr(intrinsics: &Intrinsics, ty: Type) -> PointerType { @@ -158,6 +159,10 @@ impl Intrinsics { let imported_func_ty = context.struct_type(&[i8_ptr_ty_basic, ctx_ptr_ty.as_basic_type_enum()], false); let sigindex_ty = i32_ty; + let rt_intrinsics_ty = void_ty; + let stack_lower_bound_ty = i8_ty; + let memory_base_ty = i8_ty; + let memory_bound_ty = void_ty; let local_function_ty = i8_ptr_ty; let anyfunc_ty = context.struct_type( @@ -201,6 +206,18 @@ impl Intrinsics { sigindex_ty .ptr_type(AddressSpace::Generic) .as_basic_type_enum(), + rt_intrinsics_ty + .ptr_type(AddressSpace::Generic) + .as_basic_type_enum(), + stack_lower_bound_ty + .ptr_type(AddressSpace::Generic) + .as_basic_type_enum(), + memory_base_ty + .ptr_type(AddressSpace::Generic) + .as_basic_type_enum(), + memory_bound_ty + .ptr_type(AddressSpace::Generic) + .as_basic_type_enum(), local_function_ty .ptr_type(AddressSpace::Generic) .as_basic_type_enum(), @@ -416,6 +433,10 @@ pub struct CtxType<'a> { _phantom: PhantomData<&'a FunctionValue>, } +fn offset_to_index(offset: u8) -> u32 { + (offset as usize / ::std::mem::size_of::()) as u32 +} + impl<'a> CtxType<'a> { pub fn new( info: &'a ModuleInfo, @@ -454,14 +475,22 @@ impl<'a> CtxType<'a> { let (memory_array_ptr_ptr, index, memory_type) = match index.local_or_import(info) { LocalOrImport::Local(local_mem_index) => ( unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 0, "memory_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_memories()), + "memory_array_ptr_ptr", + ) }, local_mem_index.index() as u64, info.memories[local_mem_index].memory_type(), ), LocalOrImport::Import(import_mem_index) => ( unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 3, "memory_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_imported_memories()), + "memory_array_ptr_ptr", + ) }, import_mem_index.index() as u64, info.imported_memories[import_mem_index].1.memory_type(), @@ -527,13 +556,21 @@ impl<'a> CtxType<'a> { let (table_array_ptr_ptr, index) = match index.local_or_import(info) { LocalOrImport::Local(local_table_index) => ( unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 1, "table_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_tables()), + "table_array_ptr_ptr", + ) }, local_table_index.index() as u64, ), LocalOrImport::Import(import_table_index) => ( unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 4, "table_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_imported_tables()), + "table_array_ptr_ptr", + ) }, import_table_index.index() as u64, ), @@ -578,8 +615,13 @@ impl<'a> CtxType<'a> { intrinsics: &Intrinsics, builder: &Builder, ) -> PointerValue { - let local_func_array_ptr_ptr = - unsafe { builder.build_struct_gep(self.ctx_ptr_value, 8, "local_func_array_ptr_ptr") }; + let local_func_array_ptr_ptr = unsafe { + builder.build_struct_gep( + self.ctx_ptr_value, + offset_to_index(Ctx::offset_local_functions()), + "local_func_array_ptr_ptr", + ) + }; let local_func_array_ptr = builder .build_load(local_func_array_ptr_ptr, "local_func_array_ptr") .into_pointer_value(); @@ -609,7 +651,11 @@ impl<'a> CtxType<'a> { *cached_sigindices.entry(index).or_insert_with(|| { let sigindex_array_ptr_ptr = unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 7, "sigindex_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_signatures()), + "sigindex_array_ptr_ptr", + ) }; let sigindex_array_ptr = cache_builder .build_load(sigindex_array_ptr_ptr, "sigindex_array_ptr") @@ -647,7 +693,7 @@ impl<'a> CtxType<'a> { unsafe { cache_builder.build_struct_gep( ctx_ptr_value, - 2, + offset_to_index(Ctx::offset_globals()), "globals_array_ptr_ptr", ) }, @@ -662,7 +708,7 @@ impl<'a> CtxType<'a> { unsafe { cache_builder.build_struct_gep( ctx_ptr_value, - 5, + offset_to_index(Ctx::offset_imported_globals()), "globals_array_ptr_ptr", ) }, @@ -718,7 +764,11 @@ impl<'a> CtxType<'a> { let imported_func_cache = cached_imported_functions.entry(index).or_insert_with(|| { let func_array_ptr_ptr = unsafe { - cache_builder.build_struct_gep(ctx_ptr_value, 6, "imported_func_array_ptr_ptr") + cache_builder.build_struct_gep( + ctx_ptr_value, + offset_to_index(Ctx::offset_imported_funcs()), + "imported_func_array_ptr_ptr", + ) }; let func_array_ptr = cache_builder .build_load(func_array_ptr_ptr, "func_array_ptr") From d75a2925afce33e409d2e0dd70972d780725d0be Mon Sep 17 00:00:00 2001 From: losfair Date: Tue, 14 May 2019 20:00:36 +0800 Subject: [PATCH 33/43] Fix compilation issue on Windows. --- Cargo.lock | 18 ------------------ src/bin/kwasmd.rs | 1 + 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d2ad8eb84a..e85e7353333 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -806,13 +806,6 @@ dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "http-server" -version = "0.1.0" -dependencies = [ - "kwasm-net 0.1.0", -] - [[package]] name = "httparse" version = "1.3.3" @@ -1350,10 +1343,6 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "pipe" -version = "0.1.0" - [[package]] name = "pkg-config" version = "0.3.14" @@ -2294,13 +2283,6 @@ dependencies = [ "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "wasi-networking" -version = "0.1.0" -dependencies = [ - "kwasm-net 0.1.0", -] - [[package]] name = "wasmer" version = "0.4.1" diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 559b3971f99..87ec634c3e5 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -14,6 +14,7 @@ use wasmer_runtime_core::{ use wasmer_singlepass_backend::SinglePassCompiler; use std::io::prelude::*; +#[cfg(feature = "loader:kwasm")] use std::os::unix::net::{UnixListener, UnixStream}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; From d72abf3203acd2045809f72522e21a455d350a7e Mon Sep 17 00:00:00 2001 From: losfair Date: Wed, 15 May 2019 21:43:19 +0800 Subject: [PATCH 34/43] Rename `kwasm-loader` to `wasmer-kernel-loader`. --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 6 +++--- lib/{kwasm-loader => kernel-loader}/Cargo.toml | 2 +- lib/{kwasm-loader => kernel-loader}/src/lib.rs | 0 .../src/service.rs | 0 src/bin/kwasmd.rs | 2 +- src/bin/wasmer.rs | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) rename lib/{kwasm-loader => kernel-loader}/Cargo.toml (85%) rename lib/{kwasm-loader => kernel-loader}/src/lib.rs (100%) rename lib/{kwasm-loader => kernel-loader}/src/service.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e85e7353333..2b2f55b75cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -925,14 +925,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kwasm-loader" -version = "0.1.0" -dependencies = [ - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmer-runtime-core 0.4.1", -] - [[package]] name = "kwasm-net" version = "0.1.0" @@ -2291,12 +2283,12 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "kwasm-loader 0.1.0", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasmer-clif-backend 0.4.1", "wasmer-emscripten 0.4.1", + "wasmer-kernel-loader 0.1.0", "wasmer-llvm-backend 0.4.1", "wasmer-middleware-common 0.4.1", "wasmer-runtime 0.4.1", @@ -2347,6 +2339,14 @@ dependencies = [ "wasmer-singlepass-backend 0.4.1", ] +[[package]] +name = "wasmer-kernel-loader" +version = "0.1.0" +dependencies = [ + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmer-runtime-core 0.4.1", +] + [[package]] name = "wasmer-llvm-backend" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 982535c0095..ff021012088 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,10 @@ wasmer-runtime-core = { path = "lib/runtime-core" } wasmer-emscripten = { path = "lib/emscripten" } wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true } wasmer-wasi = { path = "lib/wasi", optional = true } -kwasm-loader = { path = "lib/kwasm-loader", optional = true } +wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "lib/kwasm-net", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kernel-loader", "lib/kwasm-net", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" @@ -45,7 +45,7 @@ rustc_version = "0.2.3" [features] default = ["fast-tests", "wasi"] -"loader:kwasm" = ["kwasm-loader"] +"loader:kwasm" = ["wasmer-kernel-loader"] debug = ["wasmer-runtime-core/debug"] extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] # This feature will allow cargo test to run much faster diff --git a/lib/kwasm-loader/Cargo.toml b/lib/kernel-loader/Cargo.toml similarity index 85% rename from lib/kwasm-loader/Cargo.toml rename to lib/kernel-loader/Cargo.toml index abf2fa8f25d..921e71f9ab7 100644 --- a/lib/kwasm-loader/Cargo.toml +++ b/lib/kernel-loader/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "kwasm-loader" +name = "wasmer-kernel-loader" version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" diff --git a/lib/kwasm-loader/src/lib.rs b/lib/kernel-loader/src/lib.rs similarity index 100% rename from lib/kwasm-loader/src/lib.rs rename to lib/kernel-loader/src/lib.rs diff --git a/lib/kwasm-loader/src/service.rs b/lib/kernel-loader/src/service.rs similarity index 100% rename from lib/kwasm-loader/src/service.rs rename to lib/kernel-loader/src/service.rs diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 87ec634c3e5..15869560873 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -60,7 +60,7 @@ fn handle_client(mut stream: UnixStream) { let mut import_object = wasmer_runtime_core::import::ImportObject::new(); import_object.allow_missing_functions = true; // Import initialization might be left to the loader. let instance = module.instantiate(&import_object).unwrap(); - let mut ins = instance.load(::kwasm_loader::KernelLoader).unwrap(); + let mut ins = instance.load(::wasmer_kernel_loader::KernelLoader).unwrap(); loop { let cmd = stream.read_u32::().unwrap(); diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 1fa00afd227..099521a16bd 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -387,7 +387,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { let mut ins: Box> = match loader { LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), #[cfg(feature = "loader:kwasm")] - LoaderName::Kernel => Box::new(instance.load(::kwasm_loader::KernelLoader).unwrap()), + LoaderName::Kernel => Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap()), }; println!("{:?}", ins.call(index, &args)); return Ok(()); From 6df4e401210f339abdc04535cb7a8a3b6045fae4 Mon Sep 17 00:00:00 2001 From: losfair Date: Wed, 15 May 2019 21:43:38 +0800 Subject: [PATCH 35/43] Cargo fmt --- src/bin/wasmer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 099521a16bd..cf15e54842c 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -387,7 +387,9 @@ fn execute_wasm(options: &Run) -> Result<(), String> { let mut ins: Box> = match loader { LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), #[cfg(feature = "loader:kwasm")] - LoaderName::Kernel => Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap()), + LoaderName::Kernel => { + Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap()) + } }; println!("{:?}", ins.call(index, &args)); return Ok(()); From 13b4fe3f38df546dad77e2a8c97336deec9bce6e Mon Sep 17 00:00:00 2001 From: losfair Date: Wed, 15 May 2019 21:56:28 +0800 Subject: [PATCH 36/43] Temporarily disable caching for macos test. --- .circleci/config.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e2905a42523..75f6dcdf740 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,10 +86,6 @@ jobs: xcode: "9.0" steps: - checkout - - restore_cache: - keys: - - v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }} - - v8-cargo-cache-darwin-stable-{{ arch }} - run: name: Install crate dependencies command: | @@ -134,16 +130,6 @@ jobs: export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" make integration-tests - - save_cache: - paths: - - ~/.cargo/registry/ - - target/debug/.fingerprint - - target/debug/build - - target/debug/deps - - target/release/.fingerprint - - target/release/build - - target/release/deps - key: v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }} test-and-build: docker: From 408f89ccd6a9c5104ebffbfd73ea754357d2c175 Mon Sep 17 00:00:00 2001 From: losfair Date: Wed, 15 May 2019 22:17:31 +0800 Subject: [PATCH 37/43] Rename `loader:kwasm` to `loader:kernel` for consistency. --- Cargo.toml | 2 +- src/bin/kwasmd.rs | 12 ++++++------ src/bin/wasmer.rs | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ff021012088..7c04ebf2a97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ rustc_version = "0.2.3" [features] default = ["fast-tests", "wasi"] -"loader:kwasm" = ["wasmer-kernel-loader"] +"loader:kernel" = ["wasmer-kernel-loader"] debug = ["wasmer-runtime-core/debug"] extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] # This feature will allow cargo test to run much faster diff --git a/src/bin/kwasmd.rs b/src/bin/kwasmd.rs index 15869560873..53e69060eab 100644 --- a/src/bin/kwasmd.rs +++ b/src/bin/kwasmd.rs @@ -10,11 +10,11 @@ use wasmer_runtime_core::{ backend::{CompilerConfig, MemoryBoundCheckMode}, loader::Instance as LoadedInstance, }; -#[cfg(feature = "loader:kwasm")] +#[cfg(feature = "loader:kernel")] use wasmer_singlepass_backend::SinglePassCompiler; use std::io::prelude::*; -#[cfg(feature = "loader:kwasm")] +#[cfg(feature = "loader:kernel")] use std::os::unix::net::{UnixListener, UnixStream}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -36,7 +36,7 @@ const CMD_RUN_CODE: u32 = 0x901; const CMD_READ_MEMORY: u32 = 0x902; const CMD_WRITE_MEMORY: u32 = 0x903; -#[cfg(feature = "loader:kwasm")] +#[cfg(feature = "loader:kernel")] fn handle_client(mut stream: UnixStream) { let binary_size = stream.read_u32::().unwrap(); if binary_size > 1048576 * 16 { @@ -128,7 +128,7 @@ fn handle_client(mut stream: UnixStream) { } } -#[cfg(feature = "loader:kwasm")] +#[cfg(feature = "loader:kernel")] fn run_listen(opts: Listen) { let listener = UnixListener::bind(&opts.socket).unwrap(); for stream in listener.incoming() { @@ -150,7 +150,7 @@ fn run_listen(opts: Listen) { } } -#[cfg(feature = "loader:kwasm")] +#[cfg(feature = "loader:kernel")] fn main() { let options = CLIOptions::from_args(); match options { @@ -160,7 +160,7 @@ fn main() { } } -#[cfg(not(feature = "loader:kwasm"))] +#[cfg(not(feature = "loader:kernel"))] fn main() { panic!("Kwasm loader is not enabled during compilation."); } diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index cf15e54842c..839f7047aeb 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -116,7 +116,7 @@ struct Run { #[derive(Debug, Copy, Clone)] enum LoaderName { Local, - #[cfg(feature = "loader:kwasm")] + #[cfg(feature = "loader:kernel")] Kernel, } @@ -124,7 +124,7 @@ impl LoaderName { pub fn variants() -> &'static [&'static str] { &[ "local", - #[cfg(feature = "loader:kwasm")] + #[cfg(feature = "loader:kernel")] "kernel", ] } @@ -135,7 +135,7 @@ impl FromStr for LoaderName { fn from_str(s: &str) -> Result { match s.to_lowercase().as_str() { "local" => Ok(LoaderName::Local), - #[cfg(feature = "loader:kwasm")] + #[cfg(feature = "loader:kernel")] "kernel" => Ok(LoaderName::Kernel), _ => Err(format!("The loader {} doesn't exist", s)), } @@ -296,14 +296,14 @@ fn execute_wasm(options: &Run) -> Result<(), String> { Backend::LLVM => return Err("the llvm backend is not enabled".to_string()), }; - #[cfg(feature = "loader:kwasm")] + #[cfg(feature = "loader:kernel")] let is_kernel_loader = if let Some(LoaderName::Kernel) = options.loader { true } else { false }; - #[cfg(not(feature = "loader:kwasm"))] + #[cfg(not(feature = "loader:kernel"))] let is_kernel_loader = false; let module = if is_kernel_loader { @@ -386,7 +386,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> { let index = instance.resolve_func("_start").unwrap(); let mut ins: Box> = match loader { LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), - #[cfg(feature = "loader:kwasm")] + #[cfg(feature = "loader:kernel")] LoaderName::Kernel => { Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap()) } From 3bbf7753cbafacfe36957535f49f8c0999f10a42 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 15 May 2019 10:34:56 -0700 Subject: [PATCH 38/43] Renamed kwasm-net to wasmer-kernel-net --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- examples/http-server/Cargo.lock | 4 ++-- examples/http-server/Cargo.toml | 2 +- examples/http-server/src/main.rs | 2 +- examples/wasi-networking/Cargo.toml | 2 +- examples/wasi-networking/src/main.rs | 2 +- lib/kernel-loader/src/lib.rs | 2 +- lib/{kwasm-net => kernel-net}/Cargo.toml | 2 +- lib/{kwasm-net => kernel-net}/src/lib.rs | 0 10 files changed, 13 insertions(+), 13 deletions(-) rename lib/{kwasm-net => kernel-net}/Cargo.toml (86%) rename lib/{kwasm-net => kernel-net}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 2b2f55b75cc..cb45c487426 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -925,10 +925,6 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "kwasm-net" -version = "0.1.0" - [[package]] name = "lazy_static" version = "1.3.0" @@ -2347,6 +2343,10 @@ dependencies = [ "wasmer-runtime-core 0.4.1", ] +[[package]] +name = "wasmer-kernel-net" +version = "0.1.0" + [[package]] name = "wasmer-llvm-backend" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 7c04ebf2a97..408ccfa376c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kernel-loader", "lib/kwasm-net", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kernel-loader", "lib/kernel-net", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/http-server/Cargo.lock b/examples/http-server/Cargo.lock index da2847543ae..a689f109a29 100644 --- a/examples/http-server/Cargo.lock +++ b/examples/http-server/Cargo.lock @@ -4,10 +4,10 @@ name = "http-server" version = "0.1.0" dependencies = [ - "kwasm-net 0.1.0", + "wasmer-kernel-net 0.1.0", ] [[package]] -name = "kwasm-net" +name = "wasmer-kernel-net" version = "0.1.0" diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index daa66555cdc..30488993855 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -9,4 +9,4 @@ edition = "2018" [workspace] [dependencies] -kwasm-net = { path = "../../lib/kwasm-net" } +wasmer-kernel-net = { path = "../../lib/kernel-net" } diff --git a/examples/http-server/src/main.rs b/examples/http-server/src/main.rs index 5d1125e93af..1ba382347d6 100644 --- a/examples/http-server/src/main.rs +++ b/examples/http-server/src/main.rs @@ -1,6 +1,6 @@ #![feature(wasi_ext)] -use kwasm_net::{schedule, Epoll, Tcp4Listener, TcpStream}; +use wasmer_kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn serve(stream: Arc, mut all: Vec) { diff --git a/examples/wasi-networking/Cargo.toml b/examples/wasi-networking/Cargo.toml index fe6712c171f..27b3d5b5cb7 100644 --- a/examples/wasi-networking/Cargo.toml +++ b/examples/wasi-networking/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [workspace] [dependencies] -kwasm-net = { path = "../../lib/kwasm-net" } \ No newline at end of file +wasmer-kernel-net = { path = "../../lib/kernel-net" } \ No newline at end of file diff --git a/examples/wasi-networking/src/main.rs b/examples/wasi-networking/src/main.rs index 65504bde8a9..5c6ed157391 100644 --- a/examples/wasi-networking/src/main.rs +++ b/examples/wasi-networking/src/main.rs @@ -1,6 +1,6 @@ #![feature(wasi_ext)] -use kwasm_net::{schedule, Epoll, Tcp4Listener, TcpStream}; +use wasmer_kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn do_echo(stream: Arc, buf: Vec) { diff --git a/lib/kernel-loader/src/lib.rs b/lib/kernel-loader/src/lib.rs index 0224f8abfc4..8abc850af33 100644 --- a/lib/kernel-loader/src/lib.rs +++ b/lib/kernel-loader/src/lib.rs @@ -3,7 +3,7 @@ pub mod service; use service::{ImportInfo, LoadProfile, RunProfile, ServiceContext, TableEntryRequest}; use wasmer_runtime_core::{ backend::RunnableModule, - loader::{self, Instance, Loader}, + loader::{Instance, Loader}, module::ModuleInfo, structures::TypedIndex, types::{ diff --git a/lib/kwasm-net/Cargo.toml b/lib/kernel-net/Cargo.toml similarity index 86% rename from lib/kwasm-net/Cargo.toml rename to lib/kernel-net/Cargo.toml index 135a07c7655..e8fb8a2fc33 100644 --- a/lib/kwasm-net/Cargo.toml +++ b/lib/kernel-net/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "kwasm-net" +name = "wasmer-kernel-net" version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" diff --git a/lib/kwasm-net/src/lib.rs b/lib/kernel-net/src/lib.rs similarity index 100% rename from lib/kwasm-net/src/lib.rs rename to lib/kernel-net/src/lib.rs From 720d984d9e40c7e41854a91706f0b7b209a279b4 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 15 May 2019 10:35:09 -0700 Subject: [PATCH 39/43] Make kernel loader available by default --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 06e66e7356c..d598e422016 100644 --- a/Makefile +++ b/Makefile @@ -67,13 +67,13 @@ test-emscripten-singlepass: cargo test --manifest-path lib/emscripten/Cargo.toml --features singlepass -- --test-threads=1 $(runargs) singlepass-debug-release: - cargo +nightly build --features "backend:singlepass debug" --release + cargo +nightly build --features backend:singlepass,debug --release singlepass-release: - cargo +nightly build --features "backend:singlepass" --release + cargo +nightly build --features backend:singlepass --release singlepass-build: - cargo +nightly build --features "backend:singlepass debug" + cargo +nightly build --features backend:singlepass,debug release: # If you are in OS-X, you will need mingw-w64 for cross compiling to windows @@ -81,13 +81,13 @@ release: cargo build --release production-release: - cargo build --release --features backend:singlepass,backend:llvm + cargo build --release --features backend:singlepass,backend:llvm,loader:kernel debug-release: - cargo build --release --features "debug" + cargo build --release --features debug extra-debug-release: - cargo build --release --features "extra-debug" + cargo build --release --features extra-debug publish-release: ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/ From 82bf7ea147e8841aadea90d06ee903056a9ed771 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 15 May 2019 10:35:26 -0700 Subject: [PATCH 40/43] Improved error messages when running on a specific loader --- src/bin/wasmer.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 839f7047aeb..8231c60b410 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -381,15 +381,28 @@ fn execute_wasm(options: &Run) -> Result<(), String> { .args .iter() .map(|arg| arg.as_str()) - .map(|x| Value::I32(x.parse().unwrap())) + .map(|x| { + Value::I32(x.parse().expect(&format!( + "Can't parse the provided argument {:?} as a integer", + x + ))) + }) .collect(); - let index = instance.resolve_func("_start").unwrap(); + let index = instance + .resolve_func("_start") + .expect("The loader requires a _start function to be present in the module"); let mut ins: Box> = match loader { - LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()), + LoaderName::Local => Box::new( + instance + .load(LocalLoader) + .expect("Can't use the local loader"), + ), #[cfg(feature = "loader:kernel")] - LoaderName::Kernel => { - Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap()) - } + LoaderName::Kernel => Box::new( + instance + .load(::wasmer_kernel_loader::KernelLoader) + .expect("Can't use the kernel loader"), + ), }; println!("{:?}", ins.call(index, &args)); return Ok(()); From 0ab8a045b9c7f29b9a941d1e2ec01b0db1f3453f Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 15 May 2019 10:41:44 -0700 Subject: [PATCH 41/43] Re-enable circleci cache --- .circleci/config.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75f6dcdf740..ea0a99bd73b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,6 +86,10 @@ jobs: xcode: "9.0" steps: - checkout + - restore_cache: + keys: + - v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }} + # - v8-cargo-cache-darwin-stable-{{ arch }} - run: name: Install crate dependencies command: | @@ -130,6 +134,16 @@ jobs: export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH" export LLVM_SYS_70_PREFIX="`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/" make integration-tests + - save_cache: + paths: + - ~/.cargo/registry/ + - target/debug/.fingerprint + - target/debug/build + - target/debug/deps + - target/release/.fingerprint + - target/release/build + - target/release/deps + key: v8-cargo-cache-darwin-stable-{{ arch }}-{{ checksum "Cargo.lock" }} test-and-build: docker: @@ -358,7 +372,6 @@ jobs: -d build_parameters[CIRCLE_JOB]=bench \ https://circleci.com/api/v1.1/project/github/wasmerio/wasmer-bench/tree/master fi - workflows: version: 2 main: From b28992932e933c9bfa3935871af426837c16c3f6 Mon Sep 17 00:00:00 2001 From: losfair Date: Thu, 16 May 2019 09:22:40 +0800 Subject: [PATCH 42/43] Rename `wasmer-kernel-net` to `kernel-net`. --- Cargo.lock | 8 ++++---- examples/http-server/Cargo.lock | 4 ++-- examples/http-server/Cargo.toml | 2 +- examples/http-server/src/main.rs | 2 +- examples/wasi-networking/Cargo.lock | 13 +++++++++++++ examples/wasi-networking/Cargo.toml | 2 +- examples/wasi-networking/src/main.rs | 2 +- lib/kernel-net/Cargo.toml | 2 +- 8 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 examples/wasi-networking/Cargo.lock diff --git a/Cargo.lock b/Cargo.lock index cb45c487426..7edac3c951c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -916,6 +916,10 @@ name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "kernel-net" +version = "0.1.0" + [[package]] name = "kernel32-sys" version = "0.2.2" @@ -2343,10 +2347,6 @@ dependencies = [ "wasmer-runtime-core 0.4.1", ] -[[package]] -name = "wasmer-kernel-net" -version = "0.1.0" - [[package]] name = "wasmer-llvm-backend" version = "0.4.1" diff --git a/examples/http-server/Cargo.lock b/examples/http-server/Cargo.lock index a689f109a29..4b927b8e98d 100644 --- a/examples/http-server/Cargo.lock +++ b/examples/http-server/Cargo.lock @@ -4,10 +4,10 @@ name = "http-server" version = "0.1.0" dependencies = [ - "wasmer-kernel-net 0.1.0", + "kernel-net 0.1.0", ] [[package]] -name = "wasmer-kernel-net" +name = "kernel-net" version = "0.1.0" diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index 30488993855..f394f7f5d66 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -9,4 +9,4 @@ edition = "2018" [workspace] [dependencies] -wasmer-kernel-net = { path = "../../lib/kernel-net" } +kernel-net = { path = "../../lib/kernel-net" } diff --git a/examples/http-server/src/main.rs b/examples/http-server/src/main.rs index 1ba382347d6..12ba4615126 100644 --- a/examples/http-server/src/main.rs +++ b/examples/http-server/src/main.rs @@ -1,6 +1,6 @@ #![feature(wasi_ext)] -use wasmer_kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; +use kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn serve(stream: Arc, mut all: Vec) { diff --git a/examples/wasi-networking/Cargo.lock b/examples/wasi-networking/Cargo.lock new file mode 100644 index 00000000000..47b4f0dd535 --- /dev/null +++ b/examples/wasi-networking/Cargo.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "kernel-net" +version = "0.1.0" + +[[package]] +name = "wasi-networking" +version = "0.1.0" +dependencies = [ + "kernel-net 0.1.0", +] + diff --git a/examples/wasi-networking/Cargo.toml b/examples/wasi-networking/Cargo.toml index 27b3d5b5cb7..f9e1812129f 100644 --- a/examples/wasi-networking/Cargo.toml +++ b/examples/wasi-networking/Cargo.toml @@ -7,4 +7,4 @@ edition = "2018" [workspace] [dependencies] -wasmer-kernel-net = { path = "../../lib/kernel-net" } \ No newline at end of file +kernel-net = { path = "../../lib/kernel-net" } \ No newline at end of file diff --git a/examples/wasi-networking/src/main.rs b/examples/wasi-networking/src/main.rs index 5c6ed157391..93bacc09a1d 100644 --- a/examples/wasi-networking/src/main.rs +++ b/examples/wasi-networking/src/main.rs @@ -1,6 +1,6 @@ #![feature(wasi_ext)] -use wasmer_kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; +use kernel_net::{schedule, Epoll, Tcp4Listener, TcpStream}; use std::sync::Arc; fn do_echo(stream: Arc, buf: Vec) { diff --git a/lib/kernel-net/Cargo.toml b/lib/kernel-net/Cargo.toml index e8fb8a2fc33..28db6bf4d4f 100644 --- a/lib/kernel-net/Cargo.toml +++ b/lib/kernel-net/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasmer-kernel-net" +name = "kernel-net" version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" From a17795478cc6c3589fb719c3f086c2c2ba85f10b Mon Sep 17 00:00:00 2001 From: losfair Date: Thu, 16 May 2019 09:24:06 +0800 Subject: [PATCH 43/43] Rename `wasi-networking` to `echo-server`. --- examples/{wasi-networking => echo-server}/Cargo.lock | 10 +++++----- examples/{wasi-networking => echo-server}/Cargo.toml | 2 +- examples/{wasi-networking => echo-server}/src/main.rs | 0 3 files changed, 6 insertions(+), 6 deletions(-) rename examples/{wasi-networking => echo-server}/Cargo.lock (89%) rename examples/{wasi-networking => echo-server}/Cargo.toml (63%) rename examples/{wasi-networking => echo-server}/src/main.rs (100%) diff --git a/examples/wasi-networking/Cargo.lock b/examples/echo-server/Cargo.lock similarity index 89% rename from examples/wasi-networking/Cargo.lock rename to examples/echo-server/Cargo.lock index 47b4f0dd535..87e71d056e3 100644 --- a/examples/wasi-networking/Cargo.lock +++ b/examples/echo-server/Cargo.lock @@ -1,13 +1,13 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "kernel-net" -version = "0.1.0" - -[[package]] -name = "wasi-networking" +name = "echo-server" version = "0.1.0" dependencies = [ "kernel-net 0.1.0", ] +[[package]] +name = "kernel-net" +version = "0.1.0" + diff --git a/examples/wasi-networking/Cargo.toml b/examples/echo-server/Cargo.toml similarity index 63% rename from examples/wasi-networking/Cargo.toml rename to examples/echo-server/Cargo.toml index f9e1812129f..68643e4cd70 100644 --- a/examples/wasi-networking/Cargo.toml +++ b/examples/echo-server/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "wasi-networking" +name = "echo-server" version = "0.1.0" authors = ["Heyang Zhou "] edition = "2018" diff --git a/examples/wasi-networking/src/main.rs b/examples/echo-server/src/main.rs similarity index 100% rename from examples/wasi-networking/src/main.rs rename to examples/echo-server/src/main.rs