mirror of
https://github.com/fluencelabs/wasmer
synced 2025-05-12 02:27:11 +00:00
Library restructure (#104)
* Move wasmer-runtime to wasmer-runtime-core * Add the runtime library * Fix issue with macros using wasmer_runtime, fmt * Make default compiler dependency optional * Add instantiate and validate functions
This commit is contained in:
parent
62b8e7cc2d
commit
74875ed554
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -1100,6 +1100,7 @@ dependencies = [
|
|||||||
"wasmer-clif-backend 0.1.0",
|
"wasmer-clif-backend 0.1.0",
|
||||||
"wasmer-emscripten 0.1.1",
|
"wasmer-emscripten 0.1.1",
|
||||||
"wasmer-runtime 0.1.0",
|
"wasmer-runtime 0.1.0",
|
||||||
|
"wasmer-runtime-core 0.1.0",
|
||||||
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -1117,7 +1118,7 @@ dependencies = [
|
|||||||
"libffi 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libffi 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmer-runtime 0.1.0",
|
"wasmer-runtime-core 0.1.0",
|
||||||
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1132,12 +1133,20 @@ dependencies = [
|
|||||||
"time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmer-clif-backend 0.1.0",
|
"wasmer-clif-backend 0.1.0",
|
||||||
"wasmer-runtime 0.1.0",
|
"wasmer-runtime-core 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-runtime"
|
name = "wasmer-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"wasmer-clif-backend 0.1.0",
|
||||||
|
"wasmer-runtime-core 0.1.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmer-runtime-core"
|
||||||
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"field-offset 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"field-offset 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -1146,6 +1155,7 @@ dependencies = [
|
|||||||
"page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"page_size 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"wabt 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmer-clif-backend 0.1.0",
|
"wasmer-clif-backend 0.1.0",
|
||||||
|
"wasmparser 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -52,11 +52,12 @@ libffi = "0.6.4"
|
|||||||
time = "0.1.41"
|
time = "0.1.41"
|
||||||
wasmer-clif-backend = { path = "lib/clif-backend" }
|
wasmer-clif-backend = { path = "lib/clif-backend" }
|
||||||
wasmer-runtime = { path = "lib/runtime" }
|
wasmer-runtime = { path = "lib/runtime" }
|
||||||
|
wasmer-runtime-core = { path = "lib/runtime-core" }
|
||||||
wasmer-emscripten = { path = "lib/emscripten" }
|
wasmer-emscripten = { path = "lib/emscripten" }
|
||||||
libc = { git = "https://github.com/rust-lang/libc" }
|
libc = { git = "https://github.com/rust-lang/libc" }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["lib/clif-backend", "lib/runtime", "lib/emscripten"]
|
members = ["lib/clif-backend", "lib/runtime", "lib/runtime-core", "lib/emscripten"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
wabt = "0.7.2"
|
wabt = "0.7.2"
|
||||||
|
4
Makefile
4
Makefile
@ -7,7 +7,7 @@ endif
|
|||||||
|
|
||||||
# This will re-generate the Rust test files based on spectests/*.wast
|
# This will re-generate the Rust test files based on spectests/*.wast
|
||||||
spectests:
|
spectests:
|
||||||
WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime
|
WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime-core
|
||||||
|
|
||||||
emtests:
|
emtests:
|
||||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten
|
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten
|
||||||
@ -36,7 +36,7 @@ test:
|
|||||||
# We use one thread so the emscripten stdouts doesn't collide
|
# We use one thread so the emscripten stdouts doesn't collide
|
||||||
# cargo test --all -- --test-threads=1 $(runargs)
|
# cargo test --all -- --test-threads=1 $(runargs)
|
||||||
# cargo test --all --exclude wasmer-emscripten -- --test-threads=1 $(runargs)
|
# cargo test --all --exclude wasmer-emscripten -- --test-threads=1 $(runargs)
|
||||||
cargo test -p wasmer-runtime -- --test-threads=1 $(runargs)
|
cargo test -p wasmer-runtime-core -- --test-threads=1 $(runargs)
|
||||||
|
|
||||||
release:
|
release:
|
||||||
# If you are in OS-X, you will need mingw-w64 for cross compiling to windows
|
# If you are in OS-X, you will need mingw-w64 for cross compiling to windows
|
||||||
|
@ -5,7 +5,7 @@ authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmer-runtime = { path = "../runtime" }
|
wasmer-runtime-core = { path = "../runtime-core" }
|
||||||
cranelift-native = "0.26.0"
|
cranelift-native = "0.26.0"
|
||||||
cranelift-codegen = "0.26.0"
|
cranelift-codegen = "0.26.0"
|
||||||
cranelift-entity = "0.26.0"
|
cranelift-entity = "0.26.0"
|
||||||
|
@ -7,7 +7,7 @@ use crate::call::recovery::call_protected;
|
|||||||
use hashbrown::HashSet;
|
use hashbrown::HashSet;
|
||||||
use libffi::high::{arg as libffi_arg, call as libffi_call, CodePtr};
|
use libffi::high::{arg as libffi_arg, call as libffi_call, CodePtr};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
backend::{ProtectedCaller, Token},
|
backend::{ProtectedCaller, Token},
|
||||||
error::RuntimeResult,
|
error::RuntimeResult,
|
||||||
export::Context,
|
export::Context,
|
||||||
|
@ -12,7 +12,7 @@ use nix::sys::signal::{Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV};
|
|||||||
use std::cell::{Cell, UnsafeCell};
|
use std::cell::{Cell, UnsafeCell};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
error::{RuntimeError, RuntimeResult},
|
error::{RuntimeError, RuntimeResult},
|
||||||
structures::TypedIndex,
|
structures::TypedIndex,
|
||||||
types::{MemoryIndex, TableIndex},
|
types::{MemoryIndex, TableIndex},
|
||||||
|
@ -16,7 +16,7 @@ use cranelift_wasm::{
|
|||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use target_lexicon;
|
use target_lexicon;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
backend::SigRegistry,
|
backend::SigRegistry,
|
||||||
memory::LinearMemory,
|
memory::LinearMemory,
|
||||||
module::{
|
module::{
|
||||||
|
@ -5,7 +5,7 @@ use cranelift_codegen::{
|
|||||||
isa,
|
isa,
|
||||||
};
|
};
|
||||||
use cranelift_wasm::{self, FuncEnvironment, ModuleEnvironment};
|
use cranelift_wasm::{self, FuncEnvironment, ModuleEnvironment};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
memory::LinearMemory,
|
memory::LinearMemory,
|
||||||
structures::TypedIndex,
|
structures::TypedIndex,
|
||||||
types::{FuncIndex, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex},
|
types::{FuncIndex, GlobalIndex, LocalOrImport, MemoryIndex, TableIndex},
|
||||||
|
@ -12,7 +12,7 @@ use cranelift_codegen::{
|
|||||||
settings::{self, Configurable},
|
settings::{self, Configurable},
|
||||||
};
|
};
|
||||||
use target_lexicon::Triple;
|
use target_lexicon::Triple;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
backend::{Compiler, Token},
|
backend::{Compiler, Token},
|
||||||
error::{CompileError, CompileResult},
|
error::{CompileError, CompileResult},
|
||||||
module::ModuleInner,
|
module::ModuleInner,
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
ptr::NonNull,
|
ptr::NonNull,
|
||||||
};
|
};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
backend::SigRegistry,
|
backend::SigRegistry,
|
||||||
backend::{FuncResolver, ProtectedCaller, Token},
|
backend::{FuncResolver, ProtectedCaller, Token},
|
||||||
error::{CompileResult, RuntimeResult},
|
error::{CompileResult, RuntimeResult},
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use cranelift_codegen::{ir, isa};
|
use cranelift_codegen::{ir, isa};
|
||||||
use cranelift_wasm::{self, translate_module, FuncTranslator, ModuleEnvironment};
|
use cranelift_wasm::{self, translate_module, FuncTranslator, ModuleEnvironment};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
error::{CompileError, CompileResult},
|
error::{CompileError, CompileResult},
|
||||||
module::{DataInitializer, ExportIndex, ImportName, TableInitializer},
|
module::{DataInitializer, ExportIndex, ImportName, TableInitializer},
|
||||||
structures::{Map, TypedIndex},
|
structures::{Map, TypedIndex},
|
||||||
|
@ -6,7 +6,7 @@ use cranelift_codegen::binemit;
|
|||||||
pub use cranelift_codegen::binemit::Reloc;
|
pub use cranelift_codegen::binemit::Reloc;
|
||||||
use cranelift_codegen::ir::{self, ExternalName, LibCall, SourceLoc, TrapCode};
|
use cranelift_codegen::ir::{self, ExternalName, LibCall, SourceLoc, TrapCode};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use wasmer_runtime::{structures::TypedIndex, types::LocalFuncIndex};
|
use wasmer_runtime_core::{structures::TypedIndex, types::LocalFuncIndex};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Relocation {
|
pub struct Relocation {
|
||||||
|
@ -7,7 +7,7 @@ use byteorder::{ByteOrder, LittleEndian};
|
|||||||
use cranelift_codegen::{ir, isa, Context};
|
use cranelift_codegen::{ir, isa, Context};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr::{write_unaligned, NonNull};
|
use std::ptr::{write_unaligned, NonNull};
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
self,
|
self,
|
||||||
backend::{
|
backend::{
|
||||||
self,
|
self,
|
||||||
@ -206,7 +206,7 @@ impl FuncResolver {
|
|||||||
impl backend::FuncResolver for FuncResolver {
|
impl backend::FuncResolver for FuncResolver {
|
||||||
fn get(
|
fn get(
|
||||||
&self,
|
&self,
|
||||||
_module: &wasmer_runtime::module::ModuleInner,
|
_module: &wasmer_runtime_core::module::ModuleInner,
|
||||||
index: LocalFuncIndex,
|
index: LocalFuncIndex,
|
||||||
) -> Option<NonNull<vm::Func>> {
|
) -> Option<NonNull<vm::Func>> {
|
||||||
self.lookup(index)
|
self.lookup(index)
|
||||||
|
@ -7,7 +7,7 @@ build = "build/mod.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
hashbrown = "0.1"
|
hashbrown = "0.1"
|
||||||
wasmer-runtime = { path = "../runtime" }
|
wasmer-runtime-core = { path = "../runtime-core" }
|
||||||
libc = { git = "https://github.com/rust-lang/libc" }
|
libc = { git = "https://github.com/rust-lang/libc" }
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
time = "0.1.41"
|
time = "0.1.41"
|
||||||
|
@ -8,7 +8,7 @@ use std::mem;
|
|||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
|
|
||||||
use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
use super::utils::{allocate_on_stack, copy_cstr_into_wasm, copy_terminated_array_of_cstrs};
|
||||||
use wasmer_runtime::{types::Value, Instance};
|
use wasmer_runtime_core::{types::Value, Instance};
|
||||||
//use super::EmscriptenData;
|
//use super::EmscriptenData;
|
||||||
|
|
||||||
//impl Instance {
|
//impl Instance {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::env;
|
use super::env;
|
||||||
use super::process::_abort;
|
use super::process::_abort;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
/// emscripten: ___cxa_allocate_exception
|
/// emscripten: ___cxa_allocate_exception
|
||||||
pub extern "C" fn ___cxa_allocate_exception(size: u32, instance: &mut Instance) -> u32 {
|
pub extern "C" fn ___cxa_allocate_exception(size: u32, instance: &mut Instance) -> u32 {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use libc::printf as _printf;
|
use libc::printf as _printf;
|
||||||
|
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
/// putchar
|
/// putchar
|
||||||
pub use libc::putchar;
|
pub use libc::putchar;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use libc::{c_int, c_void};
|
use libc::{c_int, c_void};
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
/// setjmp
|
/// setjmp
|
||||||
pub extern "C" fn __setjmp(env_addr: u32, instance: &mut Instance) -> c_int {
|
pub extern "C" fn __setjmp(env_addr: u32, instance: &mut Instance) -> c_int {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate wasmer_runtime;
|
extern crate wasmer_runtime_core;
|
||||||
|
|
||||||
use byteorder::{ByteOrder, LittleEndian};
|
use byteorder::{ByteOrder, LittleEndian};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use wasmer_runtime::{
|
use wasmer_runtime_core::{
|
||||||
export::{Context, Export, FuncPointer, GlobalPointer},
|
export::{Context, Export, FuncPointer, GlobalPointer},
|
||||||
import::{ImportObject, Namespace},
|
import::{ImportObject, Namespace},
|
||||||
memory::LinearMemory,
|
memory::LinearMemory,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
// TODO: Need to implement.
|
// TODO: Need to implement.
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use libc::c_int;
|
use libc::c_int;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
// NOTE: Not implemented by Emscripten
|
// NOTE: Not implemented by Emscripten
|
||||||
pub extern "C" fn ___lock(which: c_int, varargs: c_int, _instance: &mut Instance) {
|
pub extern "C" fn ___lock(which: c_int, varargs: c_int, _instance: &mut Instance) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use super::process::abort_with_message;
|
use super::process::abort_with_message;
|
||||||
use libc::{c_int, c_void, memcpy, size_t};
|
use libc::{c_int, c_void, memcpy, size_t};
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
/// emscripten: _emscripten_memcpy_big
|
/// emscripten: _emscripten_memcpy_big
|
||||||
pub extern "C" fn _emscripten_memcpy_big(
|
pub extern "C" fn _emscripten_memcpy_big(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use super::process::abort_with_message;
|
use super::process::abort_with_message;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
pub extern "C" fn nullfunc_ii(x: u32, _instance: &Instance) {
|
pub extern "C" fn nullfunc_ii(x: u32, _instance: &Instance) {
|
||||||
debug!("emscripten::nullfunc_ii {}", x);
|
debug!("emscripten::nullfunc_ii {}", x);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use libc::{abort, c_char, c_int, exit, pid_t, EAGAIN};
|
use libc::{abort, c_char, c_int, exit, pid_t, EAGAIN};
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
pub extern "C" fn abort_with_message(message: &str) {
|
pub extern "C" fn abort_with_message(message: &str) {
|
||||||
debug!("emscripten::abort_with_message");
|
debug!("emscripten::abort_with_message");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// use super::varargs::VarArgs;
|
// use super::varargs::VarArgs;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
#[allow(clippy::cast_ptr_alignment)]
|
#[allow(clippy::cast_ptr_alignment)]
|
||||||
pub extern "C" fn _sigemptyset(set: u32, instance: &mut Instance) -> i32 {
|
pub extern "C" fn _sigemptyset(set: u32, instance: &mut Instance) -> i32 {
|
||||||
|
@ -70,7 +70,7 @@ use libc::{
|
|||||||
SO_REUSEADDR,
|
SO_REUSEADDR,
|
||||||
TIOCGWINSZ,
|
TIOCGWINSZ,
|
||||||
};
|
};
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
use super::env;
|
use super::env;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -6,7 +6,7 @@ use std::time::SystemTime;
|
|||||||
use time;
|
use time;
|
||||||
|
|
||||||
use super::env;
|
use super::env;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use libc::{CLOCK_MONOTONIC, CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME};
|
use libc::{CLOCK_MONOTONIC, CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use wasmer_runtime::{module::Module, Instance};
|
use wasmer_runtime_core::{module::Module, Instance};
|
||||||
//use wasmer_runtime::Instance;
|
//use wasmer_runtime_core::Instance;
|
||||||
use super::env;
|
use super::env;
|
||||||
use libc::stat;
|
use libc::stat;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
@ -144,7 +144,7 @@ mod tests {
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
use wasmer_runtime::{compile, module::Module};
|
use wasmer_runtime_core::{compile, module::Module};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_detect_emscripten_files() {
|
fn should_detect_emscripten_files() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use wasmer_runtime::Instance;
|
use wasmer_runtime_core::Instance;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct VarArgs {
|
pub struct VarArgs {
|
||||||
|
@ -10,7 +10,7 @@ macro_rules! assert_emscripten_output {
|
|||||||
|
|
||||||
let wasm_bytes = include_bytes!($file);
|
let wasm_bytes = include_bytes!($file);
|
||||||
|
|
||||||
let module = wasmer_runtime::compile(&wasm_bytes[..], &CraneliftCompiler::new())
|
let module = wasmer_runtime_core::compile(&wasm_bytes[..], &CraneliftCompiler::new())
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
|
|
||||||
// let module = compile(&wasm_bytes[..])
|
// let module = compile(&wasm_bytes[..])
|
||||||
|
33
lib/runtime-core/Cargo.toml
Normal file
33
lib/runtime-core/Cargo.toml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasmer-runtime-core"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
build = "build/mod.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
hashbrown = "0.1"
|
||||||
|
nix = "0.12.0"
|
||||||
|
page_size = "0.4.1"
|
||||||
|
wasmparser = "0.23.0"
|
||||||
|
|
||||||
|
[target.'cfg(windows)'.dependencies]
|
||||||
|
winapi = { version = "0.3", features = ["memoryapi"] }
|
||||||
|
|
||||||
|
[target.'cfg(unix)'.dependencies]
|
||||||
|
errno = "0.2.4"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
wabt = "0.7.2"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasmer-clif-backend = { path = "../clif-backend" }
|
||||||
|
wabt = "0.7.2"
|
||||||
|
field-offset = "0.1.1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["fast-tests"]
|
||||||
|
|
||||||
|
debug = []
|
||||||
|
# This feature will allow cargo test to compile much faster
|
||||||
|
fast-tests = []
|
@ -78,10 +78,10 @@ static COMMON: &'static str = r##"
|
|||||||
use std::{{f32, f64}};
|
use std::{{f32, f64}};
|
||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
use wasmer_runtime::import::ImportObject;
|
use wasmer_runtime_core::import::ImportObject;
|
||||||
use wasmer_runtime::types::Value;
|
use wasmer_runtime_core::types::Value;
|
||||||
use wasmer_runtime::{{Instance, module::Module}};
|
use wasmer_runtime_core::{{Instance, module::Module}};
|
||||||
use wasmer_runtime::error::Result;
|
use wasmer_runtime_core::error::Result;
|
||||||
|
|
||||||
static IMPORT_MODULE: &str = r#"
|
static IMPORT_MODULE: &str = r#"
|
||||||
(module
|
(module
|
||||||
@ -96,7 +96,7 @@ static IMPORT_MODULE: &str = r#"
|
|||||||
|
|
||||||
pub fn generate_imports() -> ImportObject {
|
pub fn generate_imports() -> ImportObject {
|
||||||
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new())
|
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
let instance = module
|
let instance = module
|
||||||
.instantiate(ImportObject::new())
|
.instantiate(ImportObject::new())
|
||||||
@ -292,8 +292,8 @@ impl WastTestGenerator {
|
|||||||
// //use wabt::wat2wasm;
|
// //use wabt::wat2wasm;
|
||||||
// use std::{{f32, f64}};
|
// use std::{{f32, f64}};
|
||||||
|
|
||||||
// use wasmer_runtime::types::Value;
|
// use wasmer_runtime_core::types::Value;
|
||||||
// use wasmer_runtime::{{Instance, module::Module}};
|
// use wasmer_runtime_core::{{Instance, module::Module}};
|
||||||
|
|
||||||
// //use crate::spectests::_common::{{
|
// //use crate::spectests::_common::{{
|
||||||
// // generate_imports,
|
// // generate_imports,
|
||||||
@ -357,7 +357,7 @@ fn test_module_{}() {{
|
|||||||
let module_str = \"{}\";
|
let module_str = \"{}\";
|
||||||
println!(\"{{}}\", module_str);
|
println!(\"{{}}\", module_str);
|
||||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect(\"WAST not valid or malformed\");
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect(\"WAST not valid or malformed\");
|
||||||
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new()).expect(\"WASM can't be compiled\");
|
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new()).expect(\"WASM can't be compiled\");
|
||||||
module.instantiate(generate_imports()).expect(\"WASM can't be instantiated\")
|
module.instantiate(generate_imports()).expect(\"WASM can't be instantiated\")
|
||||||
}}\n",
|
}}\n",
|
||||||
self.last_module,
|
self.last_module,
|
||||||
@ -397,7 +397,7 @@ fn test_module_{}() {{
|
|||||||
"#[test]
|
"#[test]
|
||||||
fn {}_assert_invalid() {{
|
fn {}_assert_invalid() {{
|
||||||
let wasm_binary = {:?};
|
let wasm_binary = {:?};
|
||||||
let module = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
let module = wasmer_runtime_core::compile_with(&wasm_binary, &CraneliftCompiler::new());
|
||||||
assert!(module.is_err(), \"WASM should not compile as is invalid\");
|
assert!(module.is_err(), \"WASM should not compile as is invalid\");
|
||||||
}}\n",
|
}}\n",
|
||||||
command_name,
|
command_name,
|
||||||
@ -528,7 +528,7 @@ fn {}_assert_invalid() {{
|
|||||||
"#[test]
|
"#[test]
|
||||||
fn {}_assert_malformed() {{
|
fn {}_assert_malformed() {{
|
||||||
let wasm_binary = {:?};
|
let wasm_binary = {:?};
|
||||||
let compilation = wasmer_runtime::compile(&wasm_binary, &CraneliftCompiler::new());
|
let compilation = wasmer_runtime_core::compile_with(&wasm_binary, &CraneliftCompiler::new());
|
||||||
assert!(compilation.is_err(), \"WASM should not compile as is malformed\");
|
assert!(compilation.is_err(), \"WASM should not compile as is malformed\");
|
||||||
}}\n",
|
}}\n",
|
||||||
command_name,
|
command_name,
|
@ -1,12 +1,12 @@
|
|||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
use wasmer_runtime::{self as runtime, error::Result, prelude::*};
|
use wasmer_runtime_core::{error::Result, prelude::*};
|
||||||
|
|
||||||
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
|
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let inner_module = runtime::compile(&wasm_binary, &CraneliftCompiler::new())?;
|
let inner_module = wasmer_runtime_core::compile_with(&wasm_binary, &CraneliftCompiler::new())?;
|
||||||
|
|
||||||
let import_object = imports! {
|
let import_object = imports! {
|
||||||
"env" => {
|
"env" => {
|
||||||
@ -20,7 +20,7 @@ fn main() -> Result<()> {
|
|||||||
"env" => inner_instance,
|
"env" => inner_instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
let outer_module = runtime::compile(EXAMPLE_WASM, &CraneliftCompiler::new())?;
|
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &CraneliftCompiler::new())?;
|
||||||
let mut outer_instance = outer_module.instantiate(outer_imports)?;
|
let mut outer_instance = outer_module.instantiate(outer_imports)?;
|
||||||
let ret = outer_instance.call("main", &[Value::I32(42)])?;
|
let ret = outer_instance.call("main", &[Value::I32(42)])?;
|
||||||
println!("ret: {:?}", ret);
|
println!("ret: {:?}", ret);
|
@ -1,6 +1,6 @@
|
|||||||
use wabt::wat2wasm;
|
use wabt::wat2wasm;
|
||||||
use wasmer_clif_backend::CraneliftCompiler;
|
use wasmer_clif_backend::CraneliftCompiler;
|
||||||
use wasmer_runtime::{import::ImportObject, Instance};
|
use wasmer_runtime_core::{import::ImportObject, Instance};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut instance = create_module_1();
|
let mut instance = create_module_1();
|
||||||
@ -24,7 +24,7 @@ fn create_module_1() -> Instance {
|
|||||||
(elem (;1;) (i32.const 9) 1))
|
(elem (;1;) (i32.const 9) 1))
|
||||||
"#;
|
"#;
|
||||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new())
|
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
module
|
module
|
||||||
.instantiate(generate_imports())
|
.instantiate(generate_imports())
|
||||||
@ -44,7 +44,7 @@ static IMPORT_MODULE: &str = r#"
|
|||||||
|
|
||||||
pub fn generate_imports() -> ImportObject {
|
pub fn generate_imports() -> ImportObject {
|
||||||
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
|
||||||
let module = wasmer_runtime::compile(&wasm_binary[..], &CraneliftCompiler::new())
|
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
|
||||||
.expect("WASM can't be compiled");
|
.expect("WASM can't be compiled");
|
||||||
let instance = module
|
let instance = module
|
||||||
.instantiate(ImportObject::new())
|
.instantiate(ImportObject::new())
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user