Skip to content

Commit

Permalink
Merge branch 'master' into feature/improve-importing
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlansneff authored Jan 29, 2019
2 parents a601323 + 7cf6fee commit 5aa7d71
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib/emscripten/emtests/* linguist-vendored
lib/runtime-core/spectests/* linguist-vendored
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<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://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>

## Introduction
Expand All @@ -15,6 +18,8 @@ Install Wasmer with:
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

`wasmer` can execute both the standard binary format (`.wasm`) and the text
Expand Down Expand Up @@ -54,15 +59,16 @@ curl https://sh.rustup.rs -sSf | sh
### Other dependencies

Please select your operating system:
* [macOS](#macos)
* [Debian-based Linuxes](#debian-based-linuxes)
* [Microsoft Windows](#windows-msvc)

- [macOS](#macos)
- [Debian-based Linuxes](#debian-based-linuxes)
- [Microsoft Windows](#windows-msvc)

#### macOS

If you have [homebrew](https://brew.sh/) installed:

``` sh
```sh
brew install cmake
```

Expand All @@ -74,21 +80,20 @@ sudo port install cmake

#### Debian-based Linuxes

``` sh
```sh
sudo apt install cmake
```

#### 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.

1. Install Python for Windows (https://www.python.org/downloads/release/python-2714/). The Windows x86-64 MSI installer is fine.
You should change the installation to install the "Add python.exe to Path" feature.
You should change the installation to install the "Add python.exe to Path" feature.

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

Expand All @@ -106,7 +111,7 @@ cargo install --path .

## 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:

Expand Down Expand Up @@ -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 fast _(partially achieved)_
- [ ] Support Emscripten calls _(on the works)_
- [ ] Support Emscripten calls _(in the works)_
- [ ] Support Rust ABI calls
- [ ] Support GO ABI calls

Expand Down
4 changes: 2 additions & 2 deletions lib/clif-backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "wasmer-clif-backend"
version = "0.1.1"
version = "0.1.2"
description = "Wasmer runtime Cranelift compiler backend"
license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
edition = "2018"

[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-codegen = "0.26.0"
cranelift-entity = "0.26.0"
Expand Down
12 changes: 4 additions & 8 deletions lib/clif-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,10 @@ impl Module {
isa: &isa::TargetIsa,
functions: Map<LocalFuncIndex, ir::Function>,
) -> CompileResult<ModuleInner> {
// we have to deduplicate `module.func_assoc`
// let func_assoc = &mut self.module.func_assoc;
// let sig_registry = &self.module.sig_registry;
// 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)?;
let imported_functions_len = self.module.imported_functions.len();
let (func_resolver_builder, handler_data) =
FuncResolverBuilder::new(isa, functions, imported_functions_len)?;

self.module.func_resolver = Box::new(func_resolver_builder.finalize()?);

let trampolines = Trampolines::new(isa, &self.module);
Expand Down
9 changes: 8 additions & 1 deletion lib/clif-backend/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use wasmer_runtime_core::{
sys::{Memory, Protect},
},
error::{CompileError, CompileResult},
structures::Map,
structures::{Map, TypedIndex},
types::LocalFuncIndex,
vm, vmcalls,
};
Expand All @@ -23,12 +23,14 @@ use wasmer_runtime_core::{
pub struct FuncResolverBuilder {
resolver: FuncResolver,
relocations: Map<LocalFuncIndex, Vec<Relocation>>,
import_len: usize,
}

impl FuncResolverBuilder {
pub fn new(
isa: &isa::TargetIsa,
function_bodies: Map<LocalFuncIndex, ir::Function>,
import_len: usize,
) -> CompileResult<(Self, HandlerData)> {
let mut compiled_functions: Vec<Vec<u8>> = Vec::with_capacity(function_bodies.len());
let mut relocations = Map::with_capacity(function_bodies.len());
Expand Down Expand Up @@ -100,6 +102,7 @@ impl FuncResolverBuilder {
Self {
resolver: FuncResolver { map, memory },
relocations,
import_len,
},
handler_data,
))
Expand All @@ -113,6 +116,10 @@ impl FuncResolverBuilder {
// This will always be an internal function
// because imported functions are not
// 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
}
RelocationType::LibCall(libcall) => match libcall {
Expand Down
4 changes: 2 additions & 2 deletions lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmer-runtime-core"
version = "0.1.1"
version = "0.1.2"
description = "Wasmer runtime core library"
license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
Expand All @@ -26,7 +26,7 @@ errno = "0.2.4"
wabt = "0.7.2"

[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"
field-offset = "0.1.1"

Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ macro_rules! __export_func_convert_type {
Type::I64
};
(u64) => {
Type::I32
Type::I64
};
(f32) => {
Type::F32
Expand Down
7 changes: 4 additions & 3 deletions lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
name = "wasmer-runtime"
version = "0.1.1"
version = "0.1.4"
description = "Wasmer runtime library"
license = "MIT"
authors = ["The Wasmer Engineering Team <[email protected]>"]
repository = "https://github.com/wasmerio/wasmer"
edition = "2018"
readme = "README.md"

[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.1" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.1", optional = true }
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.2" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.1.2", optional = true }

[features]
default = ["wasmer-clif-backend"]

0 comments on commit 5aa7d71

Please sign in to comment.