mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
commit
4e23cd4bab
@ -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: |
|
||||
@ -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:
|
||||
|
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -238,6 +238,11 @@ dependencies = [
|
||||
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.43"
|
||||
source = "git+https://github.com/rust-lang/libc#5cc006652a242c35b6fe5b615ccd39d9356a2346"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.43"
|
||||
@ -436,11 +441,6 @@ dependencies = [
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.4.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.7.0"
|
||||
@ -578,18 +578,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wabt"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wabt-sys"
|
||||
version = "0.4.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -606,18 +606,17 @@ dependencies = [
|
||||
"cranelift-wasm 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"docopt 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.43 (git+https://github.com/rust-lang/libc)",
|
||||
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wabt 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@ -679,6 +678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
|
||||
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
|
||||
"checksum libc 0.2.43 (git+https://github.com/rust-lang/libc)" = "<none>"
|
||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||
"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
|
||||
"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9"
|
||||
@ -703,7 +703,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9"
|
||||
"checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe"
|
||||
"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce"
|
||||
"checksum spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ceac490aa12c567115b40b7b7fceca03a6c9d53d5defea066123debc83c5dc1f"
|
||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||
"checksum structopt 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ca85f2c9a5a1e2d5ac686fc0be48e40f8ad803f5bbe31f692ff71eb2dd8aad45"
|
||||
"checksum structopt-derive 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "1383e5db585da799a5c4acc496c5c868e18bf82e658c00c75cc91038fa26b55f"
|
||||
@ -722,8 +721,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
|
||||
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum wabt 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0768faf932f2898c0a7545edee648fefa716906a2e143009addf4959d2335a75"
|
||||
"checksum wabt-sys 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4aaa9a8fa0d698315da5611f3e113a1e688fbb8d6fa0dd9510dfa023f665e9dc"
|
||||
"checksum wabt 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b24b2494bd6077dff717f41523f6e3e0161d58f578198589a6a6c8b314cb763"
|
||||
"checksum wabt-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "122aefe1d22c067cce1dc5d20d89d1ca47ce0eb10120246a3e2340863f9e6ddd"
|
||||
"checksum wasmparser 0.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc6511bad33610d7798f80d48e10495a6eb4f1e39306b0bb340b2de0816c4ca"
|
||||
"checksum wasmparser 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a75e0c3fe9a4d4fd91901348a5be05ba4791e29dda89e8596bfe87900ba7edc"
|
||||
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
|
||||
|
11
Cargo.toml
11
Cargo.toml
@ -2,7 +2,7 @@
|
||||
name = "wasmer"
|
||||
version = "0.1.0"
|
||||
authors = ["Syrus Akbary <me@syrusakbary.com>"]
|
||||
edition = "2018"
|
||||
# edition = "2018"
|
||||
repository = "https://github.com/wafoundation/wasmer"
|
||||
publish = true
|
||||
description = "High-Performance WebAssembly JIT interpreter"
|
||||
@ -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"
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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;
|
||||
@ -205,8 +207,7 @@ fn test_module_{}() {{
|
||||
module,
|
||||
module,
|
||||
calls.join("\n ")
|
||||
)
|
||||
.as_str(),
|
||||
).as_str(),
|
||||
);
|
||||
}
|
||||
self.module_calls.remove(&module);
|
||||
@ -215,7 +216,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(
|
||||
@ -231,8 +233,7 @@ fn test_module_{}() {{
|
||||
.replace("\n", "\n ")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\""),
|
||||
)
|
||||
.as_str(),
|
||||
).as_str(),
|
||||
);
|
||||
|
||||
// We set the start call to the module
|
||||
@ -243,8 +244,7 @@ fn test_module_{}() {{
|
||||
result_object.instance.start();
|
||||
}}\n",
|
||||
start_module_call
|
||||
)
|
||||
.as_str(),
|
||||
).as_str(),
|
||||
);
|
||||
self.module_calls
|
||||
.entry(self.last_module)
|
||||
@ -255,6 +255,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]
|
||||
@ -263,13 +264,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(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -311,8 +311,7 @@ fn {}_assert_invalid() {{
|
||||
func_return,
|
||||
args_values.join(", "),
|
||||
assertion,
|
||||
)
|
||||
.as_str(),
|
||||
).as_str(),
|
||||
);
|
||||
self.module_calls
|
||||
.entry(self.last_module)
|
||||
@ -369,8 +368,7 @@ fn {}_assert_invalid() {{
|
||||
func_return,
|
||||
args_values.join(", "),
|
||||
assertion,
|
||||
)
|
||||
.as_str(),
|
||||
).as_str(),
|
||||
);
|
||||
self.module_calls
|
||||
.entry(self.last_module)
|
||||
@ -385,6 +383,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!(
|
||||
@ -394,13 +393,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(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -464,8 +462,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();
|
||||
@ -486,7 +483,7 @@ fn {}_assert_malformed() {{
|
||||
.or_insert(Vec::new())
|
||||
.push(action_fn_name.unwrap());
|
||||
}
|
||||
|
||||
|
||||
fn visit_perform_action(&mut self, action: &Action) {
|
||||
let action_fn_name = self.visit_action(action, None);
|
||||
|
||||
@ -520,8 +517,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
|
||||
|
@ -1,9 +1,7 @@
|
||||
|
||||
use crate::webassembly::Instance;
|
||||
use std::process;
|
||||
|
||||
|
||||
pub extern "C" fn abort(_code: i32, _instance: &Instance) {
|
||||
process::abort();
|
||||
// abort!("Aborted")
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
use crate::webassembly::ImportObject;
|
||||
|
||||
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();
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
pub mod emscripten;
|
||||
|
||||
pub use self::emscripten::generate_emscripten_env;
|
||||
|
21
src/main.rs
21
src/main.rs
@ -1,18 +1,18 @@
|
||||
#![feature(test, libc, core_intrinsics)]
|
||||
|
||||
extern crate test;
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate libc;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
extern crate nix;
|
||||
extern crate spin;
|
||||
|
||||
// use std::alloc::System;
|
||||
// use std::time::{Duration, Instant};
|
||||
@ -23,7 +23,6 @@ extern crate spin;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
// use libc;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
@ -69,10 +68,16 @@ fn read_file_contents(path: &PathBuf) -> Result<Vec<u8>, io::Error> {
|
||||
|
||||
/// Execute a WASM/WAT file
|
||||
fn execute_wasm(wasm_path: PathBuf) -> Result<(), String> {
|
||||
let mut wasm_binary: Vec<u8> =
|
||||
read_file_contents(&wasm_path).map_err(|err| format!("Can't read the file {}: {}", wasm_path.as_os_str().to_string_lossy(), err))?;
|
||||
let mut wasm_binary: Vec<u8> = read_file_contents(&wasm_path).map_err(|err| {
|
||||
format!(
|
||||
"Can't read the file {}: {}",
|
||||
wasm_path.as_os_str().to_string_lossy(),
|
||||
err
|
||||
)
|
||||
})?;
|
||||
if !webassembly::utils::is_wasm_binary(&wasm_binary) {
|
||||
wasm_binary = wabt::wat2wasm(wasm_binary).map_err(|err| format!("Can't convert from wast to wasm: {:?}", err))?;
|
||||
wasm_binary = wabt::wat2wasm(wasm_binary)
|
||||
.map_err(|err| format!("Can't convert from wast to wasm: {:?}", err))?;
|
||||
}
|
||||
|
||||
let import_object = linkers::generate_emscripten_env();
|
||||
|
@ -5,7 +5,7 @@
|
||||
//! Please read more about this here: https://github.com/CraneStation/wasmtime/issues/15
|
||||
//! This code is inspired by: https://github.com/pepyakin/wasmtime/commit/625a2b6c0815b21996e111da51b9664feb174622
|
||||
use nix::sys::signal::{
|
||||
sigaction, Signal, SaFlags, SigAction, SigHandler, SigSet, SIGBUS, SIGFPE, SIGILL, SIGSEGV,
|
||||
sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV,
|
||||
};
|
||||
|
||||
static mut SETJMP_BUFFER: [::nix::libc::c_int; 27] = [0; 27];
|
||||
|
@ -146,7 +146,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"16u_bad\" (func 27))
|
||||
(export \"16s_bad\" (func 28))
|
||||
(export \"32_bad\" (func 29))
|
||||
(data (i32.const 0) \"abcdefghijklmnopqrstuvwxyz\"))
|
||||
(data (;0;) (i32.const 0) \"abcdefghijklmnopqrstuvwxyz\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -1545,7 +1545,7 @@ fn create_module_2() -> ResultObject {
|
||||
(export \"32u_bad\" (func 39))
|
||||
(export \"32s_bad\" (func 40))
|
||||
(export \"64_bad\" (func 41))
|
||||
(data (i32.const 0) \"abcdefghijklmnopqrstuvwxyz\"))
|
||||
(data (;0;) (i32.const 0) \"abcdefghijklmnopqrstuvwxyz\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -3260,7 +3260,7 @@ fn create_module_3() -> ResultObject {
|
||||
(export \"32_good4\" (func 3))
|
||||
(export \"32_good5\" (func 4))
|
||||
(export \"32_bad\" (func 5))
|
||||
(data (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\a0\\7f\\01\\00\\d0\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\a0\\7f\\01\\00\\d0\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -3554,7 +3554,7 @@ fn create_module_4() -> ResultObject {
|
||||
(export \"64_good4\" (func 3))
|
||||
(export \"64_good5\" (func 4))
|
||||
(export \"64_bad\" (func 5))
|
||||
(data (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\f4\\7f\\01\\00\\00\\00\\00\\00\\fc\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\f4\\7f\\01\\00\\00\\00\\00\\00\\fc\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -519,7 +519,7 @@ fn test_module_14() {
|
||||
fn create_module_15() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 0)
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -540,7 +540,7 @@ fn test_module_15() {
|
||||
fn create_module_16() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(table (;0;) 0 anyfunc)
|
||||
(elem (i32.const 0)))
|
||||
(elem (;0;) (i32.const 0)))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -530,7 +530,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"break-repeated\" (func 41))
|
||||
(export \"break-inner\" (func 42))
|
||||
(export \"effects\" (func 43))
|
||||
(elem (i32.const 0) 19))
|
||||
(elem (;0;) (i32.const 0) 19))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -562,7 +562,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"nested-br_if-value-cond\" (func 58))
|
||||
(export \"nested-br_table-value\" (func 59))
|
||||
(export \"nested-br_table-value-index\" (func 60))
|
||||
(elem (i32.const 0) 30))
|
||||
(elem (;0;) (i32.const 0) 30))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -574,7 +574,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"nested-br_if-value-cond\" (func 51))
|
||||
(export \"nested-br_table-value\" (func 52))
|
||||
(export \"nested-br_table-value-index\" (func 53))
|
||||
(elem (i32.const 0) 36))
|
||||
(elem (;0;) (i32.const 0) 36))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -781,7 +781,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"nested-br_table-value\" (func 66))
|
||||
(export \"nested-br_table-value-index\" (func 67))
|
||||
(export \"nested-br_table-loop-block\" (func 68))
|
||||
(elem (i32.const 0) 37))
|
||||
(elem (;0;) (i32.const 0) 37))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -316,7 +316,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"as-tee_local-value\" (func 51))
|
||||
(export \"as-set_global-value\" (func 52))
|
||||
(export \"as-load-operand\" (func 53))
|
||||
(elem (i32.const 0) 40))
|
||||
(elem (;0;) (i32.const 0) 40))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -512,7 +512,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"as-tee_local-value\" (func 63))
|
||||
(export \"as-set_global-value\" (func 64))
|
||||
(export \"as-load-operand\" (func 65))
|
||||
(elem (i32.const 0) 0 1 2 3 4 5 6 7 10 8 11 9 35 36 43 44 45 46 47 12 13 14 15 37 38 39 40 41 42))
|
||||
(elem (;0;) (i32.const 0) 0 1 2 3 4 5 6 7 10 8 11 9 35 36 43 44 45 46 47 12 13 14 15 37 38 39 40 41 42))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -19,18 +19,18 @@ use super::_common::{
|
||||
fn create_module_1() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 1)
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 1) \"abcd\")
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 0) \"abc\")
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 1) \"abcd\")
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 0) \"abc\")
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 1) \"abcd\")
|
||||
(data (i32.const 0) \"\")
|
||||
(data (i32.const 0) \"abc\"))
|
||||
(data (;0;) (i32.const 0) \"\")
|
||||
(data (;1;) (i32.const 1) \"abcd\")
|
||||
(data (;2;) (i32.const 0) \"\")
|
||||
(data (;3;) (i32.const 0) \"abc\")
|
||||
(data (;4;) (i32.const 0) \"\")
|
||||
(data (;5;) (i32.const 1) \"abcd\")
|
||||
(data (;6;) (i32.const 0) \"\")
|
||||
(data (;7;) (i32.const 0) \"abc\")
|
||||
(data (;8;) (i32.const 0) \"\")
|
||||
(data (;9;) (i32.const 1) \"abcd\")
|
||||
(data (;10;) (i32.const 0) \"\")
|
||||
(data (;11;) (i32.const 0) \"abc\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -51,7 +51,7 @@ fn test_module_1() {
|
||||
fn create_module_2() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 1)
|
||||
(data (i32.const 0) \"a\"))
|
||||
(data (;0;) (i32.const 0) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -72,7 +72,7 @@ fn test_module_2() {
|
||||
fn create_module_3() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 1))
|
||||
(data (i32.const 0) \"a\"))
|
||||
(data (;0;) (i32.const 0) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -93,11 +93,11 @@ fn test_module_3() {
|
||||
fn create_module_4() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 1)
|
||||
(data (i32.const 0) \"a\")
|
||||
(data (i32.const 3) \"b\")
|
||||
(data (i32.const 100) \"cde\")
|
||||
(data (i32.const 5) \"x\")
|
||||
(data (i32.const 3) \"c\"))
|
||||
(data (;0;) (i32.const 0) \"a\")
|
||||
(data (;1;) (i32.const 3) \"b\")
|
||||
(data (;2;) (i32.const 100) \"cde\")
|
||||
(data (;3;) (i32.const 5) \"x\")
|
||||
(data (;4;) (i32.const 3) \"c\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -118,12 +118,12 @@ fn test_module_4() {
|
||||
fn create_module_5() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 1))
|
||||
(data (i32.const 0) \"a\")
|
||||
(data (i32.const 1) \"b\")
|
||||
(data (i32.const 2) \"cde\")
|
||||
(data (i32.const 3) \"f\")
|
||||
(data (i32.const 2) \"g\")
|
||||
(data (i32.const 1) \"h\"))
|
||||
(data (;0;) (i32.const 0) \"a\")
|
||||
(data (;1;) (i32.const 1) \"b\")
|
||||
(data (;2;) (i32.const 2) \"cde\")
|
||||
(data (;3;) (i32.const 3) \"f\")
|
||||
(data (;4;) (i32.const 2) \"g\")
|
||||
(data (;5;) (i32.const 1) \"h\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -144,8 +144,8 @@ fn test_module_5() {
|
||||
fn create_module_6() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 1)
|
||||
(data (i32.const 0) \"a\")
|
||||
(data (i32.const 65535) \"b\"))
|
||||
(data (;0;) (i32.const 0) \"a\")
|
||||
(data (;1;) (i32.const 65535) \"b\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -166,8 +166,8 @@ fn test_module_6() {
|
||||
fn create_module_7() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 1))
|
||||
(data (i32.const 0) \"a\")
|
||||
(data (i32.const 65535) \"b\"))
|
||||
(data (;0;) (i32.const 0) \"a\")
|
||||
(data (;1;) (i32.const 65535) \"b\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -188,7 +188,7 @@ fn test_module_7() {
|
||||
fn create_module_8() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 2)
|
||||
(data (i32.const 131071) \"a\"))
|
||||
(data (;0;) (i32.const 131071) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -209,7 +209,7 @@ fn test_module_8() {
|
||||
fn create_module_9() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 0)
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -230,7 +230,7 @@ fn test_module_9() {
|
||||
fn create_module_10() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0))
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -251,7 +251,7 @@ fn test_module_10() {
|
||||
fn create_module_11() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 0 0)
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -272,7 +272,7 @@ fn test_module_11() {
|
||||
fn create_module_12() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 1)
|
||||
(data (i32.const 65536) \"\"))
|
||||
(data (;0;) (i32.const 65536) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -293,7 +293,7 @@ fn test_module_12() {
|
||||
fn create_module_13() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 0)
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -314,7 +314,7 @@ fn test_module_13() {
|
||||
fn create_module_14() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0))
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -335,7 +335,7 @@ fn test_module_14() {
|
||||
fn create_module_15() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(memory (;0;) 0 0)
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -356,7 +356,7 @@ fn test_module_15() {
|
||||
fn create_module_16() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0))
|
||||
(data (i32.const 0) \"a\"))
|
||||
(data (;0;) (i32.const 0) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -377,7 +377,7 @@ fn test_module_16() {
|
||||
fn create_module_17() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0 3))
|
||||
(data (i32.const 0) \"a\"))
|
||||
(data (;0;) (i32.const 0) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -398,7 +398,7 @@ fn test_module_17() {
|
||||
fn create_module_18() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0))
|
||||
(data (i32.const 1) \"a\"))
|
||||
(data (;0;) (i32.const 1) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -419,7 +419,7 @@ fn test_module_18() {
|
||||
fn create_module_19() -> ResultObject {
|
||||
let module_str = "(module
|
||||
(import \"spectest\" \"memory\" (memory (;0;) 0 3))
|
||||
(data (i32.const 1) \"a\"))
|
||||
(data (;0;) (i32.const 1) \"a\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
File diff suppressed because one or more lines are too long
@ -45,7 +45,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"f32.store\" (func 2))
|
||||
(export \"i32.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\00\\00\\a0\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\a0\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -277,7 +277,7 @@ fn create_module_2() -> ResultObject {
|
||||
(export \"f64.store\" (func 2))
|
||||
(export \"i64.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\f4\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\f4\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -509,7 +509,7 @@ fn create_module_3() -> ResultObject {
|
||||
(export \"f32.store\" (func 2))
|
||||
(export \"i32.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\00\\00\\00\\a0\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\00\\a0\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -741,7 +741,7 @@ fn create_module_4() -> ResultObject {
|
||||
(export \"f64.store\" (func 2))
|
||||
(export \"i64.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\00\\f4\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\00\\00\\00\\00\\00\\00\\00\\f4\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -973,7 +973,7 @@ fn create_module_5() -> ResultObject {
|
||||
(export \"f32.store\" (func 2))
|
||||
(export \"i32.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\01\\00\\d0\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\01\\00\\d0\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -1205,7 +1205,7 @@ fn create_module_6() -> ResultObject {
|
||||
(export \"f64.store\" (func 2))
|
||||
(export \"i64.store\" (func 3))
|
||||
(export \"reset\" (func 4))
|
||||
(data (i32.const 0) \"\\01\\00\\00\\00\\00\\00\\fc\\7f\"))
|
||||
(data (;0;) (i32.const 0) \"\\01\\00\\00\\00\\00\\00\\fc\\7f\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -1359,7 +1359,7 @@ fn create_module_3() -> ResultObject {
|
||||
(export \"signature-implicit-reused\" (func 8))
|
||||
(export \"signature-explicit-duplicate\" (func 9))
|
||||
(export \"signature-implicit-duplicate\" (func 10))
|
||||
(elem (i32.const 0) 4 2 1 4 0 5 6))
|
||||
(elem (;0;) (i32.const 0) 4 2 1 4 0 5 6))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -194,7 +194,7 @@ fn create_module_2() -> ResultObject {
|
||||
(table (;0;) 7 7 anyfunc)
|
||||
(export \"callt\" (func 5))
|
||||
(export \"callu\" (func 6))
|
||||
(elem (i32.const 0) 0 1 2 3 4 0 2))
|
||||
(elem (;0;) (i32.const 0) 0 1 2 3 4 0 2))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -533,7 +533,7 @@ fn create_module_3() -> ResultObject {
|
||||
call_indirect (type 0))
|
||||
(table (;0;) 2 2 anyfunc)
|
||||
(export \"callt\" (func 2))
|
||||
(elem (i32.const 0) 0 1))
|
||||
(elem (;0;) (i32.const 0) 0 1))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -269,7 +269,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"as-unary-operand\" (func 42))
|
||||
(export \"as-binary-operand\" (func 43))
|
||||
(export \"as-compare-operand\" (func 44))
|
||||
(elem (i32.const 0) 26))
|
||||
(elem (;0;) (i32.const 0) 26))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -635,7 +635,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"break-bare\" (func 36))
|
||||
(export \"break-value\" (func 37))
|
||||
(export \"effects\" (func 38))
|
||||
(elem (i32.const 0) 16))
|
||||
(elem (;0;) (i32.const 0) 16))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -959,7 +959,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"f64_select\" (func 127))
|
||||
(export \"br_if\" (func 128))
|
||||
(export \"br_table\" (func 129))
|
||||
(elem (i32.const 0) 0 1 2 3 4 5 6 7))
|
||||
(elem (;0;) (i32.const 0) 0 1 2 3 4 5 6 7))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -667,7 +667,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"while\" (func 42))
|
||||
(export \"for\" (func 43))
|
||||
(export \"nesting\" (func 44))
|
||||
(elem (i32.const 0) 16))
|
||||
(elem (;0;) (i32.const 0) 16))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -119,7 +119,7 @@ fn create_module_5() -> ResultObject {
|
||||
memory.size)
|
||||
(memory (;0;) 0 0)
|
||||
(export \"memsize\" (func 0))
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -157,7 +157,7 @@ fn create_module_6() -> ResultObject {
|
||||
memory.size)
|
||||
(memory (;0;) 0 0)
|
||||
(export \"memsize\" (func 0))
|
||||
(data (i32.const 0) \"\"))
|
||||
(data (;0;) (i32.const 0) \"\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -195,7 +195,7 @@ fn create_module_7() -> ResultObject {
|
||||
memory.size)
|
||||
(memory (;0;) 1 1)
|
||||
(export \"memsize\" (func 0))
|
||||
(data (i32.const 0) \"x\"))
|
||||
(data (;0;) (i32.const 0) \"x\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -632,7 +632,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"as-store-mid\" (func 80))
|
||||
(export \"as-store-last\" (func 81))
|
||||
(export \"as-store-everywhere\" (func 82))
|
||||
(elem (i32.const 0) 61))
|
||||
(elem (;0;) (i32.const 0) 61))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -412,7 +412,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"as-compare-right\" (func 56))
|
||||
(export \"as-convert-operand\" (func 57))
|
||||
(export \"as-memory.grow-size\" (func 58))
|
||||
(elem (i32.const 0) 36))
|
||||
(elem (;0;) (i32.const 0) 36))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -63,7 +63,7 @@ fn create_module_1() -> ResultObject {
|
||||
(export \"inc\" (func 0))
|
||||
(export \"get\" (func 1))
|
||||
(start 2)
|
||||
(data (i32.const 0) \"A\"))
|
||||
(data (;0;) (i32.const 0) \"A\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
@ -169,7 +169,7 @@ fn create_module_2() -> ResultObject {
|
||||
(export \"inc\" (func 0))
|
||||
(export \"get\" (func 1))
|
||||
(start 2)
|
||||
(data (i32.const 0) \"A\"))
|
||||
(data (;0;) (i32.const 0) \"A\"))
|
||||
";
|
||||
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
|
||||
instantiate(wasm_binary, spectest_importobject()).expect("WASM can't be instantiated")
|
||||
|
@ -52,7 +52,7 @@ fn get_function_addr(
|
||||
let func_pointer = if index < len {
|
||||
import_functions[index]
|
||||
} else {
|
||||
(&functions[func_index.index() - len]).as_ptr()
|
||||
(functions[index - len]).as_ptr()
|
||||
};
|
||||
func_pointer
|
||||
}
|
||||
@ -131,7 +131,7 @@ pub struct InstanceOptions {
|
||||
pub mock_missing_imports: bool,
|
||||
}
|
||||
|
||||
extern fn mock_fn() -> i32 {
|
||||
extern "C" fn mock_fn() -> i32 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -167,15 +167,16 @@ impl Instance {
|
||||
// We walk through the imported functions and set the relocations
|
||||
// for each of this functions to be an empty vector (as is defined outside of wasm)
|
||||
for (module, field) in module.info.imported_funcs.iter() {
|
||||
let function = import_object
|
||||
.get(&module.as_str(), &field.as_str());
|
||||
let function = import_object.get(&module.as_str(), &field.as_str());
|
||||
let function = if options.mock_missing_imports {
|
||||
function.unwrap_or_else(|| {
|
||||
debug!("The import {}.{} is not provided, therefore will be mocked.", module, field);
|
||||
debug!(
|
||||
"The import {}.{} is not provided, therefore will be mocked.",
|
||||
module, field
|
||||
);
|
||||
mock_fn as *const u8
|
||||
})
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
function.ok_or_else(|| {
|
||||
ErrorKind::LinkError(format!(
|
||||
"Imported function {}.{} was not provided in the import_functions",
|
||||
@ -432,7 +433,7 @@ impl Instance {
|
||||
.info
|
||||
.start_func
|
||||
.or_else(|| match module.info.exports.get("main") {
|
||||
Some(Export::Function(index)) => Some(index.to_owned()),
|
||||
Some(Export::Function(index)) => Some(*index),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
@ -627,40 +628,56 @@ extern "C" fn current_memory(memory_index: u32, instance: &mut Instance) -> u32
|
||||
// Because of this bug https://github.com/rust-lang/rust/issues/34123
|
||||
// We create internal functions for it
|
||||
|
||||
use std::intrinsics::{
|
||||
ceilf32, ceilf64, floorf32, floorf64, nearbyintf32, nearbyintf64, truncf32, truncf64,
|
||||
};
|
||||
// use std::intrinsics::{
|
||||
// ceilf32, ceilf64, floorf32, floorf64, nearbyintf32, nearbyintf64, truncf32, truncf64,
|
||||
// };
|
||||
|
||||
// F32
|
||||
unsafe extern "C" fn _ceilf32(x: f32) -> f32 {
|
||||
ceilf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _ceilf32(x: f32) -> f32 {
|
||||
// ceilf32(x)
|
||||
x.ceil()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _floorf32(x: f32) -> f32 {
|
||||
floorf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _floorf32(x: f32) -> f32 {
|
||||
// floorf32(x)
|
||||
x.floor()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _truncf32(x: f32) -> f32 {
|
||||
truncf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _truncf32(x: f32) -> f32 {
|
||||
// truncf32(x)
|
||||
x.trunc()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _nearbyintf32(x: f32) -> f32 {
|
||||
nearbyintf32(x)
|
||||
#[inline]
|
||||
extern "C" fn _nearbyintf32(x: f32) -> f32 {
|
||||
// nearbyintf32(x)
|
||||
x.round()
|
||||
}
|
||||
|
||||
// F64
|
||||
unsafe extern "C" fn _ceilf64(x: f64) -> f64 {
|
||||
ceilf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _ceilf64(x: f64) -> f64 {
|
||||
// ceilf64(x)
|
||||
x.ceil()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _floorf64(x: f64) -> f64 {
|
||||
floorf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _floorf64(x: f64) -> f64 {
|
||||
// floorf64(x)
|
||||
x.floor()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _truncf64(x: f64) -> f64 {
|
||||
truncf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _truncf64(x: f64) -> f64 {
|
||||
// truncf64(x)
|
||||
x.trunc()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn _nearbyintf64(x: f64) -> f64 {
|
||||
nearbyintf64(x)
|
||||
#[inline]
|
||||
extern "C" fn _nearbyintf64(x: f64) -> f64 {
|
||||
// nearbyintf64(x)
|
||||
x.round()
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl LinearMemory {
|
||||
// Copy old mem to new mem. Will a while loop be faster or is this going to be optimized?
|
||||
// TODO: Consider static heap for efficiency.
|
||||
for i in 0..prev_bytes {
|
||||
unsafe {
|
||||
unsafe {
|
||||
let new_mmap_index = new_mmap.get_unchecked_mut(i);
|
||||
let old_mmap_index = self.mmap.get_unchecked(i);
|
||||
*new_mmap_index = *old_mmap_index;
|
||||
|
@ -47,7 +47,13 @@ pub fn instantiate(
|
||||
) -> Result<ResultObject, ErrorKind> {
|
||||
let module = compile(buffer_source)?;
|
||||
debug!("webassembly - creating instance");
|
||||
let instance = Instance::new(&module, &import_object, InstanceOptions { mock_missing_imports: true })?;
|
||||
let instance = Instance::new(
|
||||
&module,
|
||||
&import_object,
|
||||
InstanceOptions {
|
||||
mock_missing_imports: true,
|
||||
},
|
||||
)?;
|
||||
debug!("webassembly - instance created");
|
||||
Ok(ResultObject { module, instance })
|
||||
}
|
||||
@ -100,7 +106,12 @@ pub fn validate_or_error(bytes: &[u8]) -> Result<(), ErrorKind> {
|
||||
let state = parser.read();
|
||||
match *state {
|
||||
wasmparser::ParserState::EndWasm => return Ok(()),
|
||||
wasmparser::ParserState::Error(err) => return Err(ErrorKind::CompileError(format!("Validation error: {}", err.message))),
|
||||
wasmparser::ParserState::Error(err) => {
|
||||
return Err(ErrorKind::CompileError(format!(
|
||||
"Validation error: {}",
|
||||
err.message
|
||||
)))
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -427,9 +427,7 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
|
||||
base: heap_base,
|
||||
min_size: Imm64::new(0),
|
||||
guard_size: Imm64::new(LinearMemory::DEFAULT_GUARD_SIZE as i64),
|
||||
style: ir::HeapStyle::Dynamic {
|
||||
bound_gv,
|
||||
},
|
||||
style: ir::HeapStyle::Dynamic { bound_gv },
|
||||
index_type: I32,
|
||||
})
|
||||
|
||||
@ -535,7 +533,6 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
|
||||
.special_param(ir::ArgumentPurpose::VMContext)
|
||||
.expect("Missing vmctx parameter");
|
||||
|
||||
|
||||
// The `callee` value is an index into a table of function pointers.
|
||||
// Apparently, that table is stored at absolute address 0 in this dummy environment.
|
||||
// TODO: Generate bounds checking code.
|
||||
|
Loading…
Reference in New Issue
Block a user