Skip to content

Commit

Permalink
Merge branch 'master' into fix/table-import-memory-repr-rebased
Browse files Browse the repository at this point in the history
# Conflicts:
#	.circleci/config.yml
#	install.sh
#	src/build_spectests.rs
#	src/linkers/emscripten/abort.rs
#	src/linkers/emscripten/mod.rs
#	src/linkers/mod.rs
#	src/main.rs
#	src/webassembly/instance.rs
#	src/webassembly/memory.rs
#	src/webassembly/mod.rs
#	src/webassembly/module.rs
  • Loading branch information
syrusakbary committed Nov 17, 2018
2 parents 84b9847 + 5c0e404 commit 7977d09
Show file tree
Hide file tree
Showing 38 changed files with 257 additions and 226 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
keys:
- v4-cargo-cache-linux-{{ arch }}-{{ checksum "Cargo.lock" }}
- run: sudo apt-get install -y cmake
- run: rustup default nightly-2018-10-07
- run: make test
- run:
command: |
Expand Down Expand Up @@ -50,9 +49,9 @@ jobs:
tar xf cmake-3.4.1-Darwin-x86_64.tar.gz
export PATH="`pwd`/cmake-3.4.1-Darwin-x86_64/CMake.app/Contents/bin:$PATH"
- run:
name: Install Rust Nightly
name: Install Rust
command: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2018-10-07
curl https://sh.rustup.rs -sSf | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"
cargo --version
- run:
Expand Down
27 changes: 13 additions & 14 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "wasmer"
version = "0.1.0"
authors = ["Syrus Akbary <[email protected]>"]
edition = "2018"
# edition = "2018"
repository = "https://github.com/wafoundation/wasmer"
publish = true
description = "High-Performance WebAssembly JIT interpreter"
Expand Down Expand Up @@ -34,18 +34,19 @@ serde_derive = "1.0.55"
tempdir = "0.3.7"
error-chain = "0.12.0"
structopt = "0.2.11"
wabt = "0.6.0"
wabt = "0.7.1"
wasmparser = "0.20.0"
region = "0.3.0"
memmap = "0.6.2"
spin = "0.4.10"
# spin = "0.4.10"
log = "0.4.5"
target-lexicon = { version = "0.0.3", default-features = false }
libc = "0.2"
# libc = "0.2"
libc = { git = "https://github.com/rust-lang/libc" }
nix = "0.11"

[build-dependencies]
wabt = "0.6.0"
wabt = "0.7.1"

# [dev-dependencies]
# libffi = "0.6.4"
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ To build this project you will need Rust and Cargo.
git clone https://github.com/wafoundation/wasmer.git
cd wasmer

# Use rust nightly (we use 2018-10-07 as latest are failing)
rustup default nightly-2018-10-07

