mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 06:31:32 +00:00
Merge branch 'master' into feature/improve-importing
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
lib/emscripten/emtests/* linguist-vendored
|
||||||
|
lib/runtime-core/spectests/* linguist-vendored
|
24
Cargo.lock
generated
24
Cargo.lock
generated
@ -684,15 +684,15 @@ dependencies = [
|
|||||||
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wabt 0.7.4 (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.1.1",
|
"wasmer-clif-backend 0.1.2",
|
||||||
"wasmer-emscripten 0.1.0",
|
"wasmer-emscripten 0.1.0",
|
||||||
"wasmer-runtime 0.1.1",
|
"wasmer-runtime 0.1.4",
|
||||||
"wasmer-runtime-core 0.1.1",
|
"wasmer-runtime-core 0.1.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-clif-backend"
|
name = "wasmer-clif-backend"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cranelift-codegen 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cranelift-codegen 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -702,7 +702,7 @@ dependencies = [
|
|||||||
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hashbrown 0.1.8 (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-core 0.1.1",
|
"wasmer-runtime-core 0.1.2",
|
||||||
"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)",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -716,21 +716,21 @@ dependencies = [
|
|||||||
"libc 0.2.48 (git+https://github.com/rust-lang/libc)",
|
"libc 0.2.48 (git+https://github.com/rust-lang/libc)",
|
||||||
"time 0.1.42 (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)",
|
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wasmer-clif-backend 0.1.1",
|
"wasmer-clif-backend 0.1.2",
|
||||||
"wasmer-runtime-core 0.1.1",
|
"wasmer-runtime-core 0.1.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-runtime"
|
name = "wasmer-runtime"
|
||||||
version = "0.1.1"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"wasmer-clif-backend 0.1.1",
|
"wasmer-clif-backend 0.1.2",
|
||||||
"wasmer-runtime-core 0.1.1",
|
"wasmer-runtime-core 0.1.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmer-runtime-core"
|
name = "wasmer-runtime-core"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
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)",
|
||||||
@ -740,7 +740,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)",
|
||||||
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"wabt 0.7.4 (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.1.1",
|
"wasmer-clif-backend 0.1.2",
|
||||||
"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)",
|
||||||
]
|
]
|
||||||
|
19
README.md
19
README.md
@ -3,6 +3,9 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://circleci.com/gh/wasmerio/wasmer/"><img src="https://img.shields.io/circleci/project/github/wasmerio/wasmer/master.svg" alt="Build Status"></a>
|
<a href="https://circleci.com/gh/wasmerio/wasmer/"><img src="https://img.shields.io/circleci/project/github/wasmerio/wasmer/master.svg" alt="Build Status"></a>
|
||||||
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE"><img src="https://img.shields.io/github/license/wasmerio/wasmer.svg" alt="License"></a>
|
<a href="https://github.com/wasmerio/wasmer/blob/master/LICENSE"><img src="https://img.shields.io/github/license/wasmerio/wasmer.svg" alt="License"></a>
|
||||||
|
<a href="https://spectrum.chat/wasmer">
|
||||||
|
<img alt="Join the Wasmer Community" src="https://withspectrum.github.io/badge/badge.svg" />
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
@ -15,6 +18,8 @@ Install Wasmer with:
|
|||||||
curl https://get.wasmer.io -sSfL | sh
|
curl https://get.wasmer.io -sSfL | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
_**NEW ✨**: Now you can also embed Wasmer in your Rust application, check our [example repo](https://github.com/wasmerio/wasmer-rust-example) to see how to do it!_
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
`wasmer` can execute both the standard binary format (`.wasm`) and the text
|
`wasmer` can execute both the standard binary format (`.wasm`) and the text
|
||||||
@ -54,9 +59,10 @@ curl https://sh.rustup.rs -sSf | sh
|
|||||||
### Other dependencies
|
### Other dependencies
|
||||||
|
|
||||||
Please select your operating system:
|
Please select your operating system:
|
||||||
* [macOS](#macos)
|
|
||||||
* [Debian-based Linuxes](#debian-based-linuxes)
|
- [macOS](#macos)
|
||||||
* [Microsoft Windows](#windows-msvc)
|
- [Debian-based Linuxes](#debian-based-linuxes)
|
||||||
|
- [Microsoft Windows](#windows-msvc)
|
||||||
|
|
||||||
#### macOS
|
#### macOS
|
||||||
|
|
||||||
@ -80,7 +86,7 @@ sudo apt install cmake
|
|||||||
|
|
||||||
#### Windows (MSVC)
|
#### Windows (MSVC)
|
||||||
|
|
||||||
Right now Windows support is *highly experimental*.
|
Right now Windows support is _highly experimental_.
|
||||||
We are working on this so Wasmer can soon be released for Windows.
|
We are working on this so Wasmer can soon be released for Windows.
|
||||||
|
|
||||||
1. Install Python for Windows (https://www.python.org/downloads/release/python-2714/). The Windows x86-64 MSI installer is fine.
|
1. Install Python for Windows (https://www.python.org/downloads/release/python-2714/). The Windows x86-64 MSI installer is fine.
|
||||||
@ -89,7 +95,6 @@ You should change the installation to install the "Add python.exe to Path" featu
|
|||||||
2. Install Git for Windows (https://git-scm.com/download/win). DO allow it to add git.exe to the PATH (default
|
2. Install Git for Windows (https://git-scm.com/download/win). DO allow it to add git.exe to the PATH (default
|
||||||
settings for the installer are fine).
|
settings for the installer are fine).
|
||||||
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Wasmer is built with [Cargo](https://crates.io/), the Rust package manager.
|
Wasmer is built with [Cargo](https://crates.io/), the Rust package manager.
|
||||||
@ -106,7 +111,7 @@ cargo install --path .
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Thanks to [spectests](https://github.com/wasmerio/wasmer/tree/master/spectests) we can assure 100% compatibility with the WebAssembly spec test suite.
|
Thanks to [spectests](https://github.com/wasmerio/wasmer/tree/master/lib/runtime-core/spectests) we can assure 100% compatibility with the WebAssembly spec test suite.
|
||||||
|
|
||||||
Tests can be run with:
|
Tests can be run with:
|
||||||
|
|
||||||
@ -135,7 +140,7 @@ Below are some of the goals (written with order) of this project:
|
|||||||
|
|
||||||
- [x] It should be 100% compatible with the [WebAssembly Spectest](https://github.com/wasmerio/wasmer/tree/master/spectests)
|
- [x] It should be 100% compatible with the [WebAssembly Spectest](https://github.com/wasmerio/wasmer/tree/master/spectests)
|
||||||
- [x] It should be fast _(partially achieved)_
|
- [x] It should be fast _(partially achieved)_
|
||||||
- [ ] Support Emscripten calls _(on the works)_
|
- [ ] Support Emscripten calls _(in the works)_
|
||||||
- [ ] Support Rust ABI calls
|
- [ ] Support Rust ABI calls
|
||||||
- [ ] Support GO ABI calls
|
- [ ] Support GO ABI calls
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wasmer-clif-backend"
|
name = "wasmer-clif-backend"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "Wasmer runtime Cranelift compiler backend"
|
description = "Wasmer runtime Cranelift compiler backend"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.1" }
|
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.2" }
|
||||||
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"
|
||||||
|
@ -86,14 +86,10 @@ impl Module {
|
|||||||
isa: &isa::TargetIsa,
|
isa: &isa::TargetIsa,
|
||||||
functions: Map<LocalFuncIndex, ir::Function>,
|
functions: Map<LocalFuncIndex, ir::Function>,
|
||||||
) -> CompileResult<ModuleInner> {
|
) -> CompileResult<ModuleInner> {
|
||||||
// we have to deduplicate `module.func_assoc`
|
let imported_functions_len = self.module.imported_functions.len();
|
||||||
// let func_assoc = &mut self.module.func_assoc;
|
let (func_resolver_builder, handler_data) =
|
||||||
// let sig_registry = &self.module.sig_registry;
|
FuncResolverBuilder::new(isa, functions, imported_functions_len)?;
|
||||||
// func_assoc.iter_mut().for_each(|(_, sig_index)| {
|
|
||||||
// *sig_index = sig_registry.lookup_deduplicated_sigindex(*sig_index);
|
|
||||||
// });
|
|
||||||
|
|
||||||
let (func_resolver_builder, handler_data) = FuncResolverBuilder::new(isa, functions)?;
|
|
||||||
self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);
|
self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);
|
||||||
|
|
||||||
let trampolines = Trampolines::new(isa, &self.module);
|
let trampolines = Trampolines::new(isa, &self.module);
|
||||||
|
@ -14,7 +14,7 @@ use wasmer_runtime_core::{
|
|||||||
sys::{Memory, Protect},
|
sys::{Memory, Protect},
|
||||||
},
|
},
|
||||||
error::{CompileError, CompileResult},
|
error::{CompileError, CompileResult},
|
||||||
structures::Map,
|
structures::{Map, TypedIndex},
|
||||||
types::LocalFuncIndex,
|
types::LocalFuncIndex,
|
||||||
vm, vmcalls,
|
vm, vmcalls,
|
||||||
};
|
};
|
||||||
@ -23,12 +23,14 @@ use wasmer_runtime_core::{
|
|||||||
pub struct FuncResolverBuilder {
|
pub struct FuncResolverBuilder {
|
||||||
resolver: FuncResolver,
|
resolver: FuncResolver,
|
||||||
relocations: Map<LocalFuncIndex, Vec<Relocation>>,
|
relocations: Map<LocalFuncIndex, Vec<Relocation>>,
|
||||||
|
import_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FuncResolverBuilder {
|
impl FuncResolverBuilder {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
isa: &isa::TargetIsa,
|
isa: &isa::TargetIsa,
|
||||||
function_bodies: Map<LocalFuncIndex, ir::Function>,
|
function_bodies: Map<LocalFuncIndex, ir::Function>,
|
||||||
|
import_len: usize,
|
||||||
) -> CompileResult<(Self, HandlerData)> {
|
) -> CompileResult<(Self, HandlerData)> {
|
||||||
let mut compiled_functions: Vec<Vec<u8>> = Vec::with_capacity(function_bodies.len());
|
let mut compiled_functions: Vec<Vec<u8>> = Vec::with_capacity(function_bodies.len());
|
||||||
let mut relocations = Map::with_capacity(function_bodies.len());
|
let mut relocations = Map::with_capacity(function_bodies.len());
|
||||||
@ -100,6 +102,7 @@ impl FuncResolverBuilder {
|
|||||||
Self {
|
Self {
|
||||||
resolver: FuncResolver { map, memory },
|
resolver: FuncResolver { map, memory },
|
||||||
relocations,
|
relocations,
|
||||||
|
import_len,
|
||||||
},
|
},
|
||||||
handler_data,
|
handler_data,
|
||||||
))
|
))
|
||||||
@ -113,6 +116,10 @@ impl FuncResolverBuilder {
|
|||||||
// This will always be an internal function
|
// This will always be an internal function
|
||||||
// because imported functions are not
|
// because imported functions are not
|
||||||
// called in this way.
|
// called in this way.
|
||||||
|
// Adjust from wasm-wide function index to index of locally-defined functions only.
|
||||||
|
let local_func_index =
|
||||||
|
LocalFuncIndex::new(local_func_index.index() - self.import_len);
|
||||||
|
|
||||||
self.resolver.lookup(local_func_index).unwrap().as_ptr() as isize
|
self.resolver.lookup(local_func_index).unwrap().as_ptr() as isize
|
||||||
}
|
}
|
||||||
RelocationType::LibCall(libcall) => match libcall {
|
RelocationType::LibCall(libcall) => match libcall {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wasmer-runtime-core"
|
name = "wasmer-runtime-core"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
description = "Wasmer runtime core library"
|
description = "Wasmer runtime core library"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
@ -26,7 +26,7 @@ errno = "0.2.4"
|
|||||||
wabt = "0.7.2"
|
wabt = "0.7.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.1" }
|
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2" }
|
||||||
wabt = "0.7.2"
|
wabt = "0.7.2"
|
||||||
field-offset = "0.1.1"
|
field-offset = "0.1.1"
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ macro_rules! __export_func_convert_type {
|
|||||||
Type::I64
|
Type::I64
|
||||||
};
|
};
|
||||||
(u64) => {
|
(u64) => {
|
||||||
Type::I32
|
Type::I64
|
||||||
};
|
};
|
||||||
(f32) => {
|
(f32) => {
|
||||||
Type::F32
|
Type::F32
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "wasmer-runtime"
|
name = "wasmer-runtime"
|
||||||
version = "0.1.1"
|
version = "0.1.4"
|
||||||
description = "Wasmer runtime library"
|
description = "Wasmer runtime library"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||||
repository = "https://github.com/wasmerio/wasmer"
|
repository = "https://github.com/wasmerio/wasmer"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.1" }
|
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.2" }
|
||||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.1", optional = true }
|
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["wasmer-clif-backend"]
|
default = ["wasmer-clif-backend"]
|
||||||
|
Reference in New Issue
Block a user