# install tools
# make sure that `python` is accessible.
cargo install
Expand All @@ -44,7 +41,7 @@ Thanks to [spectests](https://github.com/WAFoundation/wasmer/tree/master/spectes
Tests can be run with:

```sh
cargo test
make test
```

If you need to re-generate the Rust tests from the spectests
Expand Down
Binary file added examples/pypyjs.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/trap.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(module
(func $main (export "main") (result i32)
(i32.div_s (i32.const 0) (i32.const 0))
)
)
16 changes: 8 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,22 @@ wasmer_install() {

printf "${reset}Installing Wasmer!$reset\n"
printf "
${magenta3}###${reset}
${magenta3}#####${reset}
${magenta2}### ${magenta3}######${reset}
${magenta2}###### ${magenta3}#############${reset}
${magenta1}#${magenta2} ####### ${magenta3}##############${reset}
${magenta1}#####${magenta2} #############${magenta3}#########${reset}
${magenta1} ${magenta2} ${magenta3}###${reset}
${magenta1} ${magenta2} ${magenta3}#####${reset}
${magenta1} ${magenta2}### ${magenta3}######${reset}
${magenta1} ${magenta2}###### ${magenta3}#############${reset}
${magenta1}# ${magenta2}####### ${magenta3}##############${reset}
${magenta1}##### ${magenta2}#############${magenta3}#########${reset}
${magenta1}######${magenta2}###############${magenta3}#######${reset}
${magenta1}############${magenta2}#########${magenta3}#######${reset}
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
${magenta1}##############${magenta2}####### ${magenta3}###${reset}
${magenta1}##############${magenta2}#######${magenta3} ###${reset}
${magenta1}##############${magenta2}#######
${magenta1}###########${magenta2} ###
${magenta1}########${magenta2}
${magenta1}####${reset}
${magenta1}####${reset}
"
# if [ -d "$HOME/.wasmer" ]; then
Expand Down
38 changes: 17 additions & 21 deletions src/build_spectests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! This file will run at build time to autogenerate Rust tests based on
//! WebAssembly spec tests. It will convert the files indicated in TESTS
//! from "/spectests/{MODULE}.wast" to "/src/spectests/{MODULE}.rs".
extern crate wabt;

use std::collections::HashMap;
use std::env;
use std::fs;
Expand Down Expand Up @@ -206,8 +208,7 @@ fn test_module_{}() {{
module,
module,
calls.join("\n ")
)
.as_str(),
).as_str(),
);
}
self.module_calls.remove(&module);
Expand All @@ -216,7 +217,8 @@ fn test_module_{}() {{
fn visit_module(&mut self, module: &ModuleBinary, _name: &Option<String>) {
let wasm_binary: Vec<u8> = module.clone().into_vec();
let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
self.flush_module_calls(self.last_module);
let last_module = self.last_module;
self.flush_module_calls(last_module);
self.last_module = self.last_module + 1;
// self.module_calls.insert(self.last_module, vec![]);
self.buffer.push_str(
Expand All @@ -232,8 +234,7 @@ fn test_module_{}() {{
.replace("\n", "\n ")
.replace("\\", "\\\\")
.replace("\"", "\\\""),
)
.as_str(),
).as_str(),
);

// We set the start call to the module
Expand All @@ -244,8 +245,7 @@ fn test_module_{}() {{
result_object.instance.start();
}}\n",
start_module_call
)
.as_str(),
).as_str(),
);
self.module_calls
.entry(self.last_module)
Expand All @@ -256,6 +256,7 @@ fn test_module_{}() {{
fn visit_assert_invalid(&mut self, module: &ModuleBinary) {
let wasm_binary: Vec<u8> = module.clone().into_vec();
// let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
let command_name = self.command_name();
self.buffer.push_str(
format!(
"#[test]
Expand All @@ -264,13 +265,12 @@ fn {}_assert_invalid() {{
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), \"WASM should not compile as is invalid\");
}}\n",
self.command_name(),
command_name,
wasm_binary,
// We do this to ident four spaces back
// String::from_utf8_lossy(&wasm_binary),
// wast_string.replace("\n", "\n "),
)
.as_str(),
).as_str(),
);
}

Expand Down Expand Up @@ -312,8 +312,7 @@ fn {}_assert_invalid() {{
func_return,
args_values.join(", "),
assertion,
)
.as_str(),
).as_str(),
);
self.module_calls
.entry(self.last_module)
Expand Down Expand Up @@ -370,8 +369,7 @@ fn {}_assert_invalid() {{
func_return,
args_values.join(", "),
assertion,
)
.as_str(),
).as_str(),
);
self.module_calls
.entry(self.last_module)
Expand All @@ -386,6 +384,7 @@ fn {}_assert_invalid() {{

fn visit_assert_malformed(&mut self, module: &ModuleBinary) {
let wasm_binary: Vec<u8> = module.clone().into_vec();
let command_name = self.command_name();
// let wast_string = wasm2wat(wasm_binary).expect("Can't convert back to wasm");
self.buffer.push_str(
format!(
Expand All @@ -395,13 +394,12 @@ fn {}_assert_malformed() {{
let compilation = compile(wasm_binary.to_vec());
assert!(compilation.is_err(), \"WASM should not compile as is malformed\");
}}\n",
self.command_name(),
command_name,
wasm_binary,
// We do this to ident four spaces back
// String::from_utf8_lossy(&wasm_binary),
// wast_string.replace("\n", "\n "),
)
.as_str(),
).as_str(),
);
}

Expand Down Expand Up @@ -465,8 +463,7 @@ fn {}_assert_malformed() {{
func_return,
args_values.join(", "),
assertion,
)
.as_str(),
).as_str(),
);
Some(func_name)
// let mut module_calls = self.module_calls.get(&self.last_module).unwrap();
Expand Down Expand Up @@ -521,8 +518,7 @@ fn {}() {{
trap_func_name,
self.last_module,
action_fn_name.unwrap(),
)
.as_str(),
).as_str(),
);

// We don't group trap calls as they may cause memory faults
Expand Down
4 changes: 1 addition & 3 deletions src/linkers/emscripten/abort.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

use crate::webassembly::Instance;
use std::process;


pub extern "C" fn abort(_code: i32, _instance: &Instance) {
process::abort();
// abort!("Aborted")
}
}
2 changes: 1 addition & 1 deletion src/linkers/emscripten/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::webassembly::{ImportObject, ImportValue};

mod abort;
mod printf;
mod putchar;
mod abort;

pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
let mut import_object = ImportObject::new();
Expand Down
1 change: 0 additions & 1 deletion src/linkers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub mod emscripten;

pub use self::emscripten::generate_emscripten_env;
Loading

0 comments on commit 7977d09

Please sign in to comment.