Bug 1926357: Update wasm spec tests to wasm-3.0. r=rhunt,supply-chain-reviewers

Many proposals have been merged into the wasm-3.0 branch of the
WebAssembly spec repo. It currently represents the state of the art of
wasm, which we keep up with - proposals that are officially standardized
but not yet super widely implemented.

Basing our spec tests on this reduces duplication across proposal repos
and should help us catch spec problems earlier.

This patch reworks the spec test generator slightly to handle some new
module definition syntax, and removes proposals which have already been
merged into wasm-3.0.

Differential Revision: https://phabricator.services.mozilla.com/D227573
This commit is contained in:
Ben Visness
2024-11-11 15:38:43 +00:00
parent fd6b390c9b
commit 9756124bfc
315 changed files with 70280 additions and 21699 deletions

25
Cargo.lock generated
View File

@@ -6844,18 +6844,19 @@ version = "0.2.100"
[[package]]
name = "wasm-encoder"
version = "0.214.0"
version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff694f02a8d7a50b6922b197ae03883fbf18cdb2ae9fbee7b6148456f5f44041"
checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54"
dependencies = [
"leb128",
"wasmparser",
]
[[package]]
name = "wasm-smith"
version = "0.214.0"
version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5856b6e06e8d37dad11167111e49339a5b017ab1399f7cb708fcb4c4550d0"
checksum = "3b526e4c6eed409b619960258ba5bd8a3b44dfb30c75c12fce80b750a4487fcc"
dependencies = [
"anyhow",
"arbitrary",
@@ -6866,10 +6867,20 @@ dependencies = [
]
[[package]]
name = "wast"
version = "214.0.0"
name = "wasmparser"
version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "694bcdb24c49c8709bd8713768b71301a11e823923eee355d530f1d8d0a7f8e9"
checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5"
dependencies = [
"bitflags 2.6.0",
"indexmap 2.2.6",
]
[[package]]
name = "wast"
version = "219.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1"
dependencies = [
"bumpalo",
"leb128",

View File

@@ -6,6 +6,6 @@ authors = ["Christian Holler"]
license = "MPL-2.0"
[dependencies]
wasm-smith = "0.214.0"
wasm-smith = "0.219.1"
arbitrary = { version = "1.0.0", features = ["derive"] }
libc = "0.2"

View File

@@ -4,7 +4,7 @@ warning = '\# Wasm Spec Tests\n\nThese tests are autogenerated using a tool, do
update:
(cd ./generate-spectests && RUST_BACKTRACE=1 RUST_LOG=info cargo run --release)
rm -r ../../tests/wasm/spec
rm -r ../../tests/wasm/spec || echo "No tests to delete."
cp -R generate-spectests/tests/js ../../tests/wasm/spec
echo $(warning) > ../../tests/wasm/spec/README.md
[ -f ./spec-tests.patch ] && (cd ../../tests/wasm/spec && patch -u -p7 < ../../../etc/wasm/spec-tests.patch)

View File

@@ -4,9 +4,9 @@ version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
@@ -28,6 +28,12 @@ dependencies = [
"winapi",
]
[[package]]
name = "bitflags"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bumpalo"
version = "3.14.0"
@@ -53,6 +59,18 @@ dependencies = [
"termcolor",
]
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "hashbrown"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
[[package]]
name = "hermit-abi"
version = "0.1.18"
@@ -71,6 +89,16 @@ dependencies = [
"quick-error",
]
[[package]]
name = "indexmap"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "leb128"
version = "0.2.4"
@@ -94,9 +122,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "proc-macro2"
@@ -124,9 +152,21 @@ dependencies = [
[[package]]
name = "regex"
version = "1.7.0"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
dependencies = [
"aho-corasick",
"memchr",
@@ -135,9 +175,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.28"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "serde"
@@ -199,11 +239,12 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "wasm-encoder"
version = "0.214.0"
version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff694f02a8d7a50b6922b197ae03883fbf18cdb2ae9fbee7b6148456f5f44041"
checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54"
dependencies = [
"leb128",
"wasmparser",
]
[[package]]
@@ -221,10 +262,20 @@ dependencies = [
]
[[package]]
name = "wast"
version = "214.0.0"
name = "wasmparser"
version = "0.219.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "694bcdb24c49c8709bd8713768b71301a11e823923eee355d530f1d8d0a7f8e9"
checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5"
dependencies = [
"bitflags",
"indexmap",
]
[[package]]
name = "wast"
version = "219.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f79a9d9df79986a68689a6b40bcc8d5d40d807487b235bebc2ac69a242b54a1"
dependencies = [
"bumpalo",
"leb128",
@@ -238,6 +289,7 @@ name = "wast2js"
version = "0.1.0"
dependencies = [
"anyhow",
"regex",
"wast",
]

View File

@@ -1,43 +1,15 @@
[[repos]]
name = 'spec'
commit = 'b1fbe1a89'
[[repos]]
name = 'threads'
commit = '85b562cd'
[[repos]]
name = 'simd'
commit = 'a78b98a6'
commit = '1e1010249'
[[repos]]
name = 'memory64'
commit = '9edc82d34'
[[repos]]
name = 'relaxed-simd'
commit = '22257c57b'
[[repos]]
name = 'extended-const'
commit = '7612271a7'
[[repos]]
name = 'tail-call'
commit = '6f44ca27a'
[[repos]]
name = 'multi-memory'
commit = 'c2c00d81c'
[[repos]]
name = 'function-references'
commit = 'eab6b36ca'
commit = '179566900'
[[repos]]
name = 'exception-handling'
commit = '98e4eb60d'
commit = 'da1e90701'
[[repos]]
name = 'gc'
commit = '207333efd'
commit = '88463e822'

View File

@@ -6,17 +6,11 @@ directive = "|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-c
excluded_tests = [
# false-positive windows-specific failures
"align.wast",
# bulk-memory-operations/issues/133 (data.wast:161)
"data.wast",
# memory limits can be encoded with more bytes now
"binary.wast",
"binary-leb128.wast",
# testing that multiple tables fail (imports.wast:309)
"imports.wast",
# bulk-memory-operations/issues/133 (linking.wast:206)
"linking.wast",
# bulk-memory-operations/issues/133 (elem.wast:142)
"elem.wast",
# test harness doesn't acquire global values correctly
"exports.wast",
# false-positive windows-specific failure
@@ -29,11 +23,15 @@ excluded_tests = [
"unreached-invalid.wast",
# argument is not wasm value
"^select.wast",
# fiddly text-format rules we don't care about
"annotations.wast",
"id.wast",
]
[[repos]]
name = "spec"
url = "https://github.com/WebAssembly/spec"
branch = "wasm-3.0"
excluded_tests = []
directive = "; test-also=--no-avx; skip-variant-if: --no-avx, !getBuildConfiguration('x86') && !getBuildConfiguration('x64') || getBuildConfiguration('simulator')"
@@ -42,11 +40,21 @@ name = "exception-handling"
url = "https://github.com/WebAssembly/exception-handling"
branch = "main"
parent = "spec"
# Skip in jit-test when it's not enabled
directive = "; --setpref=wasm_exnref=true; skip-if: !wasmExnRefEnabled()"
excluded_tests = [
# harness doesn't support exnref, because JS-API globals can't use it
"ref_null.wast.js"
# Old tests reflecting old limits on globals in constant expressions
"data.wast.js",
"elem.wast.js",
"global.wast.js",
# Tests asserting that multi-memory is invalid
"memory.wast.js",
# Old and less complete ref_null tests
"ref_null.wast.js",
# Irrelevant SIMD tests
"simd_lane.wast.js",
"simd_linking.wast.js",
"simd_load.wast.js",
"simd_store.wast.js",
]
[[repos]]
@@ -57,71 +65,9 @@ parent = "spec"
directive = "; --setpref=wasm_memory64=true; skip-if: !wasmMemory64Enabled()"
excluded_tests = []
[[repos]]
name = "function-references"
url = "https://github.com/WebAssembly/function-references"
branch = "main"
parent = "spec"
excluded_tests = [
# duplicate tail calls tests
"return_call.wast",
"return_call_indirect.wast",
# table function elem subtyping
"ref_is_null.wast",
# cannot expose indexed reference type
"ref_null.wast",
# parameter subtyping
"type-equivalence.wast",
# NYI WasmValType.h:259
"table-sub.wast",
# unrelated
"tokens.wast",
# irrelevant
"simd_lane.wast",
# globals are of different type
"local_init.wast",
]
[[repos]]
name = "relaxed-simd"
url = "https://github.com/WebAssembly/relaxed-simd"
branch = "main"
parent = "spec"
directive = "; --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()"
excluded_tests = []
[[repos]]
name = "extended-const"
url = "https://github.com/WebAssembly/extended-const"
branch = "main"
parent = "spec"
excluded_tests = []
[[repos]]
name = "tail-call"
url = "https://github.com/WebAssembly/tail-call"
branch = "main"
parent = "spec"
excluded_tests = []
[[repos]]
name = "multi-memory"
url = "https://github.com/WebAssembly/multi-memory"
branch = "main"
parent = "spec"
directive = "; --setpref=wasm_multi_memory=true; skip-if: !wasmMultiMemoryEnabled()"
excluded_tests = [
# Empty test fails parsing
"memory_copy1.wast",
]
[[repos]]
name = "gc"
url = "https://github.com/WebAssembly/gc"
branch = "main"
parent = "function-references"
excluded_tests = [
# tail call tests that snuck in
"return_call.wast",
"return_call_indirect.wast",
]
parent = "spec"
excluded_tests = []

View File

@@ -8,4 +8,5 @@ edition = "2018"
[dependencies]
anyhow = "1.0.19"
wast = "214.0.0"
wast = "219.0.1"
regex = "1.11.1"

View File

@@ -13,7 +13,8 @@
* limitations under the License.
*/
use anyhow::{bail, Context as _, Result};
use anyhow::{anyhow, bail, Context as _, Result};
use regex::Regex;
use std::fmt::Write;
use std::path::Path;
use std::str;
@@ -90,8 +91,12 @@ fn convert_directive(
} else {
writeln!(out, "// {}:{}:{}", filename.display(), line + 1, col)?;
}
// For full definitions of these directives, see
// https://github.com/WebAssembly/spec/blob/main/interpreter/README.md#scripts
match directive {
Wat(wast::QuoteWat::Wat(wast::Wat::Module(module))) => {
// (module $M? ...): Instantiate a module with an optional identifier.
Module(wast::QuoteWat::Wat(wast::Wat::Module(module))) => {
let next_instance = current_instance.map(|x| x + 1).unwrap_or(0);
let module_text = module_to_js_string(&module, wast)?;
@@ -101,17 +106,14 @@ fn convert_directive(
next_instance, module_text
)?;
if let Some(id) = module.id {
writeln!(
out,
"register(${}, {});",
next_instance,
format!("`{}`", escape_template_name_string(id.name()))
)?;
writeln!(out, "let ${} = ${};", id.name(), next_instance)?;
}
*current_instance = Some(next_instance);
}
Wat(wast::QuoteWat::QuoteModule(_, source)) => {
// (module quote "..."): Instantiate a module using the given literal text.
// Identifiers are not supported.
Module(wast::QuoteWat::QuoteModule(_, source)) => {
let next_instance = current_instance.map(|x| x + 1).unwrap_or(0);
let module_text = quote_module_to_js_string(source)?;
@@ -123,29 +125,69 @@ fn convert_directive(
*current_instance = Some(next_instance);
}
Wat(_) => {
write!(out, "// unsupported quote wat")?;
Module(..) => bail!("unsupported module definition"),
// (module definition $M ...): Define and validate, but do not instantiate, a module
ModuleDefinition(wast::QuoteWat::Wat(wast::Wat::Module(module))) => {
let name = module
.id
.ok_or(anyhow!("`module define` directives must have IDs"))?
.name();
let module_text = module_definition_to_js_string(&module, wast)?;
writeln!(out, "let ${} = module(`{}`);", name, module_text)?;
}
ModuleDefinition(..) => bail!("unsupported module definition...definition"),
// (module instance $I $M): Instantiate a specific module
ModuleInstance {
span: _,
instance: Some(instance),
module: Some(module),
} => {
writeln!(
out,
"let ${} = instantiateFromModule(${});",
instance.name(),
module.name()
)?;
}
ModuleInstance { .. } => bail!("unsupported module instance definition"),
// (register "a"): Register the current instance
Register {
span: _,
name,
module,
module: None,
} => {
let instanceish = module
.map(|x| format!("`{}`", escape_template_name_string(x.name())))
.unwrap_or_else(|| format!("${}", current_instance.unwrap()));
writeln!(
out,
"register({}, `{}`);",
instanceish,
"register(${}, `{}`);",
current_instance.unwrap(),
escape_template_name_string(name)
)?;
}
// (register "a" $a): Register an item by identifier
Register {
span: _,
name,
module: Some(thing),
} => {
writeln!(
out,
"register(${}, `{}`);",
thing.name(),
escape_template_name_string(name)
)?;
}
// (invoke $M? "a" ...args): Call an exported function
Invoke(i) => {
let invoke_node = invoke_to_js(current_instance, i)?;
writeln!(out, "{};", invoke_node.output(0))?;
}
// (assert_return ...)
AssertReturn {
span: _,
exec,
@@ -164,6 +206,8 @@ fn convert_directive(
.output(0),
)?;
}
// (assert_trap ...)
AssertTrap {
span: _,
exec,
@@ -185,6 +229,8 @@ fn convert_directive(
.output(0),
)?;
}
// (assert_exhaustion ...)
AssertExhaustion {
span: _,
call,
@@ -206,6 +252,8 @@ fn convert_directive(
.output(0),
)?;
}
// (assert_invalid ...)
AssertInvalid {
span: _,
module,
@@ -232,6 +280,8 @@ fn convert_directive(
.output(0),
)?;
}
// (assert_malformed ...)
AssertMalformed {
module,
span: _,
@@ -239,7 +289,13 @@ fn convert_directive(
} => {
let text = match module {
wast::QuoteWat::Wat(wast::Wat::Module(m)) => module_to_js_string(&m, wast)?,
wast::QuoteWat::QuoteModule(_, source) => quote_module_to_js_string(source)?,
wast::QuoteWat::QuoteModule(_, source) => match quote_module_to_js_string(source) {
Ok(t) => t,
Err(err) => {
writeln!(out, "// ignoring badly-encoded assert_malformed: {:?}", err)?;
return Ok(());
}
},
other => bail!("unsupported {:?} in assert_malformed", other),
};
let exec = Box::new(JSNode::Raw(format!("instantiate(`{}`)", text)));
@@ -258,6 +314,8 @@ fn convert_directive(
.output(0),
)?;
}
// (assert_unlinkable ...)
AssertUnlinkable {
span: _,
module,
@@ -283,12 +341,14 @@ fn convert_directive(
.output(0),
)?;
}
AssertException { span: _, exec } => {
// This assert doesn't have a second parameter, so we don't bother
// formatting it using an Assert node.
let exec_node = execute_to_js(current_instance, exec, wast)?;
writeln!(out, "assert_exception(() => {});", exec_node.output(0))?;
}
AssertSuspension { .. } => unimplemented!(),
Thread(..) => unimplemented!(),
Wait { .. } => unimplemented!(),
}
@@ -343,6 +403,10 @@ fn span_to_offset(span: wast::token::Span, text: &str) -> Result<usize> {
}
fn closed_module(module: &str) -> Result<&str> {
if !module.starts_with("module") {
bail!("expected module source");
}
enum State {
Module,
QStr,
@@ -355,10 +419,7 @@ fn closed_module(module: &str) -> Result<&str> {
let mut chars = module.chars();
while level != 0 {
let next = match chars.next() {
Some(next) => next,
None => bail!("was unable to close module"),
};
let next = chars.next().ok_or(anyhow!("unable to close module"))?;
match state {
State::Module => match next {
'(' => level += 1,
@@ -402,15 +463,30 @@ fn quote_module_to_js_string(quotes: Vec<(wast::token::Span, &[u8])>) -> Result<
Ok(escaped)
}
fn module_definition_to_js_string(module: &wast::core::Module, wast: &str) -> Result<String> {
let offset = span_to_offset(module.span, wast)?;
let opened_module = &wast[offset..];
// strip "module definition $M" down to just "module"
let pattern = r"^module definition \$[a-zA-Z_$][a-zA-Z0-9_$]*(.*)";
let re = Regex::new(pattern).expect("Invalid regex pattern");
let without_definition = re.replace(opened_module, "module $1");
Ok(escape_template_module_string(&format!(
"({}",
closed_module(&without_definition)?
)))
}
fn invoke_to_js(current_instance: &Option<usize>, i: wast::WastInvoke) -> Result<Box<JSNode>> {
let instanceish = i
let instance = i
.module
.map(|x| format!("`{}`", escape_template_name_string(x.name())))
.map(|x| format!("${}", x.name()))
.unwrap_or_else(|| format!("${}", current_instance.unwrap()));
let body = to_js_value_array(&i.args, arg_to_js_value)?;
Ok(Box::new(JSNode::Invoke {
instance: instanceish,
instance: instance,
name: escape_template_name_string(i.name),
body: body,
}))
@@ -432,10 +508,10 @@ fn execute_to_js(
}
wast::WastExecute::Get { module, global, .. } => {
let instanceish = module
.map(|x| format!("`{}`", escape_template_name_string(x.name())))
.unwrap_or_else(|| format!("${}", current_instance.unwrap()));
.map(|x| format!("{}", x.name()))
.unwrap_or_else(|| format!("{}", current_instance.unwrap()));
Ok(Box::new(JSNode::Raw(format!(
"get({}, `{}`)",
"get(${}, `{}`)",
instanceish, global
))))
}
@@ -560,25 +636,25 @@ fn return_value_to_js_value(v: &wast::core::WastRetCore<'_>) -> Result<String> {
F32(x) => f32_pattern_to_js_value(x),
F64(x) => f64_pattern_to_js_value(x),
RefNull(x) => match x {
Some(wast::core::HeapType::Abstract { shared: false, ty }) => {
match ty {
wast::core::AbstractHeapType::Any => format!("value('anyref', null)"),
wast::core::AbstractHeapType::Exn => format!("value('exnref', null)"),
wast::core::AbstractHeapType::Eq => format!("value('eqref', null)"),
wast::core::AbstractHeapType::Array => format!("value('arrayref', null)"),
wast::core::AbstractHeapType::Struct => format!("value('structref', null)"),
wast::core::AbstractHeapType::I31 => format!("value('i31ref', null)"),
wast::core::AbstractHeapType::None => format!("value('nullref', null)"),
wast::core::AbstractHeapType::Func => format!("value('anyfunc', null)"),
wast::core::AbstractHeapType::NoFunc => format!("value('nullfuncref', null)"),
wast::core::AbstractHeapType::Extern => format!("value('externref', null)"),
wast::core::AbstractHeapType::NoExtern => format!("value('nullexternref', null)"),
other => bail!(
"couldn't convert ref.null {:?} to a js assertion value",
other
),
}
}
Some(wast::core::HeapType::Abstract { shared: false, ty }) => match ty {
wast::core::AbstractHeapType::Any => format!("value('anyref', null)"),
wast::core::AbstractHeapType::Exn => format!("value('exnref', null)"),
wast::core::AbstractHeapType::Eq => format!("value('eqref', null)"),
wast::core::AbstractHeapType::Array => format!("value('arrayref', null)"),
wast::core::AbstractHeapType::Struct => format!("value('structref', null)"),
wast::core::AbstractHeapType::I31 => format!("value('i31ref', null)"),
wast::core::AbstractHeapType::None => format!("value('nullref', null)"),
wast::core::AbstractHeapType::Func => format!("value('anyfunc', null)"),
wast::core::AbstractHeapType::NoFunc => format!("value('nullfuncref', null)"),
wast::core::AbstractHeapType::Extern => format!("value('externref', null)"),
wast::core::AbstractHeapType::NoExtern => format!("value('nullexternref', null)"),
wast::core::AbstractHeapType::Exn => format!("value('exnref', null)"),
wast::core::AbstractHeapType::NoExn => format!("value('nullexnref', null)"),
other => bail!(
"couldn't convert ref.null {:?} to a js assertion value",
other
),
},
None => "null".to_string(),
other => bail!(
"couldn't convert ref.null {:?} to a js assertion value",

View File

@@ -193,16 +193,10 @@ let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
function module(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
return module;
}
function instantiate(source) {
@@ -212,18 +206,23 @@ function instantiate(source) {
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
function instantiateFromModule(module) {
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
function register(instance, name) {
linkage[name] = instance;
}
function invoke(instance, field, params) {
let func = instance[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
function get(instance, field) {
let global = instance[field];
assertEq(
global instanceof WebAssembly.Global,
true,

View File

@@ -14,7 +14,6 @@
*/
#[allow(unreachable_patterns)]
mod convert;
mod out;
pub use convert::*;

View File

@@ -81,89 +81,31 @@ diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory_trap64.wast.js b/js
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory.wast.js
--- a/js/src/jit-test/tests/wasm/spec/memory64/memory.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/memory64/memory.wast.js
@@ -33,14 +33,16 @@ let $4 = instantiate(`(module (memory 1 256))`);
// ./test/core/memory.wast:8
let $5 = instantiate(`(module (memory 0 65536))`);
-// ./test/core/memory.wast:10
-assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`);
+if (!wasmMultiMemoryEnabled()) {
+ // ./test/core/memory.wast:10
+ assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`);
-// ./test/core/memory.wast:11
-assert_invalid(
- () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
- `multiple memories`,
-);
+ // ./test/core/memory.wast:11
+ assert_invalid(
+ () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
+ `multiple memories`,
+ );
+}
// ./test/core/memory.wast:13
let $6 = instantiate(`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`);
@@ -147,24 +149,6 @@ assert_invalid(
@@ -138,24 +138,6 @@ assert_invalid(
`memory size must be at most 65536 pages (4GiB)`,
);
-// ./test/core/memory.wast:79
-// ./test/core/memory.wast:76
-assert_invalid(
- () => instantiate(`(memory 0x1_0000_0000) `),
- `memory size must be at most 65536 pages (4GiB)`,
-);
-
-// ./test/core/memory.wast:83
-// ./test/core/memory.wast:80
-assert_invalid(
- () => instantiate(`(memory 0x1_0000_0000 0x1_0000_0000) `),
- `memory size must be at most 65536 pages (4GiB)`,
-);
-
-// ./test/core/memory.wast:87
-// ./test/core/memory.wast:84
-assert_invalid(
- () => instantiate(`(memory 0 0x1_0000_0000) `),
- `memory size must be at most 65536 pages (4GiB)`,
-);
-
// ./test/core/memory.wast:92
// ./test/core/memory.wast:89
let $9 = instantiate(`(module
(memory 1)
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js
--- a/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js
@@ -27,17 +27,19 @@ let $2 = instantiate(`(module (memory i64 1 256))`);
// ./test/core/memory64.wast:6
let $3 = instantiate(`(module (memory i64 0 65536))`);
-// ./test/core/memory64.wast:9
-assert_invalid(
- () => instantiate(`(module (memory i64 0) (memory i64 0))`),
- `multiple memories`,
-);
-
-// ./test/core/memory64.wast:10
-assert_invalid(
- () => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`),
- `multiple memories`,
-);
+if (!wasmMultiMemoryEnabled()) {
+ // ./test/core/memory64.wast:9
+ assert_invalid(
+ () => instantiate(`(module (memory i64 0) (memory i64 0))`),
+ `multiple memories`,
+ );
+
+ // ./test/core/memory64.wast:10
+ assert_invalid(
+ () => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`),
+ `multiple memories`,
+ );
+}
// ./test/core/memory64.wast:11
let $4 = instantiate(`(module (memory i64 (data)) (func (export "memsize") (result i64) (memory.size)))`);
diff --git a/js/src/jit-test/tests/wasm/spec/memory64/simd_address.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/simd_address.wast.js
--- a/js/src/jit-test/tests/wasm/spec/memory64/simd_address.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/memory64/simd_address.wast.js
@@ -173,176 +115,63 @@ diff --git a/js/src/jit-test/tests/wasm/spec/memory64/simd_address.wast.js b/js/
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_load.wast.js b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_load.wast.js
--- a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_load.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_load.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_memory-multi.wast.js b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_memory-multi.wast.js
--- a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_memory-multi.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_memory-multi.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_store.wast.js b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_store.wast.js
--- a/js/src/jit-test/tests/wasm/spec/multi-memory/simd_store.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/multi-memory/simd_store.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js b/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js
--- a/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js
+++ b/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js
@@ -19,6 +19,15 @@ if (!wasmIsSupported()) {
quit();
}
diff --git a/js/src/jit-test/tests/wasm/spec/spec/ref_null.wast.js b/js/src/jit-test/tests/wasm/spec/spec/ref_null.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/ref_null.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/ref_null.wast.js
@@ -37,8 +37,9 @@ assert_return(() => invoke($0, `anyref`, []), [value('anyref', null)]);
// ./test/core/ref_null.wast:17
assert_return(() => invoke($0, `funcref`, []), [value('anyfunc', null)]);
+function partialOobWriteMayWritePartialData() {
+ let arm_native = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator");
+ let arm64_native = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator");
+ return arm_native || arm64_native;
+}
+
+let native_arm = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator");
+let native_arm64 = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator");
+
function bytes(type, bytes) {
var typedBuffer = new Uint8Array(bytes);
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js b/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js
--- a/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js
@@ -562,11 +562,15 @@ assert_trap(() => invoke($0, `i64.load32_u`, [-3]), `out of bounds memory access
// ./test/core/multi-memory/memory_trap1.wast:234
assert_trap(() => invoke($0, `i64.load32_u`, [-4]), `out of bounds memory access`);
-// ./test/core/ref_null.wast:18
-assert_return(() => invoke($0, `exnref`, []), [value('exnref', null)]);
+// exnref values are not exportable to JS
+// // ./test/core/ref_null.wast:18
+// assert_return(() => invoke($0, `exnref`, []), [value('exnref', null)]);
-// ./test/core/multi-memory/memory_trap1.wast:237
-assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 7523094288207667809n)]);
+// Bug 1842293 - do not observe the partial store caused by bug 1666747 on
+// some native platforms.
+if (!partialOobWriteMayWritePartialData()) {
+ // ./test/core/multi-memory/memory_trap1.wast:237
+ assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 7523094288207667809n)]);
-// ./test/core/multi-memory/memory_trap1.wast:238
-assert_return(() => invoke($0, `i64.load`, [0]), [value("i64", 7523094288207667809n)]);
+ // ./test/core/multi-memory/memory_trap1.wast:238
+ assert_return(() => invoke($0, `i64.load`, [0]), [value("i64", 7523094288207667809n)]);
+}
// ./test/core/multi-memory/memory_trap1.wast:242
assert_return(() => invoke($0, `i64.store`, [65528, 0n]), []);
@@ -574,14 +578,18 @@ assert_return(() => invoke($0, `i64.store`, [65528, 0n]), []);
// ./test/core/multi-memory/memory_trap1.wast:243
assert_trap(() => invoke($0, `i32.store`, [65533, 305419896]), `out of bounds memory access`);
-// ./test/core/multi-memory/memory_trap1.wast:244
-assert_return(() => invoke($0, `i32.load`, [65532]), [value("i32", 0)]);
+if (!partialOobWriteMayWritePartialData()) {
+ // ./test/core/multi-memory/memory_trap1.wast:244
+ assert_return(() => invoke($0, `i32.load`, [65532]), [value("i32", 0)]);
+}
// ./test/core/multi-memory/memory_trap1.wast:245
assert_trap(() => invoke($0, `i64.store`, [65529, 1311768467294899695n]), `out of bounds memory access`);
-// ./test/core/multi-memory/memory_trap1.wast:246
-assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 0n)]);
+if (!partialOobWriteMayWritePartialData()) {
+ // ./test/core/multi-memory/memory_trap1.wast:246
+ assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 0n)]);
+}
// ./test/core/multi-memory/memory_trap1.wast:247
assert_trap(
@@ -589,8 +597,10 @@ assert_trap(
`out of bounds memory access`,
);
-// ./test/core/multi-memory/memory_trap1.wast:248
-assert_return(() => invoke($0, `f32.load`, [65532]), [value("f32", 0)]);
+if (!partialOobWriteMayWritePartialData()) {
+ // ./test/core/multi-memory/memory_trap1.wast:248
+ assert_return(() => invoke($0, `f32.load`, [65532]), [value("f32", 0)]);
+}
// ./test/core/multi-memory/memory_trap1.wast:249
assert_trap(
@@ -598,5 +608,7 @@ assert_trap(
`out of bounds memory access`,
);
-// ./test/core/multi-memory/memory_trap1.wast:250
-assert_return(() => invoke($0, `f64.load`, [65528]), [value("f64", 0)]);
+if (!partialOobWriteMayWritePartialData()) {
+ // ./test/core/multi-memory/memory_trap1.wast:250
+ assert_return(() => invoke($0, `f64.load`, [65528]), [value("f64", 0)]);
+}
diff --git a/js/src/jit-test/tests/wasm/spec/relaxed-simd/i32x4_relaxed_trunc.wast.js b/js/src/jit-test/tests/wasm/spec/relaxed-simd/i32x4_relaxed_trunc.wast.js
--- a/js/src/jit-test/tests/wasm/spec/relaxed-simd/i32x4_relaxed_trunc.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/relaxed-simd/i32x4_relaxed_trunc.wast.js
@@ -92,6 +92,7 @@ assert_return(
either(
i32x4([0x0, 0x0, 0xffffff00, 0xffffffff]),
i32x4([0x0, 0xffffffff, 0xffffff00, 0xffffffff]),
+ i32x4([0x0, 0xffffffff, 0xffffff00, 0x0]),
),
],
);
@@ -122,6 +123,7 @@ assert_return(
either(
i32x4([0x0, 0x0, 0x0, 0x0]),
i32x4([0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff]),
+ i32x4([0x80000000, 0x80000000, 0x80000000, 0x80000000]),
),
],
);
@@ -173,6 +175,7 @@ assert_return(
either(
i32x4([0x0, 0xffffffff, 0x0, 0x0]),
i32x4([0xffffffff, 0xffffffff, 0x0, 0x0]),
+ i32x4([0xfffffffe, 0x0, 0x0, 0x0]),
),
],
);
diff --git a/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js b/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js
@@ -33,14 +33,16 @@ let $4 = instantiate(`(module (memory 1 256))`);
// ./test/core/memory.wast:8
let $5 = instantiate(`(module (memory 0 65536))`);
-// ./test/core/memory.wast:10
-assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`);
// ./test/core/ref_null.wast:19
assert_return(() => invoke($0, `externref`, []), [value('externref', null)]);
@@ -115,23 +116,24 @@ assert_return(() => invoke($1, `nullfuncref`, []), [value('nullfuncref', null)])
// ./test/core/ref_null.wast:66
assert_return(() => invoke($1, `nullfuncref`, []), [null]);
-// ./test/core/ref_null.wast:67
-assert_return(() => invoke($1, `exnref`, []), [value('exnref', null)]);
-
-// ./test/core/memory.wast:11
-assert_invalid(
- () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
- `multiple memories`,
-);
+if (!wasmMultiMemoryEnabled()) {
+ // ./test/core/memory.wast:10
+ assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`);
+
+ // ./test/core/memory.wast:11
+ assert_invalid(
+ () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
+ `multiple memories`,
+ );
+}
-// ./test/core/ref_null.wast:68
-assert_return(() => invoke($1, `exnref`, []), [value('nullexnref', null)]);
-
-// ./test/core/ref_null.wast:69
-assert_return(() => invoke($1, `exnref`, []), [null]);
-
-// ./test/core/ref_null.wast:70
-assert_return(() => invoke($1, `nullexnref`, []), [value('exnref', null)]);
-
-// ./test/core/ref_null.wast:71
-assert_return(() => invoke($1, `nullexnref`, []), [value('nullexnref', null)]);
-
-// ./test/core/ref_null.wast:72
-assert_return(() => invoke($1, `nullexnref`, []), [null]);
+// exnref values are not exportable to JS
+// // ./test/core/ref_null.wast:67
+// assert_return(() => invoke($1, `exnref`, []), [value('exnref', null)]);
+//
+// // ./test/core/ref_null.wast:68
+// assert_return(() => invoke($1, `exnref`, []), [value('nullexnref', null)]);
+//
+// // ./test/core/ref_null.wast:69
+// assert_return(() => invoke($1, `exnref`, []), [null]);
+//
+// // ./test/core/ref_null.wast:70
+// assert_return(() => invoke($1, `nullexnref`, []), [value('exnref', null)]);
+//
+// // ./test/core/ref_null.wast:71
+// assert_return(() => invoke($1, `nullexnref`, []), [value('nullexnref', null)]);
+//
+// // ./test/core/ref_null.wast:72
+// assert_return(() => invoke($1, `nullexnref`, []), [null]);
// ./test/core/memory.wast:13
let $6 = instantiate(`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/ref_null.wast:73
assert_return(() => invoke($1, `externref`, []), [value('externref', null)]);
diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_address.wast.js b/js/src/jit-test/tests/wasm/spec/spec/simd_address.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/simd_address.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/simd_address.wast.js
@@ -708,6 +537,15 @@ diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_lane.wast.js b/js/src/jit
+++ b/js/src/jit-test/tests/wasm/spec/spec/simd_lane.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_linking.wast.js b/js/src/jit-test/tests/wasm/spec/spec/simd_linking.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/simd_linking.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/simd_linking.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
@@ -780,6 +618,15 @@ diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_load_zero.wast.js b/js/sr
+++ b/js/src/jit-test/tests/wasm/spec/spec/simd_load_zero.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_memory-multi.wast.js b/js/src/jit-test/tests/wasm/spec/spec/simd_memory-multi.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/simd_memory-multi.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/simd_memory-multi.wast.js
@@ -1,3 +1,5 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
/* Copyright 2021 Mozilla Foundation
*
@@ -838,75 +685,83 @@ diff --git a/js/src/jit-test/tests/wasm/spec/spec/simd_store8_lane.wast.js b/js/
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/global.wast.js b/js/src/jit-test/tests/wasm/spec/spec/global.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/global.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/global.wast.js
@@ -476,17 +476,21 @@ assert_invalid(
`unknown global`,
diff --git a/js/src/jit-test/tests/wasm/spec/spec/i8x16_relaxed_swizzle.wast.js b/js/src/jit-test/tests/wasm/spec/spec/i8x16_relaxed_swizzle.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/i8x16_relaxed_swizzle.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/i8x16_relaxed_swizzle.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/i16x8_relaxed_q15mulr_s.wast.js b/js/src/jit-test/tests/wasm/spec/spec/i16x8_relaxed_q15mulr_s.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/i16x8_relaxed_q15mulr_s.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/i16x8_relaxed_q15mulr_s.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/i32x4_relaxed_trunc.wast.js b/js/src/jit-test/tests/wasm/spec/spec/i32x4_relaxed_trunc.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/i32x4_relaxed_trunc.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/i32x4_relaxed_trunc.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -92,6 +92,7 @@ assert_return(
either(
i32x4([0x0, 0x0, 0xffffff00, 0xffffffff]),
i32x4([0x0, 0xffffffff, 0xffffff00, 0xffffffff]),
+ i32x4([0x0, 0xffffffff, 0xffffff00, 0x0]),
),
],
);
-// ./test/core/global.wast:351
-assert_invalid(
- () => instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`),
- `unknown global`,
-);
-
-// ./test/core/global.wast:355
-assert_invalid(
- () => instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`),
- `unknown global`,
-);
+// The GC proposal allows global initializers to reference previously-defined
+// immutable globals. These tests are out of date.
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=1926357
+
+// // ./test/core/global.wast:351
+// assert_invalid(
+// () => instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`),
+// `unknown global`,
+// );
+
+// // ./test/core/global.wast:355
+// assert_invalid(
+// () => instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`),
+// `unknown global`,
+// );
// ./test/core/global.wast:360
assert_invalid(
diff --git a/js/src/jit-test/tests/wasm/spec/extended-const/global.wast.js b/js/src/jit-test/tests/wasm/spec/extended-const/global.wast.js
--- a/js/src/jit-test/tests/wasm/spec/extended-const/global.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/extended-const/global.wast.js
@@ -496,17 +496,21 @@ assert_invalid(
`unknown global`,
@@ -122,6 +123,7 @@ assert_return(
either(
i32x4([0x0, 0x0, 0x0, 0x0]),
i32x4([0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff]),
+ i32x4([0x80000000, 0x80000000, 0x80000000, 0x80000000]),
),
],
);
-// ./test/core/global.wast:363
-assert_invalid(
- () => instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`),
- `unknown global`,
-);
-
-// ./test/core/global.wast:367
-assert_invalid(
- () => instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`),
- `unknown global`,
-);
+// The GC proposal allows global initializers to reference previously-defined
+// immutable globals. These tests are out of date.
+// See https://bugzilla.mozilla.org/show_bug.cgi?id=1926357
+
+// // ./test/core/global.wast:363
+// assert_invalid(
+// () => instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`),
+// `unknown global`,
+// );
+
+// // ./test/core/global.wast:367
+// assert_invalid(
+// () => instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`),
+// `unknown global`,
+// );
// ./test/core/global.wast:372
assert_invalid(
@@ -173,6 +175,7 @@ assert_return(
either(
i32x4([0x0, 0xffffffff, 0x0, 0x0]),
i32x4([0xffffffff, 0xffffffff, 0x0, 0x0]),
+ i32x4([0xfffffffe, 0x0, 0x0, 0x0]),
),
],
);
diff --git a/js/src/jit-test/tests/wasm/spec/spec/relaxed_dot_product.wast.js b/js/src/jit-test/tests/wasm/spec/spec/relaxed_dot_product.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/relaxed_dot_product.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/relaxed_dot_product.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/relaxed_laneselect.wast.js b/js/src/jit-test/tests/wasm/spec/spec/relaxed_laneselect.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/relaxed_laneselect.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/relaxed_laneselect.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/relaxed_madd_nmadd.wast.js b/js/src/jit-test/tests/wasm/spec/spec/relaxed_madd_nmadd.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/relaxed_madd_nmadd.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/relaxed_madd_nmadd.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/js/src/jit-test/tests/wasm/spec/spec/relaxed_min_max.wast.js b/js/src/jit-test/tests/wasm/spec/spec/relaxed_min_max.wast.js
--- a/js/src/jit-test/tests/wasm/spec/spec/relaxed_min_max.wast.js
+++ b/js/src/jit-test/tests/wasm/spec/spec/relaxed_min_max.wast.js
@@ -1,3 +1,4 @@
+// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -19,33 +19,16 @@
let $0 = instantiate(`(module;;comment
)`);
// ./test/core/comments.wast:57:11
// ./test/core/comments.wast:56:11
let $1 = instantiate(`(module(;comment;)
(;comment;))`);
// ./test/core/comments.wast:67
// ./test/core/comments.wast:66
let $2 = instantiate(`(module
(;comment(;nested(;further;)nested;)comment;)
)`);
// ./test/core/comments.wast:76
// ./test/core/comments.wast:75
let $3 = instantiate(`(module
(;comment;;comment(;nested;)comment;)
)`);
// ./test/core/comments.wast:83:8
let $4 = instantiate(`(func (export "f1") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) (func (export "f2") (result i32) (i32.const 1) ;; comment (return (i32.const 2))
) (func (export "f3") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) `);
// ./test/core/comments.wast:104
assert_return(() => invoke($4, `f1`, []), [value("i32", 2)]);
// ./test/core/comments.wast:105
assert_return(() => invoke($4, `f2`, []), [value("i32", 2)]);
// ./test/core/comments.wast:106
assert_return(() => invoke($4, `f3`, []), [value("i32", 2)]);

File diff suppressed because one or more lines are too long

View File

@@ -574,203 +574,191 @@ assert_malformed(
`unknown operator`,
);
// ./test/core/float_literals.wast:355
assert_malformed(
() => instantiate(`(global f32 (f32.const nan:0x80_0000)) `),
`constant out of range`,
);
// ./test/core/float_literals.wast:360
// ./test/core/float_literals.wast:356
assert_malformed(() => instantiate(`(global f64 (f64.const _100)) `), `unknown operator`);
// ./test/core/float_literals.wast:364
// ./test/core/float_literals.wast:360
assert_malformed(() => instantiate(`(global f64 (f64.const +_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:368
// ./test/core/float_literals.wast:364
assert_malformed(() => instantiate(`(global f64 (f64.const -_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:372
// ./test/core/float_literals.wast:368
assert_malformed(() => instantiate(`(global f64 (f64.const 99_)) `), `unknown operator`);
// ./test/core/float_literals.wast:376
// ./test/core/float_literals.wast:372
assert_malformed(
() => instantiate(`(global f64 (f64.const 1__000)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:380
// ./test/core/float_literals.wast:376
assert_malformed(() => instantiate(`(global f64 (f64.const _1.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:384
// ./test/core/float_literals.wast:380
assert_malformed(() => instantiate(`(global f64 (f64.const 1.0_)) `), `unknown operator`);
// ./test/core/float_literals.wast:388
// ./test/core/float_literals.wast:384
assert_malformed(() => instantiate(`(global f64 (f64.const 1_.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:392
// ./test/core/float_literals.wast:388
assert_malformed(() => instantiate(`(global f64 (f64.const 1._0)) `), `unknown operator`);
// ./test/core/float_literals.wast:396
// ./test/core/float_literals.wast:392
assert_malformed(() => instantiate(`(global f64 (f64.const _1e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:400
// ./test/core/float_literals.wast:396
assert_malformed(() => instantiate(`(global f64 (f64.const 1e1_)) `), `unknown operator`);
// ./test/core/float_literals.wast:404
// ./test/core/float_literals.wast:400
assert_malformed(() => instantiate(`(global f64 (f64.const 1_e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:408
// ./test/core/float_literals.wast:404
assert_malformed(() => instantiate(`(global f64 (f64.const 1e_1)) `), `unknown operator`);
// ./test/core/float_literals.wast:412
// ./test/core/float_literals.wast:408
assert_malformed(
() => instantiate(`(global f64 (f64.const _1.0e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:416
// ./test/core/float_literals.wast:412
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:420
// ./test/core/float_literals.wast:416
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0_e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:424
// ./test/core/float_literals.wast:420
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:428
// ./test/core/float_literals.wast:424
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:432
// ./test/core/float_literals.wast:428
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:436
// ./test/core/float_literals.wast:432
assert_malformed(
() => instantiate(`(global f64 (f64.const _0x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:440
// ./test/core/float_literals.wast:436
assert_malformed(
() => instantiate(`(global f64 (f64.const 0_x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:444
// ./test/core/float_literals.wast:440
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:448
// ./test/core/float_literals.wast:444
assert_malformed(() => instantiate(`(global f64 (f64.const 0x00_)) `), `unknown operator`);
// ./test/core/float_literals.wast:452
// ./test/core/float_literals.wast:448
assert_malformed(
() => instantiate(`(global f64 (f64.const 0xff__ffff)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:456
// ./test/core/float_literals.wast:452
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:460
// ./test/core/float_literals.wast:456
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:464
// ./test/core/float_literals.wast:460
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1_.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:468
// ./test/core/float_literals.wast:464
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1._0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:472
// ./test/core/float_literals.wast:468
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:476
// ./test/core/float_literals.wast:472
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:480
// ./test/core/float_literals.wast:476
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:484
// ./test/core/float_literals.wast:480
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:488
// ./test/core/float_literals.wast:484
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1.0p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:492
// ./test/core/float_literals.wast:488
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:496
// ./test/core/float_literals.wast:492
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:500
// ./test/core/float_literals.wast:496
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:504
// ./test/core/float_literals.wast:500
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:508
// ./test/core/float_literals.wast:504
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:512
assert_malformed(
() => instantiate(`(global f64 (f64.const nan:0x10_0000_0000_0000)) `),
`constant out of range`,
);

File diff suppressed because it is too large Load Diff

View File

@@ -198,9 +198,9 @@ let $0 = instantiate(`(module
(func (export "break-br_table-num") (param i32) (result i32)
(br_table 0 0 (i32.const 50) (local.get 0)) (i32.const 51)
)
(func (export "break-br_table-num-num") (param i32) (result f32 i64)
(br_table 0 0 (f32.const 50) (i64.const 51) (local.get 0))
(f32.const 51) (i64.const 52)
(func (export "break-br_table-num-num") (param i32) (result i32 i64)
(br_table 0 0 (i32.const 50) (i64.const 51) (local.get 0))
(i32.const 51) (i64.const 52)
)
(func (export "break-br_table-nested-empty") (param i32)
(block (br_table 0 1 0 (local.get 0)))
@@ -483,16 +483,16 @@ assert_return(() => invoke($0, `break-br_table-num`, [10]), [value("i32", 50)]);
assert_return(() => invoke($0, `break-br_table-num`, [-100]), [value("i32", 50)]);
// ./test/core/func.wast:355
assert_return(() => invoke($0, `break-br_table-num-num`, [0]), [value("f32", 50), value("i64", 51n)]);
assert_return(() => invoke($0, `break-br_table-num-num`, [0]), [value("i32", 50), value("i64", 51n)]);
// ./test/core/func.wast:358
assert_return(() => invoke($0, `break-br_table-num-num`, [1]), [value("f32", 50), value("i64", 51n)]);
assert_return(() => invoke($0, `break-br_table-num-num`, [1]), [value("i32", 50), value("i64", 51n)]);
// ./test/core/func.wast:361
assert_return(() => invoke($0, `break-br_table-num-num`, [10]), [value("f32", 50), value("i64", 51n)]);
assert_return(() => invoke($0, `break-br_table-num-num`, [10]), [value("i32", 50), value("i64", 51n)]);
// ./test/core/func.wast:364
assert_return(() => invoke($0, `break-br_table-num-num`, [-100]), [value("f32", 50), value("i64", 51n)]);
assert_return(() => invoke($0, `break-br_table-num-num`, [-100]), [value("i32", 50), value("i64", 51n)]);
// ./test/core/func.wast:367
assert_return(() => invoke($0, `break-br_table-nested-empty`, [0]), []);
@@ -798,95 +798,73 @@ assert_malformed(
`inline function type`,
);
// ./test/core/func.wast:630
assert_invalid(() => instantiate(`(module (func $$g (type 4)))`), `unknown type`);
// ./test/core/func.wast:634
assert_invalid(
() => instantiate(`(module
(func $$f (drop (ref.func $$g)))
(func $$g (type 4))
(elem declare func $$g)
)`),
`unknown type`,
);
// ./test/core/func.wast:646
// ./test/core/func.wast:633
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (result i64) (local i32) (local.get 0)))`),
`type mismatch`,
);
// ./test/core/func.wast:650
// ./test/core/func.wast:637
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (local f32) (i32.eqz (local.get 0))))`),
`type mismatch`,
);
// ./test/core/func.wast:654
// ./test/core/func.wast:641
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (local f64 i64) (f64.neg (local.get 1))))`),
`type mismatch`,
);
// ./test/core/func.wast:659
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$type-local-uninitialized (local $$x (ref $$t)) (drop (local.get $$x)))
)`),
`uninitialized local`,
);
// ./test/core/func.wast:670
// ./test/core/func.wast:649
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param i32) (result i64) (local.get 0)))`),
`type mismatch`,
);
// ./test/core/func.wast:674
// ./test/core/func.wast:653
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param f32) (i32.eqz (local.get 0))))`),
`type mismatch`,
);
// ./test/core/func.wast:678
// ./test/core/func.wast:657
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param f64 i64) (f64.neg (local.get 1))))`),
`type mismatch`,
);
// ./test/core/func.wast:686
// ./test/core/func.wast:665
assert_invalid(
() => instantiate(`(module (func $$type-empty-i32 (result i32)))`),
`type mismatch`,
);
// ./test/core/func.wast:690
// ./test/core/func.wast:669
assert_invalid(
() => instantiate(`(module (func $$type-empty-i64 (result i64)))`),
`type mismatch`,
);
// ./test/core/func.wast:694
// ./test/core/func.wast:673
assert_invalid(
() => instantiate(`(module (func $$type-empty-f32 (result f32)))`),
`type mismatch`,
);
// ./test/core/func.wast:698
// ./test/core/func.wast:677
assert_invalid(
() => instantiate(`(module (func $$type-empty-f64 (result f64)))`),
`type mismatch`,
);
// ./test/core/func.wast:702
// ./test/core/func.wast:681
assert_invalid(
() => instantiate(`(module (func $$type-empty-f64-i32 (result f64 i32)))`),
`type mismatch`,
);
// ./test/core/func.wast:707
// ./test/core/func.wast:686
assert_invalid(
() => instantiate(`(module (func $$type-value-void-vs-num (result i32)
(nop)
@@ -894,7 +872,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:713
// ./test/core/func.wast:692
assert_invalid(
() => instantiate(`(module (func $$type-value-void-vs-nums (result i32 i32)
(nop)
@@ -902,7 +880,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:719
// ./test/core/func.wast:698
assert_invalid(
() => instantiate(`(module (func $$type-value-num-vs-void
(i32.const 0)
@@ -910,7 +888,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:725
// ./test/core/func.wast:704
assert_invalid(
() => instantiate(`(module (func $$type-value-nums-vs-void
(i32.const 0) (i64.const 0)
@@ -918,7 +896,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:731
// ./test/core/func.wast:710
assert_invalid(
() => instantiate(`(module (func $$type-value-num-vs-num (result i32)
(f32.const 0)
@@ -926,7 +904,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:737
// ./test/core/func.wast:716
assert_invalid(
() => instantiate(`(module (func $$type-value-num-vs-nums (result f32 f32)
(f32.const 0)
@@ -934,7 +912,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:743
// ./test/core/func.wast:722
assert_invalid(
() => instantiate(`(module (func $$type-value-nums-vs-num (result f32)
(f32.const 0) (f32.const 0)
@@ -942,7 +920,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:750
// ./test/core/func.wast:729
assert_invalid(
() => instantiate(`(module (func $$type-return-last-empty-vs-num (result i32)
(return)
@@ -950,7 +928,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:756
// ./test/core/func.wast:735
assert_invalid(
() => instantiate(`(module (func $$type-return-last-empty-vs-nums (result i32 i32)
(return)
@@ -958,7 +936,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:762
// ./test/core/func.wast:741
assert_invalid(
() => instantiate(`(module (func $$type-return-last-void-vs-num (result i32)
(return (nop))
@@ -966,7 +944,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:768
// ./test/core/func.wast:747
assert_invalid(
() => instantiate(`(module (func $$type-return-last-void-vs-nums (result i32 i64)
(return (nop))
@@ -974,7 +952,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:774
// ./test/core/func.wast:753
assert_invalid(
() => instantiate(`(module (func $$type-return-last-num-vs-num (result i32)
(return (i64.const 0))
@@ -982,7 +960,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:780
// ./test/core/func.wast:759
assert_invalid(
() => instantiate(`(module (func $$type-return-last-num-vs-nums (result i64 i64)
(return (i64.const 0))
@@ -990,7 +968,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:787
// ./test/core/func.wast:766
assert_invalid(
() => instantiate(`(module (func $$type-return-empty-vs-num (result i32)
(return) (i32.const 1)
@@ -998,7 +976,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:793
// ./test/core/func.wast:772
assert_invalid(
() => instantiate(`(module (func $$type-return-empty-vs-nums (result i32 i32)
(return) (i32.const 1) (i32.const 2)
@@ -1006,7 +984,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:799
// ./test/core/func.wast:778
assert_invalid(
() => instantiate(`(module (func $$type-return-partial-vs-nums (result i32 i32)
(i32.const 1) (return) (i32.const 2)
@@ -1014,7 +992,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:805
// ./test/core/func.wast:784
assert_invalid(
() => instantiate(`(module (func $$type-return-void-vs-num (result i32)
(return (nop)) (i32.const 1)
@@ -1022,7 +1000,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:811
// ./test/core/func.wast:790
assert_invalid(
() => instantiate(`(module (func $$type-return-void-vs-nums (result i32 i32)
(return (nop)) (i32.const 1)
@@ -1030,7 +1008,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:817
// ./test/core/func.wast:796
assert_invalid(
() => instantiate(`(module (func $$type-return-num-vs-num (result i32)
(return (i64.const 1)) (i32.const 1)
@@ -1038,7 +1016,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:823
// ./test/core/func.wast:802
assert_invalid(
() => instantiate(`(module (func $$type-return-num-vs-nums (result i32 i32)
(return (i64.const 1)) (i32.const 1) (i32.const 2)
@@ -1046,7 +1024,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:829
// ./test/core/func.wast:808
assert_invalid(
() => instantiate(`(module (func $$type-return-first-num-vs-num (result i32)
(return (i64.const 1)) (return (i32.const 1))
@@ -1054,7 +1032,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:835
// ./test/core/func.wast:814
assert_invalid(
() => instantiate(`(module (func $$type-return-first-num-vs-nums (result i32 i32)
(return (i32.const 1)) (return (i32.const 1) (i32.const 2))
@@ -1062,7 +1040,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:842
// ./test/core/func.wast:821
assert_invalid(
() => instantiate(`(module (func $$type-break-last-void-vs-num (result i32)
(br 0)
@@ -1070,7 +1048,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:848
// ./test/core/func.wast:827
assert_invalid(
() => instantiate(`(module (func $$type-break-last-void-vs-nums (result i32 i32)
(br 0)
@@ -1078,7 +1056,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:854
// ./test/core/func.wast:833
assert_invalid(
() => instantiate(`(module (func $$type-break-last-num-vs-num (result i32)
(br 0 (f32.const 0))
@@ -1086,7 +1064,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:860
// ./test/core/func.wast:839
assert_invalid(
() => instantiate(`(module (func $$type-break-last-num-vs-nums (result i32 i32)
(br 0 (i32.const 0))
@@ -1094,7 +1072,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:866
// ./test/core/func.wast:845
assert_invalid(
() => instantiate(`(module (func $$type-break-void-vs-num (result i32)
(br 0) (i32.const 1)
@@ -1102,7 +1080,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:872
// ./test/core/func.wast:851
assert_invalid(
() => instantiate(`(module (func $$type-break-void-vs-nums (result i32 i32)
(br 0) (i32.const 1) (i32.const 2)
@@ -1110,7 +1088,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:878
// ./test/core/func.wast:857
assert_invalid(
() => instantiate(`(module (func $$type-break-num-vs-num (result i32)
(br 0 (i64.const 1)) (i32.const 1)
@@ -1118,7 +1096,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:884
// ./test/core/func.wast:863
assert_invalid(
() => instantiate(`(module (func $$type-break-num-vs-nums (result i32 i32)
(br 0 (i32.const 1)) (i32.const 1) (i32.const 2)
@@ -1126,7 +1104,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:890
// ./test/core/func.wast:869
assert_invalid(
() => instantiate(`(module (func $$type-break-first-num-vs-num (result i32)
(br 0 (i64.const 1)) (br 0 (i32.const 1))
@@ -1134,7 +1112,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:897
// ./test/core/func.wast:876
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-empty-vs-num (result i32)
(block (br 1)) (br 0 (i32.const 1))
@@ -1142,7 +1120,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:903
// ./test/core/func.wast:882
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-empty-vs-nums (result i32 i32)
(block (br 1)) (br 0 (i32.const 1) (i32.const 2))
@@ -1150,7 +1128,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:909
// ./test/core/func.wast:888
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-void-vs-num (result i32)
(block (br 1 (nop))) (br 0 (i32.const 1))
@@ -1158,7 +1136,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:915
// ./test/core/func.wast:894
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-void-vs-nums (result i32 i32)
(block (br 1 (nop))) (br 0 (i32.const 1) (i32.const 2))
@@ -1166,7 +1144,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:921
// ./test/core/func.wast:900
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-num-vs-num (result i32)
(block (br 1 (i64.const 1))) (br 0 (i32.const 1))
@@ -1174,7 +1152,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:927
// ./test/core/func.wast:906
assert_invalid(
() => instantiate(`(module (func $$type-break-nested-num-vs-nums (result i32 i32)
(block (result i32) (br 1 (i32.const 1))) (br 0 (i32.const 1) (i32.const 2))
@@ -1182,58 +1160,58 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/func.wast:937
// ./test/core/func.wast:916
assert_malformed(() => instantiate(`(func (nop) (local i32)) `), `unexpected token`);
// ./test/core/func.wast:941
// ./test/core/func.wast:920
assert_malformed(() => instantiate(`(func (nop) (param i32)) `), `unexpected token`);
// ./test/core/func.wast:945
// ./test/core/func.wast:924
assert_malformed(() => instantiate(`(func (nop) (result i32)) `), `unexpected token`);
// ./test/core/func.wast:949
// ./test/core/func.wast:928
assert_malformed(() => instantiate(`(func (local i32) (param i32)) `), `unexpected token`);
// ./test/core/func.wast:953
// ./test/core/func.wast:932
assert_malformed(
() => instantiate(`(func (local i32) (result i32) (local.get 0)) `),
`unexpected token`,
);
// ./test/core/func.wast:957
// ./test/core/func.wast:936
assert_malformed(
() => instantiate(`(func (result i32) (param i32) (local.get 0)) `),
`unexpected token`,
);
// ./test/core/func.wast:964
// ./test/core/func.wast:943
assert_malformed(() => instantiate(`(func $$foo) (func $$foo) `), `duplicate func`);
// ./test/core/func.wast:968
// ./test/core/func.wast:947
assert_malformed(
() => instantiate(`(import "" "" (func $$foo)) (func $$foo) `),
`duplicate func`,
);
// ./test/core/func.wast:972
// ./test/core/func.wast:951
assert_malformed(
() => instantiate(`(import "" "" (func $$foo)) (import "" "" (func $$foo)) `),
`duplicate func`,
);
// ./test/core/func.wast:977
// ./test/core/func.wast:956
assert_malformed(
() => instantiate(`(func (param $$foo i32) (param $$foo i32)) `),
`duplicate local`,
);
// ./test/core/func.wast:981
// ./test/core/func.wast:958
assert_malformed(
() => instantiate(`(func (param $$foo i32) (local $$foo i32)) `),
`duplicate local`,
);
// ./test/core/func.wast:985
// ./test/core/func.wast:960
assert_malformed(
() => instantiate(`(func (local $$foo i32) (local $$foo i32)) `),
`duplicate local`,

View File

@@ -193,16 +193,10 @@ let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
function module(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
return module;
}
function instantiate(source) {
@@ -212,18 +206,23 @@ function instantiate(source) {
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
function instantiateFromModule(module) {
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
function register(instance, name) {
linkage[name] = instance;
}
function invoke(instance, field, params) {
let func = instance[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
function get(instance, field) {
let global = instance[field];
assertEq(
global instanceof WebAssembly.Global,
true,

View File

@@ -0,0 +1,680 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/linking.wast
// ./test/core/linking.wast:3
let $0 = instantiate(`(module $$Mf
(func (export "call") (result i32) (call $$g))
(func $$g (result i32) (i32.const 2))
)`);
let $Mf = $0;
// ./test/core/linking.wast:7
register($Mf, `Mf`);
// ./test/core/linking.wast:9
let $1 = instantiate(`(module $$Nf
(func $$f (import "Mf" "call") (result i32))
(export "Mf.call" (func $$f))
(func (export "call Mf.call") (result i32) (call $$f))
(func (export "call") (result i32) (call $$g))
(func $$g (result i32) (i32.const 3))
)`);
let $Nf = $1;
// ./test/core/linking.wast:17
assert_return(() => invoke($Mf, `call`, []), [value("i32", 2)]);
// ./test/core/linking.wast:18
assert_return(() => invoke($Nf, `Mf.call`, []), [value("i32", 2)]);
// ./test/core/linking.wast:19
assert_return(() => invoke($Nf, `call`, []), [value("i32", 3)]);
// ./test/core/linking.wast:20
assert_return(() => invoke($Nf, `call Mf.call`, []), [value("i32", 2)]);
// ./test/core/linking.wast:22
let $2 = instantiate(`(module
(import "spectest" "print_i32" (func $$f (param i32)))
(export "print" (func $$f))
)`);
// ./test/core/linking.wast:26
register($2, `reexport_f`);
// ./test/core/linking.wast:27
assert_unlinkable(
() => instantiate(`(module (import "reexport_f" "print" (func (param i64))))`),
`incompatible import type`,
);
// ./test/core/linking.wast:31
assert_unlinkable(
() => instantiate(`(module (import "reexport_f" "print" (func (param i32) (result i32))))`),
`incompatible import type`,
);
// ./test/core/linking.wast:39
let $3 = instantiate(`(module $$Mg
(global $$glob (export "glob") i32 (i32.const 42))
(func (export "get") (result i32) (global.get $$glob))
;; export mutable globals
(global $$mut_glob (export "mut_glob") (mut i32) (i32.const 142))
(func (export "get_mut") (result i32) (global.get $$mut_glob))
(func (export "set_mut") (param i32) (global.set $$mut_glob (local.get 0)))
)`);
let $Mg = $3;
// ./test/core/linking.wast:48
register($Mg, `Mg`);
// ./test/core/linking.wast:50
let $4 = instantiate(`(module $$Ng
(global $$x (import "Mg" "glob") i32)
(global $$mut_glob (import "Mg" "mut_glob") (mut i32))
(func $$f (import "Mg" "get") (result i32))
(func $$get_mut (import "Mg" "get_mut") (result i32))
(func $$set_mut (import "Mg" "set_mut") (param i32))
(export "Mg.glob" (global $$x))
(export "Mg.get" (func $$f))
(global $$glob (export "glob") i32 (i32.const 43))
(func (export "get") (result i32) (global.get $$glob))
(export "Mg.mut_glob" (global $$mut_glob))
(export "Mg.get_mut" (func $$get_mut))
(export "Mg.set_mut" (func $$set_mut))
)`);
let $Ng = $4;
// ./test/core/linking.wast:67
assert_return(() => get($Mg, `glob`), [value("i32", 42)]);
// ./test/core/linking.wast:68
assert_return(() => get($Ng, `Mg.glob`), [value("i32", 42)]);
// ./test/core/linking.wast:69
assert_return(() => get($Ng, `glob`), [value("i32", 43)]);
// ./test/core/linking.wast:70
assert_return(() => invoke($Mg, `get`, []), [value("i32", 42)]);
// ./test/core/linking.wast:71
assert_return(() => invoke($Ng, `Mg.get`, []), [value("i32", 42)]);
// ./test/core/linking.wast:72
assert_return(() => invoke($Ng, `get`, []), [value("i32", 43)]);
// ./test/core/linking.wast:74
assert_return(() => get($Mg, `mut_glob`), [value("i32", 142)]);
// ./test/core/linking.wast:75
assert_return(() => get($Ng, `Mg.mut_glob`), [value("i32", 142)]);
// ./test/core/linking.wast:76
assert_return(() => invoke($Mg, `get_mut`, []), [value("i32", 142)]);
// ./test/core/linking.wast:77
assert_return(() => invoke($Ng, `Mg.get_mut`, []), [value("i32", 142)]);
// ./test/core/linking.wast:79
assert_return(() => invoke($Mg, `set_mut`, [241]), []);
// ./test/core/linking.wast:80
assert_return(() => get($Mg, `mut_glob`), [value("i32", 241)]);
// ./test/core/linking.wast:81
assert_return(() => get($Ng, `Mg.mut_glob`), [value("i32", 241)]);
// ./test/core/linking.wast:82
assert_return(() => invoke($Mg, `get_mut`, []), [value("i32", 241)]);
// ./test/core/linking.wast:83
assert_return(() => invoke($Ng, `Mg.get_mut`, []), [value("i32", 241)]);
// ./test/core/linking.wast:86
assert_unlinkable(
() => instantiate(`(module (import "Mg" "mut_glob" (global i32)))`),
`incompatible import type`,
);
// ./test/core/linking.wast:90
assert_unlinkable(
() => instantiate(`(module (import "Mg" "glob" (global (mut i32))))`),
`incompatible import type`,
);
// ./test/core/linking.wast:96
let $5 = instantiate(`(module $$Mref_ex
(global (export "g-const-func") funcref (ref.null func))
(global (export "g-var-func") (mut funcref) (ref.null func))
(global (export "g-const-extern") externref (ref.null extern))
(global (export "g-var-extern") (mut externref) (ref.null extern))
)`);
let $Mref_ex = $5;
// ./test/core/linking.wast:102
register($Mref_ex, `Mref_ex`);
// ./test/core/linking.wast:104
let $6 = instantiate(`(module $$Mref_im
(global (import "Mref_ex" "g-const-func") funcref)
(global (import "Mref_ex" "g-const-extern") externref)
(global (import "Mref_ex" "g-var-func") (mut funcref))
(global (import "Mref_ex" "g-var-extern") (mut externref))
)`);
let $Mref_im = $6;
// ./test/core/linking.wast:112
assert_unlinkable(
() => instantiate(`(module (global (import "Mref_ex" "g-const-extern") funcref))`),
`incompatible import type`,
);
// ./test/core/linking.wast:116
assert_unlinkable(
() => instantiate(`(module (global (import "Mref_ex" "g-const-func") externref))`),
`incompatible import type`,
);
// ./test/core/linking.wast:122
assert_unlinkable(
() => instantiate(`(module (global (import "Mref_ex" "g-var-func") (mut externref)))`),
`incompatible import type`,
);
// ./test/core/linking.wast:126
assert_unlinkable(
() => instantiate(`(module (global (import "Mref_ex" "g-var-extern") (mut funcref)))`),
`incompatible import type`,
);
// ./test/core/linking.wast:134
let $7 = instantiate(`(module $$Mt
(type (func (result i32)))
(type (func))
(table (export "tab") 10 funcref)
(elem (i32.const 2) $$g $$g $$g $$g)
(func $$g (result i32) (i32.const 4))
(func (export "h") (result i32) (i32.const -4))
(func (export "call") (param i32) (result i32)
(call_indirect (type 0) (local.get 0))
)
)`);
let $Mt = $7;
// ./test/core/linking.wast:147
register($Mt, `Mt`);
// ./test/core/linking.wast:149
let $8 = instantiate(`(module $$Nt
(type (func))
(type (func (result i32)))
(func $$f (import "Mt" "call") (param i32) (result i32))
(func $$h (import "Mt" "h") (result i32))
(table funcref (elem $$g $$g $$g $$h $$f))
(func $$g (result i32) (i32.const 5))
(export "Mt.call" (func $$f))
(func (export "call Mt.call") (param i32) (result i32)
(call $$f (local.get 0))
)
(func (export "call") (param i32) (result i32)
(call_indirect (type 1) (local.get 0))
)
)`);
let $Nt = $8;
// ./test/core/linking.wast:168
assert_return(() => invoke($Mt, `call`, [2]), [value("i32", 4)]);
// ./test/core/linking.wast:169
assert_return(() => invoke($Nt, `Mt.call`, [2]), [value("i32", 4)]);
// ./test/core/linking.wast:170
assert_return(() => invoke($Nt, `call`, [2]), [value("i32", 5)]);
// ./test/core/linking.wast:171
assert_return(() => invoke($Nt, `call Mt.call`, [2]), [value("i32", 4)]);
// ./test/core/linking.wast:173
assert_trap(() => invoke($Mt, `call`, [1]), `uninitialized element`);
// ./test/core/linking.wast:174
assert_trap(() => invoke($Nt, `Mt.call`, [1]), `uninitialized element`);
// ./test/core/linking.wast:175
assert_return(() => invoke($Nt, `call`, [1]), [value("i32", 5)]);
// ./test/core/linking.wast:176
assert_trap(() => invoke($Nt, `call Mt.call`, [1]), `uninitialized element`);
// ./test/core/linking.wast:178
assert_trap(() => invoke($Mt, `call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:179
assert_trap(() => invoke($Nt, `Mt.call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:180
assert_return(() => invoke($Nt, `call`, [0]), [value("i32", 5)]);
// ./test/core/linking.wast:181
assert_trap(() => invoke($Nt, `call Mt.call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:183
assert_trap(() => invoke($Mt, `call`, [20]), `undefined element`);
// ./test/core/linking.wast:184
assert_trap(() => invoke($Nt, `Mt.call`, [20]), `undefined element`);
// ./test/core/linking.wast:185
assert_trap(() => invoke($Nt, `call`, [7]), `undefined element`);
// ./test/core/linking.wast:186
assert_trap(() => invoke($Nt, `call Mt.call`, [20]), `undefined element`);
// ./test/core/linking.wast:188
assert_return(() => invoke($Nt, `call`, [3]), [value("i32", -4)]);
// ./test/core/linking.wast:189
assert_trap(() => invoke($Nt, `call`, [4]), `indirect call type mismatch`);
// ./test/core/linking.wast:191
let $9 = instantiate(`(module $$Ot
(type (func (result i32)))
(func $$h (import "Mt" "h") (result i32))
(table (import "Mt" "tab") 5 funcref)
(elem (i32.const 1) $$i $$h)
(func $$i (result i32) (i32.const 6))
(func (export "call") (param i32) (result i32)
(call_indirect (type 0) (local.get 0))
)
)`);
let $Ot = $9;
// ./test/core/linking.wast:204
assert_return(() => invoke($Mt, `call`, [3]), [value("i32", 4)]);
// ./test/core/linking.wast:205
assert_return(() => invoke($Nt, `Mt.call`, [3]), [value("i32", 4)]);
// ./test/core/linking.wast:206
assert_return(() => invoke($Nt, `call Mt.call`, [3]), [value("i32", 4)]);
// ./test/core/linking.wast:207
assert_return(() => invoke($Ot, `call`, [3]), [value("i32", 4)]);
// ./test/core/linking.wast:209
assert_return(() => invoke($Mt, `call`, [2]), [value("i32", -4)]);
// ./test/core/linking.wast:210
assert_return(() => invoke($Nt, `Mt.call`, [2]), [value("i32", -4)]);
// ./test/core/linking.wast:211
assert_return(() => invoke($Nt, `call`, [2]), [value("i32", 5)]);
// ./test/core/linking.wast:212
assert_return(() => invoke($Nt, `call Mt.call`, [2]), [value("i32", -4)]);
// ./test/core/linking.wast:213
assert_return(() => invoke($Ot, `call`, [2]), [value("i32", -4)]);
// ./test/core/linking.wast:215
assert_return(() => invoke($Mt, `call`, [1]), [value("i32", 6)]);
// ./test/core/linking.wast:216
assert_return(() => invoke($Nt, `Mt.call`, [1]), [value("i32", 6)]);
// ./test/core/linking.wast:217
assert_return(() => invoke($Nt, `call`, [1]), [value("i32", 5)]);
// ./test/core/linking.wast:218
assert_return(() => invoke($Nt, `call Mt.call`, [1]), [value("i32", 6)]);
// ./test/core/linking.wast:219
assert_return(() => invoke($Ot, `call`, [1]), [value("i32", 6)]);
// ./test/core/linking.wast:221
assert_trap(() => invoke($Mt, `call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:222
assert_trap(() => invoke($Nt, `Mt.call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:223
assert_return(() => invoke($Nt, `call`, [0]), [value("i32", 5)]);
// ./test/core/linking.wast:224
assert_trap(() => invoke($Nt, `call Mt.call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:225
assert_trap(() => invoke($Ot, `call`, [0]), `uninitialized element`);
// ./test/core/linking.wast:227
assert_trap(() => invoke($Ot, `call`, [20]), `undefined element`);
// ./test/core/linking.wast:229
let $10 = instantiate(`(module
(table (import "Mt" "tab") 0 funcref)
(elem (i32.const 9) $$f)
(func $$f)
)`);
// ./test/core/linking.wast:235
let $11 = instantiate(`(module $$G1 (global (export "g") i32 (i32.const 5)))`);
let $G1 = $11;
// ./test/core/linking.wast:236
register($G1, `G1`);
// ./test/core/linking.wast:237
let $12 = instantiate(`(module $$G2
(global (import "G1" "g") i32)
(global (export "g") i32 (global.get 0))
)`);
let $G2 = $12;
// ./test/core/linking.wast:241
assert_return(() => get($G2, `g`), [value("i32", 5)]);
// ./test/core/linking.wast:243
assert_trap(
() => instantiate(`(module
(table (import "Mt" "tab") 0 funcref)
(elem (i32.const 10) $$f)
(func $$f)
)`),
`out of bounds table access`,
);
// ./test/core/linking.wast:252
assert_unlinkable(
() => instantiate(`(module
(table (import "Mt" "tab") 10 funcref)
(memory (import "Mt" "mem") 1) ;; does not exist
(func $$f (result i32) (i32.const 0))
(elem (i32.const 7) $$f)
(elem (i32.const 9) $$f)
)`),
`unknown import`,
);
// ./test/core/linking.wast:262
assert_trap(() => invoke($Mt, `call`, [7]), `uninitialized element`);
// ./test/core/linking.wast:266
assert_trap(
() => instantiate(`(module
(table (import "Mt" "tab") 10 funcref)
(func $$f (result i32) (i32.const 0))
(elem (i32.const 7) $$f)
(elem (i32.const 8) $$f $$f $$f $$f $$f) ;; (partially) out of bounds
)`),
`out of bounds table access`,
);
// ./test/core/linking.wast:275
assert_return(() => invoke($Mt, `call`, [7]), [value("i32", 0)]);
// ./test/core/linking.wast:276
assert_trap(() => invoke($Mt, `call`, [8]), `uninitialized element`);
// ./test/core/linking.wast:278
assert_trap(
() => instantiate(`(module
(table (import "Mt" "tab") 10 funcref)
(func $$f (result i32) (i32.const 0))
(elem (i32.const 7) $$f)
(memory 1)
(data (i32.const 0x10000) "d") ;; out of bounds
)`),
`out of bounds memory access`,
);
// ./test/core/linking.wast:288
assert_return(() => invoke($Mt, `call`, [7]), [value("i32", 0)]);
// ./test/core/linking.wast:291
let $13 = instantiate(`(module $$Mtable_ex
(table $$t1 (export "t-func") 1 funcref)
(table $$t2 (export "t-extern") 1 externref)
)`);
let $Mtable_ex = $13;
// ./test/core/linking.wast:295
register($Mtable_ex, `Mtable_ex`);
// ./test/core/linking.wast:297
let $14 = instantiate(`(module
(table (import "Mtable_ex" "t-func") 1 funcref)
(table (import "Mtable_ex" "t-extern") 1 externref)
)`);
// ./test/core/linking.wast:302
assert_unlinkable(
() => instantiate(`(module (table (import "Mtable_ex" "t-func") 1 externref))`),
`incompatible import type`,
);
// ./test/core/linking.wast:306
assert_unlinkable(
() => instantiate(`(module (table (import "Mtable_ex" "t-extern") 1 funcref))`),
`incompatible import type`,
);
// ./test/core/linking.wast:314
let $15 = instantiate(`(module $$Mm
(memory (export "mem") 1 5)
(data (i32.const 10) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09")
(func (export "load") (param $$a i32) (result i32)
(i32.load8_u (local.get 0))
)
)`);
let $Mm = $15;
// ./test/core/linking.wast:322
register($Mm, `Mm`);
// ./test/core/linking.wast:324
let $16 = instantiate(`(module $$Nm
(func $$loadM (import "Mm" "load") (param i32) (result i32))
(memory 1)
(data (i32.const 10) "\\f0\\f1\\f2\\f3\\f4\\f5")
(export "Mm.load" (func $$loadM))
(func (export "load") (param $$a i32) (result i32)
(i32.load8_u (local.get 0))
)
)`);
let $Nm = $16;
// ./test/core/linking.wast:336
assert_return(() => invoke($Mm, `load`, [12]), [value("i32", 2)]);
// ./test/core/linking.wast:337
assert_return(() => invoke($Nm, `Mm.load`, [12]), [value("i32", 2)]);
// ./test/core/linking.wast:338
assert_return(() => invoke($Nm, `load`, [12]), [value("i32", 242)]);
// ./test/core/linking.wast:340
let $17 = instantiate(`(module $$Om
(memory (import "Mm" "mem") 1)
(data (i32.const 5) "\\a0\\a1\\a2\\a3\\a4\\a5\\a6\\a7")
(func (export "load") (param $$a i32) (result i32)
(i32.load8_u (local.get 0))
)
)`);
let $Om = $17;
// ./test/core/linking.wast:349
assert_return(() => invoke($Mm, `load`, [12]), [value("i32", 167)]);
// ./test/core/linking.wast:350
assert_return(() => invoke($Nm, `Mm.load`, [12]), [value("i32", 167)]);
// ./test/core/linking.wast:351
assert_return(() => invoke($Nm, `load`, [12]), [value("i32", 242)]);
// ./test/core/linking.wast:352
assert_return(() => invoke($Om, `load`, [12]), [value("i32", 167)]);
// ./test/core/linking.wast:354
let $18 = instantiate(`(module
(memory (import "Mm" "mem") 0)
(data (i32.const 0xffff) "a")
)`);
// ./test/core/linking.wast:359
assert_trap(
() => instantiate(`(module
(memory (import "Mm" "mem") 0)
(data (i32.const 0x10000) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/linking.wast:367
let $19 = instantiate(`(module $$Pm
(memory (import "Mm" "mem") 1 8)
(func (export "grow") (param $$a i32) (result i32)
(memory.grow (local.get 0))
)
)`);
let $Pm = $19;
// ./test/core/linking.wast:375
assert_return(() => invoke($Pm, `grow`, [0]), [value("i32", 1)]);
// ./test/core/linking.wast:376
assert_return(() => invoke($Pm, `grow`, [2]), [value("i32", 1)]);
// ./test/core/linking.wast:377
assert_return(() => invoke($Pm, `grow`, [0]), [value("i32", 3)]);
// ./test/core/linking.wast:378
assert_return(() => invoke($Pm, `grow`, [1]), [value("i32", 3)]);
// ./test/core/linking.wast:379
assert_return(() => invoke($Pm, `grow`, [1]), [value("i32", 4)]);
// ./test/core/linking.wast:380
assert_return(() => invoke($Pm, `grow`, [0]), [value("i32", 5)]);
// ./test/core/linking.wast:381
assert_return(() => invoke($Pm, `grow`, [1]), [value("i32", -1)]);
// ./test/core/linking.wast:382
assert_return(() => invoke($Pm, `grow`, [0]), [value("i32", 5)]);
// ./test/core/linking.wast:384
assert_unlinkable(
() => instantiate(`(module
(func $$host (import "spectest" "print"))
(memory (import "Mm" "mem") 1)
(table (import "Mm" "tab") 0 funcref) ;; does not exist
(data (i32.const 0) "abc")
)`),
`unknown import`,
);
// ./test/core/linking.wast:393
assert_return(() => invoke($Mm, `load`, [0]), [value("i32", 0)]);
// ./test/core/linking.wast:397
assert_trap(
() => instantiate(`(module
;; Note: the memory is 5 pages large by the time we get here.
(memory (import "Mm" "mem") 1)
(data (i32.const 0) "abc")
(data (i32.const 327670) "zzzzzzzzzzzzzzzzzz") ;; (partially) out of bounds
)`),
`out of bounds memory access`,
);
// ./test/core/linking.wast:406
assert_return(() => invoke($Mm, `load`, [0]), [value("i32", 97)]);
// ./test/core/linking.wast:407
assert_return(() => invoke($Mm, `load`, [327670]), [value("i32", 0)]);
// ./test/core/linking.wast:409
assert_trap(
() => instantiate(`(module
(memory (import "Mm" "mem") 1)
(data (i32.const 0) "abc")
(table 0 funcref)
(func)
(elem (i32.const 0) 0) ;; out of bounds
)`),
`out of bounds table access`,
);
// ./test/core/linking.wast:419
assert_return(() => invoke($Mm, `load`, [0]), [value("i32", 97)]);
// ./test/core/linking.wast:422
let $20 = instantiate(`(module $$Ms
(type $$t (func (result i32)))
(memory (export "memory") 1)
(table (export "table") 1 funcref)
(func (export "get memory[0]") (type $$t)
(i32.load8_u (i32.const 0))
)
(func (export "get table[0]") (type $$t)
(call_indirect (type $$t) (i32.const 0))
)
)`);
let $Ms = $20;
// ./test/core/linking.wast:433
register($Ms, `Ms`);
// ./test/core/linking.wast:435
assert_trap(
() => instantiate(`(module
(import "Ms" "memory" (memory 1))
(import "Ms" "table" (table 1 funcref))
(data (i32.const 0) "hello")
(elem (i32.const 0) $$f)
(func $$f (result i32)
(i32.const 0xdead)
)
(func $$main
(unreachable)
)
(start $$main)
)`),
`unreachable`,
);
// ./test/core/linking.wast:452
assert_return(() => invoke($Ms, `get memory[0]`, []), [value("i32", 104)]);
// ./test/core/linking.wast:453
assert_return(() => invoke($Ms, `get table[0]`, []), [value("i32", 57005)]);

View File

@@ -17,102 +17,6 @@
// ./test/core/load.wast:3
let $0 = instantiate(`(module
(memory $$mem1 1)
(memory $$mem2 1)
(func (export "load1") (param i32) (result i64)
(i64.load $$mem1 (local.get 0))
)
(func (export "load2") (param i32) (result i64)
(i64.load $$mem2 (local.get 0))
)
(data (memory $$mem1) (i32.const 0) "\\01")
(data (memory $$mem2) (i32.const 0) "\\02")
)`);
// ./test/core/load.wast:18
assert_return(() => invoke($0, `load1`, [0]), [value("i64", 1n)]);
// ./test/core/load.wast:19
assert_return(() => invoke($0, `load2`, [0]), [value("i64", 2n)]);
// ./test/core/load.wast:22
let $1 = instantiate(`(module $$M
(memory (export "mem") 2)
(func (export "read") (param i32) (result i32)
(i32.load8_u (local.get 0))
)
)`);
register($1, `M`);
// ./test/core/load.wast:29
register($1, `M`);
// ./test/core/load.wast:31
let $2 = instantiate(`(module
(memory $$mem1 (import "M" "mem") 2)
(memory $$mem2 3)
(data (memory $$mem1) (i32.const 20) "\\01\\02\\03\\04\\05")
(data (memory $$mem2) (i32.const 50) "\\0A\\0B\\0C\\0D\\0E")
(func (export "read1") (param i32) (result i32)
(i32.load8_u $$mem1 (local.get 0))
)
(func (export "read2") (param i32) (result i32)
(i32.load8_u $$mem2 (local.get 0))
)
)`);
// ./test/core/load.wast:46
assert_return(() => invoke(`M`, `read`, [20]), [value("i32", 1)]);
// ./test/core/load.wast:47
assert_return(() => invoke(`M`, `read`, [21]), [value("i32", 2)]);
// ./test/core/load.wast:48
assert_return(() => invoke(`M`, `read`, [22]), [value("i32", 3)]);
// ./test/core/load.wast:49
assert_return(() => invoke(`M`, `read`, [23]), [value("i32", 4)]);
// ./test/core/load.wast:50
assert_return(() => invoke(`M`, `read`, [24]), [value("i32", 5)]);
// ./test/core/load.wast:52
assert_return(() => invoke($2, `read1`, [20]), [value("i32", 1)]);
// ./test/core/load.wast:53
assert_return(() => invoke($2, `read1`, [21]), [value("i32", 2)]);
// ./test/core/load.wast:54
assert_return(() => invoke($2, `read1`, [22]), [value("i32", 3)]);
// ./test/core/load.wast:55
assert_return(() => invoke($2, `read1`, [23]), [value("i32", 4)]);
// ./test/core/load.wast:56
assert_return(() => invoke($2, `read1`, [24]), [value("i32", 5)]);
// ./test/core/load.wast:58
assert_return(() => invoke($2, `read2`, [50]), [value("i32", 10)]);
// ./test/core/load.wast:59
assert_return(() => invoke($2, `read2`, [51]), [value("i32", 11)]);
// ./test/core/load.wast:60
assert_return(() => invoke($2, `read2`, [52]), [value("i32", 12)]);
// ./test/core/load.wast:61
assert_return(() => invoke($2, `read2`, [53]), [value("i32", 13)]);
// ./test/core/load.wast:62
assert_return(() => invoke($2, `read2`, [54]), [value("i32", 14)]);
// ./test/core/load.wast:67
let $3 = instantiate(`(module
(memory 1)
(func (export "as-br-value") (result i32)
@@ -270,364 +174,364 @@ let $3 = instantiate(`(module
)
)`);
// ./test/core/load.wast:225
assert_return(() => invoke($3, `as-br-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:161
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:227
assert_return(() => invoke($3, `as-br_if-cond`, []), []);
// ./test/core/load.wast:163
assert_return(() => invoke($0, `as-br_if-cond`, []), []);
// ./test/core/load.wast:228
assert_return(() => invoke($3, `as-br_if-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:164
assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:229
assert_return(() => invoke($3, `as-br_if-value-cond`, []), [value("i32", 7)]);
// ./test/core/load.wast:165
assert_return(() => invoke($0, `as-br_if-value-cond`, []), [value("i32", 7)]);
// ./test/core/load.wast:231
assert_return(() => invoke($3, `as-br_table-index`, []), []);
// ./test/core/load.wast:167
assert_return(() => invoke($0, `as-br_table-index`, []), []);
// ./test/core/load.wast:232
assert_return(() => invoke($3, `as-br_table-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:168
assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:233
assert_return(() => invoke($3, `as-br_table-value-index`, []), [value("i32", 6)]);
// ./test/core/load.wast:169
assert_return(() => invoke($0, `as-br_table-value-index`, []), [value("i32", 6)]);
// ./test/core/load.wast:235
assert_return(() => invoke($3, `as-return-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:171
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:237
assert_return(() => invoke($3, `as-if-cond`, []), [value("i32", 1)]);
// ./test/core/load.wast:173
assert_return(() => invoke($0, `as-if-cond`, []), [value("i32", 1)]);
// ./test/core/load.wast:238
assert_return(() => invoke($3, `as-if-then`, []), [value("i32", 0)]);
// ./test/core/load.wast:174
assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 0)]);
// ./test/core/load.wast:239
assert_return(() => invoke($3, `as-if-else`, []), [value("i32", 0)]);
// ./test/core/load.wast:175
assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 0)]);
// ./test/core/load.wast:241
assert_return(() => invoke($3, `as-select-first`, [0, 1]), [value("i32", 0)]);
// ./test/core/load.wast:177
assert_return(() => invoke($0, `as-select-first`, [0, 1]), [value("i32", 0)]);
// ./test/core/load.wast:242
assert_return(() => invoke($3, `as-select-second`, [0, 0]), [value("i32", 0)]);
// ./test/core/load.wast:178
assert_return(() => invoke($0, `as-select-second`, [0, 0]), [value("i32", 0)]);
// ./test/core/load.wast:243
assert_return(() => invoke($3, `as-select-cond`, []), [value("i32", 1)]);
// ./test/core/load.wast:179
assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 1)]);
// ./test/core/load.wast:245
assert_return(() => invoke($3, `as-call-first`, []), [value("i32", -1)]);
// ./test/core/load.wast:181
assert_return(() => invoke($0, `as-call-first`, []), [value("i32", -1)]);
// ./test/core/load.wast:246
assert_return(() => invoke($3, `as-call-mid`, []), [value("i32", -1)]);
// ./test/core/load.wast:182
assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", -1)]);
// ./test/core/load.wast:247
assert_return(() => invoke($3, `as-call-last`, []), [value("i32", -1)]);
// ./test/core/load.wast:183
assert_return(() => invoke($0, `as-call-last`, []), [value("i32", -1)]);
// ./test/core/load.wast:249
assert_return(() => invoke($3, `as-call_indirect-first`, []), [value("i32", -1)]);
// ./test/core/load.wast:185
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", -1)]);
// ./test/core/load.wast:250
assert_return(() => invoke($3, `as-call_indirect-mid`, []), [value("i32", -1)]);
// ./test/core/load.wast:186
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", -1)]);
// ./test/core/load.wast:251
assert_return(() => invoke($3, `as-call_indirect-last`, []), [value("i32", -1)]);
// ./test/core/load.wast:187
assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", -1)]);
// ./test/core/load.wast:252
assert_return(() => invoke($3, `as-call_indirect-index`, []), [value("i32", -1)]);
// ./test/core/load.wast:188
assert_return(() => invoke($0, `as-call_indirect-index`, []), [value("i32", -1)]);
// ./test/core/load.wast:254
assert_return(() => invoke($3, `as-local.set-value`, []), []);
// ./test/core/load.wast:190
assert_return(() => invoke($0, `as-local.set-value`, []), []);
// ./test/core/load.wast:255
assert_return(() => invoke($3, `as-local.tee-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:191
assert_return(() => invoke($0, `as-local.tee-value`, []), [value("i32", 0)]);
// ./test/core/load.wast:256
assert_return(() => invoke($3, `as-global.set-value`, []), []);
// ./test/core/load.wast:192
assert_return(() => invoke($0, `as-global.set-value`, []), []);
// ./test/core/load.wast:258
assert_return(() => invoke($3, `as-load-address`, []), [value("i32", 0)]);
// ./test/core/load.wast:194
assert_return(() => invoke($0, `as-load-address`, []), [value("i32", 0)]);
// ./test/core/load.wast:259
assert_return(() => invoke($3, `as-loadN-address`, []), [value("i32", 0)]);
// ./test/core/load.wast:195
assert_return(() => invoke($0, `as-loadN-address`, []), [value("i32", 0)]);
// ./test/core/load.wast:260
assert_return(() => invoke($3, `as-store-address`, []), []);
// ./test/core/load.wast:196
assert_return(() => invoke($0, `as-store-address`, []), []);
// ./test/core/load.wast:261
assert_return(() => invoke($3, `as-store-value`, []), []);
// ./test/core/load.wast:197
assert_return(() => invoke($0, `as-store-value`, []), []);
// ./test/core/load.wast:262
assert_return(() => invoke($3, `as-storeN-address`, []), []);
// ./test/core/load.wast:198
assert_return(() => invoke($0, `as-storeN-address`, []), []);
// ./test/core/load.wast:263
assert_return(() => invoke($3, `as-storeN-value`, []), []);
// ./test/core/load.wast:199
assert_return(() => invoke($0, `as-storeN-value`, []), []);
// ./test/core/load.wast:265
assert_return(() => invoke($3, `as-unary-operand`, []), [value("i32", 32)]);
// ./test/core/load.wast:201
assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 32)]);
// ./test/core/load.wast:267
assert_return(() => invoke($3, `as-binary-left`, []), [value("i32", 10)]);
// ./test/core/load.wast:203
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 10)]);
// ./test/core/load.wast:268
assert_return(() => invoke($3, `as-binary-right`, []), [value("i32", 10)]);
// ./test/core/load.wast:204
assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 10)]);
// ./test/core/load.wast:270
assert_return(() => invoke($3, `as-test-operand`, []), [value("i32", 1)]);
// ./test/core/load.wast:206
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 1)]);
// ./test/core/load.wast:272
assert_return(() => invoke($3, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/load.wast:208
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/load.wast:273
assert_return(() => invoke($3, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/load.wast:209
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/load.wast:275
assert_return(() => invoke($3, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/load.wast:211
assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/load.wast:277
// ./test/core/load.wast:213
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load32 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:284
// ./test/core/load.wast:220
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load32_u (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:291
// ./test/core/load.wast:227
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load32_s (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:298
// ./test/core/load.wast:234
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load64 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:305
// ./test/core/load.wast:241
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load64_u (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:312
// ./test/core/load.wast:248
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i32) (i32.load64_s (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:320
// ./test/core/load.wast:256
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i64) (i64.load64 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:327
// ./test/core/load.wast:263
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i64) (i64.load64_u (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:334
// ./test/core/load.wast:270
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result i64) (i64.load64_s (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:342
// ./test/core/load.wast:278
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result f32) (f32.load32 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:349
// ./test/core/load.wast:285
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result f32) (f32.load64 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:357
// ./test/core/load.wast:293
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result f64) (f64.load32 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:364
// ./test/core/load.wast:300
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (result f64) (f64.load64 (local.get 0))) `),
`unknown operator`,
);
// ./test/core/load.wast:375
// ./test/core/load.wast:311
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load_i32 (i32.load (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:379
// ./test/core/load.wast:315
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load8_s_i32 (i32.load8_s (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:383
// ./test/core/load.wast:319
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load8_u_i32 (i32.load8_u (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:387
// ./test/core/load.wast:323
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load16_s_i32 (i32.load16_s (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:391
// ./test/core/load.wast:327
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load16_u_i32 (i32.load16_u (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:395
// ./test/core/load.wast:331
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load_i64 (i64.load (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:399
// ./test/core/load.wast:335
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load8_s_i64 (i64.load8_s (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:403
// ./test/core/load.wast:339
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load8_u_i64 (i64.load8_u (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:407
// ./test/core/load.wast:343
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load16_s_i64 (i64.load16_s (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:411
// ./test/core/load.wast:347
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load16_u_i64 (i64.load16_u (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:415
// ./test/core/load.wast:351
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load32_s_i64 (i64.load32_s (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:419
// ./test/core/load.wast:355
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load32_u_i64 (i64.load32_u (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:423
// ./test/core/load.wast:359
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load_f32 (f32.load (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:427
// ./test/core/load.wast:363
assert_invalid(
() => instantiate(`(module (memory 1) (func $$load_f64 (f64.load (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:435
// ./test/core/load.wast:371
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i32) (i32.load (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:436
// ./test/core/load.wast:372
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i32) (i32.load8_s (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:437
// ./test/core/load.wast:373
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i32) (i32.load8_u (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:438
// ./test/core/load.wast:374
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i32) (i32.load16_s (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:439
// ./test/core/load.wast:375
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i32) (i32.load16_u (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:440
// ./test/core/load.wast:376
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:441
// ./test/core/load.wast:377
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load8_s (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:442
// ./test/core/load.wast:378
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load8_u (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:443
// ./test/core/load.wast:379
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load16_s (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:444
// ./test/core/load.wast:380
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load16_u (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:445
// ./test/core/load.wast:381
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load32_s (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:446
// ./test/core/load.wast:382
assert_invalid(
() => instantiate(`(module (memory 1) (func (result i64) (i64.load32_u (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:447
// ./test/core/load.wast:383
assert_invalid(
() => instantiate(`(module (memory 1) (func (result f32) (f32.load (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:448
// ./test/core/load.wast:384
assert_invalid(
() => instantiate(`(module (memory 1) (func (result f64) (f64.load (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/load.wast:451
// ./test/core/load.wast:387
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -638,7 +542,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:460
// ./test/core/load.wast:396
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -650,7 +554,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:470
// ./test/core/load.wast:406
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -662,7 +566,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:480
// ./test/core/load.wast:416
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -674,7 +578,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:490
// ./test/core/load.wast:426
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -686,7 +590,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:500
// ./test/core/load.wast:436
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -698,7 +602,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:510
// ./test/core/load.wast:446
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -710,7 +614,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:520
// ./test/core/load.wast:456
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -722,7 +626,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:530
// ./test/core/load.wast:466
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -733,7 +637,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:539
// ./test/core/load.wast:475
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -744,7 +648,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:548
// ./test/core/load.wast:484
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -756,7 +660,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:558
// ./test/core/load.wast:494
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -775,7 +679,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:575
// ./test/core/load.wast:511
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -787,7 +691,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:585
// ./test/core/load.wast:521
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -799,7 +703,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:595
// ./test/core/load.wast:531
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -811,7 +715,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:605
// ./test/core/load.wast:541
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -822,7 +726,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:614
// ./test/core/load.wast:550
assert_invalid(
() => instantiate(`(module
(memory 0)
@@ -833,7 +737,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/load.wast:623
// ./test/core/load.wast:559
assert_invalid(
() => instantiate(`(module
(memory 1)

View File

@@ -0,0 +1,806 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/local_tee.wast
// ./test/core/local_tee.wast:3
let $0 = instantiate(`(module
;; Typing
(func (export "type-local-i32") (result i32) (local i32) (local.tee 0 (i32.const 0)))
(func (export "type-local-i64") (result i64) (local i64) (local.tee 0 (i64.const 0)))
(func (export "type-local-f32") (result f32) (local f32) (local.tee 0 (f32.const 0)))
(func (export "type-local-f64") (result f64) (local f64) (local.tee 0 (f64.const 0)))
(func (export "type-param-i32") (param i32) (result i32) (local.tee 0 (i32.const 10)))
(func (export "type-param-i64") (param i64) (result i64) (local.tee 0 (i64.const 11)))
(func (export "type-param-f32") (param f32) (result f32) (local.tee 0 (f32.const 11.1)))
(func (export "type-param-f64") (param f64) (result f64) (local.tee 0 (f64.const 12.2)))
(func (export "type-mixed") (param i64 f32 f64 i32 i32) (local f32 i64 i64 f64)
(drop (i64.eqz (local.tee 0 (i64.const 0))))
(drop (f32.neg (local.tee 1 (f32.const 0))))
(drop (f64.neg (local.tee 2 (f64.const 0))))
(drop (i32.eqz (local.tee 3 (i32.const 0))))
(drop (i32.eqz (local.tee 4 (i32.const 0))))
(drop (f32.neg (local.tee 5 (f32.const 0))))
(drop (i64.eqz (local.tee 6 (i64.const 0))))
(drop (i64.eqz (local.tee 7 (i64.const 0))))
(drop (f64.neg (local.tee 8 (f64.const 0))))
)
;; Writing
(func (export "write") (param i64 f32 f64 i32 i32) (result i64) (local f32 i64 i64 f64)
(drop (local.tee 1 (f32.const -0.3)))
(drop (local.tee 3 (i32.const 40)))
(drop (local.tee 4 (i32.const -7)))
(drop (local.tee 5 (f32.const 5.5)))
(drop (local.tee 6 (i64.const 6)))
(drop (local.tee 8 (f64.const 8)))
(i64.trunc_f64_s
(f64.add
(f64.convert_i64_u (local.get 0))
(f64.add
(f64.promote_f32 (local.get 1))
(f64.add
(local.get 2)
(f64.add
(f64.convert_i32_u (local.get 3))
(f64.add
(f64.convert_i32_s (local.get 4))
(f64.add
(f64.promote_f32 (local.get 5))
(f64.add
(f64.convert_i64_u (local.get 6))
(f64.add
(f64.convert_i64_u (local.get 7))
(local.get 8)
)
)
)
)
)
)
)
)
)
)
;; Result
(func (export "result") (param i64 f32 f64 i32 i32) (result f64)
(local f32 i64 i64 f64)
(f64.add
(f64.convert_i64_u (local.tee 0 (i64.const 1)))
(f64.add
(f64.promote_f32 (local.tee 1 (f32.const 2)))
(f64.add
(local.tee 2 (f64.const 3.3))
(f64.add
(f64.convert_i32_u (local.tee 3 (i32.const 4)))
(f64.add
(f64.convert_i32_s (local.tee 4 (i32.const 5)))
(f64.add
(f64.promote_f32 (local.tee 5 (f32.const 5.5)))
(f64.add
(f64.convert_i64_u (local.tee 6 (i64.const 6)))
(f64.add
(f64.convert_i64_u (local.tee 7 (i64.const 0)))
(local.tee 8 (f64.const 8))
)
)
)
)
)
)
)
)
)
(func $$dummy)
(func (export "as-block-first") (param i32) (result i32)
(block (result i32) (local.tee 0 (i32.const 1)) (call $$dummy))
)
(func (export "as-block-mid") (param i32) (result i32)
(block (result i32) (call $$dummy) (local.tee 0 (i32.const 1)) (call $$dummy))
)
(func (export "as-block-last") (param i32) (result i32)
(block (result i32) (call $$dummy) (call $$dummy) (local.tee 0 (i32.const 1)))
)
(func (export "as-loop-first") (param i32) (result i32)
(loop (result i32) (local.tee 0 (i32.const 3)) (call $$dummy))
)
(func (export "as-loop-mid") (param i32) (result i32)
(loop (result i32) (call $$dummy) (local.tee 0 (i32.const 4)) (call $$dummy))
)
(func (export "as-loop-last") (param i32) (result i32)
(loop (result i32) (call $$dummy) (call $$dummy) (local.tee 0 (i32.const 5)))
)
(func (export "as-br-value") (param i32) (result i32)
(block (result i32) (br 0 (local.tee 0 (i32.const 9))))
)
(func (export "as-br_if-cond") (param i32)
(block (br_if 0 (local.tee 0 (i32.const 1))))
)
(func (export "as-br_if-value") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (local.tee 0 (i32.const 8)) (i32.const 1))) (i32.const 7)
)
)
(func (export "as-br_if-value-cond") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 6) (local.tee 0 (i32.const 9)))) (i32.const 7)
)
)
(func (export "as-br_table-index") (param i32)
(block (br_table 0 0 0 (local.tee 0 (i32.const 0))))
)
(func (export "as-br_table-value") (param i32) (result i32)
(block (result i32)
(br_table 0 0 0 (local.tee 0 (i32.const 10)) (i32.const 1)) (i32.const 7)
)
)
(func (export "as-br_table-value-index") (param i32) (result i32)
(block (result i32)
(br_table 0 0 (i32.const 6) (local.tee 0 (i32.const 11))) (i32.const 7)
)
)
(func (export "as-return-value") (param i32) (result i32)
(return (local.tee 0 (i32.const 7)))
)
(func (export "as-if-cond") (param i32) (result i32)
(if (result i32) (local.tee 0 (i32.const 2))
(then (i32.const 0)) (else (i32.const 1))
)
)
(func (export "as-if-then") (param i32) (result i32)
(if (result i32) (local.get 0)
(then (local.tee 0 (i32.const 3))) (else (local.get 0))
)
)
(func (export "as-if-else") (param i32) (result i32)
(if (result i32) (local.get 0)
(then (local.get 0)) (else (local.tee 0 (i32.const 4)))
)
)
(func (export "as-select-first") (param i32 i32) (result i32)
(select (local.tee 0 (i32.const 5)) (local.get 0) (local.get 1))
)
(func (export "as-select-second") (param i32 i32) (result i32)
(select (local.get 0) (local.tee 0 (i32.const 6)) (local.get 1))
)
(func (export "as-select-cond") (param i32) (result i32)
(select (i32.const 0) (i32.const 1) (local.tee 0 (i32.const 7)))
)
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
(func (export "as-call-first") (param i32) (result i32)
(call $$f (local.tee 0 (i32.const 12)) (i32.const 2) (i32.const 3))
)
(func (export "as-call-mid") (param i32) (result i32)
(call $$f (i32.const 1) (local.tee 0 (i32.const 13)) (i32.const 3))
)
(func (export "as-call-last") (param i32) (result i32)
(call $$f (i32.const 1) (i32.const 2) (local.tee 0 (i32.const 14)))
)
(type $$sig (func (param i32 i32 i32) (result i32)))
(table funcref (elem $$f))
(func (export "as-call_indirect-first") (param i32) (result i32)
(call_indirect (type $$sig)
(local.tee 0 (i32.const 1)) (i32.const 2) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-mid") (param i32) (result i32)
(call_indirect (type $$sig)
(i32.const 1) (local.tee 0 (i32.const 2)) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-last") (param i32) (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (local.tee 0 (i32.const 3)) (i32.const 0)
)
)
(func (export "as-call_indirect-index") (param i32) (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (i32.const 3) (local.tee 0 (i32.const 0))
)
)
(func (export "as-local.set-value") (local i32)
(local.set 0 (local.tee 0 (i32.const 1)))
)
(func (export "as-local.tee-value") (param i32) (result i32)
(local.tee 0 (local.tee 0 (i32.const 1)))
)
(global $$g (mut i32) (i32.const 0))
(func (export "as-global.set-value") (local i32)
(global.set $$g (local.tee 0 (i32.const 1)))
)
(memory 1)
(func (export "as-load-address") (param i32) (result i32)
(i32.load (local.tee 0 (i32.const 1)))
)
(func (export "as-loadN-address") (param i32) (result i32)
(i32.load8_s (local.tee 0 (i32.const 3)))
)
(func (export "as-store-address") (param i32)
(i32.store (local.tee 0 (i32.const 30)) (i32.const 7))
)
(func (export "as-store-value") (param i32)
(i32.store (i32.const 2) (local.tee 0 (i32.const 1)))
)
(func (export "as-storeN-address") (param i32)
(i32.store8 (local.tee 0 (i32.const 1)) (i32.const 7))
)
(func (export "as-storeN-value") (param i32)
(i32.store16 (i32.const 2) (local.tee 0 (i32.const 1)))
)
(func (export "as-unary-operand") (param f32) (result f32)
(f32.neg (local.tee 0 (f32.const nan:0x0f1e2)))
)
(func (export "as-binary-left") (param i32) (result i32)
(i32.add (local.tee 0 (i32.const 3)) (i32.const 10))
)
(func (export "as-binary-right") (param i32) (result i32)
(i32.sub (i32.const 10) (local.tee 0 (i32.const 4)))
)
(func (export "as-test-operand") (param i32) (result i32)
(i32.eqz (local.tee 0 (i32.const 0)))
)
(func (export "as-compare-left") (param i32) (result i32)
(i32.le_s (local.tee 0 (i32.const 43)) (i32.const 10))
)
(func (export "as-compare-right") (param i32) (result i32)
(i32.ne (i32.const 10) (local.tee 0 (i32.const 42)))
)
(func (export "as-convert-operand") (param i64) (result i32)
(i32.wrap_i64 (local.tee 0 (i64.const 41)))
)
(func (export "as-memory.grow-size") (param i32) (result i32)
(memory.grow (local.tee 0 (i32.const 40)))
)
)`);
// ./test/core/local_tee.wast:280
assert_return(() => invoke($0, `type-local-i32`, []), [value("i32", 0)]);
// ./test/core/local_tee.wast:281
assert_return(() => invoke($0, `type-local-i64`, []), [value("i64", 0n)]);
// ./test/core/local_tee.wast:282
assert_return(() => invoke($0, `type-local-f32`, []), [value("f32", 0)]);
// ./test/core/local_tee.wast:283
assert_return(() => invoke($0, `type-local-f64`, []), [value("f64", 0)]);
// ./test/core/local_tee.wast:285
assert_return(() => invoke($0, `type-param-i32`, [2]), [value("i32", 10)]);
// ./test/core/local_tee.wast:286
assert_return(() => invoke($0, `type-param-i64`, [3n]), [value("i64", 11n)]);
// ./test/core/local_tee.wast:287
assert_return(() => invoke($0, `type-param-f32`, [value("f32", 4.4)]), [value("f32", 11.1)]);
// ./test/core/local_tee.wast:288
assert_return(() => invoke($0, `type-param-f64`, [value("f64", 5.5)]), [value("f64", 12.2)]);
// ./test/core/local_tee.wast:290
assert_return(() => invoke($0, `as-block-first`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:291
assert_return(() => invoke($0, `as-block-mid`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:292
assert_return(() => invoke($0, `as-block-last`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:294
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 3)]);
// ./test/core/local_tee.wast:295
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 4)]);
// ./test/core/local_tee.wast:296
assert_return(() => invoke($0, `as-loop-last`, [0]), [value("i32", 5)]);
// ./test/core/local_tee.wast:298
assert_return(() => invoke($0, `as-br-value`, [0]), [value("i32", 9)]);
// ./test/core/local_tee.wast:300
assert_return(() => invoke($0, `as-br_if-cond`, [0]), []);
// ./test/core/local_tee.wast:301
assert_return(() => invoke($0, `as-br_if-value`, [0]), [value("i32", 8)]);
// ./test/core/local_tee.wast:302
assert_return(() => invoke($0, `as-br_if-value-cond`, [0]), [value("i32", 6)]);
// ./test/core/local_tee.wast:304
assert_return(() => invoke($0, `as-br_table-index`, [0]), []);
// ./test/core/local_tee.wast:305
assert_return(() => invoke($0, `as-br_table-value`, [0]), [value("i32", 10)]);
// ./test/core/local_tee.wast:306
assert_return(() => invoke($0, `as-br_table-value-index`, [0]), [value("i32", 6)]);
// ./test/core/local_tee.wast:308
assert_return(() => invoke($0, `as-return-value`, [0]), [value("i32", 7)]);
// ./test/core/local_tee.wast:310
assert_return(() => invoke($0, `as-if-cond`, [0]), [value("i32", 0)]);
// ./test/core/local_tee.wast:311
assert_return(() => invoke($0, `as-if-then`, [1]), [value("i32", 3)]);
// ./test/core/local_tee.wast:312
assert_return(() => invoke($0, `as-if-else`, [0]), [value("i32", 4)]);
// ./test/core/local_tee.wast:314
assert_return(() => invoke($0, `as-select-first`, [0, 1]), [value("i32", 5)]);
// ./test/core/local_tee.wast:315
assert_return(() => invoke($0, `as-select-second`, [0, 0]), [value("i32", 6)]);
// ./test/core/local_tee.wast:316
assert_return(() => invoke($0, `as-select-cond`, [0]), [value("i32", 0)]);
// ./test/core/local_tee.wast:318
assert_return(() => invoke($0, `as-call-first`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:319
assert_return(() => invoke($0, `as-call-mid`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:320
assert_return(() => invoke($0, `as-call-last`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:322
assert_return(() => invoke($0, `as-call_indirect-first`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:323
assert_return(() => invoke($0, `as-call_indirect-mid`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:324
assert_return(() => invoke($0, `as-call_indirect-last`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:325
assert_return(() => invoke($0, `as-call_indirect-index`, [0]), [value("i32", -1)]);
// ./test/core/local_tee.wast:327
assert_return(() => invoke($0, `as-local.set-value`, []), []);
// ./test/core/local_tee.wast:328
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:329
assert_return(() => invoke($0, `as-global.set-value`, []), []);
// ./test/core/local_tee.wast:331
assert_return(() => invoke($0, `as-load-address`, [0]), [value("i32", 0)]);
// ./test/core/local_tee.wast:332
assert_return(() => invoke($0, `as-loadN-address`, [0]), [value("i32", 0)]);
// ./test/core/local_tee.wast:333
assert_return(() => invoke($0, `as-store-address`, [0]), []);
// ./test/core/local_tee.wast:334
assert_return(() => invoke($0, `as-store-value`, [0]), []);
// ./test/core/local_tee.wast:335
assert_return(() => invoke($0, `as-storeN-address`, [0]), []);
// ./test/core/local_tee.wast:336
assert_return(() => invoke($0, `as-storeN-value`, [0]), []);
// ./test/core/local_tee.wast:338
assert_return(
() => invoke($0, `as-unary-operand`, [value("f32", 0)]),
[bytes("f32", [0xe2, 0xf1, 0x80, 0xff])],
);
// ./test/core/local_tee.wast:339
assert_return(() => invoke($0, `as-binary-left`, [0]), [value("i32", 13)]);
// ./test/core/local_tee.wast:340
assert_return(() => invoke($0, `as-binary-right`, [0]), [value("i32", 6)]);
// ./test/core/local_tee.wast:341
assert_return(() => invoke($0, `as-test-operand`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:342
assert_return(() => invoke($0, `as-compare-left`, [0]), [value("i32", 0)]);
// ./test/core/local_tee.wast:343
assert_return(() => invoke($0, `as-compare-right`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:344
assert_return(() => invoke($0, `as-convert-operand`, [0n]), [value("i32", 41)]);
// ./test/core/local_tee.wast:345
assert_return(() => invoke($0, `as-memory.grow-size`, [0]), [value("i32", 1)]);
// ./test/core/local_tee.wast:347
assert_return(() => invoke($0, `type-mixed`, [1n, value("f32", 2.2), value("f64", 3.3), 4, 5]), []);
// ./test/core/local_tee.wast:353
assert_return(
() => invoke($0, `write`, [1n, value("f32", 2), value("f64", 3.3), 4, 5]),
[value("i64", 56n)],
);
// ./test/core/local_tee.wast:360
assert_return(
() => invoke($0, `result`, [-1n, value("f32", -2), value("f64", -3.3), -4, -5]),
[value("f64", 34.8)],
);
// ./test/core/local_tee.wast:370
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (result i64) (local i32) (local.tee 0 (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:374
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (local f32) (i32.eqz (local.tee 0 (f32.const 0)))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:378
assert_invalid(
() => instantiate(`(module (func $$type-local-num-vs-num (local f64 i64) (f64.neg (local.tee 1 (i64.const 0)))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:383
assert_invalid(
() => instantiate(`(module (func $$type-local-arg-void-vs-num (local i32) (local.tee 0 (nop))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:387
assert_invalid(
() => instantiate(`(module (func $$type-local-arg-num-vs-num (local i32) (local.tee 0 (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:391
assert_invalid(
() => instantiate(`(module (func $$type-local-arg-num-vs-num (local f32) (local.tee 0 (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:395
assert_invalid(
() => instantiate(`(module (func $$type-local-arg-num-vs-num (local f64 i64) (local.tee 1 (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:403
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param i32) (result i64) (local.get 0)))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:407
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param f32) (i32.eqz (local.get 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:411
assert_invalid(
() => instantiate(`(module (func $$type-param-num-vs-num (param f64 i64) (f64.neg (local.get 1))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:416
assert_invalid(
() => instantiate(`(module (func $$type-param-arg-void-vs-num (param i32) (local.tee 0 (nop))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:420
assert_invalid(
() => instantiate(`(module (func $$type-param-arg-num-vs-num (param i32) (local.tee 0 (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:424
assert_invalid(
() => instantiate(`(module (func $$type-param-arg-num-vs-num (param f32) (local.tee 0 (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:428
assert_invalid(
() => instantiate(`(module (func $$type-param-arg-num-vs-num (param f64 i64) (local.tee 1 (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:433
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num (param i32)
(local.tee 0) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:441
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-block (param i32)
(i32.const 0)
(block (local.tee 0) (drop))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:450
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-loop (param i32)
(i32.const 0)
(loop (local.tee 0) (drop))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:459
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-then (param i32)
(i32.const 0) (i32.const 0)
(if (then (local.tee 0) (drop)))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:468
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-else (param i32)
(i32.const 0) (i32.const 0)
(if (result i32) (then (i32.const 0)) (else (local.tee 0))) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:477
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-br (param i32)
(i32.const 0)
(block (br 0 (local.tee 0)) (drop))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:486
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-br_if (param i32)
(i32.const 0)
(block (br_if 0 (local.tee 0) (i32.const 1)) (drop))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:495
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-br_table (param i32)
(i32.const 0)
(block (br_table 0 (local.tee 0)) (drop))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:504
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-return (param i32)
(return (local.tee 0)) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:512
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-select (param i32)
(select (local.tee 0) (i32.const 1) (i32.const 2)) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:520
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-call (param i32)
(call 1 (local.tee 0)) (drop)
)
(func (param i32) (result i32) (local.get 0))
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:529
assert_invalid(
() => instantiate(`(module
(func $$f (param i32) (result i32) (local.get 0))
(type $$sig (func (param i32) (result i32)))
(table funcref (elem $$f))
(func $$type-param-arg-empty-vs-num-in-call_indirect (param i32)
(block (result i32)
(call_indirect (type $$sig)
(local.tee 0) (i32.const 0)
)
(drop)
)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:545
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-local.set (param i32)
(local.set 0 (local.tee 0)) (local.get 0) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:553
assert_invalid(
() => instantiate(`(module
(func $$type-param-arg-empty-vs-num-in-local.tee (param i32)
(local.tee 0 (local.tee 0)) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:561
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-param-arg-empty-vs-num-in-global.set (param i32)
(global.set $$x (local.tee 0)) (global.get $$x) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:570
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-param-arg-empty-vs-num-in-memory.grow (param i32)
(memory.grow (local.tee 0)) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:579
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-param-arg-empty-vs-num-in-load (param i32)
(i32.load (local.tee 0)) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:588
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-param-arg-empty-vs-num-in-store (param i32)
(i32.store (local.tee 0) (i32.const 1))
)
)`),
`type mismatch`,
);
// ./test/core/local_tee.wast:598
assert_invalid(
() => instantiate(`(module (func $$type-mixed-arg-num-vs-num (param f32) (local i32) (local.tee 1 (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:602
assert_invalid(
() => instantiate(`(module (func $$type-mixed-arg-num-vs-num (param i64 i32) (local f32) (local.tee 1 (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:606
assert_invalid(
() => instantiate(`(module (func $$type-mixed-arg-num-vs-num (param i64) (local f64 i64) (local.tee 1 (i64.const 0))))`),
`type mismatch`,
);
// ./test/core/local_tee.wast:614
assert_invalid(
() => instantiate(`(module (func $$unbound-local (local i32 i64) (local.tee 3 (i32.const 0)) drop))`),
`unknown local`,
);
// ./test/core/local_tee.wast:618
assert_invalid(
() => instantiate(`(module (func $$large-local (local i32 i64) (local.tee 14324343 (i32.const 0)) drop))`),
`unknown local`,
);
// ./test/core/local_tee.wast:623
assert_invalid(
() => instantiate(`(module (func $$unbound-param (param i32 i64) (local.tee 2 (i32.const 0)) drop))`),
`unknown local`,
);
// ./test/core/local_tee.wast:627
assert_invalid(
() => instantiate(`(module (func $$large-param (param i32 i64) (local.tee 714324343 (i32.const 0)) drop))`),
`unknown local`,
);
// ./test/core/local_tee.wast:632
assert_invalid(
() => instantiate(`(module (func $$unbound-mixed (param i32) (local i32 i64) (local.tee 3 (i32.const 0)) drop))`),
`unknown local`,
);
// ./test/core/local_tee.wast:636
assert_invalid(
() => instantiate(`(module (func $$large-mixed (param i64) (local i32 i64) (local.tee 214324343 (i32.const 0)) drop))`),
`unknown local`,
);

View File

@@ -0,0 +1,555 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/memory_grow.wast
// ./test/core/memory_grow.wast:1
let $0 = instantiate(`(module
(memory 0)
(func (export "load_at_zero") (result i32) (i32.load (i32.const 0)))
(func (export "store_at_zero") (i32.store (i32.const 0) (i32.const 2)))
(func (export "load_at_page_size") (result i32) (i32.load (i32.const 0x10000)))
(func (export "store_at_page_size") (i32.store (i32.const 0x10000) (i32.const 3)))
(func (export "grow") (param $$sz i32) (result i32) (memory.grow (local.get $$sz)))
(func (export "size") (result i32) (memory.size))
)`);
// ./test/core/memory_grow.wast:14
assert_return(() => invoke($0, `size`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:15
assert_trap(() => invoke($0, `store_at_zero`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:16
assert_trap(() => invoke($0, `load_at_zero`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:17
assert_trap(() => invoke($0, `store_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:18
assert_trap(() => invoke($0, `load_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:19
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:20
assert_return(() => invoke($0, `size`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:21
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:22
assert_return(() => invoke($0, `store_at_zero`, []), []);
// ./test/core/memory_grow.wast:23
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:24
assert_trap(() => invoke($0, `store_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:25
assert_trap(() => invoke($0, `load_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:26
assert_return(() => invoke($0, `grow`, [4]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:27
assert_return(() => invoke($0, `size`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:28
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:29
assert_return(() => invoke($0, `store_at_zero`, []), []);
// ./test/core/memory_grow.wast:30
assert_return(() => invoke($0, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:31
assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:32
assert_return(() => invoke($0, `store_at_page_size`, []), []);
// ./test/core/memory_grow.wast:33
assert_return(() => invoke($0, `load_at_page_size`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:36
let $1 = instantiate(`(module
(memory 0)
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);
// ./test/core/memory_grow.wast:41
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:42
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:43
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:44
assert_return(() => invoke($1, `grow`, [2]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:45
assert_return(() => invoke($1, `grow`, [800]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:46
assert_return(() => invoke($1, `grow`, [65536]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:47
assert_return(() => invoke($1, `grow`, [64736]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:48
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 803)]);
// ./test/core/memory_grow.wast:50
let $2 = instantiate(`(module
(memory 0 10)
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);
// ./test/core/memory_grow.wast:55
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:56
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:57
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:58
assert_return(() => invoke($2, `grow`, [2]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:59
assert_return(() => invoke($2, `grow`, [6]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:60
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 10)]);
// ./test/core/memory_grow.wast:61
assert_return(() => invoke($2, `grow`, [1]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:62
assert_return(() => invoke($2, `grow`, [65536]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:66
let $3 = instantiate(`(module
(memory 1)
(func (export "grow") (param i32) (result i32)
(memory.grow (local.get 0))
)
(func (export "check-memory-zero") (param i32 i32) (result i32)
(local i32)
(local.set 2 (i32.const 1))
(block
(loop
(local.set 2 (i32.load8_u (local.get 0)))
(br_if 1 (i32.ne (local.get 2) (i32.const 0)))
(br_if 1 (i32.ge_u (local.get 0) (local.get 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if 0 (i32.le_u (local.get 0) (local.get 1)))
)
)
(local.get 2)
)
)`);
// ./test/core/memory_grow.wast:87
assert_return(() => invoke($3, `check-memory-zero`, [0, 65535]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:88
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:89
assert_return(() => invoke($3, `check-memory-zero`, [65536, 131071]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:90
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:91
assert_return(() => invoke($3, `check-memory-zero`, [131072, 196607]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:92
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:93
assert_return(() => invoke($3, `check-memory-zero`, [196608, 262143]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:94
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:95
assert_return(() => invoke($3, `check-memory-zero`, [262144, 327679]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:96
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 5)]);
// ./test/core/memory_grow.wast:97
assert_return(() => invoke($3, `check-memory-zero`, [327680, 393215]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:101
let $4 = instantiate(`(module
(memory 1)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_if-cond")
(block (br_if 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_if-value") (result i32)
(block (result i32)
(drop (br_if 0 (memory.grow (i32.const 0)) (i32.const 1))) (i32.const 7)
)
)
(func (export "as-br_if-value-cond") (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 6) (memory.grow (i32.const 0)))) (i32.const 7)
)
)
(func (export "as-br_table-index")
(block (br_table 0 0 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_table-value") (result i32)
(block (result i32)
(br_table 0 0 0 (memory.grow (i32.const 0)) (i32.const 1)) (i32.const 7)
)
)
(func (export "as-br_table-value-index") (result i32)
(block (result i32)
(br_table 0 0 (i32.const 6) (memory.grow (i32.const 0))) (i32.const 7)
)
)
(func (export "as-return-value") (result i32)
(return (memory.grow (i32.const 0)))
)
(func (export "as-if-cond") (result i32)
(if (result i32) (memory.grow (i32.const 0))
(then (i32.const 0)) (else (i32.const 1))
)
)
(func (export "as-if-then") (result i32)
(if (result i32) (i32.const 1)
(then (memory.grow (i32.const 0))) (else (i32.const 0))
)
)
(func (export "as-if-else") (result i32)
(if (result i32) (i32.const 0)
(then (i32.const 0)) (else (memory.grow (i32.const 0)))
)
)
(func (export "as-select-first") (param i32 i32) (result i32)
(select (memory.grow (i32.const 0)) (local.get 0) (local.get 1))
)
(func (export "as-select-second") (param i32 i32) (result i32)
(select (local.get 0) (memory.grow (i32.const 0)) (local.get 1))
)
(func (export "as-select-cond") (result i32)
(select (i32.const 0) (i32.const 1) (memory.grow (i32.const 0)))
)
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
(func (export "as-call-first") (result i32)
(call $$f (memory.grow (i32.const 0)) (i32.const 2) (i32.const 3))
)
(func (export "as-call-mid") (result i32)
(call $$f (i32.const 1) (memory.grow (i32.const 0)) (i32.const 3))
)
(func (export "as-call-last") (result i32)
(call $$f (i32.const 1) (i32.const 2) (memory.grow (i32.const 0)))
)
(type $$sig (func (param i32 i32 i32) (result i32)))
(table funcref (elem $$f))
(func (export "as-call_indirect-first") (result i32)
(call_indirect (type $$sig)
(memory.grow (i32.const 0)) (i32.const 2) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-mid") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (memory.grow (i32.const 0)) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-last") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (memory.grow (i32.const 0)) (i32.const 0)
)
)
(func (export "as-call_indirect-index") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (i32.const 3) (memory.grow (i32.const 0))
)
)
(func (export "as-local.set-value") (local i32)
(local.set 0 (memory.grow (i32.const 0)))
)
(func (export "as-local.tee-value") (result i32) (local i32)
(local.tee 0 (memory.grow (i32.const 0)))
)
(global $$g (mut i32) (i32.const 0))
(func (export "as-global.set-value") (local i32)
(global.set $$g (memory.grow (i32.const 0)))
)
(func (export "as-load-address") (result i32)
(i32.load (memory.grow (i32.const 0)))
)
(func (export "as-loadN-address") (result i32)
(i32.load8_s (memory.grow (i32.const 0)))
)
(func (export "as-store-address")
(i32.store (memory.grow (i32.const 0)) (i32.const 7))
)
(func (export "as-store-value")
(i32.store (i32.const 2) (memory.grow (i32.const 0)))
)
(func (export "as-storeN-address")
(i32.store8 (memory.grow (i32.const 0)) (i32.const 7))
)
(func (export "as-storeN-value")
(i32.store16 (i32.const 2) (memory.grow (i32.const 0)))
)
(func (export "as-unary-operand") (result i32)
(i32.clz (memory.grow (i32.const 0)))
)
(func (export "as-binary-left") (result i32)
(i32.add (memory.grow (i32.const 0)) (i32.const 10))
)
(func (export "as-binary-right") (result i32)
(i32.sub (i32.const 10) (memory.grow (i32.const 0)))
)
(func (export "as-test-operand") (result i32)
(i32.eqz (memory.grow (i32.const 0)))
)
(func (export "as-compare-left") (result i32)
(i32.le_s (memory.grow (i32.const 0)) (i32.const 10))
)
(func (export "as-compare-right") (result i32)
(i32.ne (i32.const 10) (memory.grow (i32.const 0)))
)
(func (export "as-memory.grow-size") (result i32)
(memory.grow (memory.grow (i32.const 0)))
)
)`);
// ./test/core/memory_grow.wast:259
assert_return(() => invoke($4, `as-br-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:261
assert_return(() => invoke($4, `as-br_if-cond`, []), []);
// ./test/core/memory_grow.wast:262
assert_return(() => invoke($4, `as-br_if-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:263
assert_return(() => invoke($4, `as-br_if-value-cond`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:265
assert_return(() => invoke($4, `as-br_table-index`, []), []);
// ./test/core/memory_grow.wast:266
assert_return(() => invoke($4, `as-br_table-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:267
assert_return(() => invoke($4, `as-br_table-value-index`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:269
assert_return(() => invoke($4, `as-return-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:271
assert_return(() => invoke($4, `as-if-cond`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:272
assert_return(() => invoke($4, `as-if-then`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:273
assert_return(() => invoke($4, `as-if-else`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:275
assert_return(() => invoke($4, `as-select-first`, [0, 1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:276
assert_return(() => invoke($4, `as-select-second`, [0, 0]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:277
assert_return(() => invoke($4, `as-select-cond`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:279
assert_return(() => invoke($4, `as-call-first`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:280
assert_return(() => invoke($4, `as-call-mid`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:281
assert_return(() => invoke($4, `as-call-last`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:283
assert_return(() => invoke($4, `as-call_indirect-first`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:284
assert_return(() => invoke($4, `as-call_indirect-mid`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:285
assert_return(() => invoke($4, `as-call_indirect-last`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:286
assert_trap(() => invoke($4, `as-call_indirect-index`, []), `undefined element`);
// ./test/core/memory_grow.wast:288
assert_return(() => invoke($4, `as-local.set-value`, []), []);
// ./test/core/memory_grow.wast:289
assert_return(() => invoke($4, `as-local.tee-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:290
assert_return(() => invoke($4, `as-global.set-value`, []), []);
// ./test/core/memory_grow.wast:292
assert_return(() => invoke($4, `as-load-address`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:293
assert_return(() => invoke($4, `as-loadN-address`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:294
assert_return(() => invoke($4, `as-store-address`, []), []);
// ./test/core/memory_grow.wast:295
assert_return(() => invoke($4, `as-store-value`, []), []);
// ./test/core/memory_grow.wast:296
assert_return(() => invoke($4, `as-storeN-address`, []), []);
// ./test/core/memory_grow.wast:297
assert_return(() => invoke($4, `as-storeN-value`, []), []);
// ./test/core/memory_grow.wast:299
assert_return(() => invoke($4, `as-unary-operand`, []), [value("i32", 31)]);
// ./test/core/memory_grow.wast:301
assert_return(() => invoke($4, `as-binary-left`, []), [value("i32", 11)]);
// ./test/core/memory_grow.wast:302
assert_return(() => invoke($4, `as-binary-right`, []), [value("i32", 9)]);
// ./test/core/memory_grow.wast:304
assert_return(() => invoke($4, `as-test-operand`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:306
assert_return(() => invoke($4, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:307
assert_return(() => invoke($4, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:309
assert_return(() => invoke($4, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:312
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32 (result i32)
(memory.grow)
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:321
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-block (result i32)
(i32.const 0)
(block (result i32) (memory.grow))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:331
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-loop (result i32)
(i32.const 0)
(loop (result i32) (memory.grow))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:341
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-then (result i32)
(i32.const 0) (i32.const 0)
(if (result i32) (then (memory.grow)))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:352
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-size-f32-vs-i32 (result i32)
(memory.grow (f32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:362
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-result-i32-vs-empty
(memory.grow (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:371
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-result-i32-vs-f32 (result f32)
(memory.grow (i32.const 0))
)
)`),
`type mismatch`,
);

View File

@@ -152,40 +152,6 @@ assert_return(() => invoke($3, `grow`, [1]), []);
assert_return(() => invoke($3, `size`, []), [value("i32", 8)]);
// ./test/core/memory_size.wast:68
let $4 = instantiate(`(module
(memory (export "mem1") 2 4)
(memory (export "mem2") 0)
)`);
// ./test/core/memory_size.wast:72
register($4, `M`);
// ./test/core/memory_size.wast:74
let $5 = instantiate(`(module
(memory $$mem1 (import "M" "mem1") 1 5)
(memory $$mem2 (import "M" "mem2") 0)
(memory $$mem3 3)
(memory $$mem4 4 5)
(func (export "size1") (result i32) (memory.size $$mem1))
(func (export "size2") (result i32) (memory.size $$mem2))
(func (export "size3") (result i32) (memory.size $$mem3))
(func (export "size4") (result i32) (memory.size $$mem4))
)`);
// ./test/core/memory_size.wast:86
assert_return(() => invoke($5, `size1`, []), [value("i32", 2)]);
// ./test/core/memory_size.wast:87
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);
// ./test/core/memory_size.wast:88
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_size.wast:89
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_size.wast:94
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -196,7 +162,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/memory_size.wast:103
// ./test/core/memory_size.wast:77
assert_invalid(
() => instantiate(`(module
(memory 1)

View File

@@ -0,0 +1,97 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/ref_is_null.wast
// ./test/core/ref_is_null.wast:1
let $0 = instantiate(`(module
(func $$f1 (export "funcref") (param $$x funcref) (result i32)
(ref.is_null (local.get $$x))
)
(func $$f2 (export "externref") (param $$x externref) (result i32)
(ref.is_null (local.get $$x))
)
(table $$t1 2 funcref)
(table $$t2 2 externref)
(elem (table $$t1) (i32.const 1) func $$dummy)
(func $$dummy)
(func (export "init") (param $$r externref)
(table.set $$t2 (i32.const 1) (local.get $$r))
)
(func (export "deinit")
(table.set $$t1 (i32.const 1) (ref.null func))
(table.set $$t2 (i32.const 1) (ref.null extern))
)
(func (export "funcref-elem") (param $$x i32) (result i32)
(call $$f1 (table.get $$t1 (local.get $$x)))
)
(func (export "externref-elem") (param $$x i32) (result i32)
(call $$f2 (table.get $$t2 (local.get $$x)))
)
)`);
// ./test/core/ref_is_null.wast:30
assert_return(() => invoke($0, `funcref`, [null]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:31
assert_return(() => invoke($0, `externref`, [null]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:33
assert_return(() => invoke($0, `externref`, [externref(1)]), [value("i32", 0)]);
// ./test/core/ref_is_null.wast:35
invoke($0, `init`, [externref(0)]);
// ./test/core/ref_is_null.wast:37
assert_return(() => invoke($0, `funcref-elem`, [0]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:38
assert_return(() => invoke($0, `externref-elem`, [0]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:40
assert_return(() => invoke($0, `funcref-elem`, [1]), [value("i32", 0)]);
// ./test/core/ref_is_null.wast:41
assert_return(() => invoke($0, `externref-elem`, [1]), [value("i32", 0)]);
// ./test/core/ref_is_null.wast:43
invoke($0, `deinit`, []);
// ./test/core/ref_is_null.wast:45
assert_return(() => invoke($0, `funcref-elem`, [0]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:46
assert_return(() => invoke($0, `externref-elem`, [0]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:48
assert_return(() => invoke($0, `funcref-elem`, [1]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:49
assert_return(() => invoke($0, `externref-elem`, [1]), [value("i32", 1)]);
// ./test/core/ref_is_null.wast:51
assert_invalid(
() => instantiate(`(module (func $$ref-vs-num (param i32) (ref.is_null (local.get 0))))`),
`type mismatch`,
);
// ./test/core/ref_is_null.wast:55
assert_invalid(
() => instantiate(`(module (func $$ref-vs-empty (ref.is_null)))`),
`type mismatch`,
);

View File

@@ -17,226 +17,6 @@
// ./test/core/store.wast:3
let $0 = instantiate(`(module
(memory $$mem1 1)
(memory $$mem2 1)
(func (export "load1") (param i32) (result i64)
(i64.load $$mem1 (local.get 0))
)
(func (export "load2") (param i32) (result i64)
(i64.load $$mem2 (local.get 0))
)
(func (export "store1") (param i32 i64)
(i64.store $$mem1 (local.get 0) (local.get 1))
)
(func (export "store2") (param i32 i64)
(i64.store $$mem2 (local.get 0) (local.get 1))
)
)`);
// ./test/core/store.wast:22
invoke($0, `store1`, [0, 1n]);
// ./test/core/store.wast:23
invoke($0, `store2`, [0, 2n]);
// ./test/core/store.wast:24
assert_return(() => invoke($0, `load1`, [0]), [value("i64", 1n)]);
// ./test/core/store.wast:25
assert_return(() => invoke($0, `load2`, [0]), [value("i64", 2n)]);
// ./test/core/store.wast:28
let $1 = instantiate(`(module $$M1
(memory (export "mem") 1)
(func (export "load") (param i32) (result i64)
(i64.load (local.get 0))
)
(func (export "store") (param i32 i64)
(i64.store (local.get 0) (local.get 1))
)
)`);
register($1, `M1`);
// ./test/core/store.wast:38
register($1, `M1`);
// ./test/core/store.wast:40
let $2 = instantiate(`(module $$M2
(memory (export "mem") 1)
(func (export "load") (param i32) (result i64)
(i64.load (local.get 0))
)
(func (export "store") (param i32 i64)
(i64.store (local.get 0) (local.get 1))
)
)`);
register($2, `M2`);
// ./test/core/store.wast:50
register($2, `M2`);
// ./test/core/store.wast:52
invoke(`M1`, `store`, [0, 1n]);
// ./test/core/store.wast:53
invoke(`M2`, `store`, [0, 2n]);
// ./test/core/store.wast:54
assert_return(() => invoke(`M1`, `load`, [0]), [value("i64", 1n)]);
// ./test/core/store.wast:55
assert_return(() => invoke(`M2`, `load`, [0]), [value("i64", 2n)]);
// ./test/core/store.wast:57
let $3 = instantiate(`(module
(memory $$mem1 (import "M1" "mem") 1)
(memory $$mem2 (import "M2" "mem") 1)
(func (export "load1") (param i32) (result i64)
(i64.load $$mem1 (local.get 0))
)
(func (export "load2") (param i32) (result i64)
(i64.load $$mem2 (local.get 0))
)
(func (export "store1") (param i32 i64)
(i64.store $$mem1 (local.get 0) (local.get 1))
)
(func (export "store2") (param i32 i64)
(i64.store $$mem2 (local.get 0) (local.get 1))
)
)`);
// ./test/core/store.wast:76
invoke($3, `store1`, [0, 1n]);
// ./test/core/store.wast:77
invoke($3, `store2`, [0, 2n]);
// ./test/core/store.wast:78
assert_return(() => invoke($3, `load1`, [0]), [value("i64", 1n)]);
// ./test/core/store.wast:79
assert_return(() => invoke($3, `load2`, [0]), [value("i64", 2n)]);
// ./test/core/store.wast:82
let $4 = instantiate(`(module
(memory (export "mem") 2)
)`);
// ./test/core/store.wast:85
register($4, `M`);
// ./test/core/store.wast:87
let $5 = instantiate(`(module
(memory $$mem1 (import "M" "mem") 2)
(memory $$mem2 3)
(data (memory $$mem1) (i32.const 20) "\\01\\02\\03\\04\\05")
(data (memory $$mem2) (i32.const 50) "\\0A\\0B\\0C\\0D\\0E")
(func (export "read1") (param i32) (result i32)
(i32.load8_u $$mem1 (local.get 0))
)
(func (export "read2") (param i32) (result i32)
(i32.load8_u $$mem2 (local.get 0))
)
(func (export "copy-1-to-2")
(local $$i i32)
(local.set $$i (i32.const 20))
(loop $$cont
(br_if 1 (i32.eq (local.get $$i) (i32.const 23)))
(i32.store8 $$mem2 (local.get $$i) (i32.load8_u $$mem1 (local.get $$i)))
(local.set $$i (i32.add (local.get $$i) (i32.const 1)))
(br $$cont)
)
)
(func (export "copy-2-to-1")
(local $$i i32)
(local.set $$i (i32.const 50))
(loop $$cont
(br_if 1 (i32.eq (local.get $$i) (i32.const 54)))
(i32.store8 $$mem1 (local.get $$i) (i32.load8_u $$mem2 (local.get $$i)))
(local.set $$i (i32.add (local.get $$i) (i32.const 1)))
(br $$cont)
)
)
)`);
// ./test/core/store.wast:124
assert_return(() => invoke($5, `read2`, [20]), [value("i32", 0)]);
// ./test/core/store.wast:125
assert_return(() => invoke($5, `read2`, [21]), [value("i32", 0)]);
// ./test/core/store.wast:126
assert_return(() => invoke($5, `read2`, [22]), [value("i32", 0)]);
// ./test/core/store.wast:127
assert_return(() => invoke($5, `read2`, [23]), [value("i32", 0)]);
// ./test/core/store.wast:128
assert_return(() => invoke($5, `read2`, [24]), [value("i32", 0)]);
// ./test/core/store.wast:129
invoke($5, `copy-1-to-2`, []);
// ./test/core/store.wast:130
assert_return(() => invoke($5, `read2`, [20]), [value("i32", 1)]);
// ./test/core/store.wast:131
assert_return(() => invoke($5, `read2`, [21]), [value("i32", 2)]);
// ./test/core/store.wast:132
assert_return(() => invoke($5, `read2`, [22]), [value("i32", 3)]);
// ./test/core/store.wast:133
assert_return(() => invoke($5, `read2`, [23]), [value("i32", 0)]);
// ./test/core/store.wast:134
assert_return(() => invoke($5, `read2`, [24]), [value("i32", 0)]);
// ./test/core/store.wast:136
assert_return(() => invoke($5, `read1`, [50]), [value("i32", 0)]);
// ./test/core/store.wast:137
assert_return(() => invoke($5, `read1`, [51]), [value("i32", 0)]);
// ./test/core/store.wast:138
assert_return(() => invoke($5, `read1`, [52]), [value("i32", 0)]);
// ./test/core/store.wast:139
assert_return(() => invoke($5, `read1`, [53]), [value("i32", 0)]);
// ./test/core/store.wast:140
assert_return(() => invoke($5, `read1`, [54]), [value("i32", 0)]);
// ./test/core/store.wast:141
invoke($5, `copy-2-to-1`, []);
// ./test/core/store.wast:142
assert_return(() => invoke($5, `read1`, [50]), [value("i32", 10)]);
// ./test/core/store.wast:143
assert_return(() => invoke($5, `read1`, [51]), [value("i32", 11)]);
// ./test/core/store.wast:144
assert_return(() => invoke($5, `read1`, [52]), [value("i32", 12)]);
// ./test/core/store.wast:145
assert_return(() => invoke($5, `read1`, [53]), [value("i32", 13)]);
// ./test/core/store.wast:146
assert_return(() => invoke($5, `read1`, [54]), [value("i32", 0)]);
// ./test/core/store.wast:151
let $6 = instantiate(`(module
(memory 1)
(func (export "as-block-value")
@@ -277,130 +57,130 @@ let $6 = instantiate(`(module
)
)`);
// ./test/core/store.wast:192
assert_return(() => invoke($6, `as-block-value`, []), []);
// ./test/core/store.wast:44
assert_return(() => invoke($0, `as-block-value`, []), []);
// ./test/core/store.wast:193
assert_return(() => invoke($6, `as-loop-value`, []), []);
// ./test/core/store.wast:45
assert_return(() => invoke($0, `as-loop-value`, []), []);
// ./test/core/store.wast:195
assert_return(() => invoke($6, `as-br-value`, []), []);
// ./test/core/store.wast:47
assert_return(() => invoke($0, `as-br-value`, []), []);
// ./test/core/store.wast:196
assert_return(() => invoke($6, `as-br_if-value`, []), []);
// ./test/core/store.wast:48
assert_return(() => invoke($0, `as-br_if-value`, []), []);
// ./test/core/store.wast:197
assert_return(() => invoke($6, `as-br_if-value-cond`, []), []);
// ./test/core/store.wast:49
assert_return(() => invoke($0, `as-br_if-value-cond`, []), []);
// ./test/core/store.wast:198
assert_return(() => invoke($6, `as-br_table-value`, []), []);
// ./test/core/store.wast:50
assert_return(() => invoke($0, `as-br_table-value`, []), []);
// ./test/core/store.wast:200
assert_return(() => invoke($6, `as-return-value`, []), []);
// ./test/core/store.wast:52
assert_return(() => invoke($0, `as-return-value`, []), []);
// ./test/core/store.wast:202
assert_return(() => invoke($6, `as-if-then`, []), []);
// ./test/core/store.wast:54
assert_return(() => invoke($0, `as-if-then`, []), []);
// ./test/core/store.wast:203
assert_return(() => invoke($6, `as-if-else`, []), []);
// ./test/core/store.wast:55
assert_return(() => invoke($0, `as-if-else`, []), []);
// ./test/core/store.wast:205
// ./test/core/store.wast:57
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (i32.store32 (local.get 0) (i32.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:212
// ./test/core/store.wast:64
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (i32.store64 (local.get 0) (i64.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:220
// ./test/core/store.wast:72
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (i64.store64 (local.get 0) (i64.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:228
// ./test/core/store.wast:80
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (f32.store32 (local.get 0) (f32.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:235
// ./test/core/store.wast:87
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (f32.store64 (local.get 0) (f64.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:243
// ./test/core/store.wast:95
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (f64.store32 (local.get 0) (f32.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:250
// ./test/core/store.wast:102
assert_malformed(
() => instantiate(`(memory 1) (func (param i32) (f64.store64 (local.get 0) (f64.const 0))) `),
`unknown operator`,
);
// ./test/core/store.wast:259
// ./test/core/store.wast:111
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i32) (result i32) (i32.store (i32.const 0) (i32.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:263
// ./test/core/store.wast:115
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i64) (result i64) (i64.store (i32.const 0) (i64.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:267
// ./test/core/store.wast:119
assert_invalid(
() => instantiate(`(module (memory 1) (func (param f32) (result f32) (f32.store (i32.const 0) (f32.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:271
// ./test/core/store.wast:123
assert_invalid(
() => instantiate(`(module (memory 1) (func (param f64) (result f64) (f64.store (i32.const 0) (f64.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:275
// ./test/core/store.wast:127
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i32) (result i32) (i32.store8 (i32.const 0) (i32.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:279
// ./test/core/store.wast:131
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i32) (result i32) (i32.store16 (i32.const 0) (i32.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:283
// ./test/core/store.wast:135
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i64) (result i64) (i64.store8 (i32.const 0) (i64.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:287
// ./test/core/store.wast:139
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i64) (result i64) (i64.store16 (i32.const 0) (i64.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:291
// ./test/core/store.wast:143
assert_invalid(
() => instantiate(`(module (memory 1) (func (param i64) (result i64) (i64.store32 (i32.const 0) (i64.const 1))))`),
`type mismatch`,
);
// ./test/core/store.wast:297
// ./test/core/store.wast:149
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -411,7 +191,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:306
// ./test/core/store.wast:158
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -422,7 +202,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:315
// ./test/core/store.wast:167
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -434,7 +214,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:325
// ./test/core/store.wast:177
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -446,7 +226,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:335
// ./test/core/store.wast:187
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -458,7 +238,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:345
// ./test/core/store.wast:197
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -470,7 +250,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:355
// ./test/core/store.wast:207
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -482,7 +262,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:365
// ./test/core/store.wast:217
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -494,7 +274,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:375
// ./test/core/store.wast:227
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -506,7 +286,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:385
// ./test/core/store.wast:237
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -518,7 +298,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:395
// ./test/core/store.wast:247
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -530,7 +310,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:405
// ./test/core/store.wast:257
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -542,7 +322,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:415
// ./test/core/store.wast:267
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -554,7 +334,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:425
// ./test/core/store.wast:277
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -566,7 +346,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:435
// ./test/core/store.wast:287
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -578,7 +358,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:445
// ./test/core/store.wast:297
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -590,7 +370,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:455
// ./test/core/store.wast:307
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -601,7 +381,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:464
// ./test/core/store.wast:316
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -612,7 +392,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:473
// ./test/core/store.wast:325
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -623,7 +403,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:482
// ./test/core/store.wast:334
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -634,7 +414,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:491
// ./test/core/store.wast:343
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -646,7 +426,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:501
// ./test/core/store.wast:353
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -658,7 +438,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:511
// ./test/core/store.wast:363
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -676,7 +456,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:527
// ./test/core/store.wast:379
assert_invalid(
() => instantiate(`(module
(memory 1)
@@ -694,109 +474,109 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/store.wast:547
// ./test/core/store.wast:399
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store (f32.const 0) (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:548
// ./test/core/store.wast:400
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store8 (f32.const 0) (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:549
// ./test/core/store.wast:401
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store16 (f32.const 0) (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:550
// ./test/core/store.wast:402
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store (f32.const 0) (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:551
// ./test/core/store.wast:403
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store8 (f32.const 0) (i64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:552
// ./test/core/store.wast:404
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store16 (f32.const 0) (i64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:553
// ./test/core/store.wast:405
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store32 (f32.const 0) (i64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:554
// ./test/core/store.wast:406
assert_invalid(
() => instantiate(`(module (memory 1) (func (f32.store (f32.const 0) (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:555
// ./test/core/store.wast:407
assert_invalid(
() => instantiate(`(module (memory 1) (func (f64.store (f32.const 0) (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:557
// ./test/core/store.wast:409
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store (i32.const 0) (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:558
// ./test/core/store.wast:410
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store8 (i32.const 0) (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:559
// ./test/core/store.wast:411
assert_invalid(
() => instantiate(`(module (memory 1) (func (i32.store16 (i32.const 0) (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:560
// ./test/core/store.wast:412
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store (i32.const 0) (f32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:561
// ./test/core/store.wast:413
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store8 (i32.const 0) (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:562
// ./test/core/store.wast:414
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store16 (i32.const 0) (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:563
// ./test/core/store.wast:415
assert_invalid(
() => instantiate(`(module (memory 1) (func (i64.store32 (i32.const 0) (f64.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:564
// ./test/core/store.wast:416
assert_invalid(
() => instantiate(`(module (memory 1) (func (f32.store (i32.const 0) (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/store.wast:565
// ./test/core/store.wast:417
assert_invalid(
() => instantiate(`(module (memory 1) (func (f64.store (i32.const 0) (i64.const 0))))`),
`type mismatch`,

View File

@@ -0,0 +1,40 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/table-sub.wast
// ./test/core/table-sub.wast:1
assert_invalid(
() => instantiate(`(module
(table $$t1 10 funcref)
(table $$t2 10 externref)
(func $$f
(table.copy $$t1 $$t2 (i32.const 0) (i32.const 1) (i32.const 2))
)
)`),
`type mismatch`,
);
// ./test/core/table-sub.wast:12
assert_invalid(
() => instantiate(`(module
(table $$t 10 funcref)
(elem $$el externref)
(func $$f
(table.init $$t $$el (i32.const 0) (i32.const 1) (i32.const 2))
)
)`),
`type mismatch`,
);

View File

@@ -0,0 +1,271 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/table_grow.wast
// ./test/core/table_grow.wast:1
let $0 = instantiate(`(module
(table $$t 0 externref)
(func (export "get") (param $$i i32) (result externref) (table.get $$t (local.get $$i)))
(func (export "set") (param $$i i32) (param $$r externref) (table.set $$t (local.get $$i) (local.get $$r)))
(func (export "grow") (param $$sz i32) (param $$init externref) (result i32)
(table.grow $$t (local.get $$init) (local.get $$sz))
)
(func (export "grow-abbrev") (param $$sz i32) (param $$init externref) (result i32)
(table.grow (local.get $$init) (local.get $$sz))
)
(func (export "size") (result i32) (table.size $$t))
)`);
// ./test/core/table_grow.wast:16
assert_return(() => invoke($0, `size`, []), [value("i32", 0)]);
// ./test/core/table_grow.wast:17
assert_trap(() => invoke($0, `set`, [0, externref(2)]), `out of bounds table access`);
// ./test/core/table_grow.wast:18
assert_trap(() => invoke($0, `get`, [0]), `out of bounds table access`);
// ./test/core/table_grow.wast:20
assert_return(() => invoke($0, `grow`, [1, null]), [value("i32", 0)]);
// ./test/core/table_grow.wast:21
assert_return(() => invoke($0, `size`, []), [value("i32", 1)]);
// ./test/core/table_grow.wast:22
assert_return(() => invoke($0, `get`, [0]), [value('externref', null)]);
// ./test/core/table_grow.wast:23
assert_return(() => invoke($0, `set`, [0, externref(2)]), []);
// ./test/core/table_grow.wast:24
assert_return(() => invoke($0, `get`, [0]), [new ExternRefResult(2)]);
// ./test/core/table_grow.wast:25
assert_trap(() => invoke($0, `set`, [1, externref(2)]), `out of bounds table access`);
// ./test/core/table_grow.wast:26
assert_trap(() => invoke($0, `get`, [1]), `out of bounds table access`);
// ./test/core/table_grow.wast:28
assert_return(() => invoke($0, `grow-abbrev`, [4, externref(3)]), [value("i32", 1)]);
// ./test/core/table_grow.wast:29
assert_return(() => invoke($0, `size`, []), [value("i32", 5)]);
// ./test/core/table_grow.wast:30
assert_return(() => invoke($0, `get`, [0]), [new ExternRefResult(2)]);
// ./test/core/table_grow.wast:31
assert_return(() => invoke($0, `set`, [0, externref(2)]), []);
// ./test/core/table_grow.wast:32
assert_return(() => invoke($0, `get`, [0]), [new ExternRefResult(2)]);
// ./test/core/table_grow.wast:33
assert_return(() => invoke($0, `get`, [1]), [new ExternRefResult(3)]);
// ./test/core/table_grow.wast:34
assert_return(() => invoke($0, `get`, [4]), [new ExternRefResult(3)]);
// ./test/core/table_grow.wast:35
assert_return(() => invoke($0, `set`, [4, externref(4)]), []);
// ./test/core/table_grow.wast:36
assert_return(() => invoke($0, `get`, [4]), [new ExternRefResult(4)]);
// ./test/core/table_grow.wast:37
assert_trap(() => invoke($0, `set`, [5, externref(2)]), `out of bounds table access`);
// ./test/core/table_grow.wast:38
assert_trap(() => invoke($0, `get`, [5]), `out of bounds table access`);
// ./test/core/table_grow.wast:42
let $1 = instantiate(`(module
(table $$t 0x10 funcref)
(elem declare func $$f)
(func $$f (export "grow") (result i32)
(table.grow $$t (ref.func $$f) (i32.const 0xffff_fff0))
)
)`);
// ./test/core/table_grow.wast:50
assert_return(() => invoke($1, `grow`, []), [value("i32", -1)]);
// ./test/core/table_grow.wast:53
let $2 = instantiate(`(module
(table $$t 0 externref)
(func (export "grow") (param i32) (result i32)
(table.grow $$t (ref.null extern) (local.get 0))
)
)`);
// ./test/core/table_grow.wast:60
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 0)]);
// ./test/core/table_grow.wast:61
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 0)]);
// ./test/core/table_grow.wast:62
assert_return(() => invoke($2, `grow`, [0]), [value("i32", 1)]);
// ./test/core/table_grow.wast:63
assert_return(() => invoke($2, `grow`, [2]), [value("i32", 1)]);
// ./test/core/table_grow.wast:64
assert_return(() => invoke($2, `grow`, [800]), [value("i32", 3)]);
// ./test/core/table_grow.wast:67
let $3 = instantiate(`(module
(table $$t 0 10 externref)
(func (export "grow") (param i32) (result i32)
(table.grow $$t (ref.null extern) (local.get 0))
)
)`);
// ./test/core/table_grow.wast:74
assert_return(() => invoke($3, `grow`, [0]), [value("i32", 0)]);
// ./test/core/table_grow.wast:75
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 0)]);
// ./test/core/table_grow.wast:76
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 1)]);
// ./test/core/table_grow.wast:77
assert_return(() => invoke($3, `grow`, [2]), [value("i32", 2)]);
// ./test/core/table_grow.wast:78
assert_return(() => invoke($3, `grow`, [6]), [value("i32", 4)]);
// ./test/core/table_grow.wast:79
assert_return(() => invoke($3, `grow`, [0]), [value("i32", 10)]);
// ./test/core/table_grow.wast:80
assert_return(() => invoke($3, `grow`, [1]), [value("i32", -1)]);
// ./test/core/table_grow.wast:81
assert_return(() => invoke($3, `grow`, [65536]), [value("i32", -1)]);
// ./test/core/table_grow.wast:84
let $4 = instantiate(`(module
(table $$t 10 funcref)
(func (export "grow") (param i32) (result i32)
(table.grow $$t (ref.null func) (local.get 0))
)
(elem declare func 1)
(func (export "check-table-null") (param i32 i32) (result funcref)
(local funcref)
(local.set 2 (ref.func 1))
(block
(loop
(local.set 2 (table.get $$t (local.get 0)))
(br_if 1 (i32.eqz (ref.is_null (local.get 2))))
(br_if 1 (i32.ge_u (local.get 0) (local.get 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if 0 (i32.le_u (local.get 0) (local.get 1)))
)
)
(local.get 2)
)
)`);
// ./test/core/table_grow.wast:106
assert_return(() => invoke($4, `check-table-null`, [0, 9]), [value('anyfunc', null)]);
// ./test/core/table_grow.wast:107
assert_return(() => invoke($4, `grow`, [10]), [value("i32", 10)]);
// ./test/core/table_grow.wast:108
assert_return(() => invoke($4, `check-table-null`, [0, 19]), [value('anyfunc', null)]);
// ./test/core/table_grow.wast:113
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
(func $$type-init-size-empty-vs-i32-externref (result i32)
(table.grow $$t)
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:122
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
(func $$type-size-empty-vs-i32 (result i32)
(table.grow $$t (ref.null extern))
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:131
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
(func $$type-init-empty-vs-externref (result i32)
(table.grow $$t (i32.const 1))
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:140
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
(func $$type-size-f32-vs-i32 (result i32)
(table.grow $$t (ref.null extern) (f32.const 1))
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:149
assert_invalid(
() => instantiate(`(module
(table $$t 0 funcref)
(func $$type-init-externref-vs-funcref (param $$r externref) (result i32)
(table.grow $$t (local.get $$r) (i32.const 1))
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:159
assert_invalid(
() => instantiate(`(module
(table $$t 1 externref)
(func $$type-result-i32-vs-empty
(table.grow $$t (ref.null extern) (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/table_grow.wast:168
assert_invalid(
() => instantiate(`(module
(table $$t 1 externref)
(func $$type-result-i32-vs-f32 (result f32)
(table.grow $$t (ref.null extern) (i32.const 0))
)
)`),
`type mismatch`,
);

View File

@@ -0,0 +1,22 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/token.wast
// ./test/core/token.wast:3
assert_malformed(() => instantiate(`(func (drop (i32.const0))) `), `unknown operator`);
// ./test/core/token.wast:7
assert_malformed(() => instantiate(`(func br 0drop) `), `unknown operator`);

View File

@@ -22,8 +22,8 @@ let $0 = instantiate(`(module
(func $$dummy3 (param i32 i32 i32))
(func (export "type-i32") (result i32) (unreachable))
(func (export "type-i64") (result i64) (unreachable))
(func (export "type-f32") (result f32) (unreachable))
(func (export "type-i64") (result i32) (unreachable))
(func (export "type-f32") (result f64) (unreachable))
(func (export "type-f64") (result f64) (unreachable))
(func (export "as-func-first") (result i32)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js

View File

@@ -1,832 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/global.wast
// ./test/core/global.wast:3
let $0 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(global (import "spectest" "global_i64") i64)
(global $$a i32 (i32.const -2))
(global (;3;) f32 (f32.const -3))
(global (;4;) f64 (f64.const -4))
(global $$b i64 (i64.const -5))
(global $$x (mut i32) (i32.const -12))
(global (;7;) (mut f32) (f32.const -13))
(global (;8;) (mut f64) (f64.const -14))
(global $$y (mut i64) (i64.const -15))
(global $$z1 i32 (global.get 0))
(global $$z2 i64 (global.get 1))
(global $$z3 i32 (i32.add (i32.sub (i32.mul (i32.const 20) (i32.const 2)) (i32.const 2)) (i32.const 4)))
(global $$z4 i64 (i64.add (i64.sub (i64.mul (i64.const 20) (i64.const 2)) (i64.const 2)) (i64.const 5)))
(global $$z5 i32 (i32.add (global.get 0) (i32.const 42)))
(global $$z6 i64 (i64.add (global.get 1) (i64.const 42)))
(global $$r externref (ref.null extern))
(global $$mr (mut externref) (ref.null extern))
(global funcref (ref.null func))
(func (export "get-a") (result i32) (global.get $$a))
(func (export "get-b") (result i64) (global.get $$b))
(func (export "get-r") (result externref) (global.get $$r))
(func (export "get-mr") (result externref) (global.get $$mr))
(func (export "get-x") (result i32) (global.get $$x))
(func (export "get-y") (result i64) (global.get $$y))
(func (export "get-z1") (result i32) (global.get $$z1))
(func (export "get-z2") (result i64) (global.get $$z2))
(func (export "get-z3") (result i32) (global.get $$z3))
(func (export "get-z4") (result i64) (global.get $$z4))
(func (export "get-z5") (result i32) (global.get $$z5))
(func (export "get-z6") (result i64) (global.get $$z6))
(func (export "set-x") (param i32) (global.set $$x (local.get 0)))
(func (export "set-y") (param i64) (global.set $$y (local.get 0)))
(func (export "set-mr") (param externref) (global.set $$mr (local.get 0)))
(func (export "get-3") (result f32) (global.get 3))
(func (export "get-4") (result f64) (global.get 4))
(func (export "get-7") (result f32) (global.get 7))
(func (export "get-8") (result f64) (global.get 8))
(func (export "set-7") (param f32) (global.set 7 (local.get 0)))
(func (export "set-8") (param f64) (global.set 8 (local.get 0)))
;; As the argument of control constructs and instructions
(memory 1)
(func $$dummy)
(func (export "as-select-first") (result i32)
(select (global.get $$x) (i32.const 2) (i32.const 3))
)
(func (export "as-select-mid") (result i32)
(select (i32.const 2) (global.get $$x) (i32.const 3))
)
(func (export "as-select-last") (result i32)
(select (i32.const 2) (i32.const 3) (global.get $$x))
)
(func (export "as-loop-first") (result i32)
(loop (result i32)
(global.get $$x) (call $$dummy) (call $$dummy)
)
)
(func (export "as-loop-mid") (result i32)
(loop (result i32)
(call $$dummy) (global.get $$x) (call $$dummy)
)
)
(func (export "as-loop-last") (result i32)
(loop (result i32)
(call $$dummy) (call $$dummy) (global.get $$x)
)
)
(func (export "as-if-condition") (result i32)
(if (result i32) (global.get $$x)
(then (call $$dummy) (i32.const 2))
(else (call $$dummy) (i32.const 3))
)
)
(func (export "as-if-then") (result i32)
(if (result i32) (i32.const 1)
(then (global.get $$x)) (else (i32.const 2))
)
)
(func (export "as-if-else") (result i32)
(if (result i32) (i32.const 0)
(then (i32.const 2)) (else (global.get $$x))
)
)
(func (export "as-br_if-first") (result i32)
(block (result i32)
(br_if 0 (global.get $$x) (i32.const 2))
(return (i32.const 3))
)
)
(func (export "as-br_if-last") (result i32)
(block (result i32)
(br_if 0 (i32.const 2) (global.get $$x))
(return (i32.const 3))
)
)
(func (export "as-br_table-first") (result i32)
(block (result i32)
(global.get $$x) (i32.const 2) (br_table 0 0)
)
)
(func (export "as-br_table-last") (result i32)
(block (result i32)
(i32.const 2) (global.get $$x) (br_table 0 0)
)
)
(func $$func (param i32 i32) (result i32) (local.get 0))
(type $$check (func (param i32 i32) (result i32)))
(table funcref (elem $$func))
(func (export "as-call_indirect-first") (result i32)
(block (result i32)
(call_indirect (type $$check)
(global.get $$x) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-mid") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (global.get $$x) (i32.const 0)
)
)
)
(func (export "as-call_indirect-last") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (i32.const 0) (global.get $$x)
)
)
)
(func (export "as-store-first")
(global.get $$x) (i32.const 1) (i32.store)
)
(func (export "as-store-last")
(i32.const 0) (global.get $$x) (i32.store)
)
(func (export "as-load-operand") (result i32)
(i32.load (global.get $$x))
)
(func (export "as-memory.grow-value") (result i32)
(memory.grow (global.get $$x))
)
(func $$f (param i32) (result i32) (local.get 0))
(func (export "as-call-value") (result i32)
(call $$f (global.get $$x))
)
(func (export "as-return-value") (result i32)
(global.get $$x) (return)
)
(func (export "as-drop-operand")
(drop (global.get $$x))
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (global.get $$x)))
)
(func (export "as-local.set-value") (param i32) (result i32)
(local.set 0 (global.get $$x))
(local.get 0)
)
(func (export "as-local.tee-value") (param i32) (result i32)
(local.tee 0 (global.get $$x))
)
(func (export "as-global.set-value") (result i32)
(global.set $$x (global.get $$x))
(global.get $$x)
)
(func (export "as-unary-operand") (result i32)
(i32.eqz (global.get $$x))
)
(func (export "as-binary-operand") (result i32)
(i32.mul
(global.get $$x) (global.get $$x)
)
)
(func (export "as-compare-operand") (result i32)
(i32.gt_u
(global.get 0) (i32.const 1)
)
)
)`);
// ./test/core/global.wast:204
assert_return(() => invoke($0, `get-a`, []), [value("i32", -2)]);
// ./test/core/global.wast:205
assert_return(() => invoke($0, `get-b`, []), [value("i64", -5n)]);
// ./test/core/global.wast:206
assert_return(() => invoke($0, `get-r`, []), [value('externref', null)]);
// ./test/core/global.wast:207
assert_return(() => invoke($0, `get-mr`, []), [value('externref', null)]);
// ./test/core/global.wast:208
assert_return(() => invoke($0, `get-x`, []), [value("i32", -12)]);
// ./test/core/global.wast:209
assert_return(() => invoke($0, `get-y`, []), [value("i64", -15n)]);
// ./test/core/global.wast:210
assert_return(() => invoke($0, `get-z1`, []), [value("i32", 666)]);
// ./test/core/global.wast:211
assert_return(() => invoke($0, `get-z2`, []), [value("i64", 666n)]);
// ./test/core/global.wast:212
assert_return(() => invoke($0, `get-z3`, []), [value("i32", 42)]);
// ./test/core/global.wast:213
assert_return(() => invoke($0, `get-z4`, []), [value("i64", 43n)]);
// ./test/core/global.wast:214
assert_return(() => invoke($0, `get-z5`, []), [value("i32", 708)]);
// ./test/core/global.wast:215
assert_return(() => invoke($0, `get-z6`, []), [value("i64", 708n)]);
// ./test/core/global.wast:217
assert_return(() => invoke($0, `get-3`, []), [value("f32", -3)]);
// ./test/core/global.wast:218
assert_return(() => invoke($0, `get-4`, []), [value("f64", -4)]);
// ./test/core/global.wast:219
assert_return(() => invoke($0, `get-7`, []), [value("f32", -13)]);
// ./test/core/global.wast:220
assert_return(() => invoke($0, `get-8`, []), [value("f64", -14)]);
// ./test/core/global.wast:222
assert_return(() => invoke($0, `set-x`, [6]), []);
// ./test/core/global.wast:223
assert_return(() => invoke($0, `set-y`, [7n]), []);
// ./test/core/global.wast:225
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:226
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:228
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:229
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:230
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:231
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:233
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:234
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:235
assert_return(() => invoke($0, `set-mr`, [externref(10)]), []);
// ./test/core/global.wast:237
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:238
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:239
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:240
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:241
assert_return(() => invoke($0, `get-mr`, []), [new ExternRefResult(10)]);
// ./test/core/global.wast:243
assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:244
assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:245
assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:247
assert_return(() => invoke($0, `as-loop-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:248
assert_return(() => invoke($0, `as-loop-mid`, []), [value("i32", 6)]);
// ./test/core/global.wast:249
assert_return(() => invoke($0, `as-loop-last`, []), [value("i32", 6)]);
// ./test/core/global.wast:251
assert_return(() => invoke($0, `as-if-condition`, []), [value("i32", 2)]);
// ./test/core/global.wast:252
assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 6)]);
// ./test/core/global.wast:253
assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 6)]);
// ./test/core/global.wast:255
assert_return(() => invoke($0, `as-br_if-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:256
assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:258
assert_return(() => invoke($0, `as-br_table-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:259
assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:261
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:262
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:263
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `undefined element`);
// ./test/core/global.wast:265
assert_return(() => invoke($0, `as-store-first`, []), []);
// ./test/core/global.wast:266
assert_return(() => invoke($0, `as-store-last`, []), []);
// ./test/core/global.wast:267
assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:268
assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
// ./test/core/global.wast:270
assert_return(() => invoke($0, `as-call-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:272
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:273
assert_return(() => invoke($0, `as-drop-operand`, []), []);
// ./test/core/global.wast:274
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:276
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:277
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:278
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:280
assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 0)]);
// ./test/core/global.wast:281
assert_return(() => invoke($0, `as-binary-operand`, []), [value("i32", 36)]);
// ./test/core/global.wast:282
assert_return(() => invoke($0, `as-compare-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:284
assert_invalid(
() => instantiate(`(module (global f32 (f32.const 0)) (func (global.set 0 (f32.const 1))))`),
`global is immutable`,
);
// ./test/core/global.wast:289
assert_invalid(
() => instantiate(`(module (import "spectest" "global_i32" (global i32)) (func (global.set 0 (i32.const 1))))`),
`global is immutable`,
);
// ./test/core/global.wast:295
let $1 = instantiate(`(module (global (mut f32) (f32.const 0)) (export "a" (global 0)))`);
// ./test/core/global.wast:296
let $2 = instantiate(`(module (global (export "a") (mut f32) (f32.const 0)))`);
// ./test/core/global.wast:298
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:303
assert_invalid(
() => instantiate(`(module (global f32 (local.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:308
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 1))))`),
`constant expression required`,
);
// ./test/core/global.wast:313
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:318
assert_invalid(
() => instantiate(`(module (global i32 (i32.ctz (i32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:323
assert_invalid(
() => instantiate(`(module (global i32 (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:328
assert_invalid(() => instantiate(`(module (global i32 (f32.const 0)))`), `type mismatch`);
// ./test/core/global.wast:333
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (i32.const 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:338
assert_invalid(
() => instantiate(`(module (global i32 (;empty instruction sequence;)))`),
`type mismatch`,
);
// ./test/core/global.wast:343
assert_invalid(
() => instantiate(`(module (global (import "" "") externref) (global funcref (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:348
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:353
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (i32.const 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:358
assert_invalid(
() => instantiate(`(module (global i32 (global.get 0)))`),
`unknown global`,
);
// The GC proposal allows global initializers to reference previously-defined
// immutable globals. These tests are out of date.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1926357
// // ./test/core/global.wast:363
// assert_invalid(
// () => instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`),
// `unknown global`,
// );
// // ./test/core/global.wast:367
// assert_invalid(
// () => instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`),
// `unknown global`,
// );
// ./test/core/global.wast:372
assert_invalid(
() => instantiate(`(module (global i32 (global.get 1)) (global i32 (i32.const 0)))`),
`unknown global`,
);
// ./test/core/global.wast:377
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 2)))`),
`unknown global`,
);
// ./test/core/global.wast:382
assert_invalid(
() => instantiate(`(module (global (import "test" "global-mut-i32") (mut i32)) (global i32 (global.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:387
let $3 = instantiate(`(module
(import "spectest" "global_i32" (global i32))
)`);
// ./test/core/global.wast:390
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\02" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:403
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\ff" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:417
let $4 = instantiate(`(module
(global i32 (i32.const 0))
)`);
// ./test/core/global.wast:420
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\02" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:432
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\ff" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:446
assert_invalid(
() => instantiate(`(module (func (result i32) (global.get 0)))`),
`unknown global`,
);
// ./test/core/global.wast:451
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:459
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:467
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (result i32) (global.get 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:477
assert_invalid(
() => instantiate(`(module (func (i32.const 0) (global.set 0)))`),
`unknown global`,
);
// ./test/core/global.wast:482
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:490
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:498
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:508
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty
(global.set $$x)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:517
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-block
(i32.const 0)
(block (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:527
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-loop
(i32.const 0)
(loop (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:537
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-then
(i32.const 0) (i32.const 0)
(if (then (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:547
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-else
(i32.const 0) (i32.const 0)
(if (result i32) (then (i32.const 0)) (else (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:557
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br
(i32.const 0)
(block (br 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:567
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_if
(i32.const 0)
(block (br_if 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:577
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_table
(i32.const 0)
(block (br_table 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:587
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-return
(return (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:596
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-select
(select (global.set $$x) (i32.const 1) (i32.const 2))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:605
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-call
(call 1 (global.set $$x))
)
(func (param i32) (result i32) (local.get 0))
)`),
`type mismatch`,
);
// ./test/core/global.wast:615
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$f (param i32) (result i32) (local.get 0))
(type $$sig (func (param i32) (result i32)))
(table funcref (elem $$f))
(func $$type-global.set-value-empty-in-call_indirect
(block (result i32)
(call_indirect (type $$sig)
(global.set $$x) (i32.const 0)
)
)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:634
assert_malformed(
() => instantiate(`(global $$foo i32 (i32.const 0)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:638
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:642
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (import "" "" (global $$foo i32)) `),
`duplicate global`,
);

View File

@@ -1 +0,0 @@
|jit-test| skip-if: true

View File

@@ -1,445 +0,0 @@
"use strict";
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!wasmIsSupported()) {
quit();
}
function bytes(type, bytes) {
var typedBuffer = new Uint8Array(bytes);
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
}
function value(type, value) {
return new WebAssembly.Global({
value: type,
mutable: false,
}, value);
}
function i8x16(elements) {
let typedBuffer = new Uint8Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i16x8(elements) {
let typedBuffer = new Uint16Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i32x4(elements) {
let typedBuffer = new Uint32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i64x2(elements) {
let typedBuffer = new BigUint64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f32x4(elements) {
let typedBuffer = new Float32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f64x2(elements) {
let typedBuffer = new Float64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function either(...arr) {
return new EitherVariants(arr);
}
class F32x4Pattern {
constructor(x, y, z, w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
}
class F64x2Pattern {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class RefWithType {
constructor(type) {
this.type = type;
}
formatExpected() {
return `RefWithType(${this.type})`;
}
test(refGlobal) {
try {
new WebAssembly.Global({value: this.type}, refGlobal.value);
return true;
} catch (err) {
assertEq(err instanceof TypeError, true, `wrong type of error when creating global: ${err}`);
assertEq(!!err.message.match(/can only pass/), true, `wrong type of error when creating global: ${err}`);
return false;
}
}
}
// ref.extern values created by spec tests will be JS objects of the form
// { [externsym]: <number> }. Other externref values are possible to observe
// if extern.convert_any is used.
let externsym = Symbol("externref");
function externref(s) {
return { [externsym]: s };
}
function is_externref(x) {
return (x !== null && externsym in x) ? 1 : 0;
}
function is_funcref(x) {
return typeof x === "function" ? 1 : 0;
}
function eq_externref(x, y) {
return x === y ? 1 : 0;
}
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
class ExternRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.extern ${this.n}`;
}
test(global) {
// the global's value can either be an externref or just a plain old JS number
let result = global.value;
if (typeof global.value === "object" && externsym in global.value) {
result = global.value[externsym];
}
return result === this.n;
}
}
// ref.host values created by spectests will be whatever the JS API does to
// convert the given value to anyref. It should implicitly be like any.convert_extern.
function hostref(v) {
const { internalizeNum } = new WebAssembly.Instance(
new WebAssembly.Module(wasmTextToBinary(`(module
(func (import "test" "coerce") (param i32) (result anyref))
(func (export "internalizeNum") (param i32) (result anyref)
(call 0 (local.get 0))
)
)`)),
{ "test": { "coerce": x => x } },
).exports;
return internalizeNum(v);
}
class HostRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.host ${this.n}`;
}
test(externrefGlobal) {
assertEq(externsym in externrefGlobal.value, true, `HostRefResult only works with externref inputs`);
return externrefGlobal.value[externsym] === this.n;
}
}
let spectest = {
externref: externref,
is_externref: is_externref,
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
print_f64_f64: console.log.bind(console),
print_f32: console.log.bind(console),
print_f64: console.log.bind(console),
global_i32: 666,
global_i64: 666n,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({
initial: 10,
maximum: 20,
element: "anyfunc",
}),
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
};
let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
}
function instantiate(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
assertEq(
global instanceof WebAssembly.Global,
true,
"expected a WebAssembly.Global",
);
return global;
}
function assert_trap(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.RuntimeError) {
return;
}
err.message = `expected trap (${message}): ${err.message}`;
throw err;
}
}
let StackOverflow;
try {
(function f() {
1 + f();
})();
} catch (e) {
StackOverflow = e.constructor;
}
function assert_exhaustion(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof StackOverflow) {
return;
}
err.message = `expected exhaustion (${message}): ${err.message}`;
throw err;
}
}
function assert_invalid(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected invalid module (${message}): ${err.message}`;
throw err;
}
}
function assert_unlinkable(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected an unlinkable module (${message}): ${err.message}`;
throw err;
}
}
function assert_malformed(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (
err instanceof TypeError ||
err instanceof SyntaxError ||
err instanceof WebAssembly.CompileError ||
err instanceof WebAssembly.LinkError
) {
return;
}
err.message = `expected a malformed module (${message}): ${err.message}`;
throw err;
}
}
function assert_exception(thunk) {
let thrown = false;
try {
thunk();
} catch (err) {
thrown = true;
}
assertEq(thrown, true, "expected an exception to be thrown");
}
function assert_return(thunk, expected) {
let results = thunk();
if (results === undefined) {
results = [];
} else if (!Array.isArray(results)) {
results = [results];
}
if (!Array.isArray(expected)) {
expected = [expected];
}
if (!compareResults(results, expected)) {
let got = results.map((x) => formatResult(x)).join(", ");
let wanted = expected.map((x) => formatExpected(x)).join(", ");
assertEq(
`[${got}]`,
`[${wanted}]`,
);
assertEq(true, false, `${got} !== ${wanted}`);
}
}
function formatResult(result) {
if (typeof (result) === "object") {
return wasmGlobalToString(result);
} else {
return `${result}`;
}
}
function formatExpected(expected) {
if (
expected === `f32_canonical_nan` ||
expected === `f32_arithmetic_nan` ||
expected === `f64_canonical_nan` ||
expected === `f64_arithmetic_nan`
) {
return expected;
} else if (expected instanceof F32x4Pattern) {
return `f32x4(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
}, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`;
} else if (expected instanceof F64x2Pattern) {
return `f64x2(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
})`;
} else if (expected instanceof EitherVariants) {
return expected.formatExpected();
} else if (expected instanceof RefWithType) {
return expected.formatExpected();
} else if (expected instanceof ExternRefResult) {
return expected.formatExpected();
} else if (expected instanceof HostRefResult) {
return expected.formatExpected();
} else if (typeof (expected) === "object") {
return wasmGlobalToString(expected);
} else {
throw new Error("unknown expected result");
}
}
class EitherVariants {
constructor(arr) {
this.arr = arr;
}
matches(v) {
return this.arr.some((e) => compareResult(v, e));
}
formatExpected() {
return `either(${this.arr.map(formatExpected).join(", ")})`;
}
}
function compareResults(results, expected) {
if (results.length !== expected.length) {
return false;
}
for (let i in results) {
if (expected[i] instanceof EitherVariants) {
return expected[i].matches(results[i]);
}
if (!compareResult(results[i], expected[i])) {
return false;
}
}
return true;
}
function compareResult(result, expected) {
if (
expected === `canonical_nan` ||
expected === `arithmetic_nan`
) {
return wasmGlobalIsNaN(result, expected);
} else if (expected === null) {
return result.value === null;
} else if (expected instanceof F32x4Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f32x4", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w);
} else if (expected instanceof F64x2Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f64x2", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y);
} else if (expected instanceof RefWithType) {
return expected.test(result);
} else if (expected instanceof ExternRefResult) {
return expected.test(result);
} else if (expected instanceof HostRefResult) {
return expected.test(result);
} else if (typeof (expected) === "object") {
return wasmGlobalsEqual(result, expected);
} else {
throw new Error("unknown expected result");
}
}

View File

@@ -1 +0,0 @@
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js

View File

@@ -1,796 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/global.wast
// ./test/core/global.wast:3
let $0 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(global (import "spectest" "global_i64") i64)
(global $$a i32 (i32.const -2))
(global (;3;) f32 (f32.const -3))
(global (;4;) f64 (f64.const -4))
(global $$b i64 (i64.const -5))
(global $$x (mut i32) (i32.const -12))
(global (;7;) (mut f32) (f32.const -13))
(global (;8;) (mut f64) (f64.const -14))
(global $$y (mut i64) (i64.const -15))
(global $$z1 i32 (global.get 0))
(global $$z2 i64 (global.get 1))
(global $$r externref (ref.null extern))
(global $$mr (mut externref) (ref.null extern))
(global funcref (ref.null func))
(func (export "get-a") (result i32) (global.get $$a))
(func (export "get-b") (result i64) (global.get $$b))
(func (export "get-r") (result externref) (global.get $$r))
(func (export "get-mr") (result externref) (global.get $$mr))
(func (export "get-x") (result i32) (global.get $$x))
(func (export "get-y") (result i64) (global.get $$y))
(func (export "get-z1") (result i32) (global.get $$z1))
(func (export "get-z2") (result i64) (global.get $$z2))
(func (export "set-x") (param i32) (global.set $$x (local.get 0)))
(func (export "set-y") (param i64) (global.set $$y (local.get 0)))
(func (export "set-mr") (param externref) (global.set $$mr (local.get 0)))
(func (export "get-3") (result f32) (global.get 3))
(func (export "get-4") (result f64) (global.get 4))
(func (export "get-7") (result f32) (global.get 7))
(func (export "get-8") (result f64) (global.get 8))
(func (export "set-7") (param f32) (global.set 7 (local.get 0)))
(func (export "set-8") (param f64) (global.set 8 (local.get 0)))
;; As the argument of control constructs and instructions
(memory 1)
(func $$dummy)
(func (export "as-select-first") (result i32)
(select (global.get $$x) (i32.const 2) (i32.const 3))
)
(func (export "as-select-mid") (result i32)
(select (i32.const 2) (global.get $$x) (i32.const 3))
)
(func (export "as-select-last") (result i32)
(select (i32.const 2) (i32.const 3) (global.get $$x))
)
(func (export "as-loop-first") (result i32)
(loop (result i32)
(global.get $$x) (call $$dummy) (call $$dummy)
)
)
(func (export "as-loop-mid") (result i32)
(loop (result i32)
(call $$dummy) (global.get $$x) (call $$dummy)
)
)
(func (export "as-loop-last") (result i32)
(loop (result i32)
(call $$dummy) (call $$dummy) (global.get $$x)
)
)
(func (export "as-if-condition") (result i32)
(if (result i32) (global.get $$x)
(then (call $$dummy) (i32.const 2))
(else (call $$dummy) (i32.const 3))
)
)
(func (export "as-if-then") (result i32)
(if (result i32) (i32.const 1)
(then (global.get $$x)) (else (i32.const 2))
)
)
(func (export "as-if-else") (result i32)
(if (result i32) (i32.const 0)
(then (i32.const 2)) (else (global.get $$x))
)
)
(func (export "as-br_if-first") (result i32)
(block (result i32)
(br_if 0 (global.get $$x) (i32.const 2))
(return (i32.const 3))
)
)
(func (export "as-br_if-last") (result i32)
(block (result i32)
(br_if 0 (i32.const 2) (global.get $$x))
(return (i32.const 3))
)
)
(func (export "as-br_table-first") (result i32)
(block (result i32)
(global.get $$x) (i32.const 2) (br_table 0 0)
)
)
(func (export "as-br_table-last") (result i32)
(block (result i32)
(i32.const 2) (global.get $$x) (br_table 0 0)
)
)
(func $$func (param i32 i32) (result i32) (local.get 0))
(type $$check (func (param i32 i32) (result i32)))
(table funcref (elem $$func))
(func (export "as-call_indirect-first") (result i32)
(block (result i32)
(call_indirect (type $$check)
(global.get $$x) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-mid") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (global.get $$x) (i32.const 0)
)
)
)
(func (export "as-call_indirect-last") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (i32.const 0) (global.get $$x)
)
)
)
(func (export "as-store-first")
(global.get $$x) (i32.const 1) (i32.store)
)
(func (export "as-store-last")
(i32.const 0) (global.get $$x) (i32.store)
)
(func (export "as-load-operand") (result i32)
(i32.load (global.get $$x))
)
(func (export "as-memory.grow-value") (result i32)
(memory.grow (global.get $$x))
)
(func $$f (param i32) (result i32) (local.get 0))
(func (export "as-call-value") (result i32)
(call $$f (global.get $$x))
)
(func (export "as-return-value") (result i32)
(global.get $$x) (return)
)
(func (export "as-drop-operand")
(drop (global.get $$x))
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (global.get $$x)))
)
(func (export "as-local.set-value") (param i32) (result i32)
(local.set 0 (global.get $$x))
(local.get 0)
)
(func (export "as-local.tee-value") (param i32) (result i32)
(local.tee 0 (global.get $$x))
)
(func (export "as-global.set-value") (result i32)
(global.set $$x (global.get $$x))
(global.get $$x)
)
(func (export "as-unary-operand") (result i32)
(i32.eqz (global.get $$x))
)
(func (export "as-binary-operand") (result i32)
(i32.mul
(global.get $$x) (global.get $$x)
)
)
(func (export "as-compare-operand") (result i32)
(i32.gt_u
(global.get 0) (i32.const 1)
)
)
)`);
// ./test/core/global.wast:196
assert_return(() => invoke($0, `get-a`, []), [value("i32", -2)]);
// ./test/core/global.wast:197
assert_return(() => invoke($0, `get-b`, []), [value("i64", -5n)]);
// ./test/core/global.wast:198
assert_return(() => invoke($0, `get-r`, []), [value('externref', null)]);
// ./test/core/global.wast:199
assert_return(() => invoke($0, `get-mr`, []), [value('externref', null)]);
// ./test/core/global.wast:200
assert_return(() => invoke($0, `get-x`, []), [value("i32", -12)]);
// ./test/core/global.wast:201
assert_return(() => invoke($0, `get-y`, []), [value("i64", -15n)]);
// ./test/core/global.wast:202
assert_return(() => invoke($0, `get-z1`, []), [value("i32", 666)]);
// ./test/core/global.wast:203
assert_return(() => invoke($0, `get-z2`, []), [value("i64", 666n)]);
// ./test/core/global.wast:205
assert_return(() => invoke($0, `get-3`, []), [value("f32", -3)]);
// ./test/core/global.wast:206
assert_return(() => invoke($0, `get-4`, []), [value("f64", -4)]);
// ./test/core/global.wast:207
assert_return(() => invoke($0, `get-7`, []), [value("f32", -13)]);
// ./test/core/global.wast:208
assert_return(() => invoke($0, `get-8`, []), [value("f64", -14)]);
// ./test/core/global.wast:210
assert_return(() => invoke($0, `set-x`, [6]), []);
// ./test/core/global.wast:211
assert_return(() => invoke($0, `set-y`, [7n]), []);
// ./test/core/global.wast:213
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:214
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:216
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:217
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:218
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:219
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:221
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:222
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:223
assert_return(() => invoke($0, `set-mr`, [externref(10)]), []);
// ./test/core/global.wast:225
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:226
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:227
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:228
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:229
assert_return(() => invoke($0, `get-mr`, []), [new ExternRefResult(10)]);
// ./test/core/global.wast:231
assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:232
assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:233
assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:235
assert_return(() => invoke($0, `as-loop-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:236
assert_return(() => invoke($0, `as-loop-mid`, []), [value("i32", 6)]);
// ./test/core/global.wast:237
assert_return(() => invoke($0, `as-loop-last`, []), [value("i32", 6)]);
// ./test/core/global.wast:239
assert_return(() => invoke($0, `as-if-condition`, []), [value("i32", 2)]);
// ./test/core/global.wast:240
assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 6)]);
// ./test/core/global.wast:241
assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 6)]);
// ./test/core/global.wast:243
assert_return(() => invoke($0, `as-br_if-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:244
assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:246
assert_return(() => invoke($0, `as-br_table-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:247
assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:249
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:250
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:251
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `undefined element`);
// ./test/core/global.wast:253
assert_return(() => invoke($0, `as-store-first`, []), []);
// ./test/core/global.wast:254
assert_return(() => invoke($0, `as-store-last`, []), []);
// ./test/core/global.wast:255
assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:256
assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
// ./test/core/global.wast:258
assert_return(() => invoke($0, `as-call-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:260
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:261
assert_return(() => invoke($0, `as-drop-operand`, []), []);
// ./test/core/global.wast:262
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:264
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:265
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:266
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:268
assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 0)]);
// ./test/core/global.wast:269
assert_return(() => invoke($0, `as-binary-operand`, []), [value("i32", 36)]);
// ./test/core/global.wast:270
assert_return(() => invoke($0, `as-compare-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:272
assert_invalid(
() => instantiate(`(module (global f32 (f32.const 0)) (func (global.set 0 (f32.const 1))))`),
`immutable global`,
);
// ./test/core/global.wast:277
assert_invalid(
() => instantiate(`(module (import "spectest" "global_i32" (global i32)) (func (global.set 0 (i32.const 1))))`),
`immutable global`,
);
// ./test/core/global.wast:283
let $1 = instantiate(`(module (global (mut f32) (f32.const 0)) (export "a" (global 0)))`);
// ./test/core/global.wast:284
let $2 = instantiate(`(module (global (export "a") (mut f32) (f32.const 0)))`);
// ./test/core/global.wast:286
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:291
assert_invalid(
() => instantiate(`(module (global f32 (local.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:296
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 1))))`),
`constant expression required`,
);
// ./test/core/global.wast:301
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:306
assert_invalid(
() => instantiate(`(module (global i32 (i32.ctz (i32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:311
assert_invalid(
() => instantiate(`(module (global i32 (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:316
assert_invalid(() => instantiate(`(module (global i32 (f32.const 0)))`), `type mismatch`);
// ./test/core/global.wast:321
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (i32.const 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:326
assert_invalid(
() => instantiate(`(module (global i32 (;empty instruction sequence;)))`),
`type mismatch`,
);
// ./test/core/global.wast:331
assert_invalid(
() => instantiate(`(module (global (import "" "") externref) (global funcref (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:336
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:341
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (i32.const 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:346
assert_invalid(
() => instantiate(`(module (global i32 (global.get 0)))`),
`unknown global`,
);
// ./test/core/global.wast:351
assert_invalid(
() => instantiate(`(module (global i32 (global.get 1)) (global i32 (i32.const 0)))`),
`unknown global`,
);
// ./test/core/global.wast:356
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 2)))`),
`unknown global`,
);
// ./test/core/global.wast:361
assert_invalid(
() => instantiate(`(module (global (import "test" "global-mut-i32") (mut i32)) (global i32 (global.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:366
let $3 = instantiate(`(module
(import "spectest" "global_i32" (global i32))
)`);
// ./test/core/global.wast:369
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\02" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:382
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\ff" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:396
let $4 = instantiate(`(module
(global i32 (i32.const 0))
)`);
// ./test/core/global.wast:399
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\02" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:411
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\ff" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:425
assert_invalid(
() => instantiate(`(module (func (result i32) (global.get 0)))`),
`unknown global`,
);
// ./test/core/global.wast:430
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:438
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:446
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (result i32) (global.get 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:456
assert_invalid(
() => instantiate(`(module (func (i32.const 0) (global.set 0)))`),
`unknown global`,
);
// ./test/core/global.wast:461
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:469
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:477
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:487
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty
(global.set $$x)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:496
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-block
(i32.const 0)
(block (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:506
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-loop
(i32.const 0)
(loop (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:516
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-then
(i32.const 0) (i32.const 0)
(if (then (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:526
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-else
(i32.const 0) (i32.const 0)
(if (result i32) (then (i32.const 0)) (else (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:536
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br
(i32.const 0)
(block (br 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:546
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_if
(i32.const 0)
(block (br_if 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:556
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_table
(i32.const 0)
(block (br_table 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:566
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-return
(return (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:575
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-select
(select (global.set $$x) (i32.const 1) (i32.const 2))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:584
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-call
(call 1 (global.set $$x))
)
(func (param i32) (result i32) (local.get 0))
)`),
`type mismatch`,
);
// ./test/core/global.wast:594
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$f (param i32) (result i32) (local.get 0))
(type $$sig (func (param i32) (result i32)))
(table funcref (elem $$f))
(func $$type-global.set-value-empty-in-call_indirect
(block (result i32)
(call_indirect (type $$sig)
(global.set $$x) (i32.const 0)
)
)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:613
assert_malformed(
() => instantiate(`(global $$foo i32 (i32.const 0)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:617
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:621
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (import "" "" (global $$foo i32)) `),
`duplicate global`,
);

View File

@@ -1 +0,0 @@
|jit-test| skip-if: true

View File

@@ -1,445 +0,0 @@
"use strict";
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!wasmIsSupported()) {
quit();
}
function bytes(type, bytes) {
var typedBuffer = new Uint8Array(bytes);
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
}
function value(type, value) {
return new WebAssembly.Global({
value: type,
mutable: false,
}, value);
}
function i8x16(elements) {
let typedBuffer = new Uint8Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i16x8(elements) {
let typedBuffer = new Uint16Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i32x4(elements) {
let typedBuffer = new Uint32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i64x2(elements) {
let typedBuffer = new BigUint64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f32x4(elements) {
let typedBuffer = new Float32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f64x2(elements) {
let typedBuffer = new Float64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function either(...arr) {
return new EitherVariants(arr);
}
class F32x4Pattern {
constructor(x, y, z, w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
}
class F64x2Pattern {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class RefWithType {
constructor(type) {
this.type = type;
}
formatExpected() {
return `RefWithType(${this.type})`;
}
test(refGlobal) {
try {
new WebAssembly.Global({value: this.type}, refGlobal.value);
return true;
} catch (err) {
assertEq(err instanceof TypeError, true, `wrong type of error when creating global: ${err}`);
assertEq(!!err.message.match(/can only pass/), true, `wrong type of error when creating global: ${err}`);
return false;
}
}
}
// ref.extern values created by spec tests will be JS objects of the form
// { [externsym]: <number> }. Other externref values are possible to observe
// if extern.convert_any is used.
let externsym = Symbol("externref");
function externref(s) {
return { [externsym]: s };
}
function is_externref(x) {
return (x !== null && externsym in x) ? 1 : 0;
}
function is_funcref(x) {
return typeof x === "function" ? 1 : 0;
}
function eq_externref(x, y) {
return x === y ? 1 : 0;
}
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
class ExternRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.extern ${this.n}`;
}
test(global) {
// the global's value can either be an externref or just a plain old JS number
let result = global.value;
if (typeof global.value === "object" && externsym in global.value) {
result = global.value[externsym];
}
return result === this.n;
}
}
// ref.host values created by spectests will be whatever the JS API does to
// convert the given value to anyref. It should implicitly be like any.convert_extern.
function hostref(v) {
const { internalizeNum } = new WebAssembly.Instance(
new WebAssembly.Module(wasmTextToBinary(`(module
(func (import "test" "coerce") (param i32) (result anyref))
(func (export "internalizeNum") (param i32) (result anyref)
(call 0 (local.get 0))
)
)`)),
{ "test": { "coerce": x => x } },
).exports;
return internalizeNum(v);
}
class HostRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.host ${this.n}`;
}
test(externrefGlobal) {
assertEq(externsym in externrefGlobal.value, true, `HostRefResult only works with externref inputs`);
return externrefGlobal.value[externsym] === this.n;
}
}
let spectest = {
externref: externref,
is_externref: is_externref,
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
print_f64_f64: console.log.bind(console),
print_f32: console.log.bind(console),
print_f64: console.log.bind(console),
global_i32: 666,
global_i64: 666n,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({
initial: 10,
maximum: 20,
element: "anyfunc",
}),
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
};
let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
}
function instantiate(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
assertEq(
global instanceof WebAssembly.Global,
true,
"expected a WebAssembly.Global",
);
return global;
}
function assert_trap(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.RuntimeError) {
return;
}
err.message = `expected trap (${message}): ${err.message}`;
throw err;
}
}
let StackOverflow;
try {
(function f() {
1 + f();
})();
} catch (e) {
StackOverflow = e.constructor;
}
function assert_exhaustion(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof StackOverflow) {
return;
}
err.message = `expected exhaustion (${message}): ${err.message}`;
throw err;
}
}
function assert_invalid(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected invalid module (${message}): ${err.message}`;
throw err;
}
}
function assert_unlinkable(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected an unlinkable module (${message}): ${err.message}`;
throw err;
}
}
function assert_malformed(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (
err instanceof TypeError ||
err instanceof SyntaxError ||
err instanceof WebAssembly.CompileError ||
err instanceof WebAssembly.LinkError
) {
return;
}
err.message = `expected a malformed module (${message}): ${err.message}`;
throw err;
}
}
function assert_exception(thunk) {
let thrown = false;
try {
thunk();
} catch (err) {
thrown = true;
}
assertEq(thrown, true, "expected an exception to be thrown");
}
function assert_return(thunk, expected) {
let results = thunk();
if (results === undefined) {
results = [];
} else if (!Array.isArray(results)) {
results = [results];
}
if (!Array.isArray(expected)) {
expected = [expected];
}
if (!compareResults(results, expected)) {
let got = results.map((x) => formatResult(x)).join(", ");
let wanted = expected.map((x) => formatExpected(x)).join(", ");
assertEq(
`[${got}]`,
`[${wanted}]`,
);
assertEq(true, false, `${got} !== ${wanted}`);
}
}
function formatResult(result) {
if (typeof (result) === "object") {
return wasmGlobalToString(result);
} else {
return `${result}`;
}
}
function formatExpected(expected) {
if (
expected === `f32_canonical_nan` ||
expected === `f32_arithmetic_nan` ||
expected === `f64_canonical_nan` ||
expected === `f64_arithmetic_nan`
) {
return expected;
} else if (expected instanceof F32x4Pattern) {
return `f32x4(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
}, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`;
} else if (expected instanceof F64x2Pattern) {
return `f64x2(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
})`;
} else if (expected instanceof EitherVariants) {
return expected.formatExpected();
} else if (expected instanceof RefWithType) {
return expected.formatExpected();
} else if (expected instanceof ExternRefResult) {
return expected.formatExpected();
} else if (expected instanceof HostRefResult) {
return expected.formatExpected();
} else if (typeof (expected) === "object") {
return wasmGlobalToString(expected);
} else {
throw new Error("unknown expected result");
}
}
class EitherVariants {
constructor(arr) {
this.arr = arr;
}
matches(v) {
return this.arr.some((e) => compareResult(v, e));
}
formatExpected() {
return `either(${this.arr.map(formatExpected).join(", ")})`;
}
}
function compareResults(results, expected) {
if (results.length !== expected.length) {
return false;
}
for (let i in results) {
if (expected[i] instanceof EitherVariants) {
return expected[i].matches(results[i]);
}
if (!compareResult(results[i], expected[i])) {
return false;
}
}
return true;
}
function compareResult(result, expected) {
if (
expected === `canonical_nan` ||
expected === `arithmetic_nan`
) {
return wasmGlobalIsNaN(result, expected);
} else if (expected === null) {
return result.value === null;
} else if (expected instanceof F32x4Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f32x4", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w);
} else if (expected instanceof F64x2Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f64x2", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y);
} else if (expected instanceof RefWithType) {
return expected.test(result);
} else if (expected instanceof ExternRefResult) {
return expected.test(result);
} else if (expected instanceof HostRefResult) {
return expected.test(result);
} else if (typeof (expected) === "object") {
return wasmGlobalsEqual(result, expected);
} else {
throw new Error("unknown expected result");
}
}

View File

@@ -1,109 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/unreached-valid.wast
// ./test/core/unreached-valid.wast:1
let $0 = instantiate(`(module
;; Check that both sides of the select are evaluated
(func (export "select-trap-left") (param $$cond i32) (result i32)
(select (unreachable) (i32.const 0) (local.get $$cond))
)
(func (export "select-trap-right") (param $$cond i32) (result i32)
(select (i32.const 0) (unreachable) (local.get $$cond))
)
(func (export "select-unreached")
(unreachable) (select)
(unreachable) (i32.const 0) (select)
(unreachable) (i32.const 0) (i32.const 0) (select)
(unreachable) (i32.const 0) (i32.const 0) (i32.const 0) (select)
(unreachable) (f32.const 0) (i32.const 0) (select)
(unreachable)
)
(func (export "select-unreached-result1") (result i32)
(unreachable) (i32.add (select))
)
(func (export "select-unreached-result2") (result i64)
(unreachable) (i64.add (select (i64.const 0) (i32.const 0)))
)
(func (export "select-unreached-num")
(unreachable)
(select)
(i32.eqz)
(drop)
)
(func (export "select-unreached-ref")
(unreachable)
(select)
(ref.is_null)
(drop)
)
(type $$t (func (param i32) (result i32)))
(func (export "call_ref-unreached") (result i32)
(unreachable)
(call_ref $$t)
)
)`);
// ./test/core/unreached-valid.wast:48
assert_trap(() => invoke($0, `select-trap-left`, [1]), `unreachable`);
// ./test/core/unreached-valid.wast:49
assert_trap(() => invoke($0, `select-trap-left`, [0]), `unreachable`);
// ./test/core/unreached-valid.wast:50
assert_trap(() => invoke($0, `select-trap-right`, [1]), `unreachable`);
// ./test/core/unreached-valid.wast:51
assert_trap(() => invoke($0, `select-trap-right`, [0]), `unreachable`);
// ./test/core/unreached-valid.wast:53
assert_trap(() => invoke($0, `select-unreached-result1`, []), `unreachable`);
// ./test/core/unreached-valid.wast:54
assert_trap(() => invoke($0, `select-unreached-result2`, []), `unreachable`);
// ./test/core/unreached-valid.wast:55
assert_trap(() => invoke($0, `select-unreached-num`, []), `unreachable`);
// ./test/core/unreached-valid.wast:56
assert_trap(() => invoke($0, `select-unreached-ref`, []), `unreachable`);
// ./test/core/unreached-valid.wast:58
assert_trap(() => invoke($0, `call_ref-unreached`, []), `unreachable`);
// ./test/core/unreached-valid.wast:63
let $1 = instantiate(`(module
(func (export "meet-bottom")
(block (result f64)
(block (result f32)
(unreachable)
(br_table 0 1 1 (i32.const 1))
)
(drop)
(f64.const 0)
)
(drop)
)
)`);
// ./test/core/unreached-valid.wast:77
assert_trap(() => invoke($1, `meet-bottom`, []), `unreachable`);

View File

@@ -0,0 +1,100 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/gc/array_new_data.wast
// ./test/core/gc/array_new_data.wast:1
let $0 = instantiate(`(module
(type $$arr (array (mut i8)))
(data $$d "abcd")
(func (export "array-new-data") (param i32 i32) (result (ref $$arr))
(array.new_data $$arr $$d (local.get 0) (local.get 1))
)
)`);
// ./test/core/gc/array_new_data.wast:12
assert_return(() => invoke($0, `array-new-data`, [0, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_data.wast:13
assert_return(() => invoke($0, `array-new-data`, [0, 4]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_data.wast:14
assert_return(() => invoke($0, `array-new-data`, [1, 2]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_data.wast:15
assert_return(() => invoke($0, `array-new-data`, [4, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_data.wast:18
assert_trap(() => invoke($0, `array-new-data`, [0, 5]), `out of bounds memory access`);
// ./test/core/gc/array_new_data.wast:19
assert_trap(() => invoke($0, `array-new-data`, [5, 0]), `out of bounds memory access`);
// ./test/core/gc/array_new_data.wast:20
assert_trap(() => invoke($0, `array-new-data`, [1, 4]), `out of bounds memory access`);
// ./test/core/gc/array_new_data.wast:21
assert_trap(() => invoke($0, `array-new-data`, [4, 1]), `out of bounds memory access`);
// ./test/core/gc/array_new_data.wast:24
let $1 = instantiate(`(module
(type $$arr (array (mut i8)))
(data $$d "\\aa\\bb\\cc\\dd")
(func (export "array-new-data-contents") (result i32 i32)
(local (ref $$arr))
(local.set 0 (array.new_data $$arr $$d (i32.const 1) (i32.const 2)))
(array.get_u $$arr (local.get 0) (i32.const 0))
(array.get_u $$arr (local.get 0) (i32.const 1))
)
)`);
// ./test/core/gc/array_new_data.wast:38
assert_return(() => invoke($1, `array-new-data-contents`, []), [value("i32", 187), value("i32", 204)]);
// ./test/core/gc/array_new_data.wast:40
let $2 = instantiate(`(module
(type $$arr (array (mut i32)))
(data $$d "\\aa\\bb\\cc\\dd")
(func (export "array-new-data-little-endian") (result i32)
(array.get $$arr
(array.new_data $$arr $$d (i32.const 0) (i32.const 1))
(i32.const 0))
)
)`);
// ./test/core/gc/array_new_data.wast:53
assert_return(() => invoke($2, `array-new-data-little-endian`, []), [value("i32", -573785174)]);
// ./test/core/gc/array_new_data.wast:55
let $3 = instantiate(`(module
(type $$arr (array (mut i16)))
(data $$d "\\00\\11\\22")
(func (export "array-new-data-unaligned") (result i32)
(array.get_u $$arr
(array.new_data $$arr $$d (i32.const 1) (i32.const 1))
(i32.const 0))
)
)`);
// ./test/core/gc/array_new_data.wast:68
assert_return(() => invoke($3, `array-new-data-unaligned`, []), [value("i32", 8721)]);

View File

@@ -0,0 +1,144 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/gc/array_new_elem.wast
// ./test/core/gc/array_new_elem.wast:3
let $0 = instantiate(`(module
(type $$arr (array i31ref))
(elem $$e i31ref
(ref.i31 (i32.const 0xaa))
(ref.i31 (i32.const 0xbb))
(ref.i31 (i32.const 0xcc))
(ref.i31 (i32.const 0xdd)))
(func (export "array-new-elem") (param i32 i32) (result (ref $$arr))
(array.new_elem $$arr $$e (local.get 0) (local.get 1))
)
)`);
// ./test/core/gc/array_new_elem.wast:18
assert_return(() => invoke($0, `array-new-elem`, [0, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:19
assert_return(() => invoke($0, `array-new-elem`, [0, 4]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:20
assert_return(() => invoke($0, `array-new-elem`, [1, 2]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:21
assert_return(() => invoke($0, `array-new-elem`, [4, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:24
assert_trap(() => invoke($0, `array-new-elem`, [0, 5]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:25
assert_trap(() => invoke($0, `array-new-elem`, [5, 0]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:26
assert_trap(() => invoke($0, `array-new-elem`, [1, 4]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:27
assert_trap(() => invoke($0, `array-new-elem`, [4, 1]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:29
let $1 = instantiate(`(module
(type $$arr (array i31ref))
(elem $$e i31ref
(ref.i31 (i32.const 0xaa))
(ref.i31 (i32.const 0xbb))
(ref.i31 (i32.const 0xcc))
(ref.i31 (i32.const 0xdd)))
(func (export "array-new-elem-contents") (result i32 i32)
(local (ref $$arr))
(local.set 0 (array.new_elem $$arr $$e (i32.const 1) (i32.const 2)))
(i31.get_u (array.get $$arr (local.get 0) (i32.const 0)))
(i31.get_u (array.get $$arr (local.get 0) (i32.const 1)))
)
)`);
// ./test/core/gc/array_new_elem.wast:47
assert_return(() => invoke($1, `array-new-elem-contents`, []), [value("i32", 187), value("i32", 204)]);
// ./test/core/gc/array_new_elem.wast:51
let $2 = instantiate(`(module
(type $$arr (array funcref))
(elem $$e func $$aa $$bb $$cc $$dd)
(func $$aa (result i32) (i32.const 0xaa))
(func $$bb (result i32) (i32.const 0xbb))
(func $$cc (result i32) (i32.const 0xcc))
(func $$dd (result i32) (i32.const 0xdd))
(func (export "array-new-elem") (param i32 i32) (result (ref $$arr))
(array.new_elem $$arr $$e (local.get 0) (local.get 1))
)
)`);
// ./test/core/gc/array_new_elem.wast:66
assert_return(() => invoke($2, `array-new-elem`, [0, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:67
assert_return(() => invoke($2, `array-new-elem`, [0, 4]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:68
assert_return(() => invoke($2, `array-new-elem`, [1, 2]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:69
assert_return(() => invoke($2, `array-new-elem`, [4, 0]), [new RefWithType('arrayref')]);
// ./test/core/gc/array_new_elem.wast:72
assert_trap(() => invoke($2, `array-new-elem`, [0, 5]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:73
assert_trap(() => invoke($2, `array-new-elem`, [5, 0]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:74
assert_trap(() => invoke($2, `array-new-elem`, [1, 4]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:75
assert_trap(() => invoke($2, `array-new-elem`, [4, 1]), `out of bounds table access`);
// ./test/core/gc/array_new_elem.wast:77
let $3 = instantiate(`(module
(type $$f (func (result i32)))
(type $$arr (array funcref))
(elem $$e func $$aa $$bb $$cc $$dd)
(func $$aa (result i32) (i32.const 0xaa))
(func $$bb (result i32) (i32.const 0xbb))
(func $$cc (result i32) (i32.const 0xcc))
(func $$dd (result i32) (i32.const 0xdd))
(table $$t 2 2 funcref)
(func (export "array-new-elem-contents") (result i32 i32)
(local (ref $$arr))
(local.set 0 (array.new_elem $$arr $$e (i32.const 1) (i32.const 2)))
(table.set $$t (i32.const 0) (array.get $$arr (local.get 0) (i32.const 0)))
(table.set $$t (i32.const 1) (array.get $$arr (local.get 0) (i32.const 1)))
(call_indirect (type $$f) (i32.const 0))
(call_indirect (type $$f) (i32.const 1))
)
)`);
// ./test/core/gc/array_new_elem.wast:103
assert_return(() => invoke($3, `array-new-elem-contents`, []), [value("i32", 187), value("i32", 204)]);

View File

@@ -1,886 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/br_if.wast
// ./test/core/br_if.wast:3
let $0 = instantiate(`(module
(func $$dummy)
(func (export "type-i32")
(block (drop (i32.ctz (br_if 0 (i32.const 0) (i32.const 1)))))
)
(func (export "type-i64")
(block (drop (i64.ctz (br_if 0 (i64.const 0) (i32.const 1)))))
)
(func (export "type-f32")
(block (drop (f32.neg (br_if 0 (f32.const 0) (i32.const 1)))))
)
(func (export "type-f64")
(block (drop (f64.neg (br_if 0 (f64.const 0) (i32.const 1)))))
)
(func (export "type-i32-value") (result i32)
(block (result i32) (i32.ctz (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "type-i64-value") (result i64)
(block (result i64) (i64.ctz (br_if 0 (i64.const 2) (i32.const 1))))
)
(func (export "type-f32-value") (result f32)
(block (result f32) (f32.neg (br_if 0 (f32.const 3) (i32.const 1))))
)
(func (export "type-f64-value") (result f64)
(block (result f64) (f64.neg (br_if 0 (f64.const 4) (i32.const 1))))
)
(func (export "as-block-first") (param i32) (result i32)
(block (br_if 0 (local.get 0)) (return (i32.const 2))) (i32.const 3)
)
(func (export "as-block-mid") (param i32) (result i32)
(block (call $$dummy) (br_if 0 (local.get 0)) (return (i32.const 2)))
(i32.const 3)
)
(func (export "as-block-last") (param i32)
(block (call $$dummy) (call $$dummy) (br_if 0 (local.get 0)))
)
(func (export "as-block-first-value") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 10) (local.get 0))) (return (i32.const 11))
)
)
(func (export "as-block-mid-value") (param i32) (result i32)
(block (result i32)
(call $$dummy)
(drop (br_if 0 (i32.const 20) (local.get 0)))
(return (i32.const 21))
)
)
(func (export "as-block-last-value") (param i32) (result i32)
(block (result i32)
(call $$dummy) (call $$dummy) (br_if 0 (i32.const 11) (local.get 0))
)
)
(func (export "as-loop-first") (param i32) (result i32)
(block (loop (br_if 1 (local.get 0)) (return (i32.const 2)))) (i32.const 3)
)
(func (export "as-loop-mid") (param i32) (result i32)
(block (loop (call $$dummy) (br_if 1 (local.get 0)) (return (i32.const 2))))
(i32.const 4)
)
(func (export "as-loop-last") (param i32)
(loop (call $$dummy) (br_if 1 (local.get 0)))
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (br_if 0 (i32.const 1) (i32.const 2))))
)
(func (export "as-br_if-cond")
(block (br_if 0 (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-br_if-value") (result i32)
(block (result i32)
(drop (br_if 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)))
(i32.const 4)
)
)
(func (export "as-br_if-value-cond") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 2) (br_if 0 (i32.const 1) (local.get 0))))
(i32.const 4)
)
)
(func (export "as-br_table-index")
(block (br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2))))
)
(func (export "as-br_table-value") (result i32)
(block (result i32)
(br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)) (i32.const 4)
)
)
(func (export "as-br_table-value-index") (result i32)
(block (result i32)
(br_table 0 0 (i32.const 2) (br_if 0 (i32.const 1) (i32.const 3))) (i32.const 4)
)
)
(func (export "as-return-value") (result i64)
(block (result i64) (return (br_if 0 (i64.const 1) (i32.const 2))))
)
(func (export "as-if-cond") (param i32) (result i32)
(block (result i32)
(if (result i32)
(br_if 0 (i32.const 1) (local.get 0))
(then (i32.const 2))
(else (i32.const 3))
)
)
)
(func (export "as-if-then") (param i32 i32)
(block
(if (local.get 0) (then (br_if 1 (local.get 1))) (else (call $$dummy)))
)
)
(func (export "as-if-else") (param i32 i32)
(block
(if (local.get 0) (then (call $$dummy)) (else (br_if 1 (local.get 1))))
)
)
(func (export "as-select-first") (param i32) (result i32)
(block (result i32)
(select (br_if 0 (i32.const 3) (i32.const 10)) (i32.const 2) (local.get 0))
)
)
(func (export "as-select-second") (param i32) (result i32)
(block (result i32)
(select (i32.const 1) (br_if 0 (i32.const 3) (i32.const 10)) (local.get 0))
)
)
(func (export "as-select-cond") (result i32)
(block (result i32)
(select (i32.const 1) (i32.const 2) (br_if 0 (i32.const 3) (i32.const 10)))
)
)
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
(func (export "as-call-first") (result i32)
(block (result i32)
(call $$f
(br_if 0 (i32.const 12) (i32.const 1)) (i32.const 2) (i32.const 3)
)
)
)
(func (export "as-call-mid") (result i32)
(block (result i32)
(call $$f
(i32.const 1) (br_if 0 (i32.const 13) (i32.const 1)) (i32.const 3)
)
)
)
(func (export "as-call-last") (result i32)
(block (result i32)
(call $$f
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 14) (i32.const 1))
)
)
)
(func $$func (param i32 i32 i32) (result i32) (local.get 0))
(type $$check (func (param i32 i32 i32) (result i32)))
(table funcref (elem $$func))
(func (export "as-call_indirect-func") (result i32)
(block (result i32)
(call_indirect (type $$check)
(br_if 0 (i32.const 4) (i32.const 10))
(i32.const 1) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-first") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-mid") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 0)
)
)
)
(func (export "as-call_indirect-last") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (i32.const 2) (i32.const 3) (br_if 0 (i32.const 4) (i32.const 10))
)
)
)
(func (export "as-local.set-value") (param i32) (result i32)
(local i32)
(block (result i32)
(local.set 0 (br_if 0 (i32.const 17) (local.get 0)))
(i32.const -1)
)
)
(func (export "as-local.tee-value") (param i32) (result i32)
(block (result i32)
(local.tee 0 (br_if 0 (i32.const 1) (local.get 0)))
(return (i32.const -1))
)
)
(global $$a (mut i32) (i32.const 10))
(func (export "as-global.set-value") (param i32) (result i32)
(block (result i32)
(global.set $$a (br_if 0 (i32.const 1) (local.get 0)))
(return (i32.const -1))
)
)
(memory 1)
(func (export "as-load-address") (result i32)
(block (result i32) (i32.load (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-loadN-address") (result i32)
(block (result i32) (i32.load8_s (br_if 0 (i32.const 30) (i32.const 1))))
)
(func (export "as-store-address") (result i32)
(block (result i32)
(i32.store (br_if 0 (i32.const 30) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-store-value") (result i32)
(block (result i32)
(i32.store (i32.const 2) (br_if 0 (i32.const 31) (i32.const 1))) (i32.const -1)
)
)
(func (export "as-storeN-address") (result i32)
(block (result i32)
(i32.store8 (br_if 0 (i32.const 32) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-storeN-value") (result i32)
(block (result i32)
(i32.store16 (i32.const 2) (br_if 0 (i32.const 33) (i32.const 1))) (i32.const -1)
)
)
(func (export "as-unary-operand") (result f64)
(block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
)
(func (export "as-binary-left") (result i32)
(block (result i32) (i32.add (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
)
(func (export "as-binary-right") (result i32)
(block (result i32) (i32.sub (i32.const 10) (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-test-operand") (result i32)
(block (result i32) (i32.eqz (br_if 0 (i32.const 0) (i32.const 1))))
)
(func (export "as-compare-left") (result i32)
(block (result i32) (i32.le_u (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
)
(func (export "as-compare-right") (result i32)
(block (result i32) (i32.ne (i32.const 10) (br_if 0 (i32.const 1) (i32.const 42))))
)
(func (export "as-memory.grow-size") (result i32)
(block (result i32) (memory.grow (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "nested-block-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(i32.add
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0)))
(i32.const 16)
)
)
)
)
)
(func (export "nested-br-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
)
(i32.const 16)
)
)
)
(func (export "nested-br_if-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(drop (br_if 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
(i32.const 1)
))
(i32.const 16)
)
)
)
(func (export "nested-br_if-value-cond") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(drop (br_if 0
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
)
))
(i32.const 16)
)
)
)
(func (export "nested-br_table-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br_table 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
(i32.const 1)
)
(i32.const 16)
)
)
)
(func (export "nested-br_table-value-index") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br_table 0
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
)
)
(i32.const 16)
)
)
)
)`);
// ./test/core/br_if.wast:372
assert_return(() => invoke($0, `type-i32`, []), []);
// ./test/core/br_if.wast:373
assert_return(() => invoke($0, `type-i64`, []), []);
// ./test/core/br_if.wast:374
assert_return(() => invoke($0, `type-f32`, []), []);
// ./test/core/br_if.wast:375
assert_return(() => invoke($0, `type-f64`, []), []);
// ./test/core/br_if.wast:377
assert_return(() => invoke($0, `type-i32-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:378
assert_return(() => invoke($0, `type-i64-value`, []), [value("i64", 2n)]);
// ./test/core/br_if.wast:379
assert_return(() => invoke($0, `type-f32-value`, []), [value("f32", 3)]);
// ./test/core/br_if.wast:380
assert_return(() => invoke($0, `type-f64-value`, []), [value("f64", 4)]);
// ./test/core/br_if.wast:382
assert_return(() => invoke($0, `as-block-first`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:383
assert_return(() => invoke($0, `as-block-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:384
assert_return(() => invoke($0, `as-block-mid`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:385
assert_return(() => invoke($0, `as-block-mid`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:386
assert_return(() => invoke($0, `as-block-last`, [0]), []);
// ./test/core/br_if.wast:387
assert_return(() => invoke($0, `as-block-last`, [1]), []);
// ./test/core/br_if.wast:389
assert_return(() => invoke($0, `as-block-first-value`, [0]), [value("i32", 11)]);
// ./test/core/br_if.wast:390
assert_return(() => invoke($0, `as-block-first-value`, [1]), [value("i32", 10)]);
// ./test/core/br_if.wast:391
assert_return(() => invoke($0, `as-block-mid-value`, [0]), [value("i32", 21)]);
// ./test/core/br_if.wast:392
assert_return(() => invoke($0, `as-block-mid-value`, [1]), [value("i32", 20)]);
// ./test/core/br_if.wast:393
assert_return(() => invoke($0, `as-block-last-value`, [0]), [value("i32", 11)]);
// ./test/core/br_if.wast:394
assert_return(() => invoke($0, `as-block-last-value`, [1]), [value("i32", 11)]);
// ./test/core/br_if.wast:396
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:397
assert_return(() => invoke($0, `as-loop-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:398
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:399
assert_return(() => invoke($0, `as-loop-mid`, [1]), [value("i32", 4)]);
// ./test/core/br_if.wast:400
assert_return(() => invoke($0, `as-loop-last`, [0]), []);
// ./test/core/br_if.wast:401
assert_return(() => invoke($0, `as-loop-last`, [1]), []);
// ./test/core/br_if.wast:403
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:405
assert_return(() => invoke($0, `as-br_if-cond`, []), []);
// ./test/core/br_if.wast:406
assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:407
assert_return(() => invoke($0, `as-br_if-value-cond`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:408
assert_return(() => invoke($0, `as-br_if-value-cond`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:410
assert_return(() => invoke($0, `as-br_table-index`, []), []);
// ./test/core/br_if.wast:411
assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:412
assert_return(() => invoke($0, `as-br_table-value-index`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:414
assert_return(() => invoke($0, `as-return-value`, []), [value("i64", 1n)]);
// ./test/core/br_if.wast:416
assert_return(() => invoke($0, `as-if-cond`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:417
assert_return(() => invoke($0, `as-if-cond`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:418
assert_return(() => invoke($0, `as-if-then`, [0, 0]), []);
// ./test/core/br_if.wast:419
assert_return(() => invoke($0, `as-if-then`, [4, 0]), []);
// ./test/core/br_if.wast:420
assert_return(() => invoke($0, `as-if-then`, [0, 1]), []);
// ./test/core/br_if.wast:421
assert_return(() => invoke($0, `as-if-then`, [4, 1]), []);
// ./test/core/br_if.wast:422
assert_return(() => invoke($0, `as-if-else`, [0, 0]), []);
// ./test/core/br_if.wast:423
assert_return(() => invoke($0, `as-if-else`, [3, 0]), []);
// ./test/core/br_if.wast:424
assert_return(() => invoke($0, `as-if-else`, [0, 1]), []);
// ./test/core/br_if.wast:425
assert_return(() => invoke($0, `as-if-else`, [3, 1]), []);
// ./test/core/br_if.wast:427
assert_return(() => invoke($0, `as-select-first`, [0]), [value("i32", 3)]);
// ./test/core/br_if.wast:428
assert_return(() => invoke($0, `as-select-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:429
assert_return(() => invoke($0, `as-select-second`, [0]), [value("i32", 3)]);
// ./test/core/br_if.wast:430
assert_return(() => invoke($0, `as-select-second`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:431
assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 3)]);
// ./test/core/br_if.wast:433
assert_return(() => invoke($0, `as-call-first`, []), [value("i32", 12)]);
// ./test/core/br_if.wast:434
assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", 13)]);
// ./test/core/br_if.wast:435
assert_return(() => invoke($0, `as-call-last`, []), [value("i32", 14)]);
// ./test/core/br_if.wast:437
assert_return(() => invoke($0, `as-call_indirect-func`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:438
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:439
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:440
assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:442
assert_return(() => invoke($0, `as-local.set-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:443
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 17)]);
// ./test/core/br_if.wast:445
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:446
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:448
assert_return(() => invoke($0, `as-global.set-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:449
assert_return(() => invoke($0, `as-global.set-value`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:451
assert_return(() => invoke($0, `as-load-address`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:452
assert_return(() => invoke($0, `as-loadN-address`, []), [value("i32", 30)]);
// ./test/core/br_if.wast:454
assert_return(() => invoke($0, `as-store-address`, []), [value("i32", 30)]);
// ./test/core/br_if.wast:455
assert_return(() => invoke($0, `as-store-value`, []), [value("i32", 31)]);
// ./test/core/br_if.wast:456
assert_return(() => invoke($0, `as-storeN-address`, []), [value("i32", 32)]);
// ./test/core/br_if.wast:457
assert_return(() => invoke($0, `as-storeN-value`, []), [value("i32", 33)]);
// ./test/core/br_if.wast:459
assert_return(() => invoke($0, `as-unary-operand`, []), [value("f64", 1)]);
// ./test/core/br_if.wast:460
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:461
assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:462
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
// ./test/core/br_if.wast:463
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:464
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:465
assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:467
assert_return(() => invoke($0, `nested-block-value`, [0]), [value("i32", 21)]);
// ./test/core/br_if.wast:468
assert_return(() => invoke($0, `nested-block-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:469
assert_return(() => invoke($0, `nested-br-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:470
assert_return(() => invoke($0, `nested-br-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:471
assert_return(() => invoke($0, `nested-br_if-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:472
assert_return(() => invoke($0, `nested-br_if-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:473
assert_return(() => invoke($0, `nested-br_if-value-cond`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:474
assert_return(() => invoke($0, `nested-br_if-value-cond`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:475
assert_return(() => invoke($0, `nested-br_table-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:476
assert_return(() => invoke($0, `nested-br_table-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:477
assert_return(() => invoke($0, `nested-br_table-value-index`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:478
assert_return(() => invoke($0, `nested-br_table-value-index`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:480
assert_invalid(
() => instantiate(`(module (func $$type-false-i32 (block (i32.ctz (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:484
assert_invalid(
() => instantiate(`(module (func $$type-false-i64 (block (i64.ctz (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:488
assert_invalid(
() => instantiate(`(module (func $$type-false-f32 (block (f32.neg (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:492
assert_invalid(
() => instantiate(`(module (func $$type-false-f64 (block (f64.neg (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:497
assert_invalid(
() => instantiate(`(module (func $$type-true-i32 (block (i32.ctz (br_if 0 (i32.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:501
assert_invalid(
() => instantiate(`(module (func $$type-true-i64 (block (i64.ctz (br_if 0 (i64.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:505
assert_invalid(
() => instantiate(`(module (func $$type-true-f32 (block (f32.neg (br_if 0 (f32.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:509
assert_invalid(
() => instantiate(`(module (func $$type-true-f64 (block (f64.neg (br_if 0 (i64.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:514
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (i32.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:520
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (i32.const 1)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:526
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-num-vs-void
(block (br_if 0 (i32.const 0) (i32.const 0)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:532
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-num-vs-void
(block (br_if 0 (i32.const 0) (i32.const 1)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:539
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (nop) (i32.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:545
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (nop) (i32.const 1)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:551
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-num-vs-num (result i32)
(block (result i32)
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
)
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:559
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-num-vs-num (result i32)
(block (result i32)
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
)
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:568
assert_invalid(
() => instantiate(`(module (func $$type-cond-empty-vs-i32
(block (br_if 0))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:574
assert_invalid(
() => instantiate(`(module (func $$type-cond-void-vs-i32
(block (br_if 0 (nop)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:580
assert_invalid(
() => instantiate(`(module (func $$type-cond-num-vs-i32
(block (br_if 0 (i64.const 0)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:586
assert_invalid(
() => instantiate(`(module (func $$type-arg-cond-void-vs-i32 (result i32)
(block (result i32) (br_if 0 (i32.const 0) (nop)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:592
assert_invalid(
() => instantiate(`(module (func $$type-arg-void-vs-num-nested (result i32)
(block (result i32) (i32.const 0) (block (br_if 1 (i32.const 1))))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:598
assert_invalid(
() => instantiate(`(module (func $$type-arg-cond-num-vs-i32 (result i32)
(block (result i32) (br_if 0 (i32.const 0) (i64.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:605
assert_invalid(
() => instantiate(`(module
(func $$type-1st-cond-empty-in-then
(block
(i32.const 0) (i32.const 0)
(if (result i32) (then (br_if 0)))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:617
assert_invalid(
() => instantiate(`(module
(func $$type-2nd-cond-empty-in-then
(block
(i32.const 0) (i32.const 0)
(if (result i32) (then (br_if 0 (i32.const 1))))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:629
assert_invalid(
() => instantiate(`(module
(func $$type-1st-cond-empty-in-return
(block (result i32)
(return (br_if 0))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:640
assert_invalid(
() => instantiate(`(module
(func $$type-2nd-cond-empty-in-return
(block (result i32)
(return (br_if 0 (i32.const 1)))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:653
assert_invalid(
() => instantiate(`(module (func $$unbound-label (br_if 1 (i32.const 1))))`),
`unknown label`,
);
// ./test/core/br_if.wast:657
assert_invalid(
() => instantiate(`(module (func $$unbound-nested-label (block (block (br_if 5 (i32.const 1))))))`),
`unknown label`,
);
// ./test/core/br_if.wast:661
assert_invalid(
() => instantiate(`(module (func $$large-label (br_if 0x10000001 (i32.const 1))))`),
`unknown label`,
);

View File

@@ -1,869 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/global.wast
// ./test/core/global.wast:3
let $0 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(global (import "spectest" "global_i64") i64)
(global $$a i32 (i32.const -2))
(global (;3;) f32 (f32.const -3))
(global (;4;) f64 (f64.const -4))
(global $$b i64 (i64.const -5))
(global $$x (mut i32) (i32.const -12))
(global (;7;) (mut f32) (f32.const -13))
(global (;8;) (mut f64) (f64.const -14))
(global $$y (mut i64) (i64.const -15))
(global $$z1 i32 (global.get 0))
(global $$z2 i64 (global.get 1))
(global $$r externref (ref.null extern))
(global $$mr (mut externref) (ref.null extern))
(global funcref (ref.null func))
(func (export "get-a") (result i32) (global.get $$a))
(func (export "get-b") (result i64) (global.get $$b))
(func (export "get-r") (result externref) (global.get $$r))
(func (export "get-mr") (result externref) (global.get $$mr))
(func (export "get-x") (result i32) (global.get $$x))
(func (export "get-y") (result i64) (global.get $$y))
(func (export "get-z1") (result i32) (global.get $$z1))
(func (export "get-z2") (result i64) (global.get $$z2))
(func (export "set-x") (param i32) (global.set $$x (local.get 0)))
(func (export "set-y") (param i64) (global.set $$y (local.get 0)))
(func (export "set-mr") (param externref) (global.set $$mr (local.get 0)))
(func (export "get-3") (result f32) (global.get 3))
(func (export "get-4") (result f64) (global.get 4))
(func (export "get-7") (result f32) (global.get 7))
(func (export "get-8") (result f64) (global.get 8))
(func (export "set-7") (param f32) (global.set 7 (local.get 0)))
(func (export "set-8") (param f64) (global.set 8 (local.get 0)))
;; As the argument of control constructs and instructions
(memory 1)
(func $$dummy)
(func (export "as-select-first") (result i32)
(select (global.get $$x) (i32.const 2) (i32.const 3))
)
(func (export "as-select-mid") (result i32)
(select (i32.const 2) (global.get $$x) (i32.const 3))
)
(func (export "as-select-last") (result i32)
(select (i32.const 2) (i32.const 3) (global.get $$x))
)
(func (export "as-loop-first") (result i32)
(loop (result i32)
(global.get $$x) (call $$dummy) (call $$dummy)
)
)
(func (export "as-loop-mid") (result i32)
(loop (result i32)
(call $$dummy) (global.get $$x) (call $$dummy)
)
)
(func (export "as-loop-last") (result i32)
(loop (result i32)
(call $$dummy) (call $$dummy) (global.get $$x)
)
)
(func (export "as-if-condition") (result i32)
(if (result i32) (global.get $$x)
(then (call $$dummy) (i32.const 2))
(else (call $$dummy) (i32.const 3))
)
)
(func (export "as-if-then") (result i32)
(if (result i32) (i32.const 1)
(then (global.get $$x)) (else (i32.const 2))
)
)
(func (export "as-if-else") (result i32)
(if (result i32) (i32.const 0)
(then (i32.const 2)) (else (global.get $$x))
)
)
(func (export "as-br_if-first") (result i32)
(block (result i32)
(br_if 0 (global.get $$x) (i32.const 2))
(return (i32.const 3))
)
)
(func (export "as-br_if-last") (result i32)
(block (result i32)
(br_if 0 (i32.const 2) (global.get $$x))
(return (i32.const 3))
)
)
(func (export "as-br_table-first") (result i32)
(block (result i32)
(global.get $$x) (i32.const 2) (br_table 0 0)
)
)
(func (export "as-br_table-last") (result i32)
(block (result i32)
(i32.const 2) (global.get $$x) (br_table 0 0)
)
)
(func $$func (param i32 i32) (result i32) (local.get 0))
(type $$check (func (param i32 i32) (result i32)))
(table funcref (elem $$func))
(func (export "as-call_indirect-first") (result i32)
(block (result i32)
(call_indirect (type $$check)
(global.get $$x) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-mid") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (global.get $$x) (i32.const 0)
)
)
)
(func (export "as-call_indirect-last") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 2) (i32.const 0) (global.get $$x)
)
)
)
(func (export "as-store-first")
(global.get $$x) (i32.const 1) (i32.store)
)
(func (export "as-store-last")
(i32.const 0) (global.get $$x) (i32.store)
)
(func (export "as-load-operand") (result i32)
(i32.load (global.get $$x))
)
(func (export "as-memory.grow-value") (result i32)
(memory.grow (global.get $$x))
)
(func $$f (param i32) (result i32) (local.get 0))
(func (export "as-call-value") (result i32)
(call $$f (global.get $$x))
)
(func (export "as-return-value") (result i32)
(global.get $$x) (return)
)
(func (export "as-drop-operand")
(drop (global.get $$x))
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (global.get $$x)))
)
(func (export "as-local.set-value") (param i32) (result i32)
(local.set 0 (global.get $$x))
(local.get 0)
)
(func (export "as-local.tee-value") (param i32) (result i32)
(local.tee 0 (global.get $$x))
)
(func (export "as-global.set-value") (result i32)
(global.set $$x (global.get $$x))
(global.get $$x)
)
(func (export "as-unary-operand") (result i32)
(i32.eqz (global.get $$x))
)
(func (export "as-binary-operand") (result i32)
(i32.mul
(global.get $$x) (global.get $$x)
)
)
(func (export "as-compare-operand") (result i32)
(i32.gt_u
(global.get 0) (i32.const 1)
)
)
)`);
// ./test/core/global.wast:196
assert_return(() => invoke($0, `get-a`, []), [value("i32", -2)]);
// ./test/core/global.wast:197
assert_return(() => invoke($0, `get-b`, []), [value("i64", -5n)]);
// ./test/core/global.wast:198
assert_return(() => invoke($0, `get-r`, []), [value('externref', null)]);
// ./test/core/global.wast:199
assert_return(() => invoke($0, `get-mr`, []), [value('externref', null)]);
// ./test/core/global.wast:200
assert_return(() => invoke($0, `get-x`, []), [value("i32", -12)]);
// ./test/core/global.wast:201
assert_return(() => invoke($0, `get-y`, []), [value("i64", -15n)]);
// ./test/core/global.wast:202
assert_return(() => invoke($0, `get-z1`, []), [value("i32", 666)]);
// ./test/core/global.wast:203
assert_return(() => invoke($0, `get-z2`, []), [value("i64", 666n)]);
// ./test/core/global.wast:205
assert_return(() => invoke($0, `get-3`, []), [value("f32", -3)]);
// ./test/core/global.wast:206
assert_return(() => invoke($0, `get-4`, []), [value("f64", -4)]);
// ./test/core/global.wast:207
assert_return(() => invoke($0, `get-7`, []), [value("f32", -13)]);
// ./test/core/global.wast:208
assert_return(() => invoke($0, `get-8`, []), [value("f64", -14)]);
// ./test/core/global.wast:210
assert_return(() => invoke($0, `set-x`, [6]), []);
// ./test/core/global.wast:211
assert_return(() => invoke($0, `set-y`, [7n]), []);
// ./test/core/global.wast:213
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:214
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:216
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:217
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:218
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:219
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:221
assert_return(() => invoke($0, `set-7`, [value("f32", 8)]), []);
// ./test/core/global.wast:222
assert_return(() => invoke($0, `set-8`, [value("f64", 9)]), []);
// ./test/core/global.wast:223
assert_return(() => invoke($0, `set-mr`, [externref(10)]), []);
// ./test/core/global.wast:225
assert_return(() => invoke($0, `get-x`, []), [value("i32", 6)]);
// ./test/core/global.wast:226
assert_return(() => invoke($0, `get-y`, []), [value("i64", 7n)]);
// ./test/core/global.wast:227
assert_return(() => invoke($0, `get-7`, []), [value("f32", 8)]);
// ./test/core/global.wast:228
assert_return(() => invoke($0, `get-8`, []), [value("f64", 9)]);
// ./test/core/global.wast:229
assert_return(() => invoke($0, `get-mr`, []), [new ExternRefResult(10)]);
// ./test/core/global.wast:231
assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:232
assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:233
assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:235
assert_return(() => invoke($0, `as-loop-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:236
assert_return(() => invoke($0, `as-loop-mid`, []), [value("i32", 6)]);
// ./test/core/global.wast:237
assert_return(() => invoke($0, `as-loop-last`, []), [value("i32", 6)]);
// ./test/core/global.wast:239
assert_return(() => invoke($0, `as-if-condition`, []), [value("i32", 2)]);
// ./test/core/global.wast:240
assert_return(() => invoke($0, `as-if-then`, []), [value("i32", 6)]);
// ./test/core/global.wast:241
assert_return(() => invoke($0, `as-if-else`, []), [value("i32", 6)]);
// ./test/core/global.wast:243
assert_return(() => invoke($0, `as-br_if-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:244
assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:246
assert_return(() => invoke($0, `as-br_table-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:247
assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
// ./test/core/global.wast:249
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", 6)]);
// ./test/core/global.wast:250
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 2)]);
// ./test/core/global.wast:251
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `undefined element`);
// ./test/core/global.wast:253
assert_return(() => invoke($0, `as-store-first`, []), []);
// ./test/core/global.wast:254
assert_return(() => invoke($0, `as-store-last`, []), []);
// ./test/core/global.wast:255
assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:256
assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
// ./test/core/global.wast:258
assert_return(() => invoke($0, `as-call-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:260
assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:261
assert_return(() => invoke($0, `as-drop-operand`, []), []);
// ./test/core/global.wast:262
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:264
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:265
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 6)]);
// ./test/core/global.wast:266
assert_return(() => invoke($0, `as-global.set-value`, []), [value("i32", 6)]);
// ./test/core/global.wast:268
assert_return(() => invoke($0, `as-unary-operand`, []), [value("i32", 0)]);
// ./test/core/global.wast:269
assert_return(() => invoke($0, `as-binary-operand`, []), [value("i32", 36)]);
// ./test/core/global.wast:270
assert_return(() => invoke($0, `as-compare-operand`, []), [value("i32", 1)]);
// ./test/core/global.wast:272
assert_invalid(
() => instantiate(`(module (global f32 (f32.const 0)) (func (global.set 0 (f32.const 1))))`),
`immutable global`,
);
// ./test/core/global.wast:277
assert_invalid(
() => instantiate(`(module (import "spectest" "global_i32" (global i32)) (func (global.set 0 (i32.const 1))))`),
`immutable global`,
);
// ./test/core/global.wast:283
let $1 = instantiate(`(module (global (mut f32) (f32.const 0)) (export "a" (global 0)))`);
// ./test/core/global.wast:284
let $2 = instantiate(`(module (global (export "a") (mut f32) (f32.const 0)))`);
// ./test/core/global.wast:286
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:291
assert_invalid(
() => instantiate(`(module (global f32 (local.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:296
assert_invalid(
() => instantiate(`(module (global f32 (f32.neg (f32.const 1))))`),
`constant expression required`,
);
// ./test/core/global.wast:301
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:306
assert_invalid(
() => instantiate(`(module (global i32 (i32.ctz (i32.const 0))))`),
`constant expression required`,
);
// ./test/core/global.wast:311
assert_invalid(
() => instantiate(`(module (global i32 (nop)))`),
`constant expression required`,
);
// ./test/core/global.wast:316
assert_invalid(() => instantiate(`(module (global i32 (f32.const 0)))`), `type mismatch`);
// ./test/core/global.wast:321
assert_invalid(
() => instantiate(`(module (global i32 (i32.const 0) (i32.const 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:326
assert_invalid(
() => instantiate(`(module (global i32 (;empty instruction sequence;)))`),
`type mismatch`,
);
// ./test/core/global.wast:331
assert_invalid(
() => instantiate(`(module (global (import "" "") externref) (global funcref (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:336
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:341
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (i32.const 0) (global.get 0)))`),
`type mismatch`,
);
// ./test/core/global.wast:346
assert_invalid(
() => instantiate(`(module (global i32 (global.get 0)))`),
`unknown global`,
);
// ./test/core/global.wast:351
assert_invalid(
() => instantiate(`(module (global i32 (global.get 1)) (global i32 (i32.const 0)))`),
`unknown global`,
);
// ./test/core/global.wast:356
assert_invalid(
() => instantiate(`(module (global (import "test" "global-i32") i32) (global i32 (global.get 2)))`),
`unknown global`,
);
// ./test/core/global.wast:361
let $3 = instantiate(`(module (global i32 (i32.const 0)) (global i32 (global.get 0)))`);
// ./test/core/global.wast:362
let $4 = instantiate(`(module (global $$g i32 (i32.const 0)) (global i32 (global.get $$g)))`);
// ./test/core/global.wast:364
assert_invalid(
() => instantiate(`(module (global (import "test" "global-mut-i32") (mut i32)) (global i32 (global.get 0)))`),
`constant expression required`,
);
// ./test/core/global.wast:369
let $5 = instantiate(`(module
(import "spectest" "global_i32" (global i32))
)`);
// ./test/core/global.wast:372
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\02" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:385
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\02\\98\\80\\80\\80\\00" ;; import section
"\\01" ;; length 1
"\\08\\73\\70\\65\\63\\74\\65\\73\\74" ;; "spectest"
"\\0a\\67\\6c\\6f\\62\\61\\6c\\5f\\69\\33\\32" ;; "global_i32"
"\\03" ;; GlobalImport
"\\7f" ;; i32
"\\ff" ;; malformed mutability
)`),
`malformed mutability`,
);
// ./test/core/global.wast:399
let $6 = instantiate(`(module
(global i32 (i32.const 0))
)`);
// ./test/core/global.wast:402
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\02" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:414
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\06\\86\\80\\80\\80\\00" ;; global section
"\\01" ;; length 1
"\\7f" ;; i32
"\\ff" ;; malformed mutability
"\\41\\00" ;; i32.const 0
"\\0b" ;; end
)`),
`malformed mutability`,
);
// ./test/core/global.wast:428
assert_invalid(
() => instantiate(`(module (func (result i32) (global.get 0)))`),
`unknown global`,
);
// ./test/core/global.wast:433
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:441
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (result i32) (global.get 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:449
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (result i32) (global.get 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:459
assert_invalid(
() => instantiate(`(module (func (i32.const 0) (global.set 0)))`),
`unknown global`,
);
// ./test/core/global.wast:464
assert_invalid(
() => instantiate(`(module
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:472
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(func (i32.const 0) (global.set 1))
)`),
`unknown global`,
);
// ./test/core/global.wast:480
assert_invalid(
() => instantiate(`(module
(import "spectest" "global_i32" (global i32))
(global i32 (i32.const 0))
(func (i32.const 0) (global.set 2))
)`),
`unknown global`,
);
// ./test/core/global.wast:490
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty
(global.set $$x)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:499
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-block
(i32.const 0)
(block (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:509
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-loop
(i32.const 0)
(loop (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:519
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-then
(i32.const 0) (i32.const 0)
(if (then (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:529
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-else
(i32.const 0) (i32.const 0)
(if (result i32) (then (i32.const 0)) (else (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:539
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br
(i32.const 0)
(block (br 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:549
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_if
(i32.const 0)
(block (br_if 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:559
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-br_table
(i32.const 0)
(block (br_table 0 (global.set $$x)))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:569
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-return
(return (global.set $$x))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:578
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-select
(select (global.set $$x) (i32.const 1) (i32.const 2))
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:587
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$type-global.set-value-empty-in-call
(call 1 (global.set $$x))
)
(func (param i32) (result i32) (local.get 0))
)`),
`type mismatch`,
);
// ./test/core/global.wast:597
assert_invalid(
() => instantiate(`(module
(global $$x (mut i32) (i32.const 0))
(func $$f (param i32) (result i32) (local.get 0))
(type $$sig (func (param i32) (result i32)))
(table funcref (elem $$f))
(func $$type-global.set-value-empty-in-call_indirect
(block (result i32)
(call_indirect (type $$sig)
(global.set $$x) (i32.const 0)
)
)
)
)`),
`type mismatch`,
);
// ./test/core/global.wast:617
let $7 = instantiate(`(module
(global (export "g") i32 (i32.const 4))
)`);
// ./test/core/global.wast:620
register($7, `G`);
// ./test/core/global.wast:622
let $8 = instantiate(`(module
(global $$g0 (import "G" "g") i32)
(global $$g1 i32 (i32.const 8))
(global $$g2 i32 (global.get $$g0))
(global $$g3 i32 (global.get $$g1))
(global $$gf funcref (ref.func $$f))
(func $$f)
(table $$t 10 funcref (ref.null func))
(elem (table $$t) (global.get $$g2) funcref (ref.func $$f))
(elem (table $$t) (global.get $$g3) funcref (global.get $$gf))
(memory $$m 1)
(data (global.get $$g2) "\\44\\44\\44\\44")
(data (global.get $$g3) "\\88\\88\\88\\88")
(func (export "get-elem") (param $$i i32) (result funcref)
(table.get $$t (local.get $$i))
)
(func (export "get-data") (param $$i i32) (result i32)
(i32.load (local.get $$i))
)
)`);
// ./test/core/global.wast:647
assert_return(() => invoke($8, `get-elem`, [0]), [null]);
// ./test/core/global.wast:648
assert_return(() => invoke($8, `get-elem`, [4]), [new RefWithType('funcref')]);
// ./test/core/global.wast:649
assert_return(() => invoke($8, `get-elem`, [8]), [new RefWithType('funcref')]);
// ./test/core/global.wast:651
assert_return(() => invoke($8, `get-data`, [4]), [value("i32", 1145324612)]);
// ./test/core/global.wast:652
assert_return(() => invoke($8, `get-data`, [8]), [value("i32", -2004318072)]);
// ./test/core/global.wast:654
assert_invalid(
() => instantiate(`(module
(global $$g1 i32 (global.get $$g2))
(global $$g2 i32 (i32.const 0))
)`),
`unknown global`,
);
// ./test/core/global.wast:662
assert_invalid(
() => instantiate(`(module
(global $$g funcref (ref.null func))
(table $$t 10 funcref (global.get $$g))
)`),
`unknown global`,
);
// ./test/core/global.wast:673
assert_malformed(
() => instantiate(`(global $$foo i32 (i32.const 0)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:680
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (global $$foo i32 (i32.const 0)) `),
`duplicate global`,
);
// ./test/core/global.wast:687
assert_malformed(
() => instantiate(`(import "" "" (global $$foo i32)) (import "" "" (global $$foo i32)) `),
`duplicate global`,
);

View File

@@ -193,16 +193,10 @@ let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
function module(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
return module;
}
function instantiate(source) {
@@ -212,18 +206,23 @@ function instantiate(source) {
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
function instantiateFromModule(module) {
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
function register(instance, name) {
linkage[name] = instance;
}
function invoke(instance, field, params) {
let func = instance[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
function get(instance, field) {
let global = instance[field];
assertEq(
global instanceof WebAssembly.Global,
true,

View File

@@ -32,73 +32,330 @@ let $0 = instantiate(`(module
(i31.get_u (ref.null i31))
)
(func (export "get_s-null") (result i32)
(i31.get_u (ref.null i31))
(i31.get_s (ref.null i31))
)
(global $$i (ref i31) (ref.i31 (i32.const 2)))
(global $$m (mut (ref i31)) (ref.i31 (i32.const 3)))
(func (export "get_globals") (result i32 i32)
(i31.get_u (global.get $$i))
(i31.get_u (global.get $$m))
)
(func (export "set_global") (param i32)
(global.set $$m (ref.i31 (local.get 0)))
)
)`);
// ./test/core/gc/i31.wast:28
// ./test/core/gc/i31.wast:33
assert_return(() => invoke($0, `new`, [1]), [new RefWithType('i31ref')]);
// ./test/core/gc/i31.wast:30
// ./test/core/gc/i31.wast:35
assert_return(() => invoke($0, `get_u`, [0]), [value("i32", 0)]);
// ./test/core/gc/i31.wast:31
// ./test/core/gc/i31.wast:36
assert_return(() => invoke($0, `get_u`, [100]), [value("i32", 100)]);
// ./test/core/gc/i31.wast:32
// ./test/core/gc/i31.wast:37
assert_return(() => invoke($0, `get_u`, [-1]), [value("i32", 2147483647)]);
// ./test/core/gc/i31.wast:33
// ./test/core/gc/i31.wast:38
assert_return(() => invoke($0, `get_u`, [1073741823]), [value("i32", 1073741823)]);
// ./test/core/gc/i31.wast:34
// ./test/core/gc/i31.wast:39
assert_return(() => invoke($0, `get_u`, [1073741824]), [value("i32", 1073741824)]);
// ./test/core/gc/i31.wast:35
// ./test/core/gc/i31.wast:40
assert_return(() => invoke($0, `get_u`, [2147483647]), [value("i32", 2147483647)]);
// ./test/core/gc/i31.wast:36
// ./test/core/gc/i31.wast:41
assert_return(() => invoke($0, `get_u`, [-1431655766]), [value("i32", 715827882)]);
// ./test/core/gc/i31.wast:37
// ./test/core/gc/i31.wast:42
assert_return(() => invoke($0, `get_u`, [-894784854]), [value("i32", 1252698794)]);
// ./test/core/gc/i31.wast:39
// ./test/core/gc/i31.wast:44
assert_return(() => invoke($0, `get_s`, [0]), [value("i32", 0)]);
// ./test/core/gc/i31.wast:40
// ./test/core/gc/i31.wast:45
assert_return(() => invoke($0, `get_s`, [100]), [value("i32", 100)]);
// ./test/core/gc/i31.wast:41
// ./test/core/gc/i31.wast:46
assert_return(() => invoke($0, `get_s`, [-1]), [value("i32", -1)]);
// ./test/core/gc/i31.wast:42
// ./test/core/gc/i31.wast:47
assert_return(() => invoke($0, `get_s`, [1073741823]), [value("i32", 1073741823)]);
// ./test/core/gc/i31.wast:43
// ./test/core/gc/i31.wast:48
assert_return(() => invoke($0, `get_s`, [1073741824]), [value("i32", -1073741824)]);
// ./test/core/gc/i31.wast:44
// ./test/core/gc/i31.wast:49
assert_return(() => invoke($0, `get_s`, [2147483647]), [value("i32", -1)]);
// ./test/core/gc/i31.wast:45
// ./test/core/gc/i31.wast:50
assert_return(() => invoke($0, `get_s`, [-1431655766]), [value("i32", 715827882)]);
// ./test/core/gc/i31.wast:46
// ./test/core/gc/i31.wast:51
assert_return(() => invoke($0, `get_s`, [-894784854]), [value("i32", -894784854)]);
// ./test/core/gc/i31.wast:48
// ./test/core/gc/i31.wast:53
assert_trap(() => invoke($0, `get_u-null`, []), `null i31 reference`);
// ./test/core/gc/i31.wast:49
// ./test/core/gc/i31.wast:54
assert_trap(() => invoke($0, `get_s-null`, []), `null i31 reference`);
// ./test/core/gc/i31.wast:51
// ./test/core/gc/i31.wast:56
assert_return(() => invoke($0, `get_globals`, []), [value("i32", 2), value("i32", 3)]);
// ./test/core/gc/i31.wast:58
invoke($0, `set_global`, [1234]);
// ./test/core/gc/i31.wast:59
assert_return(() => invoke($0, `get_globals`, []), [value("i32", 2), value("i32", 1234)]);
// ./test/core/gc/i31.wast:61
let $1 = instantiate(`(module $$tables_of_i31ref
(table $$table 3 10 i31ref)
(elem (table $$table) (i32.const 0) i31ref (item (ref.i31 (i32.const 999)))
(item (ref.i31 (i32.const 888)))
(item (ref.i31 (i32.const 777))))
(func (export "size") (result i32)
table.size $$table
)
(func (export "get") (param i32) (result i32)
(i31.get_u (table.get $$table (local.get 0)))
)
(func (export "grow") (param i32 i32) (result i32)
(table.grow $$table (ref.i31 (local.get 1)) (local.get 0))
)
(func (export "fill") (param i32 i32 i32)
(table.fill $$table (local.get 0) (ref.i31 (local.get 1)) (local.get 2))
)
(func (export "copy") (param i32 i32 i32)
(table.copy $$table $$table (local.get 0) (local.get 1) (local.get 2))
)
(elem $$elem i31ref (item (ref.i31 (i32.const 123)))
(item (ref.i31 (i32.const 456)))
(item (ref.i31 (i32.const 789))))
(func (export "init") (param i32 i32 i32)
(table.init $$table $$elem (local.get 0) (local.get 1) (local.get 2))
)
)`);
let $tables_of_i31ref = $1;
// ./test/core/gc/i31.wast:96
assert_return(() => invoke($1, `size`, []), [value("i32", 3)]);
// ./test/core/gc/i31.wast:97
assert_return(() => invoke($1, `get`, [0]), [value("i32", 999)]);
// ./test/core/gc/i31.wast:98
assert_return(() => invoke($1, `get`, [1]), [value("i32", 888)]);
// ./test/core/gc/i31.wast:99
assert_return(() => invoke($1, `get`, [2]), [value("i32", 777)]);
// ./test/core/gc/i31.wast:102
assert_return(() => invoke($1, `grow`, [2, 333]), [value("i32", 3)]);
// ./test/core/gc/i31.wast:103
assert_return(() => invoke($1, `size`, []), [value("i32", 5)]);
// ./test/core/gc/i31.wast:104
assert_return(() => invoke($1, `get`, [3]), [value("i32", 333)]);
// ./test/core/gc/i31.wast:105
assert_return(() => invoke($1, `get`, [4]), [value("i32", 333)]);
// ./test/core/gc/i31.wast:108
invoke($1, `fill`, [2, 111, 2]);
// ./test/core/gc/i31.wast:109
assert_return(() => invoke($1, `get`, [2]), [value("i32", 111)]);
// ./test/core/gc/i31.wast:110
assert_return(() => invoke($1, `get`, [3]), [value("i32", 111)]);
// ./test/core/gc/i31.wast:113
invoke($1, `copy`, [3, 0, 2]);
// ./test/core/gc/i31.wast:114
assert_return(() => invoke($1, `get`, [3]), [value("i32", 999)]);
// ./test/core/gc/i31.wast:115
assert_return(() => invoke($1, `get`, [4]), [value("i32", 888)]);
// ./test/core/gc/i31.wast:118
invoke($1, `init`, [1, 0, 3]);
// ./test/core/gc/i31.wast:119
assert_return(() => invoke($1, `get`, [1]), [value("i32", 123)]);
// ./test/core/gc/i31.wast:120
assert_return(() => invoke($1, `get`, [2]), [value("i32", 456)]);
// ./test/core/gc/i31.wast:121
assert_return(() => invoke($1, `get`, [3]), [value("i32", 789)]);
// ./test/core/gc/i31.wast:123
let $2 = instantiate(`(module $$env
(global (export "g") i32 (i32.const 42))
)`);
let $env = $2;
// ./test/core/gc/i31.wast:126
register($2, `env`);
// ./test/core/gc/i31.wast:128
let $3 = instantiate(`(module $$i31ref_of_global_table_initializer
(global $$g (import "env" "g") i32)
(table $$t 3 3 (ref i31) (ref.i31 (global.get $$g)))
(func (export "get") (param i32) (result i32)
(i31.get_u (local.get 0) (table.get $$t))
)
)`);
let $i31ref_of_global_table_initializer = $3;
// ./test/core/gc/i31.wast:136
assert_return(() => invoke($3, `get`, [0]), [value("i32", 42)]);
// ./test/core/gc/i31.wast:137
assert_return(() => invoke($3, `get`, [1]), [value("i32", 42)]);
// ./test/core/gc/i31.wast:138
assert_return(() => invoke($3, `get`, [2]), [value("i32", 42)]);
// ./test/core/gc/i31.wast:140
let $4 = instantiate(`(module $$i31ref_of_global_global_initializer
(global $$g0 (import "env" "g") i32)
(global $$g1 i31ref (ref.i31 (global.get $$g0)))
(func (export "get") (result i32)
(i31.get_u (global.get $$g1))
)
)`);
let $i31ref_of_global_global_initializer = $4;
// ./test/core/gc/i31.wast:148
assert_return(() => invoke($4, `get`, []), [value("i32", 42)]);
// ./test/core/gc/i31.wast:150
let $5 = instantiate(`(module $$anyref_global_of_i31ref
(global $$c anyref (ref.i31 (i32.const 1234)))
(global $$m (mut anyref) (ref.i31 (i32.const 5678)))
(func (export "get_globals") (result i32 i32)
(i31.get_u (ref.cast i31ref (global.get $$c)))
(i31.get_u (ref.cast i31ref (global.get $$m)))
)
(func (export "set_global") (param i32)
(global.set $$m (ref.i31 (local.get 0)))
)
)`);
let $anyref_global_of_i31ref = $5;
// ./test/core/gc/i31.wast:164
assert_return(() => invoke($5, `get_globals`, []), [value("i32", 1234), value("i32", 5678)]);
// ./test/core/gc/i31.wast:165
invoke($5, `set_global`, [0]);
// ./test/core/gc/i31.wast:166
assert_return(() => invoke($5, `get_globals`, []), [value("i32", 1234), value("i32", 0)]);
// ./test/core/gc/i31.wast:168
let $6 = instantiate(`(module $$anyref_table_of_i31ref
(table $$table 3 10 anyref)
(elem (table $$table) (i32.const 0) i31ref (item (ref.i31 (i32.const 999)))
(item (ref.i31 (i32.const 888)))
(item (ref.i31 (i32.const 777))))
(func (export "size") (result i32)
table.size $$table
)
(func (export "get") (param i32) (result i32)
(i31.get_u (ref.cast i31ref (table.get $$table (local.get 0))))
)
(func (export "grow") (param i32 i32) (result i32)
(table.grow $$table (ref.i31 (local.get 1)) (local.get 0))
)
(func (export "fill") (param i32 i32 i32)
(table.fill $$table (local.get 0) (ref.i31 (local.get 1)) (local.get 2))
)
(func (export "copy") (param i32 i32 i32)
(table.copy $$table $$table (local.get 0) (local.get 1) (local.get 2))
)
(elem $$elem i31ref (item (ref.i31 (i32.const 123)))
(item (ref.i31 (i32.const 456)))
(item (ref.i31 (i32.const 789))))
(func (export "init") (param i32 i32 i32)
(table.init $$table $$elem (local.get 0) (local.get 1) (local.get 2))
)
)`);
let $anyref_table_of_i31ref = $6;
// ./test/core/gc/i31.wast:203
assert_return(() => invoke($6, `size`, []), [value("i32", 3)]);
// ./test/core/gc/i31.wast:204
assert_return(() => invoke($6, `get`, [0]), [value("i32", 999)]);
// ./test/core/gc/i31.wast:205
assert_return(() => invoke($6, `get`, [1]), [value("i32", 888)]);
// ./test/core/gc/i31.wast:206
assert_return(() => invoke($6, `get`, [2]), [value("i32", 777)]);
// ./test/core/gc/i31.wast:209
assert_return(() => invoke($6, `grow`, [2, 333]), [value("i32", 3)]);
// ./test/core/gc/i31.wast:210
assert_return(() => invoke($6, `size`, []), [value("i32", 5)]);
// ./test/core/gc/i31.wast:211
assert_return(() => invoke($6, `get`, [3]), [value("i32", 333)]);
// ./test/core/gc/i31.wast:212
assert_return(() => invoke($6, `get`, [4]), [value("i32", 333)]);
// ./test/core/gc/i31.wast:215
invoke($6, `fill`, [2, 111, 2]);
// ./test/core/gc/i31.wast:216
assert_return(() => invoke($6, `get`, [2]), [value("i32", 111)]);
// ./test/core/gc/i31.wast:217
assert_return(() => invoke($6, `get`, [3]), [value("i32", 111)]);
// ./test/core/gc/i31.wast:220
invoke($6, `copy`, [3, 0, 2]);
// ./test/core/gc/i31.wast:221
assert_return(() => invoke($6, `get`, [3]), [value("i32", 999)]);
// ./test/core/gc/i31.wast:222
assert_return(() => invoke($6, `get`, [4]), [value("i32", 888)]);
// ./test/core/gc/i31.wast:225
invoke($6, `init`, [1, 0, 3]);
// ./test/core/gc/i31.wast:226
assert_return(() => invoke($6, `get`, [1]), [value("i32", 123)]);
// ./test/core/gc/i31.wast:227
assert_return(() => invoke($6, `get`, [2]), [value("i32", 456)]);
// ./test/core/gc/i31.wast:228
assert_return(() => invoke($6, `get`, [3]), [value("i32", 789)]);

File diff suppressed because it is too large Load Diff

View File

@@ -1,127 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/ref_null.wast
// ./test/core/ref_null.wast:1
let $0 = instantiate(`(module
(type $$t (func))
(func (export "anyref") (result anyref) (ref.null any))
(func (export "funcref") (result funcref) (ref.null func))
(func (export "ref") (result (ref null $$t)) (ref.null $$t))
(global anyref (ref.null any))
(global funcref (ref.null func))
(global (ref null $$t) (ref.null $$t))
)`);
// ./test/core/ref_null.wast:12
assert_return(() => invoke($0, `anyref`, []), [value('anyref', null)]);
// ./test/core/ref_null.wast:13
assert_return(() => invoke($0, `funcref`, []), [value('anyfunc', null)]);
// ./test/core/ref_null.wast:14
assert_return(() => invoke($0, `ref`, []), [null]);
// ./test/core/ref_null.wast:17
let $1 = instantiate(`(module
(type $$t (func))
(global $$null nullref (ref.null none))
(global $$nullfunc nullfuncref (ref.null nofunc))
(global $$nullextern nullexternref (ref.null noextern))
(func (export "anyref") (result anyref) (global.get $$null))
(func (export "nullref") (result nullref) (global.get $$null))
(func (export "funcref") (result funcref) (global.get $$nullfunc))
(func (export "nullfuncref") (result nullfuncref) (global.get $$nullfunc))
(func (export "externref") (result externref) (global.get $$nullextern))
(func (export "nullexternref") (result nullexternref) (global.get $$nullextern))
(func (export "ref") (result (ref null $$t)) (global.get $$nullfunc))
(global anyref (ref.null any))
(global anyref (ref.null none))
(global funcref (ref.null func))
(global funcref (ref.null nofunc))
(global externref (ref.null extern))
(global externref (ref.null noextern))
(global nullref (ref.null none))
(global nullfuncref (ref.null nofunc))
(global nullexternref (ref.null noextern))
(global (ref null $$t) (ref.null $$t))
(global (ref null $$t) (ref.null nofunc))
)`);
// ./test/core/ref_null.wast:43
assert_return(() => invoke($1, `anyref`, []), [value('anyref', null)]);
// ./test/core/ref_null.wast:44
assert_return(() => invoke($1, `anyref`, []), [value('nullref', null)]);
// ./test/core/ref_null.wast:45
assert_return(() => invoke($1, `anyref`, []), [null]);
// ./test/core/ref_null.wast:46
assert_return(() => invoke($1, `nullref`, []), [value('anyref', null)]);
// ./test/core/ref_null.wast:47
assert_return(() => invoke($1, `nullref`, []), [value('nullref', null)]);
// ./test/core/ref_null.wast:48
assert_return(() => invoke($1, `nullref`, []), [null]);
// ./test/core/ref_null.wast:49
assert_return(() => invoke($1, `funcref`, []), [value('anyfunc', null)]);
// ./test/core/ref_null.wast:50
assert_return(() => invoke($1, `funcref`, []), [value('nullfuncref', null)]);
// ./test/core/ref_null.wast:51
assert_return(() => invoke($1, `funcref`, []), [null]);
// ./test/core/ref_null.wast:52
assert_return(() => invoke($1, `nullfuncref`, []), [value('anyfunc', null)]);
// ./test/core/ref_null.wast:53
assert_return(() => invoke($1, `nullfuncref`, []), [value('nullfuncref', null)]);
// ./test/core/ref_null.wast:54
assert_return(() => invoke($1, `nullfuncref`, []), [null]);
// ./test/core/ref_null.wast:55
assert_return(() => invoke($1, `externref`, []), [value('externref', null)]);
// ./test/core/ref_null.wast:56
assert_return(() => invoke($1, `externref`, []), [value('nullexternref', null)]);
// ./test/core/ref_null.wast:57
assert_return(() => invoke($1, `externref`, []), [null]);
// ./test/core/ref_null.wast:58
assert_return(() => invoke($1, `nullexternref`, []), [value('externref', null)]);
// ./test/core/ref_null.wast:59
assert_return(() => invoke($1, `nullexternref`, []), [value('nullexternref', null)]);
// ./test/core/ref_null.wast:60
assert_return(() => invoke($1, `nullexternref`, []), [null]);
// ./test/core/ref_null.wast:61
assert_return(() => invoke($1, `ref`, []), [value('anyfunc', null)]);
// ./test/core/ref_null.wast:62
assert_return(() => invoke($1, `ref`, []), [value('nullfuncref', null)]);
// ./test/core/ref_null.wast:63
assert_return(() => invoke($1, `ref`, []), [null]);

View File

@@ -1,289 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/token.wast
// ./test/core/token.wast:3
assert_malformed(() => instantiate(`(func (drop (i32.const0))) `), `unknown operator`);
// ./test/core/token.wast:7
assert_malformed(() => instantiate(`(func br 0drop) `), `unknown operator`);
// ./test/core/token.wast:15
let $0 = instantiate(`(module
(func(nop))
)`);
// ./test/core/token.wast:18
let $1 = instantiate(`(module
(func (nop)nop)
)`);
// ./test/core/token.wast:21
let $2 = instantiate(`(module
(func nop(nop))
)`);
// ./test/core/token.wast:24
let $3 = instantiate(`(module
(func(nop)(nop))
)`);
// ./test/core/token.wast:27
let $4 = instantiate(`(module
(func $$f(nop))
)`);
// ./test/core/token.wast:30
let $5 = instantiate(`(module
(func br 0(nop))
)`);
// ./test/core/token.wast:33
let $6 = instantiate(`(module
(table 1 funcref)
(func)
(elem (i32.const 0)0)
)`);
// ./test/core/token.wast:38
let $7 = instantiate(`(module
(table 1 funcref)
(func $$f)
(elem (i32.const 0)$$f)
)`);
// ./test/core/token.wast:43
let $8 = instantiate(`(module
(memory 1)
(data (i32.const 0)"a")
)`);
// ./test/core/token.wast:47
let $9 = instantiate(`(module
(import "spectest" "print"(func))
)`);
// ./test/core/token.wast:54
let $10 = instantiate(`(module
(func;;bla
)
)`);
// ./test/core/token.wast:58
let $11 = instantiate(`(module
(func (nop);;bla
)
)`);
// ./test/core/token.wast:62
let $12 = instantiate(`(module
(func nop;;bla
)
)`);
// ./test/core/token.wast:66
let $13 = instantiate(`(module
(func $$f;;bla
)
)`);
// ./test/core/token.wast:70
let $14 = instantiate(`(module
(func br 0;;bla
)
)`);
// ./test/core/token.wast:74
let $15 = instantiate(`(module
(data "a";;bla
)
)`);
// ./test/core/token.wast:82
let $16 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table 0 $$l)))
)`);
// ./test/core/token.wast:85
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table 0$$l))) `),
`unknown operator`,
);
// ./test/core/token.wast:92
let $17 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table $$l 0)))
)`);
// ./test/core/token.wast:95
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table $$l0))) `),
`unknown label`,
);
// ./test/core/token.wast:102
let $18 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table $$l $$l)))
)`);
// ./test/core/token.wast:105
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table $$l$$l))) `),
`unknown label`,
);
// ./test/core/token.wast:112
let $19 = instantiate(`(module
(func (block $$l0 (i32.const 0) (br_table $$l0)))
)`);
// ./test/core/token.wast:115
let $20 = instantiate(`(module
(func (block $$l$$l (i32.const 0) (br_table $$l$$l)))
)`);
// ./test/core/token.wast:122
let $21 = instantiate(`(module
(data "a")
)`);
// ./test/core/token.wast:125
assert_malformed(() => instantiate(`(data"a") `), `unknown operator`);
// ./test/core/token.wast:132
let $22 = instantiate(`(module
(data $$l "a")
)`);
// ./test/core/token.wast:135
assert_malformed(() => instantiate(`(data $$l"a") `), `unknown operator`);
// ./test/core/token.wast:142
let $23 = instantiate(`(module
(data $$l " a")
)`);
// ./test/core/token.wast:145
assert_malformed(() => instantiate(`(data $$l" a") `), `unknown operator`);
// ./test/core/token.wast:152
let $24 = instantiate(`(module
(data $$l "a ")
)`);
// ./test/core/token.wast:155
assert_malformed(() => instantiate(`(data $$l"a ") `), `unknown operator`);
// ./test/core/token.wast:162
let $25 = instantiate(`(module
(data $$l "a " "b")
)`);
// ./test/core/token.wast:165
assert_malformed(() => instantiate(`(data $$l"a ""b") `), `unknown operator`);
// ./test/core/token.wast:172
let $26 = instantiate(`(module
(data $$l "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:175
assert_malformed(() => instantiate(`(data $$l"\u{f61a}\u{f4a9}") `), `unknown operator`);
// ./test/core/token.wast:182
let $27 = instantiate(`(module
(data $$l " \u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:185
assert_malformed(() => instantiate(`(data $$l" \u{f61a}\u{f4a9}") `), `unknown operator`);
// ./test/core/token.wast:192
let $28 = instantiate(`(module
(data $$l "\u{f61a}\u{f4a9} ")
)`);
// ./test/core/token.wast:195
assert_malformed(() => instantiate(`(data $$l"\u{f61a}\u{f4a9} ") `), `unknown operator`);
// ./test/core/token.wast:202
let $29 = instantiate(`(module
(data "a" "b")
)`);
// ./test/core/token.wast:205
assert_malformed(() => instantiate(`(data "a""b") `), `unknown operator`);
// ./test/core/token.wast:212
let $30 = instantiate(`(module
(data "a" " b")
)`);
// ./test/core/token.wast:215
assert_malformed(() => instantiate(`(data "a"" b") `), `unknown operator`);
// ./test/core/token.wast:222
let $31 = instantiate(`(module
(data "a " "b")
)`);
// ./test/core/token.wast:225
assert_malformed(() => instantiate(`(data "a ""b") `), `unknown operator`);
// ./test/core/token.wast:232
let $32 = instantiate(`(module
(data "\u{f61a}\u{f4a9}" "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:235
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9}""\u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:242
let $33 = instantiate(`(module
(data "\u{f61a}\u{f4a9}" " \u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:245
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9}"" \u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:252
let $34 = instantiate(`(module
(data "\u{f61a}\u{f4a9} " "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:255
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9} ""\u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:263
assert_malformed(() => instantiate(`(func "a"x) `), `unknown operator`);
// ./test/core/token.wast:269
assert_malformed(() => instantiate(`(func "a"0) `), `unknown operator`);
// ./test/core/token.wast:275
assert_malformed(() => instantiate(`(func 0"a") `), `unknown operator`);
// ./test/core/token.wast:281
assert_malformed(() => instantiate(`(func "a"$$x) `), `unknown operator`);

View File

@@ -1,424 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/unreachable.wast
// ./test/core/unreachable.wast:3
let $0 = instantiate(`(module
;; Auxiliary definitions
(func $$dummy)
(func $$dummy3 (param i32 i32 i32))
(func (export "type-i32") (result i32) (unreachable))
(func (export "type-i64") (result i64) (unreachable))
(func (export "type-f32") (result f32) (unreachable))
(func (export "type-f64") (result f64) (unreachable))
(func (export "as-func-first") (result i32)
(unreachable) (i32.const -1)
)
(func (export "as-func-mid") (result i32)
(call $$dummy) (unreachable) (i32.const -1)
)
(func (export "as-func-last")
(call $$dummy) (unreachable)
)
(func (export "as-func-value") (result i32)
(call $$dummy) (unreachable)
)
(func (export "as-block-first") (result i32)
(block (result i32) (unreachable) (i32.const 2))
)
(func (export "as-block-mid") (result i32)
(block (result i32) (call $$dummy) (unreachable) (i32.const 2))
)
(func (export "as-block-last")
(block (nop) (call $$dummy) (unreachable))
)
(func (export "as-block-value") (result i32)
(block (result i32) (nop) (call $$dummy) (unreachable))
)
(func (export "as-block-broke") (result i32)
(block (result i32) (call $$dummy) (br 0 (i32.const 1)) (unreachable))
)
(func (export "as-loop-first") (result i32)
(loop (result i32) (unreachable) (i32.const 2))
)
(func (export "as-loop-mid") (result i32)
(loop (result i32) (call $$dummy) (unreachable) (i32.const 2))
)
(func (export "as-loop-last")
(loop (nop) (call $$dummy) (unreachable))
)
(func (export "as-loop-broke") (result i32)
(block (result i32)
(loop (result i32) (call $$dummy) (br 1 (i32.const 1)) (unreachable))
)
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (unreachable)))
)
(func (export "as-br_if-cond")
(block (br_if 0 (unreachable)))
)
(func (export "as-br_if-value") (result i32)
(block (result i32)
(drop (br_if 0 (unreachable) (i32.const 1))) (i32.const 7)
)
)
(func (export "as-br_if-value-cond") (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 6) (unreachable))) (i32.const 7)
)
)
(func (export "as-br_table-index")
(block (br_table 0 0 0 (unreachable)))
)
(func (export "as-br_table-value") (result i32)
(block (result i32)
(br_table 0 0 0 (unreachable) (i32.const 1)) (i32.const 7)
)
)
(func (export "as-br_table-value-2") (result i32)
(block (result i32)
(block (result i32) (br_table 0 1 (unreachable) (i32.const 1)))
)
)
(func (export "as-br_table-value-index") (result i32)
(block (result i32)
(br_table 0 0 (i32.const 6) (unreachable)) (i32.const 7)
)
)
(func (export "as-br_table-value-and-index") (result i32)
(block (result i32) (br_table 0 0 (unreachable)) (i32.const 8))
)
(func (export "as-return-value") (result i64)
(return (unreachable))
)
(func (export "as-if-cond") (result i32)
(if (result i32) (unreachable) (then (i32.const 0)) (else (i32.const 1)))
)
(func (export "as-if-then") (param i32 i32) (result i32)
(if (result i32) (local.get 0) (then (unreachable)) (else (local.get 1)))
)
(func (export "as-if-else") (param i32 i32) (result i32)
(if (result i32) (local.get 0) (then (local.get 1)) (else (unreachable)))
)
(func (export "as-if-then-no-else") (param i32 i32) (result i32)
(if (local.get 0) (then (unreachable))) (local.get 1)
)
(func (export "as-select-first") (param i32 i32) (result i32)
(select (unreachable) (local.get 0) (local.get 1))
)
(func (export "as-select-second") (param i32 i32) (result i32)
(select (local.get 0) (unreachable) (local.get 1))
)
(func (export "as-select-cond") (result i32)
(select (i32.const 0) (i32.const 1) (unreachable))
)
(func (export "as-call-first")
(call $$dummy3 (unreachable) (i32.const 2) (i32.const 3))
)
(func (export "as-call-mid")
(call $$dummy3 (i32.const 1) (unreachable) (i32.const 3))
)
(func (export "as-call-last")
(call $$dummy3 (i32.const 1) (i32.const 2) (unreachable))
)
(type $$sig (func (param i32 i32 i32)))
(table funcref (elem $$dummy3))
(func (export "as-call_indirect-func")
(call_indirect (type $$sig)
(unreachable) (i32.const 1) (i32.const 2) (i32.const 3)
)
)
(func (export "as-call_indirect-first")
(call_indirect (type $$sig)
(i32.const 0) (unreachable) (i32.const 2) (i32.const 3)
)
)
(func (export "as-call_indirect-mid")
(call_indirect (type $$sig)
(i32.const 0) (i32.const 1) (unreachable) (i32.const 3)
)
)
(func (export "as-call_indirect-last")
(call_indirect (type $$sig)
(i32.const 0) (i32.const 1) (i32.const 2) (unreachable)
)
)
(func (export "as-local.set-value") (local f32)
(local.set 0 (unreachable))
)
(func (export "as-local.tee-value") (result f32) (local f32)
(local.tee 0 (unreachable))
)
(global $$a (mut f32) (f32.const 0))
(func (export "as-global.set-value") (result f32)
(global.set $$a (unreachable))
)
(memory 1)
(func (export "as-load-address") (result f32)
(f32.load (unreachable))
)
(func (export "as-loadN-address") (result i64)
(i64.load8_s (unreachable))
)
(func (export "as-store-address")
(f64.store (unreachable) (f64.const 7))
)
(func (export "as-store-value")
(i64.store (i32.const 2) (unreachable))
)
(func (export "as-storeN-address")
(i32.store8 (unreachable) (i32.const 7))
)
(func (export "as-storeN-value")
(i64.store16 (i32.const 2) (unreachable))
)
(func (export "as-unary-operand") (result f32)
(f32.neg (unreachable))
)
(func (export "as-binary-left") (result i32)
(i32.add (unreachable) (i32.const 10))
)
(func (export "as-binary-right") (result i64)
(i64.sub (i64.const 10) (unreachable))
)
(func (export "as-test-operand") (result i32)
(i32.eqz (unreachable))
)
(func (export "as-compare-left") (result i32)
(f64.le (unreachable) (f64.const 10))
)
(func (export "as-compare-right") (result i32)
(f32.ne (f32.const 10) (unreachable))
)
(func (export "as-convert-operand") (result i32)
(i32.wrap_i64 (unreachable))
)
(func (export "as-memory.grow-size") (result i32)
(memory.grow (unreachable))
)
)`);
// ./test/core/unreachable.wast:221
assert_trap(() => invoke($0, `type-i32`, []), `unreachable`);
// ./test/core/unreachable.wast:222
assert_trap(() => invoke($0, `type-i64`, []), `unreachable`);
// ./test/core/unreachable.wast:223
assert_trap(() => invoke($0, `type-f32`, []), `unreachable`);
// ./test/core/unreachable.wast:224
assert_trap(() => invoke($0, `type-f64`, []), `unreachable`);
// ./test/core/unreachable.wast:226
assert_trap(() => invoke($0, `as-func-first`, []), `unreachable`);
// ./test/core/unreachable.wast:227
assert_trap(() => invoke($0, `as-func-mid`, []), `unreachable`);
// ./test/core/unreachable.wast:228
assert_trap(() => invoke($0, `as-func-last`, []), `unreachable`);
// ./test/core/unreachable.wast:229
assert_trap(() => invoke($0, `as-func-value`, []), `unreachable`);
// ./test/core/unreachable.wast:231
assert_trap(() => invoke($0, `as-block-first`, []), `unreachable`);
// ./test/core/unreachable.wast:232
assert_trap(() => invoke($0, `as-block-mid`, []), `unreachable`);
// ./test/core/unreachable.wast:233
assert_trap(() => invoke($0, `as-block-last`, []), `unreachable`);
// ./test/core/unreachable.wast:234
assert_trap(() => invoke($0, `as-block-value`, []), `unreachable`);
// ./test/core/unreachable.wast:235
assert_return(() => invoke($0, `as-block-broke`, []), [value("i32", 1)]);
// ./test/core/unreachable.wast:237
assert_trap(() => invoke($0, `as-loop-first`, []), `unreachable`);
// ./test/core/unreachable.wast:238
assert_trap(() => invoke($0, `as-loop-mid`, []), `unreachable`);
// ./test/core/unreachable.wast:239
assert_trap(() => invoke($0, `as-loop-last`, []), `unreachable`);
// ./test/core/unreachable.wast:240
assert_return(() => invoke($0, `as-loop-broke`, []), [value("i32", 1)]);
// ./test/core/unreachable.wast:242
assert_trap(() => invoke($0, `as-br-value`, []), `unreachable`);
// ./test/core/unreachable.wast:244
assert_trap(() => invoke($0, `as-br_if-cond`, []), `unreachable`);
// ./test/core/unreachable.wast:245
assert_trap(() => invoke($0, `as-br_if-value`, []), `unreachable`);
// ./test/core/unreachable.wast:246
assert_trap(() => invoke($0, `as-br_if-value-cond`, []), `unreachable`);
// ./test/core/unreachable.wast:248
assert_trap(() => invoke($0, `as-br_table-index`, []), `unreachable`);
// ./test/core/unreachable.wast:249
assert_trap(() => invoke($0, `as-br_table-value`, []), `unreachable`);
// ./test/core/unreachable.wast:250
assert_trap(() => invoke($0, `as-br_table-value-2`, []), `unreachable`);
// ./test/core/unreachable.wast:251
assert_trap(() => invoke($0, `as-br_table-value-index`, []), `unreachable`);
// ./test/core/unreachable.wast:252
assert_trap(() => invoke($0, `as-br_table-value-and-index`, []), `unreachable`);
// ./test/core/unreachable.wast:254
assert_trap(() => invoke($0, `as-return-value`, []), `unreachable`);
// ./test/core/unreachable.wast:256
assert_trap(() => invoke($0, `as-if-cond`, []), `unreachable`);
// ./test/core/unreachable.wast:257
assert_trap(() => invoke($0, `as-if-then`, [1, 6]), `unreachable`);
// ./test/core/unreachable.wast:258
assert_return(() => invoke($0, `as-if-then`, [0, 6]), [value("i32", 6)]);
// ./test/core/unreachable.wast:259
assert_trap(() => invoke($0, `as-if-else`, [0, 6]), `unreachable`);
// ./test/core/unreachable.wast:260
assert_return(() => invoke($0, `as-if-else`, [1, 6]), [value("i32", 6)]);
// ./test/core/unreachable.wast:261
assert_trap(() => invoke($0, `as-if-then-no-else`, [1, 6]), `unreachable`);
// ./test/core/unreachable.wast:262
assert_return(() => invoke($0, `as-if-then-no-else`, [0, 6]), [value("i32", 6)]);
// ./test/core/unreachable.wast:264
assert_trap(() => invoke($0, `as-select-first`, [0, 6]), `unreachable`);
// ./test/core/unreachable.wast:265
assert_trap(() => invoke($0, `as-select-first`, [1, 6]), `unreachable`);
// ./test/core/unreachable.wast:266
assert_trap(() => invoke($0, `as-select-second`, [0, 6]), `unreachable`);
// ./test/core/unreachable.wast:267
assert_trap(() => invoke($0, `as-select-second`, [1, 6]), `unreachable`);
// ./test/core/unreachable.wast:268
assert_trap(() => invoke($0, `as-select-cond`, []), `unreachable`);
// ./test/core/unreachable.wast:270
assert_trap(() => invoke($0, `as-call-first`, []), `unreachable`);
// ./test/core/unreachable.wast:271
assert_trap(() => invoke($0, `as-call-mid`, []), `unreachable`);
// ./test/core/unreachable.wast:272
assert_trap(() => invoke($0, `as-call-last`, []), `unreachable`);
// ./test/core/unreachable.wast:274
assert_trap(() => invoke($0, `as-call_indirect-func`, []), `unreachable`);
// ./test/core/unreachable.wast:275
assert_trap(() => invoke($0, `as-call_indirect-first`, []), `unreachable`);
// ./test/core/unreachable.wast:276
assert_trap(() => invoke($0, `as-call_indirect-mid`, []), `unreachable`);
// ./test/core/unreachable.wast:277
assert_trap(() => invoke($0, `as-call_indirect-last`, []), `unreachable`);
// ./test/core/unreachable.wast:279
assert_trap(() => invoke($0, `as-local.set-value`, []), `unreachable`);
// ./test/core/unreachable.wast:280
assert_trap(() => invoke($0, `as-local.tee-value`, []), `unreachable`);
// ./test/core/unreachable.wast:281
assert_trap(() => invoke($0, `as-global.set-value`, []), `unreachable`);
// ./test/core/unreachable.wast:283
assert_trap(() => invoke($0, `as-load-address`, []), `unreachable`);
// ./test/core/unreachable.wast:284
assert_trap(() => invoke($0, `as-loadN-address`, []), `unreachable`);
// ./test/core/unreachable.wast:286
assert_trap(() => invoke($0, `as-store-address`, []), `unreachable`);
// ./test/core/unreachable.wast:287
assert_trap(() => invoke($0, `as-store-value`, []), `unreachable`);
// ./test/core/unreachable.wast:288
assert_trap(() => invoke($0, `as-storeN-address`, []), `unreachable`);
// ./test/core/unreachable.wast:289
assert_trap(() => invoke($0, `as-storeN-value`, []), `unreachable`);
// ./test/core/unreachable.wast:291
assert_trap(() => invoke($0, `as-unary-operand`, []), `unreachable`);
// ./test/core/unreachable.wast:293
assert_trap(() => invoke($0, `as-binary-left`, []), `unreachable`);
// ./test/core/unreachable.wast:294
assert_trap(() => invoke($0, `as-binary-right`, []), `unreachable`);
// ./test/core/unreachable.wast:296
assert_trap(() => invoke($0, `as-test-operand`, []), `unreachable`);
// ./test/core/unreachable.wast:298
assert_trap(() => invoke($0, `as-compare-left`, []), `unreachable`);
// ./test/core/unreachable.wast:299
assert_trap(() => invoke($0, `as-compare-right`, []), `unreachable`);
// ./test/core/unreachable.wast:301
assert_trap(() => invoke($0, `as-convert-operand`, []), `unreachable`);
// ./test/core/unreachable.wast:303
assert_trap(() => invoke($0, `as-memory.grow-size`, []), `unreachable`);

View File

@@ -1,138 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/unreached-valid.wast
// ./test/core/unreached-valid.wast:1
let $0 = instantiate(`(module
;; Check that both sides of the select are evaluated
(func (export "select-trap-left") (param $$cond i32) (result i32)
(select (unreachable) (i32.const 0) (local.get $$cond))
)
(func (export "select-trap-right") (param $$cond i32) (result i32)
(select (i32.const 0) (unreachable) (local.get $$cond))
)
(func (export "select-unreached")
(unreachable) (select)
(unreachable) (i32.const 0) (select)
(unreachable) (i32.const 0) (i32.const 0) (select)
(unreachable) (i32.const 0) (i32.const 0) (i32.const 0) (select)
(unreachable) (f32.const 0) (i32.const 0) (select)
(unreachable)
)
(func (export "select-unreached-result1") (result i32)
(unreachable) (i32.add (select))
)
(func (export "select-unreached-result2") (result i64)
(unreachable) (i64.add (select (i64.const 0) (i32.const 0)))
)
(func (export "select-unreached-num")
(unreachable)
(select)
(i32.eqz)
(drop)
)
(func (export "select-unreached-ref")
(unreachable)
(select)
(ref.is_null)
(drop)
)
(type $$t (func (param i32) (result i32)))
(func (export "call_ref-unreached") (result i32)
(unreachable)
(call_ref $$t)
)
)`);
// ./test/core/unreached-valid.wast:48
assert_trap(() => invoke($0, `select-trap-left`, [1]), `unreachable`);
// ./test/core/unreached-valid.wast:49
assert_trap(() => invoke($0, `select-trap-left`, [0]), `unreachable`);
// ./test/core/unreached-valid.wast:50
assert_trap(() => invoke($0, `select-trap-right`, [1]), `unreachable`);
// ./test/core/unreached-valid.wast:51
assert_trap(() => invoke($0, `select-trap-right`, [0]), `unreachable`);
// ./test/core/unreached-valid.wast:53
assert_trap(() => invoke($0, `select-unreached-result1`, []), `unreachable`);
// ./test/core/unreached-valid.wast:54
assert_trap(() => invoke($0, `select-unreached-result2`, []), `unreachable`);
// ./test/core/unreached-valid.wast:55
assert_trap(() => invoke($0, `select-unreached-num`, []), `unreachable`);
// ./test/core/unreached-valid.wast:56
assert_trap(() => invoke($0, `select-unreached-ref`, []), `unreachable`);
// ./test/core/unreached-valid.wast:58
assert_trap(() => invoke($0, `call_ref-unreached`, []), `unreachable`);
// ./test/core/unreached-valid.wast:63
let $1 = instantiate(`(module
(func (export "meet-bottom")
(block (result f64)
(block (result f32)
(unreachable)
(br_table 0 1 1 (i32.const 1))
)
(drop)
(f64.const 0)
)
(drop)
)
)`);
// ./test/core/unreached-valid.wast:77
assert_trap(() => invoke($1, `meet-bottom`, []), `unreachable`);
// ./test/core/unreached-valid.wast:82
let $2 = instantiate(`(module
(func (result (ref func))
(unreachable)
(ref.as_non_null)
)
(func (result (ref extern))
(unreachable)
(ref.as_non_null)
)
(func (result (ref func))
(block (result funcref)
(unreachable)
(br_on_null 0)
(return)
)
(unreachable)
)
(func (result (ref extern))
(block (result externref)
(unreachable)
(br_on_null 0)
(return)
)
(unreachable)
)
)`);

View File

@@ -0,0 +1,88 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/multi-memory/binary0.wast
// ./test/core/multi-memory/binary0.wast:2
let $0 = instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\07\\02" ;; Memory section with 2 entries
"\\00\\82\\00" ;; no max, minimum 2
"\\00\\82\\00" ;; no max, minimum 2
)`);
// ./test/core/multi-memory/binary0.wast:8
let $1 = instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\13\\03" ;; Memory section with 3 entries
"\\00\\83\\80\\80\\80\\00" ;; no max, minimum 3
"\\00\\84\\80\\80\\80\\00" ;; no max, minimum 4
"\\00\\85\\80\\80\\80\\00" ;; no max, minimum 5
)`);
// ./test/core/multi-memory/binary0.wast:16
let $2 = instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\05\\02" ;; Memory section with 2 entries
"\\00\\00" ;; no max, minimum 0
"\\00\\00" ;; no max, minimum 0
"\\0b\\06\\01" ;; Data section with 1 entry
"\\00" ;; Memory index 0
"\\41\\00\\0b\\00" ;; (i32.const 0) with contents ""
)`);
// ./test/core/multi-memory/binary0.wast:26
let $3 = instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\05\\02" ;; Memory section with 2 entries
"\\00\\00" ;; no max, minimum 0
"\\00\\01" ;; no max, minimum 1
"\\0b\\07\\01" ;; Data section with 1 entry
"\\02\\01" ;; Memory index 1
"\\41\\00\\0b\\00" ;; (i32.const 0) with contents ""
)`);
// ./test/core/multi-memory/binary0.wast:36
let $4 = instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\05\\02" ;; Memory section with 2 entries
"\\00\\00" ;; no max, minimum 0
"\\00\\01" ;; no max, minimum 1
"\\0b\\0a\\01" ;; Data section with 1 entry
"\\02\\81\\80\\80\\00" ;; Memory index 1
"\\41\\00\\0b\\00" ;; (i32.const 0) with contents ""
)`);
// ./test/core/multi-memory/binary0.wast:47
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\10\\02" ;; Memory section with 2 entries
"\\00\\01" ;; no max, minimum 1
"\\00\\82\\80\\80\\80\\80\\80\\80\\80\\80\\80\\80\\00" ;; no max, minimum 2 with one byte too many
)`),
`integer representation too long`,
);
// ./test/core/multi-memory/binary0.wast:58
assert_malformed(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\03\\02" ;; memory section with inconsistent count (1 declared, 0 given)
"\\00\\00" ;; memory 0 (missed)
;; "\\00\\00" ;; memory 1 (missing)
)`),
`unexpected end of section or function`,
);

View File

@@ -1,886 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/br_if.wast
// ./test/core/br_if.wast:3
let $0 = instantiate(`(module
(func $$dummy)
(func (export "type-i32")
(block (drop (i32.ctz (br_if 0 (i32.const 0) (i32.const 1)))))
)
(func (export "type-i64")
(block (drop (i64.ctz (br_if 0 (i64.const 0) (i32.const 1)))))
)
(func (export "type-f32")
(block (drop (f32.neg (br_if 0 (f32.const 0) (i32.const 1)))))
)
(func (export "type-f64")
(block (drop (f64.neg (br_if 0 (f64.const 0) (i32.const 1)))))
)
(func (export "type-i32-value") (result i32)
(block (result i32) (i32.ctz (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "type-i64-value") (result i64)
(block (result i64) (i64.ctz (br_if 0 (i64.const 2) (i32.const 1))))
)
(func (export "type-f32-value") (result f32)
(block (result f32) (f32.neg (br_if 0 (f32.const 3) (i32.const 1))))
)
(func (export "type-f64-value") (result f64)
(block (result f64) (f64.neg (br_if 0 (f64.const 4) (i32.const 1))))
)
(func (export "as-block-first") (param i32) (result i32)
(block (br_if 0 (local.get 0)) (return (i32.const 2))) (i32.const 3)
)
(func (export "as-block-mid") (param i32) (result i32)
(block (call $$dummy) (br_if 0 (local.get 0)) (return (i32.const 2)))
(i32.const 3)
)
(func (export "as-block-last") (param i32)
(block (call $$dummy) (call $$dummy) (br_if 0 (local.get 0)))
)
(func (export "as-block-first-value") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 10) (local.get 0))) (return (i32.const 11))
)
)
(func (export "as-block-mid-value") (param i32) (result i32)
(block (result i32)
(call $$dummy)
(drop (br_if 0 (i32.const 20) (local.get 0)))
(return (i32.const 21))
)
)
(func (export "as-block-last-value") (param i32) (result i32)
(block (result i32)
(call $$dummy) (call $$dummy) (br_if 0 (i32.const 11) (local.get 0))
)
)
(func (export "as-loop-first") (param i32) (result i32)
(block (loop (br_if 1 (local.get 0)) (return (i32.const 2)))) (i32.const 3)
)
(func (export "as-loop-mid") (param i32) (result i32)
(block (loop (call $$dummy) (br_if 1 (local.get 0)) (return (i32.const 2))))
(i32.const 4)
)
(func (export "as-loop-last") (param i32)
(loop (call $$dummy) (br_if 1 (local.get 0)))
)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (br_if 0 (i32.const 1) (i32.const 2))))
)
(func (export "as-br_if-cond")
(block (br_if 0 (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-br_if-value") (result i32)
(block (result i32)
(drop (br_if 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)))
(i32.const 4)
)
)
(func (export "as-br_if-value-cond") (param i32) (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 2) (br_if 0 (i32.const 1) (local.get 0))))
(i32.const 4)
)
)
(func (export "as-br_table-index")
(block (br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2))))
)
(func (export "as-br_table-value") (result i32)
(block (result i32)
(br_table 0 0 0 (br_if 0 (i32.const 1) (i32.const 2)) (i32.const 3)) (i32.const 4)
)
)
(func (export "as-br_table-value-index") (result i32)
(block (result i32)
(br_table 0 0 (i32.const 2) (br_if 0 (i32.const 1) (i32.const 3))) (i32.const 4)
)
)
(func (export "as-return-value") (result i64)
(block (result i64) (return (br_if 0 (i64.const 1) (i32.const 2))))
)
(func (export "as-if-cond") (param i32) (result i32)
(block (result i32)
(if (result i32)
(br_if 0 (i32.const 1) (local.get 0))
(then (i32.const 2))
(else (i32.const 3))
)
)
)
(func (export "as-if-then") (param i32 i32)
(block
(if (local.get 0) (then (br_if 1 (local.get 1))) (else (call $$dummy)))
)
)
(func (export "as-if-else") (param i32 i32)
(block
(if (local.get 0) (then (call $$dummy)) (else (br_if 1 (local.get 1))))
)
)
(func (export "as-select-first") (param i32) (result i32)
(block (result i32)
(select (br_if 0 (i32.const 3) (i32.const 10)) (i32.const 2) (local.get 0))
)
)
(func (export "as-select-second") (param i32) (result i32)
(block (result i32)
(select (i32.const 1) (br_if 0 (i32.const 3) (i32.const 10)) (local.get 0))
)
)
(func (export "as-select-cond") (result i32)
(block (result i32)
(select (i32.const 1) (i32.const 2) (br_if 0 (i32.const 3) (i32.const 10)))
)
)
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
(func (export "as-call-first") (result i32)
(block (result i32)
(call $$f
(br_if 0 (i32.const 12) (i32.const 1)) (i32.const 2) (i32.const 3)
)
)
)
(func (export "as-call-mid") (result i32)
(block (result i32)
(call $$f
(i32.const 1) (br_if 0 (i32.const 13) (i32.const 1)) (i32.const 3)
)
)
)
(func (export "as-call-last") (result i32)
(block (result i32)
(call $$f
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 14) (i32.const 1))
)
)
)
(func $$func (param i32 i32 i32) (result i32) (local.get 0))
(type $$check (func (param i32 i32 i32) (result i32)))
(table funcref (elem $$func))
(func (export "as-call_indirect-func") (result i32)
(block (result i32)
(call_indirect (type $$check)
(br_if 0 (i32.const 4) (i32.const 10))
(i32.const 1) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-first") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 2) (i32.const 0)
)
)
)
(func (export "as-call_indirect-mid") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (i32.const 2) (br_if 0 (i32.const 4) (i32.const 10)) (i32.const 0)
)
)
)
(func (export "as-call_indirect-last") (result i32)
(block (result i32)
(call_indirect (type $$check)
(i32.const 1) (i32.const 2) (i32.const 3) (br_if 0 (i32.const 4) (i32.const 10))
)
)
)
(func (export "as-local.set-value") (param i32) (result i32)
(local i32)
(block (result i32)
(local.set 0 (br_if 0 (i32.const 17) (local.get 0)))
(i32.const -1)
)
)
(func (export "as-local.tee-value") (param i32) (result i32)
(block (result i32)
(local.tee 0 (br_if 0 (i32.const 1) (local.get 0)))
(return (i32.const -1))
)
)
(global $$a (mut i32) (i32.const 10))
(func (export "as-global.set-value") (param i32) (result i32)
(block (result i32)
(global.set $$a (br_if 0 (i32.const 1) (local.get 0)))
(return (i32.const -1))
)
)
(memory 1)
(func (export "as-load-address") (result i32)
(block (result i32) (i32.load (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-loadN-address") (result i32)
(block (result i32) (i32.load8_s (br_if 0 (i32.const 30) (i32.const 1))))
)
(func (export "as-store-address") (result i32)
(block (result i32)
(i32.store (br_if 0 (i32.const 30) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-store-value") (result i32)
(block (result i32)
(i32.store (i32.const 2) (br_if 0 (i32.const 31) (i32.const 1))) (i32.const -1)
)
)
(func (export "as-storeN-address") (result i32)
(block (result i32)
(i32.store8 (br_if 0 (i32.const 32) (i32.const 1)) (i32.const 7)) (i32.const -1)
)
)
(func (export "as-storeN-value") (result i32)
(block (result i32)
(i32.store16 (i32.const 2) (br_if 0 (i32.const 33) (i32.const 1))) (i32.const -1)
)
)
(func (export "as-unary-operand") (result f64)
(block (result f64) (f64.neg (br_if 0 (f64.const 1.0) (i32.const 1))))
)
(func (export "as-binary-left") (result i32)
(block (result i32) (i32.add (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
)
(func (export "as-binary-right") (result i32)
(block (result i32) (i32.sub (i32.const 10) (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "as-test-operand") (result i32)
(block (result i32) (i32.eqz (br_if 0 (i32.const 0) (i32.const 1))))
)
(func (export "as-compare-left") (result i32)
(block (result i32) (i32.le_u (br_if 0 (i32.const 1) (i32.const 1)) (i32.const 10)))
)
(func (export "as-compare-right") (result i32)
(block (result i32) (i32.ne (i32.const 10) (br_if 0 (i32.const 1) (i32.const 42))))
)
(func (export "as-memory.grow-size") (result i32)
(block (result i32) (memory.grow (br_if 0 (i32.const 1) (i32.const 1))))
)
(func (export "nested-block-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(i32.add
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0)))
(i32.const 16)
)
)
)
)
)
(func (export "nested-br-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
)
(i32.const 16)
)
)
)
(func (export "nested-br_if-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(drop (br_if 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
(i32.const 1)
))
(i32.const 16)
)
)
)
(func (export "nested-br_if-value-cond") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(drop (br_if 0
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
)
))
(i32.const 16)
)
)
)
(func (export "nested-br_table-value") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br_table 0
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 4)
)
(i32.const 1)
)
(i32.const 16)
)
)
)
(func (export "nested-br_table-value-index") (param i32) (result i32)
(i32.add
(i32.const 1)
(block (result i32)
(drop (i32.const 2))
(br_table 0
(i32.const 4)
(block (result i32)
(drop (br_if 1 (i32.const 8) (local.get 0))) (i32.const 1)
)
)
(i32.const 16)
)
)
)
)`);
// ./test/core/br_if.wast:372
assert_return(() => invoke($0, `type-i32`, []), []);
// ./test/core/br_if.wast:373
assert_return(() => invoke($0, `type-i64`, []), []);
// ./test/core/br_if.wast:374
assert_return(() => invoke($0, `type-f32`, []), []);
// ./test/core/br_if.wast:375
assert_return(() => invoke($0, `type-f64`, []), []);
// ./test/core/br_if.wast:377
assert_return(() => invoke($0, `type-i32-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:378
assert_return(() => invoke($0, `type-i64-value`, []), [value("i64", 2n)]);
// ./test/core/br_if.wast:379
assert_return(() => invoke($0, `type-f32-value`, []), [value("f32", 3)]);
// ./test/core/br_if.wast:380
assert_return(() => invoke($0, `type-f64-value`, []), [value("f64", 4)]);
// ./test/core/br_if.wast:382
assert_return(() => invoke($0, `as-block-first`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:383
assert_return(() => invoke($0, `as-block-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:384
assert_return(() => invoke($0, `as-block-mid`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:385
assert_return(() => invoke($0, `as-block-mid`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:386
assert_return(() => invoke($0, `as-block-last`, [0]), []);
// ./test/core/br_if.wast:387
assert_return(() => invoke($0, `as-block-last`, [1]), []);
// ./test/core/br_if.wast:389
assert_return(() => invoke($0, `as-block-first-value`, [0]), [value("i32", 11)]);
// ./test/core/br_if.wast:390
assert_return(() => invoke($0, `as-block-first-value`, [1]), [value("i32", 10)]);
// ./test/core/br_if.wast:391
assert_return(() => invoke($0, `as-block-mid-value`, [0]), [value("i32", 21)]);
// ./test/core/br_if.wast:392
assert_return(() => invoke($0, `as-block-mid-value`, [1]), [value("i32", 20)]);
// ./test/core/br_if.wast:393
assert_return(() => invoke($0, `as-block-last-value`, [0]), [value("i32", 11)]);
// ./test/core/br_if.wast:394
assert_return(() => invoke($0, `as-block-last-value`, [1]), [value("i32", 11)]);
// ./test/core/br_if.wast:396
assert_return(() => invoke($0, `as-loop-first`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:397
assert_return(() => invoke($0, `as-loop-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:398
assert_return(() => invoke($0, `as-loop-mid`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:399
assert_return(() => invoke($0, `as-loop-mid`, [1]), [value("i32", 4)]);
// ./test/core/br_if.wast:400
assert_return(() => invoke($0, `as-loop-last`, [0]), []);
// ./test/core/br_if.wast:401
assert_return(() => invoke($0, `as-loop-last`, [1]), []);
// ./test/core/br_if.wast:403
assert_return(() => invoke($0, `as-br-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:405
assert_return(() => invoke($0, `as-br_if-cond`, []), []);
// ./test/core/br_if.wast:406
assert_return(() => invoke($0, `as-br_if-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:407
assert_return(() => invoke($0, `as-br_if-value-cond`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:408
assert_return(() => invoke($0, `as-br_if-value-cond`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:410
assert_return(() => invoke($0, `as-br_table-index`, []), []);
// ./test/core/br_if.wast:411
assert_return(() => invoke($0, `as-br_table-value`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:412
assert_return(() => invoke($0, `as-br_table-value-index`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:414
assert_return(() => invoke($0, `as-return-value`, []), [value("i64", 1n)]);
// ./test/core/br_if.wast:416
assert_return(() => invoke($0, `as-if-cond`, [0]), [value("i32", 2)]);
// ./test/core/br_if.wast:417
assert_return(() => invoke($0, `as-if-cond`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:418
assert_return(() => invoke($0, `as-if-then`, [0, 0]), []);
// ./test/core/br_if.wast:419
assert_return(() => invoke($0, `as-if-then`, [4, 0]), []);
// ./test/core/br_if.wast:420
assert_return(() => invoke($0, `as-if-then`, [0, 1]), []);
// ./test/core/br_if.wast:421
assert_return(() => invoke($0, `as-if-then`, [4, 1]), []);
// ./test/core/br_if.wast:422
assert_return(() => invoke($0, `as-if-else`, [0, 0]), []);
// ./test/core/br_if.wast:423
assert_return(() => invoke($0, `as-if-else`, [3, 0]), []);
// ./test/core/br_if.wast:424
assert_return(() => invoke($0, `as-if-else`, [0, 1]), []);
// ./test/core/br_if.wast:425
assert_return(() => invoke($0, `as-if-else`, [3, 1]), []);
// ./test/core/br_if.wast:427
assert_return(() => invoke($0, `as-select-first`, [0]), [value("i32", 3)]);
// ./test/core/br_if.wast:428
assert_return(() => invoke($0, `as-select-first`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:429
assert_return(() => invoke($0, `as-select-second`, [0]), [value("i32", 3)]);
// ./test/core/br_if.wast:430
assert_return(() => invoke($0, `as-select-second`, [1]), [value("i32", 3)]);
// ./test/core/br_if.wast:431
assert_return(() => invoke($0, `as-select-cond`, []), [value("i32", 3)]);
// ./test/core/br_if.wast:433
assert_return(() => invoke($0, `as-call-first`, []), [value("i32", 12)]);
// ./test/core/br_if.wast:434
assert_return(() => invoke($0, `as-call-mid`, []), [value("i32", 13)]);
// ./test/core/br_if.wast:435
assert_return(() => invoke($0, `as-call-last`, []), [value("i32", 14)]);
// ./test/core/br_if.wast:437
assert_return(() => invoke($0, `as-call_indirect-func`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:438
assert_return(() => invoke($0, `as-call_indirect-first`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:439
assert_return(() => invoke($0, `as-call_indirect-mid`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:440
assert_return(() => invoke($0, `as-call_indirect-last`, []), [value("i32", 4)]);
// ./test/core/br_if.wast:442
assert_return(() => invoke($0, `as-local.set-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:443
assert_return(() => invoke($0, `as-local.set-value`, [1]), [value("i32", 17)]);
// ./test/core/br_if.wast:445
assert_return(() => invoke($0, `as-local.tee-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:446
assert_return(() => invoke($0, `as-local.tee-value`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:448
assert_return(() => invoke($0, `as-global.set-value`, [0]), [value("i32", -1)]);
// ./test/core/br_if.wast:449
assert_return(() => invoke($0, `as-global.set-value`, [1]), [value("i32", 1)]);
// ./test/core/br_if.wast:451
assert_return(() => invoke($0, `as-load-address`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:452
assert_return(() => invoke($0, `as-loadN-address`, []), [value("i32", 30)]);
// ./test/core/br_if.wast:454
assert_return(() => invoke($0, `as-store-address`, []), [value("i32", 30)]);
// ./test/core/br_if.wast:455
assert_return(() => invoke($0, `as-store-value`, []), [value("i32", 31)]);
// ./test/core/br_if.wast:456
assert_return(() => invoke($0, `as-storeN-address`, []), [value("i32", 32)]);
// ./test/core/br_if.wast:457
assert_return(() => invoke($0, `as-storeN-value`, []), [value("i32", 33)]);
// ./test/core/br_if.wast:459
assert_return(() => invoke($0, `as-unary-operand`, []), [value("f64", 1)]);
// ./test/core/br_if.wast:460
assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:461
assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:462
assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
// ./test/core/br_if.wast:463
assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:464
assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:465
assert_return(() => invoke($0, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/br_if.wast:467
assert_return(() => invoke($0, `nested-block-value`, [0]), [value("i32", 21)]);
// ./test/core/br_if.wast:468
assert_return(() => invoke($0, `nested-block-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:469
assert_return(() => invoke($0, `nested-br-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:470
assert_return(() => invoke($0, `nested-br-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:471
assert_return(() => invoke($0, `nested-br_if-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:472
assert_return(() => invoke($0, `nested-br_if-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:473
assert_return(() => invoke($0, `nested-br_if-value-cond`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:474
assert_return(() => invoke($0, `nested-br_if-value-cond`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:475
assert_return(() => invoke($0, `nested-br_table-value`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:476
assert_return(() => invoke($0, `nested-br_table-value`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:477
assert_return(() => invoke($0, `nested-br_table-value-index`, [0]), [value("i32", 5)]);
// ./test/core/br_if.wast:478
assert_return(() => invoke($0, `nested-br_table-value-index`, [1]), [value("i32", 9)]);
// ./test/core/br_if.wast:480
assert_invalid(
() => instantiate(`(module (func $$type-false-i32 (block (i32.ctz (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:484
assert_invalid(
() => instantiate(`(module (func $$type-false-i64 (block (i64.ctz (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:488
assert_invalid(
() => instantiate(`(module (func $$type-false-f32 (block (f32.neg (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:492
assert_invalid(
() => instantiate(`(module (func $$type-false-f64 (block (f64.neg (br_if 0 (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:497
assert_invalid(
() => instantiate(`(module (func $$type-true-i32 (block (i32.ctz (br_if 0 (i32.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:501
assert_invalid(
() => instantiate(`(module (func $$type-true-i64 (block (i64.ctz (br_if 0 (i64.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:505
assert_invalid(
() => instantiate(`(module (func $$type-true-f32 (block (f32.neg (br_if 0 (f32.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:509
assert_invalid(
() => instantiate(`(module (func $$type-true-f64 (block (f64.neg (br_if 0 (i64.const 1))))))`),
`type mismatch`,
);
// ./test/core/br_if.wast:514
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (i32.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:520
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (i32.const 1)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:526
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-num-vs-void
(block (br_if 0 (i32.const 0) (i32.const 0)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:532
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-num-vs-void
(block (br_if 0 (i32.const 0) (i32.const 1)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:539
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (nop) (i32.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:545
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-void-vs-num (result i32)
(block (result i32) (br_if 0 (nop) (i32.const 1)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:551
assert_invalid(
() => instantiate(`(module (func $$type-false-arg-num-vs-num (result i32)
(block (result i32)
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
)
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:559
assert_invalid(
() => instantiate(`(module (func $$type-true-arg-num-vs-num (result i32)
(block (result i32)
(drop (br_if 0 (i64.const 1) (i32.const 0))) (i32.const 1)
)
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:568
assert_invalid(
() => instantiate(`(module (func $$type-cond-empty-vs-i32
(block (br_if 0))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:574
assert_invalid(
() => instantiate(`(module (func $$type-cond-void-vs-i32
(block (br_if 0 (nop)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:580
assert_invalid(
() => instantiate(`(module (func $$type-cond-num-vs-i32
(block (br_if 0 (i64.const 0)))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:586
assert_invalid(
() => instantiate(`(module (func $$type-arg-cond-void-vs-i32 (result i32)
(block (result i32) (br_if 0 (i32.const 0) (nop)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:592
assert_invalid(
() => instantiate(`(module (func $$type-arg-void-vs-num-nested (result i32)
(block (result i32) (i32.const 0) (block (br_if 1 (i32.const 1))))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:598
assert_invalid(
() => instantiate(`(module (func $$type-arg-cond-num-vs-i32 (result i32)
(block (result i32) (br_if 0 (i32.const 0) (i64.const 0)) (i32.const 1))
))`),
`type mismatch`,
);
// ./test/core/br_if.wast:605
assert_invalid(
() => instantiate(`(module
(func $$type-1st-cond-empty-in-then
(block
(i32.const 0) (i32.const 0)
(if (result i32) (then (br_if 0)))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:617
assert_invalid(
() => instantiate(`(module
(func $$type-2nd-cond-empty-in-then
(block
(i32.const 0) (i32.const 0)
(if (result i32) (then (br_if 0 (i32.const 1))))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:629
assert_invalid(
() => instantiate(`(module
(func $$type-1st-cond-empty-in-return
(block (result i32)
(return (br_if 0))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:640
assert_invalid(
() => instantiate(`(module
(func $$type-2nd-cond-empty-in-return
(block (result i32)
(return (br_if 0 (i32.const 1)))
)
(i32.eqz) (drop)
)
)`),
`type mismatch`,
);
// ./test/core/br_if.wast:653
assert_invalid(
() => instantiate(`(module (func $$unbound-label (br_if 1 (i32.const 1))))`),
`unknown label`,
);
// ./test/core/br_if.wast:657
assert_invalid(
() => instantiate(`(module (func $$unbound-nested-label (block (block (br_if 5 (i32.const 1))))))`),
`unknown label`,
);
// ./test/core/br_if.wast:661
assert_invalid(
() => instantiate(`(module (func $$large-label (br_if 0x10000001 (i32.const 1))))`),
`unknown label`,
);

View File

@@ -1,51 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/comments.wast
// ./test/core/comments.wast:10:0
let $0 = instantiate(`(module;;comment
)`);
// ./test/core/comments.wast:57:11
let $1 = instantiate(`(module(;comment;)
(;comment;))`);
// ./test/core/comments.wast:67
let $2 = instantiate(`(module
(;comment(;nested(;further;)nested;)comment;)
)`);
// ./test/core/comments.wast:76
let $3 = instantiate(`(module
(;comment;;comment(;nested;)comment;)
)`);
// ./test/core/comments.wast:83:8
let $4 = instantiate(`(func (export "f1") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) (func (export "f2") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) (func (export "f3") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) `);
// ./test/core/comments.wast:104
assert_return(() => invoke($4, `f1`, []), [value("i32", 2)]);
// ./test/core/comments.wast:105
assert_return(() => invoke($4, `f2`, []), [value("i32", 2)]);
// ./test/core/comments.wast:106

View File

@@ -1,840 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/float_literals.wast
// ./test/core/float_literals.wast:3
let $0 = instantiate(`(module
;; f32 special values
(func (export "f32.nan") (result i32) (i32.reinterpret_f32 (f32.const nan)))
(func (export "f32.positive_nan") (result i32) (i32.reinterpret_f32 (f32.const +nan)))
(func (export "f32.negative_nan") (result i32) (i32.reinterpret_f32 (f32.const -nan)))
(func (export "f32.plain_nan") (result i32) (i32.reinterpret_f32 (f32.const nan:0x400000)))
(func (export "f32.informally_known_as_plain_snan") (result i32) (i32.reinterpret_f32 (f32.const nan:0x200000)))
(func (export "f32.all_ones_nan") (result i32) (i32.reinterpret_f32 (f32.const -nan:0x7fffff)))
(func (export "f32.misc_nan") (result i32) (i32.reinterpret_f32 (f32.const nan:0x012345)))
(func (export "f32.misc_positive_nan") (result i32) (i32.reinterpret_f32 (f32.const +nan:0x304050)))
(func (export "f32.misc_negative_nan") (result i32) (i32.reinterpret_f32 (f32.const -nan:0x2abcde)))
(func (export "f32.infinity") (result i32) (i32.reinterpret_f32 (f32.const inf)))
(func (export "f32.positive_infinity") (result i32) (i32.reinterpret_f32 (f32.const +inf)))
(func (export "f32.negative_infinity") (result i32) (i32.reinterpret_f32 (f32.const -inf)))
;; f32 numbers
(func (export "f32.zero") (result i32) (i32.reinterpret_f32 (f32.const 0x0.0p0)))
(func (export "f32.positive_zero") (result i32) (i32.reinterpret_f32 (f32.const +0x0.0p0)))
(func (export "f32.negative_zero") (result i32) (i32.reinterpret_f32 (f32.const -0x0.0p0)))
(func (export "f32.misc") (result i32) (i32.reinterpret_f32 (f32.const 0x1.921fb6p+2)))
(func (export "f32.min_positive") (result i32) (i32.reinterpret_f32 (f32.const 0x1p-149)))
(func (export "f32.min_normal") (result i32) (i32.reinterpret_f32 (f32.const 0x1p-126)))
(func (export "f32.max_finite") (result i32) (i32.reinterpret_f32 (f32.const 0x1.fffffep+127)))
(func (export "f32.max_subnormal") (result i32) (i32.reinterpret_f32 (f32.const 0x1.fffffcp-127)))
(func (export "f32.trailing_dot") (result i32) (i32.reinterpret_f32 (f32.const 0x1.p10)))
(func (export "f32.misc_int") (result i32) (i32.reinterpret_f32 (f32.const 0x12345)))
(func (export "f32.large_int") (result i32) (i32.reinterpret_f32 (f32.const 0x1_0000_0000_0000_0000_0000)))
(func (export "f32.min_int32") (result i32) (i32.reinterpret_f32 (f32.const -0x8000_0000)))
(func (export "f32.min_int64") (result i32) (i32.reinterpret_f32 (f32.const -0x8000_0000_0000_0000)))
;; f32 in decimal format
(func (export "f32_dec.zero") (result i32) (i32.reinterpret_f32 (f32.const 0.0e0)))
(func (export "f32_dec.positive_zero") (result i32) (i32.reinterpret_f32 (f32.const +0.0e0)))
(func (export "f32_dec.negative_zero") (result i32) (i32.reinterpret_f32 (f32.const -0.0e0)))
(func (export "f32_dec.misc") (result i32) (i32.reinterpret_f32 (f32.const 6.28318548202514648)))
(func (export "f32_dec.min_positive") (result i32) (i32.reinterpret_f32 (f32.const 1.4013e-45)))
(func (export "f32_dec.min_normal") (result i32) (i32.reinterpret_f32 (f32.const 1.1754944e-38)))
(func (export "f32_dec.max_subnormal") (result i32) (i32.reinterpret_f32 (f32.const 1.1754942e-38)))
(func (export "f32_dec.max_finite") (result i32) (i32.reinterpret_f32 (f32.const 3.4028234e+38)))
(func (export "f32_dec.trailing_dot") (result i32) (i32.reinterpret_f32 (f32.const 1.e10)))
(func (export "f32_dec.misc_int") (result i32) (i32.reinterpret_f32 (f32.const 12345)))
(func (export "f32_dec.large_int") (result i32) (i32.reinterpret_f32 (f32.const 100_000_000_000_000_000_000)))
(func (export "f32_dec.min_int32") (result i32) (i32.reinterpret_f32 (f32.const -2147483648)))
(func (export "f32_dec.min_int64") (result i32) (i32.reinterpret_f32 (f32.const -9223372036854775808)))
;; https://twitter.com/Archivd/status/994637336506912768
(func (export "f32_dec.root_beer_float") (result i32) (i32.reinterpret_f32 (f32.const 1.000000119)))
;; f64 special values
(func (export "f64.nan") (result i64) (i64.reinterpret_f64 (f64.const nan)))
(func (export "f64.positive_nan") (result i64) (i64.reinterpret_f64 (f64.const +nan)))
(func (export "f64.negative_nan") (result i64) (i64.reinterpret_f64 (f64.const -nan)))
(func (export "f64.plain_nan") (result i64) (i64.reinterpret_f64 (f64.const nan:0x8000000000000)))
(func (export "f64.informally_known_as_plain_snan") (result i64) (i64.reinterpret_f64 (f64.const nan:0x4000000000000)))
(func (export "f64.all_ones_nan") (result i64) (i64.reinterpret_f64 (f64.const -nan:0xfffffffffffff)))
(func (export "f64.misc_nan") (result i64) (i64.reinterpret_f64 (f64.const nan:0x0123456789abc)))
(func (export "f64.misc_positive_nan") (result i64) (i64.reinterpret_f64 (f64.const +nan:0x3040506070809)))
(func (export "f64.misc_negative_nan") (result i64) (i64.reinterpret_f64 (f64.const -nan:0x2abcdef012345)))
(func (export "f64.infinity") (result i64) (i64.reinterpret_f64 (f64.const inf)))
(func (export "f64.positive_infinity") (result i64) (i64.reinterpret_f64 (f64.const +inf)))
(func (export "f64.negative_infinity") (result i64) (i64.reinterpret_f64 (f64.const -inf)))
;; f64 numbers
(func (export "f64.zero") (result i64) (i64.reinterpret_f64 (f64.const 0x0.0p0)))
(func (export "f64.positive_zero") (result i64) (i64.reinterpret_f64 (f64.const +0x0.0p0)))
(func (export "f64.negative_zero") (result i64) (i64.reinterpret_f64 (f64.const -0x0.0p0)))
(func (export "f64.misc") (result i64) (i64.reinterpret_f64 (f64.const 0x1.921fb54442d18p+2)))
(func (export "f64.min_positive") (result i64) (i64.reinterpret_f64 (f64.const 0x0.0000000000001p-1022)))
(func (export "f64.min_normal") (result i64) (i64.reinterpret_f64 (f64.const 0x1p-1022)))
(func (export "f64.max_subnormal") (result i64) (i64.reinterpret_f64 (f64.const 0x0.fffffffffffffp-1022)))
(func (export "f64.max_finite") (result i64) (i64.reinterpret_f64 (f64.const 0x1.fffffffffffffp+1023)))
(func (export "f64.trailing_dot") (result i64) (i64.reinterpret_f64 (f64.const 0x1.p100)))
(func (export "f64.misc_int") (result i64) (i64.reinterpret_f64 (f64.const 0x12345)))
(func (export "f64.large_int") (result i64) (i64.reinterpret_f64 (f64.const 0x1_0000_0000_0000_0000_0000)))
(func (export "f64.min_int32") (result i64) (i64.reinterpret_f64 (f64.const -0x8000_0000)))
(func (export "f64.min_int64") (result i64) (i64.reinterpret_f64 (f64.const -0x8000_0000_0000_0000)))
;; f64 numbers in decimal format
(func (export "f64_dec.zero") (result i64) (i64.reinterpret_f64 (f64.const 0.0e0)))
(func (export "f64_dec.positive_zero") (result i64) (i64.reinterpret_f64 (f64.const +0.0e0)))
(func (export "f64_dec.negative_zero") (result i64) (i64.reinterpret_f64 (f64.const -0.0e0)))
(func (export "f64_dec.misc") (result i64) (i64.reinterpret_f64 (f64.const 6.28318530717958623)))
(func (export "f64_dec.min_positive") (result i64) (i64.reinterpret_f64 (f64.const 4.94066e-324)))
(func (export "f64_dec.min_normal") (result i64) (i64.reinterpret_f64 (f64.const 2.2250738585072012e-308)))
(func (export "f64_dec.max_subnormal") (result i64) (i64.reinterpret_f64 (f64.const 2.2250738585072011e-308)))
(func (export "f64_dec.max_finite") (result i64) (i64.reinterpret_f64 (f64.const 1.7976931348623157e+308)))
(func (export "f64_dec.trailing_dot") (result i64) (i64.reinterpret_f64 (f64.const 1.e100)))
(func (export "f64_dec.misc_int") (result i64) (i64.reinterpret_f64 (f64.const 12345)))
(func (export "f64_dec.large_int") (result i64) (i64.reinterpret_f64 (f64.const 100_000_000_000_000_000_000)))
(func (export "f64_dec.min_int32") (result i64) (i64.reinterpret_f64 (f64.const -2147483648)))
(func (export "f64_dec.min_int64") (result i64) (i64.reinterpret_f64 (f64.const -9223372036854775808)))
;; https://twitter.com/Archivd/status/994637336506912768
(func (export "f64_dec.root_beer_float") (result i64) (i64.reinterpret_f64 (f64.const 1.000000119)))
(func (export "f32-dec-sep1") (result f32) (f32.const 1_000_000))
(func (export "f32-dec-sep2") (result f32) (f32.const 1_0_0_0))
(func (export "f32-dec-sep3") (result f32) (f32.const 100_3.141_592))
(func (export "f32-dec-sep4") (result f32) (f32.const 99e+1_3))
(func (export "f32-dec-sep5") (result f32) (f32.const 122_000.11_3_54E0_2_3))
(func (export "f32-hex-sep1") (result f32) (f32.const 0xa_0f_00_99))
(func (export "f32-hex-sep2") (result f32) (f32.const 0x1_a_A_0_f))
(func (export "f32-hex-sep3") (result f32) (f32.const 0xa0_ff.f141_a59a))
(func (export "f32-hex-sep4") (result f32) (f32.const 0xf0P+1_3))
(func (export "f32-hex-sep5") (result f32) (f32.const 0x2a_f00a.1f_3_eep2_3))
(func (export "f64-dec-sep1") (result f64) (f64.const 1_000_000))
(func (export "f64-dec-sep2") (result f64) (f64.const 1_0_0_0))
(func (export "f64-dec-sep3") (result f64) (f64.const 100_3.141_592))
(func (export "f64-dec-sep4") (result f64) (f64.const 99e-1_23))
(func (export "f64-dec-sep5") (result f64) (f64.const 122_000.11_3_54e0_2_3))
(func (export "f64-hex-sep1") (result f64) (f64.const 0xa_f00f_0000_9999))
(func (export "f64-hex-sep2") (result f64) (f64.const 0x1_a_A_0_f))
(func (export "f64-hex-sep3") (result f64) (f64.const 0xa0_ff.f141_a59a))
(func (export "f64-hex-sep4") (result f64) (f64.const 0xf0P+1_3))
(func (export "f64-hex-sep5") (result f64) (f64.const 0x2a_f00a.1f_3_eep2_3))
)`);
// ./test/core/float_literals.wast:121
assert_return(() => invoke($0, `f32.nan`, []), [value("i32", 2143289344)]);
// ./test/core/float_literals.wast:122
assert_return(() => invoke($0, `f32.positive_nan`, []), [value("i32", 2143289344)]);
// ./test/core/float_literals.wast:123
assert_return(() => invoke($0, `f32.negative_nan`, []), [value("i32", -4194304)]);
// ./test/core/float_literals.wast:124
assert_return(() => invoke($0, `f32.plain_nan`, []), [value("i32", 2143289344)]);
// ./test/core/float_literals.wast:125
assert_return(() => invoke($0, `f32.informally_known_as_plain_snan`, []), [value("i32", 2141192192)]);
// ./test/core/float_literals.wast:126
assert_return(() => invoke($0, `f32.all_ones_nan`, []), [value("i32", -1)]);
// ./test/core/float_literals.wast:127
assert_return(() => invoke($0, `f32.misc_nan`, []), [value("i32", 2139169605)]);
// ./test/core/float_literals.wast:128
assert_return(() => invoke($0, `f32.misc_positive_nan`, []), [value("i32", 2142257232)]);
// ./test/core/float_literals.wast:129
assert_return(() => invoke($0, `f32.misc_negative_nan`, []), [value("i32", -5587746)]);
// ./test/core/float_literals.wast:130
assert_return(() => invoke($0, `f32.infinity`, []), [value("i32", 2139095040)]);
// ./test/core/float_literals.wast:131
assert_return(() => invoke($0, `f32.positive_infinity`, []), [value("i32", 2139095040)]);
// ./test/core/float_literals.wast:132
assert_return(() => invoke($0, `f32.negative_infinity`, []), [value("i32", -8388608)]);
// ./test/core/float_literals.wast:133
assert_return(() => invoke($0, `f32.zero`, []), [value("i32", 0)]);
// ./test/core/float_literals.wast:134
assert_return(() => invoke($0, `f32.positive_zero`, []), [value("i32", 0)]);
// ./test/core/float_literals.wast:135
assert_return(() => invoke($0, `f32.negative_zero`, []), [value("i32", -2147483648)]);
// ./test/core/float_literals.wast:136
assert_return(() => invoke($0, `f32.misc`, []), [value("i32", 1086918619)]);
// ./test/core/float_literals.wast:137
assert_return(() => invoke($0, `f32.min_positive`, []), [value("i32", 1)]);
// ./test/core/float_literals.wast:138
assert_return(() => invoke($0, `f32.min_normal`, []), [value("i32", 8388608)]);
// ./test/core/float_literals.wast:139
assert_return(() => invoke($0, `f32.max_subnormal`, []), [value("i32", 8388607)]);
// ./test/core/float_literals.wast:140
assert_return(() => invoke($0, `f32.max_finite`, []), [value("i32", 2139095039)]);
// ./test/core/float_literals.wast:141
assert_return(() => invoke($0, `f32.trailing_dot`, []), [value("i32", 1149239296)]);
// ./test/core/float_literals.wast:142
assert_return(() => invoke($0, `f32.misc_int`, []), [value("i32", 1200726656)]);
// ./test/core/float_literals.wast:143
assert_return(() => invoke($0, `f32.large_int`, []), [value("i32", 1736441856)]);
// ./test/core/float_literals.wast:144
assert_return(() => invoke($0, `f32.min_int32`, []), [value("i32", -822083584)]);
// ./test/core/float_literals.wast:145
assert_return(() => invoke($0, `f32.min_int64`, []), [value("i32", -553648128)]);
// ./test/core/float_literals.wast:146
assert_return(() => invoke($0, `f32_dec.zero`, []), [value("i32", 0)]);
// ./test/core/float_literals.wast:147
assert_return(() => invoke($0, `f32_dec.positive_zero`, []), [value("i32", 0)]);
// ./test/core/float_literals.wast:148
assert_return(() => invoke($0, `f32_dec.negative_zero`, []), [value("i32", -2147483648)]);
// ./test/core/float_literals.wast:149
assert_return(() => invoke($0, `f32_dec.misc`, []), [value("i32", 1086918619)]);
// ./test/core/float_literals.wast:150
assert_return(() => invoke($0, `f32_dec.min_positive`, []), [value("i32", 1)]);
// ./test/core/float_literals.wast:151
assert_return(() => invoke($0, `f32_dec.min_normal`, []), [value("i32", 8388608)]);
// ./test/core/float_literals.wast:152
assert_return(() => invoke($0, `f32_dec.max_subnormal`, []), [value("i32", 8388607)]);
// ./test/core/float_literals.wast:153
assert_return(() => invoke($0, `f32_dec.max_finite`, []), [value("i32", 2139095039)]);
// ./test/core/float_literals.wast:154
assert_return(() => invoke($0, `f32_dec.trailing_dot`, []), [value("i32", 1343554297)]);
// ./test/core/float_literals.wast:155
assert_return(() => invoke($0, `f32_dec.root_beer_float`, []), [value("i32", 1065353217)]);
// ./test/core/float_literals.wast:156
assert_return(() => invoke($0, `f32_dec.misc_int`, []), [value("i32", 1178657792)]);
// ./test/core/float_literals.wast:157
assert_return(() => invoke($0, `f32_dec.large_int`, []), [value("i32", 1621981420)]);
// ./test/core/float_literals.wast:158
assert_return(() => invoke($0, `f32_dec.min_int32`, []), [value("i32", -822083584)]);
// ./test/core/float_literals.wast:159
assert_return(() => invoke($0, `f32_dec.min_int64`, []), [value("i32", -553648128)]);
// ./test/core/float_literals.wast:161
assert_return(() => invoke($0, `f64.nan`, []), [value("i64", 9221120237041090560n)]);
// ./test/core/float_literals.wast:162
assert_return(() => invoke($0, `f64.positive_nan`, []), [value("i64", 9221120237041090560n)]);
// ./test/core/float_literals.wast:163
assert_return(() => invoke($0, `f64.negative_nan`, []), [value("i64", -2251799813685248n)]);
// ./test/core/float_literals.wast:164
assert_return(() => invoke($0, `f64.plain_nan`, []), [value("i64", 9221120237041090560n)]);
// ./test/core/float_literals.wast:165
assert_return(
() => invoke($0, `f64.informally_known_as_plain_snan`, []),
[value("i64", 9219994337134247936n)],
);
// ./test/core/float_literals.wast:166
assert_return(() => invoke($0, `f64.all_ones_nan`, []), [value("i64", -1n)]);
// ./test/core/float_literals.wast:167
assert_return(() => invoke($0, `f64.misc_nan`, []), [value("i64", 9218888453225749180n)]);
// ./test/core/float_literals.wast:168
assert_return(() => invoke($0, `f64.misc_positive_nan`, []), [value("i64", 9219717281780008969n)]);
// ./test/core/float_literals.wast:169
assert_return(() => invoke($0, `f64.misc_negative_nan`, []), [value("i64", -3751748707474619n)]);
// ./test/core/float_literals.wast:170
assert_return(() => invoke($0, `f64.infinity`, []), [value("i64", 9218868437227405312n)]);
// ./test/core/float_literals.wast:171
assert_return(() => invoke($0, `f64.positive_infinity`, []), [value("i64", 9218868437227405312n)]);
// ./test/core/float_literals.wast:172
assert_return(() => invoke($0, `f64.negative_infinity`, []), [value("i64", -4503599627370496n)]);
// ./test/core/float_literals.wast:173
assert_return(() => invoke($0, `f64.zero`, []), [value("i64", 0n)]);
// ./test/core/float_literals.wast:174
assert_return(() => invoke($0, `f64.positive_zero`, []), [value("i64", 0n)]);
// ./test/core/float_literals.wast:175
assert_return(() => invoke($0, `f64.negative_zero`, []), [value("i64", -9223372036854775808n)]);
// ./test/core/float_literals.wast:176
assert_return(() => invoke($0, `f64.misc`, []), [value("i64", 4618760256179416344n)]);
// ./test/core/float_literals.wast:177
assert_return(() => invoke($0, `f64.min_positive`, []), [value("i64", 1n)]);
// ./test/core/float_literals.wast:178
assert_return(() => invoke($0, `f64.min_normal`, []), [value("i64", 4503599627370496n)]);
// ./test/core/float_literals.wast:179
assert_return(() => invoke($0, `f64.max_subnormal`, []), [value("i64", 4503599627370495n)]);
// ./test/core/float_literals.wast:180
assert_return(() => invoke($0, `f64.max_finite`, []), [value("i64", 9218868437227405311n)]);
// ./test/core/float_literals.wast:181
assert_return(() => invoke($0, `f64.trailing_dot`, []), [value("i64", 5057542381537067008n)]);
// ./test/core/float_literals.wast:182
assert_return(() => invoke($0, `f64.misc_int`, []), [value("i64", 4679860480993394688n)]);
// ./test/core/float_literals.wast:183
assert_return(() => invoke($0, `f64.large_int`, []), [value("i64", 4967470388989657088n)]);
// ./test/core/float_literals.wast:184
assert_return(() => invoke($0, `f64.min_int32`, []), [value("i64", -4476578029606273024n)]);
// ./test/core/float_literals.wast:185
assert_return(() => invoke($0, `f64.min_int64`, []), [value("i64", -4332462841530417152n)]);
// ./test/core/float_literals.wast:186
assert_return(() => invoke($0, `f64_dec.zero`, []), [value("i64", 0n)]);
// ./test/core/float_literals.wast:187
assert_return(() => invoke($0, `f64_dec.positive_zero`, []), [value("i64", 0n)]);
// ./test/core/float_literals.wast:188
assert_return(() => invoke($0, `f64_dec.negative_zero`, []), [value("i64", -9223372036854775808n)]);
// ./test/core/float_literals.wast:189
assert_return(() => invoke($0, `f64_dec.misc`, []), [value("i64", 4618760256179416344n)]);
// ./test/core/float_literals.wast:190
assert_return(() => invoke($0, `f64_dec.min_positive`, []), [value("i64", 1n)]);
// ./test/core/float_literals.wast:191
assert_return(() => invoke($0, `f64_dec.min_normal`, []), [value("i64", 4503599627370496n)]);
// ./test/core/float_literals.wast:192
assert_return(() => invoke($0, `f64_dec.max_subnormal`, []), [value("i64", 4503599627370495n)]);
// ./test/core/float_literals.wast:193
assert_return(() => invoke($0, `f64_dec.max_finite`, []), [value("i64", 9218868437227405311n)]);
// ./test/core/float_literals.wast:194
assert_return(() => invoke($0, `f64_dec.trailing_dot`, []), [value("i64", 6103021453049119613n)]);
// ./test/core/float_literals.wast:195
assert_return(() => invoke($0, `f64_dec.root_beer_float`, []), [value("i64", 4607182419335945764n)]);
// ./test/core/float_literals.wast:196
assert_return(() => invoke($0, `f64_dec.misc_int`, []), [value("i64", 4668012349850910720n)]);
// ./test/core/float_literals.wast:197
assert_return(() => invoke($0, `f64_dec.large_int`, []), [value("i64", 4906019910204099648n)]);
// ./test/core/float_literals.wast:198
assert_return(() => invoke($0, `f64_dec.min_int32`, []), [value("i64", -4476578029606273024n)]);
// ./test/core/float_literals.wast:199
assert_return(() => invoke($0, `f64_dec.min_int64`, []), [value("i64", -4332462841530417152n)]);
// ./test/core/float_literals.wast:201
assert_return(() => invoke($0, `f32-dec-sep1`, []), [value("f32", 1000000)]);
// ./test/core/float_literals.wast:202
assert_return(() => invoke($0, `f32-dec-sep2`, []), [value("f32", 1000)]);
// ./test/core/float_literals.wast:203
assert_return(() => invoke($0, `f32-dec-sep3`, []), [value("f32", 1003.1416)]);
// ./test/core/float_literals.wast:204
assert_return(() => invoke($0, `f32-dec-sep4`, []), [value("f32", 990000000000000)]);
// ./test/core/float_literals.wast:205
assert_return(() => invoke($0, `f32-dec-sep5`, []), [value("f32", 12200012000000000000000000000)]);
// ./test/core/float_literals.wast:206
assert_return(() => invoke($0, `f32-hex-sep1`, []), [value("f32", 168755360)]);
// ./test/core/float_literals.wast:207
assert_return(() => invoke($0, `f32-hex-sep2`, []), [value("f32", 109071)]);
// ./test/core/float_literals.wast:208
assert_return(() => invoke($0, `f32-hex-sep3`, []), [value("f32", 41215.94)]);
// ./test/core/float_literals.wast:209
assert_return(() => invoke($0, `f32-hex-sep4`, []), [value("f32", 1966080)]);
// ./test/core/float_literals.wast:210
assert_return(() => invoke($0, `f32-hex-sep5`, []), [value("f32", 23605224000000)]);
// ./test/core/float_literals.wast:212
assert_return(() => invoke($0, `f64-dec-sep1`, []), [value("f64", 1000000)]);
// ./test/core/float_literals.wast:213
assert_return(() => invoke($0, `f64-dec-sep2`, []), [value("f64", 1000)]);
// ./test/core/float_literals.wast:214
assert_return(() => invoke($0, `f64-dec-sep3`, []), [value("f64", 1003.141592)]);
// ./test/core/float_literals.wast:215
assert_return(
() => invoke($0, `f64-dec-sep4`, []),
[
value("f64", 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099),
],
);
// ./test/core/float_literals.wast:216
assert_return(() => invoke($0, `f64-dec-sep5`, []), [value("f64", 12200011354000000000000000000)]);
// ./test/core/float_literals.wast:217
assert_return(() => invoke($0, `f64-hex-sep1`, []), [value("f64", 3078696982321561)]);
// ./test/core/float_literals.wast:218
assert_return(() => invoke($0, `f64-hex-sep2`, []), [value("f64", 109071)]);
// ./test/core/float_literals.wast:219
assert_return(() => invoke($0, `f64-hex-sep3`, []), [value("f64", 41215.94240794191)]);
// ./test/core/float_literals.wast:220
assert_return(() => invoke($0, `f64-hex-sep4`, []), [value("f64", 1966080)]);
// ./test/core/float_literals.wast:221
assert_return(() => invoke($0, `f64-hex-sep5`, []), [value("f64", 23605225168752)]);
// ./test/core/float_literals.wast:224
let $1 = instantiate(`(module binary
;; (func (export "4294967249") (result f64) (f64.const 4294967249))
"\\00\\61\\73\\6d\\01\\00\\00\\00\\01\\85\\80\\80\\80\\00\\01\\60"
"\\00\\01\\7c\\03\\82\\80\\80\\80\\00\\01\\00\\07\\8e\\80\\80\\80"
"\\00\\01\\0a\\34\\32\\39\\34\\39\\36\\37\\32\\34\\39\\00\\00\\0a"
"\\91\\80\\80\\80\\00\\01\\8b\\80\\80\\80\\00\\00\\44\\00\\00\\20"
"\\fa\\ff\\ff\\ef\\41\\0b"
)`);
// ./test/core/float_literals.wast:233
assert_return(() => invoke($1, `4294967249`, []), [value("f64", 4294967249)]);
// ./test/core/float_literals.wast:235
assert_malformed(() => instantiate(`(global f32 (f32.const _100)) `), `unknown operator`);
// ./test/core/float_literals.wast:239
assert_malformed(() => instantiate(`(global f32 (f32.const +_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:243
assert_malformed(() => instantiate(`(global f32 (f32.const -_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:247
assert_malformed(() => instantiate(`(global f32 (f32.const 99_)) `), `unknown operator`);
// ./test/core/float_literals.wast:251
assert_malformed(
() => instantiate(`(global f32 (f32.const 1__000)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:255
assert_malformed(() => instantiate(`(global f32 (f32.const _1.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:259
assert_malformed(() => instantiate(`(global f32 (f32.const 1.0_)) `), `unknown operator`);
// ./test/core/float_literals.wast:263
assert_malformed(() => instantiate(`(global f32 (f32.const 1_.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:267
assert_malformed(() => instantiate(`(global f32 (f32.const 1._0)) `), `unknown operator`);
// ./test/core/float_literals.wast:271
assert_malformed(() => instantiate(`(global f32 (f32.const _1e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:275
assert_malformed(() => instantiate(`(global f32 (f32.const 1e1_)) `), `unknown operator`);
// ./test/core/float_literals.wast:279
assert_malformed(() => instantiate(`(global f32 (f32.const 1_e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:283
assert_malformed(() => instantiate(`(global f32 (f32.const 1e_1)) `), `unknown operator`);
// ./test/core/float_literals.wast:287
assert_malformed(
() => instantiate(`(global f32 (f32.const _1.0e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:291
assert_malformed(
() => instantiate(`(global f32 (f32.const 1.0e1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:295
assert_malformed(
() => instantiate(`(global f32 (f32.const 1.0_e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:299
assert_malformed(
() => instantiate(`(global f32 (f32.const 1.0e_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:303
assert_malformed(
() => instantiate(`(global f32 (f32.const 1.0e+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:307
assert_malformed(
() => instantiate(`(global f32 (f32.const 1.0e_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:311
assert_malformed(
() => instantiate(`(global f32 (f32.const _0x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:315
assert_malformed(
() => instantiate(`(global f32 (f32.const 0_x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:319
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x_100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:323
assert_malformed(() => instantiate(`(global f32 (f32.const 0x00_)) `), `unknown operator`);
// ./test/core/float_literals.wast:327
assert_malformed(
() => instantiate(`(global f32 (f32.const 0xff__ffff)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:331
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x_1.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:335
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:339
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1_.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:343
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1._0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:347
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x_1p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:351
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:355
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:359
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:363
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x_1.0p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:367
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:371
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:375
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:379
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0p+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:383
assert_malformed(
() => instantiate(`(global f32 (f32.const 0x1.0p_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:387
assert_malformed(
() => instantiate(`(global f32 (f32.const nan:0x80_0000)) `),
`constant out of range`,
);
// ./test/core/float_literals.wast:392
assert_malformed(() => instantiate(`(global f64 (f64.const _100)) `), `unknown operator`);
// ./test/core/float_literals.wast:396
assert_malformed(() => instantiate(`(global f64 (f64.const +_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:400
assert_malformed(() => instantiate(`(global f64 (f64.const -_100)) `), `unknown operator`);
// ./test/core/float_literals.wast:404
assert_malformed(() => instantiate(`(global f64 (f64.const 99_)) `), `unknown operator`);
// ./test/core/float_literals.wast:408
assert_malformed(
() => instantiate(`(global f64 (f64.const 1__000)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:412
assert_malformed(() => instantiate(`(global f64 (f64.const _1.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:416
assert_malformed(() => instantiate(`(global f64 (f64.const 1.0_)) `), `unknown operator`);
// ./test/core/float_literals.wast:420
assert_malformed(() => instantiate(`(global f64 (f64.const 1_.0)) `), `unknown operator`);
// ./test/core/float_literals.wast:424
assert_malformed(() => instantiate(`(global f64 (f64.const 1._0)) `), `unknown operator`);
// ./test/core/float_literals.wast:428
assert_malformed(() => instantiate(`(global f64 (f64.const _1e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:432
assert_malformed(() => instantiate(`(global f64 (f64.const 1e1_)) `), `unknown operator`);
// ./test/core/float_literals.wast:436
assert_malformed(() => instantiate(`(global f64 (f64.const 1_e1)) `), `unknown operator`);
// ./test/core/float_literals.wast:440
assert_malformed(() => instantiate(`(global f64 (f64.const 1e_1)) `), `unknown operator`);
// ./test/core/float_literals.wast:444
assert_malformed(
() => instantiate(`(global f64 (f64.const _1.0e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:448
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:452
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0_e1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:456
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:460
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:464
assert_malformed(
() => instantiate(`(global f64 (f64.const 1.0e_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:468
assert_malformed(
() => instantiate(`(global f64 (f64.const _0x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:472
assert_malformed(
() => instantiate(`(global f64 (f64.const 0_x100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:476
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_100)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:480
assert_malformed(() => instantiate(`(global f64 (f64.const 0x00_)) `), `unknown operator`);
// ./test/core/float_literals.wast:484
assert_malformed(
() => instantiate(`(global f64 (f64.const 0xff__ffff)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:488
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:492
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:496
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1_.0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:500
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1._0)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:504
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:508
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:512
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:516
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:520
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x_1.0p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:524
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p1_)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:528
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0_p1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:532
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:536
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p+_1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:540
assert_malformed(
() => instantiate(`(global f64 (f64.const 0x1.0p_+1)) `),
`unknown operator`,
);
// ./test/core/float_literals.wast:544
assert_malformed(
() => instantiate(`(global f64 (f64.const nan:0x10_0000_0000_0000)) `),
`constant out of range`,
);

View File

@@ -202,16 +202,10 @@ let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
function module(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
return module;
}
function instantiate(source) {
@@ -221,18 +215,23 @@ function instantiate(source) {
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
function instantiateFromModule(module) {
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
function register(instance, name) {
linkage[name] = instance;
}
function invoke(instance, field, params) {
let func = instance[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
function get(instance, field) {
let global = instance[field];
assertEq(
global instanceof WebAssembly.Global,
true,

File diff suppressed because it is too large Load Diff

View File

@@ -33,123 +33,112 @@ let $4 = instantiate(`(module (memory 1 256))`);
// ./test/core/memory.wast:8
let $5 = instantiate(`(module (memory 0 65536))`);
if (!wasmMultiMemoryEnabled()) {
// ./test/core/memory.wast:10
assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`);
// ./test/core/memory.wast:11
assert_invalid(
() => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`),
`multiple memories`,
);
}
// ./test/core/memory.wast:13
// ./test/core/memory.wast:10
let $6 = instantiate(`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:14
// ./test/core/memory.wast:11
assert_return(() => invoke($6, `memsize`, []), [value("i32", 0)]);
// ./test/core/memory.wast:15
// ./test/core/memory.wast:12
let $7 = instantiate(`(module (memory (data "")) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:16
// ./test/core/memory.wast:13
assert_return(() => invoke($7, `memsize`, []), [value("i32", 0)]);
// ./test/core/memory.wast:17
// ./test/core/memory.wast:14
let $8 = instantiate(`(module (memory (data "x")) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:18
// ./test/core/memory.wast:15
assert_return(() => invoke($8, `memsize`, []), [value("i32", 1)]);
// ./test/core/memory.wast:20
// ./test/core/memory.wast:17
assert_invalid(() => instantiate(`(module (data (i32.const 0)))`), `unknown memory`);
// ./test/core/memory.wast:21
// ./test/core/memory.wast:18
assert_invalid(() => instantiate(`(module (data (i32.const 0) ""))`), `unknown memory`);
// ./test/core/memory.wast:22
// ./test/core/memory.wast:19
assert_invalid(() => instantiate(`(module (data (i32.const 0) "x"))`), `unknown memory`);
// ./test/core/memory.wast:24
// ./test/core/memory.wast:21
assert_invalid(
() => instantiate(`(module (func (drop (f32.load (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:28
// ./test/core/memory.wast:25
assert_invalid(
() => instantiate(`(module (func (f32.store (i32.const 0) (f32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory.wast:32
// ./test/core/memory.wast:29
assert_invalid(
() => instantiate(`(module (func (drop (i32.load8_s (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:36
// ./test/core/memory.wast:33
assert_invalid(
() => instantiate(`(module (func (i32.store8 (i32.const 0) (i32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory.wast:40
// ./test/core/memory.wast:37
assert_invalid(
() => instantiate(`(module (func (drop (memory.size))))`),
`unknown memory`,
);
// ./test/core/memory.wast:44
// ./test/core/memory.wast:41
assert_invalid(
() => instantiate(`(module (func (drop (memory.grow (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:50
// ./test/core/memory.wast:47
assert_invalid(
() => instantiate(`(module (memory 1 0))`),
`size minimum must not be greater than maximum`,
);
// ./test/core/memory.wast:54
// ./test/core/memory.wast:51
assert_invalid(
() => instantiate(`(module (memory 65537))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:58
// ./test/core/memory.wast:55
assert_invalid(
() => instantiate(`(module (memory 2147483648))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:62
// ./test/core/memory.wast:59
assert_invalid(
() => instantiate(`(module (memory 4294967295))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:66
// ./test/core/memory.wast:63
assert_invalid(
() => instantiate(`(module (memory 0 65537))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:70
// ./test/core/memory.wast:67
assert_invalid(
() => instantiate(`(module (memory 0 2147483648))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:74
// ./test/core/memory.wast:71
assert_invalid(
() => instantiate(`(module (memory 0 4294967295))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:92
// ./test/core/memory.wast:89
let $9 = instantiate(`(module
(memory 1)
(data (i32.const 0) "ABC\\a7D") (data (i32.const 20) "WASM")
@@ -238,146 +227,184 @@ let $9 = instantiate(`(module
)
)`);
// ./test/core/memory.wast:180
// ./test/core/memory.wast:177
assert_return(() => invoke($9, `data`, []), [value("i32", 1)]);
// ./test/core/memory.wast:181
// ./test/core/memory.wast:178
assert_return(() => invoke($9, `cast`, []), [value("f64", 42)]);
// ./test/core/memory.wast:183
// ./test/core/memory.wast:180
assert_return(() => invoke($9, `i32_load8_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory.wast:184
// ./test/core/memory.wast:181
assert_return(() => invoke($9, `i32_load8_u`, [-1]), [value("i32", 255)]);
// ./test/core/memory.wast:185
// ./test/core/memory.wast:182
assert_return(() => invoke($9, `i32_load16_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory.wast:186
// ./test/core/memory.wast:183
assert_return(() => invoke($9, `i32_load16_u`, [-1]), [value("i32", 65535)]);
// ./test/core/memory.wast:188
// ./test/core/memory.wast:185
assert_return(() => invoke($9, `i32_load8_s`, [100]), [value("i32", 100)]);
// ./test/core/memory.wast:189
// ./test/core/memory.wast:186
assert_return(() => invoke($9, `i32_load8_u`, [200]), [value("i32", 200)]);
// ./test/core/memory.wast:190
// ./test/core/memory.wast:187
assert_return(() => invoke($9, `i32_load16_s`, [20000]), [value("i32", 20000)]);
// ./test/core/memory.wast:191
// ./test/core/memory.wast:188
assert_return(() => invoke($9, `i32_load16_u`, [40000]), [value("i32", 40000)]);
// ./test/core/memory.wast:193
// ./test/core/memory.wast:190
assert_return(() => invoke($9, `i32_load8_s`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory.wast:194
// ./test/core/memory.wast:191
assert_return(() => invoke($9, `i32_load8_s`, [878104047]), [value("i32", -17)]);
// ./test/core/memory.wast:195
// ./test/core/memory.wast:192
assert_return(() => invoke($9, `i32_load8_u`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory.wast:196
// ./test/core/memory.wast:193
assert_return(() => invoke($9, `i32_load8_u`, [878104047]), [value("i32", 239)]);
// ./test/core/memory.wast:197
// ./test/core/memory.wast:194
assert_return(() => invoke($9, `i32_load16_s`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory.wast:198
// ./test/core/memory.wast:195
assert_return(() => invoke($9, `i32_load16_s`, [878104047]), [value("i32", -12817)]);
// ./test/core/memory.wast:199
// ./test/core/memory.wast:196
assert_return(() => invoke($9, `i32_load16_u`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory.wast:200
// ./test/core/memory.wast:197
assert_return(() => invoke($9, `i32_load16_u`, [878104047]), [value("i32", 52719)]);
// ./test/core/memory.wast:202
// ./test/core/memory.wast:199
assert_return(() => invoke($9, `i64_load8_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:203
// ./test/core/memory.wast:200
assert_return(() => invoke($9, `i64_load8_u`, [-1n]), [value("i64", 255n)]);
// ./test/core/memory.wast:204
// ./test/core/memory.wast:201
assert_return(() => invoke($9, `i64_load16_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:205
// ./test/core/memory.wast:202
assert_return(() => invoke($9, `i64_load16_u`, [-1n]), [value("i64", 65535n)]);
// ./test/core/memory.wast:206
// ./test/core/memory.wast:203
assert_return(() => invoke($9, `i64_load32_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:207
// ./test/core/memory.wast:204
assert_return(() => invoke($9, `i64_load32_u`, [-1n]), [value("i64", 4294967295n)]);
// ./test/core/memory.wast:209
// ./test/core/memory.wast:206
assert_return(() => invoke($9, `i64_load8_s`, [100n]), [value("i64", 100n)]);
// ./test/core/memory.wast:210
// ./test/core/memory.wast:207
assert_return(() => invoke($9, `i64_load8_u`, [200n]), [value("i64", 200n)]);
// ./test/core/memory.wast:211
// ./test/core/memory.wast:208
assert_return(() => invoke($9, `i64_load16_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory.wast:212
// ./test/core/memory.wast:209
assert_return(() => invoke($9, `i64_load16_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory.wast:213
// ./test/core/memory.wast:210
assert_return(() => invoke($9, `i64_load32_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory.wast:214
// ./test/core/memory.wast:211
assert_return(() => invoke($9, `i64_load32_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory.wast:216
// ./test/core/memory.wast:213
assert_return(() => invoke($9, `i64_load8_s`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory.wast:217
// ./test/core/memory.wast:214
assert_return(() => invoke($9, `i64_load8_s`, [3771275841602506223n]), [value("i64", -17n)]);
// ./test/core/memory.wast:218
// ./test/core/memory.wast:215
assert_return(() => invoke($9, `i64_load8_u`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory.wast:219
// ./test/core/memory.wast:216
assert_return(() => invoke($9, `i64_load8_u`, [3771275841602506223n]), [value("i64", 239n)]);
// ./test/core/memory.wast:220
// ./test/core/memory.wast:217
assert_return(() => invoke($9, `i64_load16_s`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory.wast:221
// ./test/core/memory.wast:218
assert_return(() => invoke($9, `i64_load16_s`, [3771275841602506223n]), [value("i64", -12817n)]);
// ./test/core/memory.wast:222
// ./test/core/memory.wast:219
assert_return(() => invoke($9, `i64_load16_u`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory.wast:223
// ./test/core/memory.wast:220
assert_return(() => invoke($9, `i64_load16_u`, [3771275841602506223n]), [value("i64", 52719n)]);
// ./test/core/memory.wast:224
// ./test/core/memory.wast:221
assert_return(() => invoke($9, `i64_load32_s`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory.wast:225
// ./test/core/memory.wast:222
assert_return(() => invoke($9, `i64_load32_s`, [3771275841602506223n]), [value("i64", -1732588049n)]);
// ./test/core/memory.wast:226
// ./test/core/memory.wast:223
assert_return(() => invoke($9, `i64_load32_u`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory.wast:227
// ./test/core/memory.wast:224
assert_return(() => invoke($9, `i64_load32_u`, [3771275841602506223n]), [value("i64", 2562379247n)]);
// ./test/core/memory.wast:231
// ./test/core/memory.wast:228
assert_malformed(
() => instantiate(`(memory $$foo 1) (memory $$foo 1) `),
`duplicate memory`,
);
// ./test/core/memory.wast:235
// ./test/core/memory.wast:232
assert_malformed(
() => instantiate(`(import "" "" (memory $$foo 1)) (memory $$foo 1) `),
`duplicate memory`,
);
// ./test/core/memory.wast:239
// ./test/core/memory.wast:236
assert_malformed(
() => instantiate(`(import "" "" (memory $$foo 1)) (import "" "" (memory $$foo 1)) `),
`duplicate memory`,
);
// ./test/core/memory.wast:243
let $10 = instantiate(`(module
(memory (export "memory") 1 1)
;; These should not change the behavior of memory accesses.
(global (export "__data_end") i32 (i32.const 10000))
(global (export "__stack_top") i32 (i32.const 10000))
(global (export "__heap_base") i32 (i32.const 10000))
(func (export "load") (param i32) (result i32)
(i32.load8_u (local.get 0))
)
)`);
// ./test/core/memory.wast:257
assert_return(() => invoke($10, `load`, [0]), [value("i32", 0)]);
// ./test/core/memory.wast:258
assert_return(() => invoke($10, `load`, [10000]), [value("i32", 0)]);
// ./test/core/memory.wast:259
assert_return(() => invoke($10, `load`, [20000]), [value("i32", 0)]);
// ./test/core/memory.wast:260
assert_return(() => invoke($10, `load`, [30000]), [value("i32", 0)]);
// ./test/core/memory.wast:261
assert_return(() => invoke($10, `load`, [40000]), [value("i32", 0)]);
// ./test/core/memory.wast:262
assert_return(() => invoke($10, `load`, [50000]), [value("i32", 0)]);
// ./test/core/memory.wast:263
assert_return(() => invoke($10, `load`, [60000]), [value("i32", 0)]);
// ./test/core/memory.wast:264
assert_return(() => invoke($10, `load`, [65535]), [value("i32", 0)]);

View File

@@ -27,90 +27,76 @@ let $2 = instantiate(`(module (memory i64 1 256))`);
// ./test/core/memory64.wast:7
let $3 = instantiate(`(module (memory i64 0 65536))`);
if (!wasmMultiMemoryEnabled()) {
// ./test/core/memory64.wast:9
assert_invalid(
() => instantiate(`(module (memory i64 0) (memory i64 0))`),
`multiple memories`,
);
// ./test/core/memory64.wast:10
assert_invalid(
() => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`),
`multiple memories`,
);
}
// ./test/core/memory64.wast:12
// ./test/core/memory64.wast:9
let $4 = instantiate(`(module (memory i64 (data)) (func (export "memsize") (result i64) (memory.size)))`);
// ./test/core/memory64.wast:13
// ./test/core/memory64.wast:10
assert_return(() => invoke($4, `memsize`, []), [value("i64", 0n)]);
// ./test/core/memory64.wast:14
// ./test/core/memory64.wast:11
let $5 = instantiate(`(module (memory i64 (data "")) (func (export "memsize") (result i64) (memory.size)))`);
// ./test/core/memory64.wast:15
// ./test/core/memory64.wast:12
assert_return(() => invoke($5, `memsize`, []), [value("i64", 0n)]);
// ./test/core/memory64.wast:16
// ./test/core/memory64.wast:13
let $6 = instantiate(`(module (memory i64 (data "x")) (func (export "memsize") (result i64) (memory.size)))`);
// ./test/core/memory64.wast:17
// ./test/core/memory64.wast:14
assert_return(() => invoke($6, `memsize`, []), [value("i64", 1n)]);
// ./test/core/memory64.wast:19
// ./test/core/memory64.wast:16
assert_invalid(() => instantiate(`(module (data (i64.const 0)))`), `unknown memory`);
// ./test/core/memory64.wast:20
// ./test/core/memory64.wast:17
assert_invalid(() => instantiate(`(module (data (i64.const 0) ""))`), `unknown memory`);
// ./test/core/memory64.wast:21
// ./test/core/memory64.wast:18
assert_invalid(() => instantiate(`(module (data (i64.const 0) "x"))`), `unknown memory`);
// ./test/core/memory64.wast:23
// ./test/core/memory64.wast:20
assert_invalid(
() => instantiate(`(module (func (drop (f32.load (i64.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:27
// ./test/core/memory64.wast:24
assert_invalid(
() => instantiate(`(module (func (f32.store (i64.const 0) (f32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:31
// ./test/core/memory64.wast:28
assert_invalid(
() => instantiate(`(module (func (drop (i32.load8_s (i64.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:35
// ./test/core/memory64.wast:32
assert_invalid(
() => instantiate(`(module (func (i32.store8 (i64.const 0) (i32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:39
// ./test/core/memory64.wast:36
assert_invalid(
() => instantiate(`(module (func (drop (memory.size))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:43
// ./test/core/memory64.wast:40
assert_invalid(
() => instantiate(`(module (func (drop (memory.grow (i64.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory64.wast:49
// ./test/core/memory64.wast:46
assert_invalid(
() => instantiate(`(module (memory i64 1 0))`),
`size minimum must not be greater than maximum`,
);
// ./test/core/memory64.wast:54
// ./test/core/memory64.wast:51
let $7 = instantiate(`(module
(memory i64 1)
(data (i64.const 0) "ABC\\a7D") (data (i64.const 20) "WASM")
@@ -199,128 +185,128 @@ let $7 = instantiate(`(module
)
)`);
// ./test/core/memory64.wast:142
// ./test/core/memory64.wast:139
assert_return(() => invoke($7, `data`, []), [value("i32", 1)]);
// ./test/core/memory64.wast:143
// ./test/core/memory64.wast:140
assert_return(() => invoke($7, `cast`, []), [value("f64", 42)]);
// ./test/core/memory64.wast:145
// ./test/core/memory64.wast:142
assert_return(() => invoke($7, `i32_load8_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory64.wast:146
// ./test/core/memory64.wast:143
assert_return(() => invoke($7, `i32_load8_u`, [-1]), [value("i32", 255)]);
// ./test/core/memory64.wast:147
// ./test/core/memory64.wast:144
assert_return(() => invoke($7, `i32_load16_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory64.wast:148
// ./test/core/memory64.wast:145
assert_return(() => invoke($7, `i32_load16_u`, [-1]), [value("i32", 65535)]);
// ./test/core/memory64.wast:150
// ./test/core/memory64.wast:147
assert_return(() => invoke($7, `i32_load8_s`, [100]), [value("i32", 100)]);
// ./test/core/memory64.wast:151
// ./test/core/memory64.wast:148
assert_return(() => invoke($7, `i32_load8_u`, [200]), [value("i32", 200)]);
// ./test/core/memory64.wast:152
// ./test/core/memory64.wast:149
assert_return(() => invoke($7, `i32_load16_s`, [20000]), [value("i32", 20000)]);
// ./test/core/memory64.wast:153
// ./test/core/memory64.wast:150
assert_return(() => invoke($7, `i32_load16_u`, [40000]), [value("i32", 40000)]);
// ./test/core/memory64.wast:155
// ./test/core/memory64.wast:152
assert_return(() => invoke($7, `i32_load8_s`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory64.wast:156
// ./test/core/memory64.wast:153
assert_return(() => invoke($7, `i32_load8_s`, [878104047]), [value("i32", -17)]);
// ./test/core/memory64.wast:157
// ./test/core/memory64.wast:154
assert_return(() => invoke($7, `i32_load8_u`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory64.wast:158
// ./test/core/memory64.wast:155
assert_return(() => invoke($7, `i32_load8_u`, [878104047]), [value("i32", 239)]);
// ./test/core/memory64.wast:159
// ./test/core/memory64.wast:156
assert_return(() => invoke($7, `i32_load16_s`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory64.wast:160
// ./test/core/memory64.wast:157
assert_return(() => invoke($7, `i32_load16_s`, [878104047]), [value("i32", -12817)]);
// ./test/core/memory64.wast:161
// ./test/core/memory64.wast:158
assert_return(() => invoke($7, `i32_load16_u`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory64.wast:162
// ./test/core/memory64.wast:159
assert_return(() => invoke($7, `i32_load16_u`, [878104047]), [value("i32", 52719)]);
// ./test/core/memory64.wast:164
// ./test/core/memory64.wast:161
assert_return(() => invoke($7, `i64_load8_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory64.wast:165
// ./test/core/memory64.wast:162
assert_return(() => invoke($7, `i64_load8_u`, [-1n]), [value("i64", 255n)]);
// ./test/core/memory64.wast:166
// ./test/core/memory64.wast:163
assert_return(() => invoke($7, `i64_load16_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory64.wast:167
// ./test/core/memory64.wast:164
assert_return(() => invoke($7, `i64_load16_u`, [-1n]), [value("i64", 65535n)]);
// ./test/core/memory64.wast:168
// ./test/core/memory64.wast:165
assert_return(() => invoke($7, `i64_load32_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory64.wast:169
// ./test/core/memory64.wast:166
assert_return(() => invoke($7, `i64_load32_u`, [-1n]), [value("i64", 4294967295n)]);
// ./test/core/memory64.wast:171
// ./test/core/memory64.wast:168
assert_return(() => invoke($7, `i64_load8_s`, [100n]), [value("i64", 100n)]);
// ./test/core/memory64.wast:172
// ./test/core/memory64.wast:169
assert_return(() => invoke($7, `i64_load8_u`, [200n]), [value("i64", 200n)]);
// ./test/core/memory64.wast:173
// ./test/core/memory64.wast:170
assert_return(() => invoke($7, `i64_load16_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory64.wast:174
// ./test/core/memory64.wast:171
assert_return(() => invoke($7, `i64_load16_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory64.wast:175
// ./test/core/memory64.wast:172
assert_return(() => invoke($7, `i64_load32_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory64.wast:176
// ./test/core/memory64.wast:173
assert_return(() => invoke($7, `i64_load32_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory64.wast:178
// ./test/core/memory64.wast:175
assert_return(() => invoke($7, `i64_load8_s`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory64.wast:179
// ./test/core/memory64.wast:176
assert_return(() => invoke($7, `i64_load8_s`, [3771275841602506223n]), [value("i64", -17n)]);
// ./test/core/memory64.wast:180
// ./test/core/memory64.wast:177
assert_return(() => invoke($7, `i64_load8_u`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory64.wast:181
// ./test/core/memory64.wast:178
assert_return(() => invoke($7, `i64_load8_u`, [3771275841602506223n]), [value("i64", 239n)]);
// ./test/core/memory64.wast:182
// ./test/core/memory64.wast:179
assert_return(() => invoke($7, `i64_load16_s`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory64.wast:183
// ./test/core/memory64.wast:180
assert_return(() => invoke($7, `i64_load16_s`, [3771275841602506223n]), [value("i64", -12817n)]);
// ./test/core/memory64.wast:184
// ./test/core/memory64.wast:181
assert_return(() => invoke($7, `i64_load16_u`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory64.wast:185
// ./test/core/memory64.wast:182
assert_return(() => invoke($7, `i64_load16_u`, [3771275841602506223n]), [value("i64", 52719n)]);
// ./test/core/memory64.wast:186
// ./test/core/memory64.wast:183
assert_return(() => invoke($7, `i64_load32_s`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory64.wast:187
// ./test/core/memory64.wast:184
assert_return(() => invoke($7, `i64_load32_s`, [3771275841602506223n]), [value("i64", -1732588049n)]);
// ./test/core/memory64.wast:188
// ./test/core/memory64.wast:185
assert_return(() => invoke($7, `i64_load32_u`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory64.wast:189
// ./test/core/memory64.wast:186
assert_return(() => invoke($7, `i64_load32_u`, [3771275841602506223n]), [value("i64", 2562379247n)]);

View File

@@ -1,82 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/obsolete-keywords.wast
// ./test/core/obsolete-keywords.wast:2
assert_malformed(
() => instantiate(`(memory 1) (func (drop (current_memory))) `),
`unknown operator current_memory`,
);
// ./test/core/obsolete-keywords.wast:10
assert_malformed(
() => instantiate(`(memory 1) (func (drop (grow_memory (i32.const 0)))) `),
`unknown operator grow_memory`,
);
// ./test/core/obsolete-keywords.wast:19
assert_malformed(
() => instantiate(`(func (local $$i i32) (drop (get_local $$i))) `),
`unknown operator get_local`,
);
// ./test/core/obsolete-keywords.wast:26
assert_malformed(
() => instantiate(`(func (local $$i i32) (set_local $$i (i32.const 0))) `),
`unknown operator set_local`,
);
// ./test/core/obsolete-keywords.wast:33
assert_malformed(
() => instantiate(`(func (local $$i i32) (drop (tee_local $$i (i32.const 0)))) `),
`unknown operator tee_local`,
);
// ./test/core/obsolete-keywords.wast:40
assert_malformed(
() => instantiate(`(global $$g anyfunc (ref.null func)) `),
`unknown operator anyfunc`,
);
// ./test/core/obsolete-keywords.wast:47
assert_malformed(
() => instantiate(`(global $$g i32 (i32.const 0)) (func (drop (get_global $$g))) `),
`unknown operator get_global`,
);
// ./test/core/obsolete-keywords.wast:55
assert_malformed(
() => instantiate(`(global $$g (mut i32) (i32.const 0)) (func (set_global $$g (i32.const 0))) `),
`unknown operator set_global`,
);
// ./test/core/obsolete-keywords.wast:63
assert_malformed(
() => instantiate(`(func (drop (i32.wrap/i64 (i64.const 0)))) `),
`unknown operator i32.wrap/i64`,
);
// ./test/core/obsolete-keywords.wast:70
assert_malformed(
() => instantiate(`(func (drop (i32.trunc_s:sat/f32 (f32.const 0)))) `),
`unknown operator i32.trunc_s:sat/f32`,
);
// ./test/core/obsolete-keywords.wast:77
assert_malformed(
() => instantiate(`(func (drop (f32x4.convert_s/i32x4 (v128.const i64x2 0 0)))) `),
`unknown operator f32x4.convert_s/i32x4`,
);

View File

@@ -566,7 +566,20 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/return_call_indirect.wast:515
// ./test/core/return_call_indirect.wast:511
assert_invalid(
() => instantiate(`(module
(type $$ty (func (result i32 i32)))
(import "env" "table" (table $$table 0 funcref))
(func (param i32) (result i32)
local.get 0
return_call_indirect $$table (type $$ty)
)
)`),
`type mismatch`,
);
// ./test/core/return_call_indirect.wast:525
assert_invalid(
() => instantiate(`(module
(table 0 funcref)
@@ -575,7 +588,7 @@ assert_invalid(
`unknown type`,
);
// ./test/core/return_call_indirect.wast:522
// ./test/core/return_call_indirect.wast:532
assert_invalid(
() => instantiate(`(module
(table 0 funcref)
@@ -584,7 +597,7 @@ assert_invalid(
`unknown type`,
);
// ./test/core/return_call_indirect.wast:533
// ./test/core/return_call_indirect.wast:543
assert_invalid(
() => instantiate(`(module (table funcref (elem 0 0)))`),
`unknown function 0`,

View File

@@ -265,7 +265,45 @@ assert_return(() => invoke($4, `grow`, [10]), [value("i32", 10)]);
// ./test/core/table_grow.wast:141
assert_return(() => invoke($4, `check-table-null`, [0, 19]), [value('anyfunc', null)]);
// ./test/core/table_grow.wast:146
// ./test/core/table_grow.wast:144
let $5 = instantiate(`(module $$Tgt
(table (export "table") 1 funcref) ;; initial size is 1
(func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1)))
)`);
let $Tgt = $5;
// ./test/core/table_grow.wast:148
register($Tgt, `grown-table`);
// ./test/core/table_grow.wast:149
assert_return(() => invoke($Tgt, `grow`, []), [value("i32", 1)]);
// ./test/core/table_grow.wast:150
let $6 = instantiate(`(module $$Tgit1
;; imported table limits should match, because external table size is 2 now
(table (export "table") (import "grown-table" "table") 2 funcref)
(func (export "grow") (result i32) (table.grow (ref.null func) (i32.const 1)))
)`);
let $Tgit1 = $6;
// ./test/core/table_grow.wast:155
register($Tgit1, `grown-imported-table`);
// ./test/core/table_grow.wast:156
assert_return(() => invoke($Tgit1, `grow`, []), [value("i32", 2)]);
// ./test/core/table_grow.wast:157
let $7 = instantiate(`(module $$Tgit2
;; imported table limits should match, because external table size is 3 now
(import "grown-imported-table" "table" (table 3 funcref))
(func (export "size") (result i32) (table.size))
)`);
let $Tgit2 = $7;
// ./test/core/table_grow.wast:162
assert_return(() => invoke($Tgit2, `size`, []), [value("i32", 3)]);
// ./test/core/table_grow.wast:167
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
@@ -276,7 +314,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:155
// ./test/core/table_grow.wast:176
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
@@ -287,7 +325,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:164
// ./test/core/table_grow.wast:185
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
@@ -298,7 +336,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:173
// ./test/core/table_grow.wast:194
assert_invalid(
() => instantiate(`(module
(table $$t 0 externref)
@@ -309,7 +347,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:182
// ./test/core/table_grow.wast:203
assert_invalid(
() => instantiate(`(module
(table $$t 0 funcref)
@@ -320,7 +358,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:192
// ./test/core/table_grow.wast:213
assert_invalid(
() => instantiate(`(module
(table $$t 1 externref)
@@ -331,7 +369,7 @@ assert_invalid(
`type mismatch`,
);
// ./test/core/table_grow.wast:201
// ./test/core/table_grow.wast:222
assert_invalid(
() => instantiate(`(module
(table $$t 1 externref)

View File

@@ -1,289 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/token.wast
// ./test/core/token.wast:3
assert_malformed(() => instantiate(`(func (drop (i32.const0))) `), `unknown operator`);
// ./test/core/token.wast:7
assert_malformed(() => instantiate(`(func br 0drop) `), `unknown operator`);
// ./test/core/token.wast:15
let $0 = instantiate(`(module
(func(nop))
)`);
// ./test/core/token.wast:18
let $1 = instantiate(`(module
(func (nop)nop)
)`);
// ./test/core/token.wast:21
let $2 = instantiate(`(module
(func nop(nop))
)`);
// ./test/core/token.wast:24
let $3 = instantiate(`(module
(func(nop)(nop))
)`);
// ./test/core/token.wast:27
let $4 = instantiate(`(module
(func $$f(nop))
)`);
// ./test/core/token.wast:30
let $5 = instantiate(`(module
(func br 0(nop))
)`);
// ./test/core/token.wast:33
let $6 = instantiate(`(module
(table 1 funcref)
(func)
(elem (i32.const 0)0)
)`);
// ./test/core/token.wast:38
let $7 = instantiate(`(module
(table 1 funcref)
(func $$f)
(elem (i32.const 0)$$f)
)`);
// ./test/core/token.wast:43
let $8 = instantiate(`(module
(memory 1)
(data (i32.const 0)"a")
)`);
// ./test/core/token.wast:47
let $9 = instantiate(`(module
(import "spectest" "print"(func))
)`);
// ./test/core/token.wast:54
let $10 = instantiate(`(module
(func;;bla
)
)`);
// ./test/core/token.wast:58
let $11 = instantiate(`(module
(func (nop);;bla
)
)`);
// ./test/core/token.wast:62
let $12 = instantiate(`(module
(func nop;;bla
)
)`);
// ./test/core/token.wast:66
let $13 = instantiate(`(module
(func $$f;;bla
)
)`);
// ./test/core/token.wast:70
let $14 = instantiate(`(module
(func br 0;;bla
)
)`);
// ./test/core/token.wast:74
let $15 = instantiate(`(module
(data "a";;bla
)
)`);
// ./test/core/token.wast:82
let $16 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table 0 $$l)))
)`);
// ./test/core/token.wast:85
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table 0$$l))) `),
`unknown operator`,
);
// ./test/core/token.wast:92
let $17 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table $$l 0)))
)`);
// ./test/core/token.wast:95
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table $$l0))) `),
`unknown label`,
);
// ./test/core/token.wast:102
let $18 = instantiate(`(module
(func (block $$l (i32.const 0) (br_table $$l $$l)))
)`);
// ./test/core/token.wast:105
assert_malformed(
() => instantiate(`(func (block $$l (i32.const 0) (br_table $$l$$l))) `),
`unknown label`,
);
// ./test/core/token.wast:112
let $19 = instantiate(`(module
(func (block $$l0 (i32.const 0) (br_table $$l0)))
)`);
// ./test/core/token.wast:115
let $20 = instantiate(`(module
(func (block $$l$$l (i32.const 0) (br_table $$l$$l)))
)`);
// ./test/core/token.wast:122
let $21 = instantiate(`(module
(data "a")
)`);
// ./test/core/token.wast:125
assert_malformed(() => instantiate(`(data"a") `), `unknown operator`);
// ./test/core/token.wast:132
let $22 = instantiate(`(module
(data $$l "a")
)`);
// ./test/core/token.wast:135
assert_malformed(() => instantiate(`(data $$l"a") `), `unknown operator`);
// ./test/core/token.wast:142
let $23 = instantiate(`(module
(data $$l " a")
)`);
// ./test/core/token.wast:145
assert_malformed(() => instantiate(`(data $$l" a") `), `unknown operator`);
// ./test/core/token.wast:152
let $24 = instantiate(`(module
(data $$l "a ")
)`);
// ./test/core/token.wast:155
assert_malformed(() => instantiate(`(data $$l"a ") `), `unknown operator`);
// ./test/core/token.wast:162
let $25 = instantiate(`(module
(data $$l "a " "b")
)`);
// ./test/core/token.wast:165
assert_malformed(() => instantiate(`(data $$l"a ""b") `), `unknown operator`);
// ./test/core/token.wast:172
let $26 = instantiate(`(module
(data $$l "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:175
assert_malformed(() => instantiate(`(data $$l"\u{f61a}\u{f4a9}") `), `unknown operator`);
// ./test/core/token.wast:182
let $27 = instantiate(`(module
(data $$l " \u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:185
assert_malformed(() => instantiate(`(data $$l" \u{f61a}\u{f4a9}") `), `unknown operator`);
// ./test/core/token.wast:192
let $28 = instantiate(`(module
(data $$l "\u{f61a}\u{f4a9} ")
)`);
// ./test/core/token.wast:195
assert_malformed(() => instantiate(`(data $$l"\u{f61a}\u{f4a9} ") `), `unknown operator`);
// ./test/core/token.wast:202
let $29 = instantiate(`(module
(data "a" "b")
)`);
// ./test/core/token.wast:205
assert_malformed(() => instantiate(`(data "a""b") `), `unknown operator`);
// ./test/core/token.wast:212
let $30 = instantiate(`(module
(data "a" " b")
)`);
// ./test/core/token.wast:215
assert_malformed(() => instantiate(`(data "a"" b") `), `unknown operator`);
// ./test/core/token.wast:222
let $31 = instantiate(`(module
(data "a " "b")
)`);
// ./test/core/token.wast:225
assert_malformed(() => instantiate(`(data "a ""b") `), `unknown operator`);
// ./test/core/token.wast:232
let $32 = instantiate(`(module
(data "\u{f61a}\u{f4a9}" "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:235
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9}""\u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:242
let $33 = instantiate(`(module
(data "\u{f61a}\u{f4a9}" " \u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:245
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9}"" \u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:252
let $34 = instantiate(`(module
(data "\u{f61a}\u{f4a9} " "\u{f61a}\u{f4a9}")
)`);
// ./test/core/token.wast:255
assert_malformed(
() => instantiate(`(data "\u{f61a}\u{f4a9} ""\u{f61a}\u{f4a9}") `),
`unknown operator`,
);
// ./test/core/token.wast:263
assert_malformed(() => instantiate(`(func "a"x) `), `unknown operator`);
// ./test/core/token.wast:269
assert_malformed(() => instantiate(`(func "a"0) `), `unknown operator`);
// ./test/core/token.wast:275
assert_malformed(() => instantiate(`(func 0"a") `), `unknown operator`);
// ./test/core/token.wast:281
assert_malformed(() => instantiate(`(func "a"$$x) `), `unknown operator`);

View File

@@ -1 +0,0 @@
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_multi_memory=true; skip-if: !wasmMultiMemoryEnabled()

View File

@@ -1,361 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/float_memory.wast
// ./test/core/float_memory.wast:5
let $0 = instantiate(`(module
(memory (data "\\00\\00\\a0\\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x200000)))
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fa00000)))
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
)`);
// ./test/core/float_memory.wast:15
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:16
assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:17
invoke($0, `reset`, []);
// ./test/core/float_memory.wast:18
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:19
assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:20
invoke($0, `f32.store`, []);
// ./test/core/float_memory.wast:21
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:22
assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:23
invoke($0, `reset`, []);
// ./test/core/float_memory.wast:24
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:25
assert_return(() => invoke($0, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:26
invoke($0, `i32.store`, []);
// ./test/core/float_memory.wast:27
assert_return(() => invoke($0, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:28
assert_return(() => invoke($0, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:30
let $1 = instantiate(`(module
(memory (data "\\00\\00\\00\\00\\00\\00\\f4\\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0x4000000000000)))
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ff4000000000000)))
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
)`);
// ./test/core/float_memory.wast:40
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:41
assert_return(
() => invoke($1, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:42
invoke($1, `reset`, []);
// ./test/core/float_memory.wast:43
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:44
assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:45
invoke($1, `f64.store`, []);
// ./test/core/float_memory.wast:46
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:47
assert_return(
() => invoke($1, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:48
invoke($1, `reset`, []);
// ./test/core/float_memory.wast:49
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:50
assert_return(() => invoke($1, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:51
invoke($1, `i64.store`, []);
// ./test/core/float_memory.wast:52
assert_return(() => invoke($1, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:53
assert_return(
() => invoke($1, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:57
let $2 = instantiate(`(module
(memory (data "\\00\\00\\00\\a0\\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 1)))
(func (export "i32.load") (result i32) (i32.load (i32.const 1)))
(func (export "f32.store") (f32.store (i32.const 1) (f32.const nan:0x200000)))
(func (export "i32.store") (i32.store (i32.const 1) (i32.const 0x7fa00000)))
(func (export "reset") (i32.store (i32.const 1) (i32.const 0)))
)`);
// ./test/core/float_memory.wast:67
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:68
assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:69
invoke($2, `reset`, []);
// ./test/core/float_memory.wast:70
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:71
assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:72
invoke($2, `f32.store`, []);
// ./test/core/float_memory.wast:73
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:74
assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:75
invoke($2, `reset`, []);
// ./test/core/float_memory.wast:76
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:77
assert_return(() => invoke($2, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:78
invoke($2, `i32.store`, []);
// ./test/core/float_memory.wast:79
assert_return(() => invoke($2, `i32.load`, []), [value("i32", 2141192192)]);
// ./test/core/float_memory.wast:80
assert_return(() => invoke($2, `f32.load`, []), [bytes("f32", [0x0, 0x0, 0xa0, 0x7f])]);
// ./test/core/float_memory.wast:82
let $3 = instantiate(`(module
(memory (data "\\00\\00\\00\\00\\00\\00\\00\\f4\\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 1)))
(func (export "i64.load") (result i64) (i64.load (i32.const 1)))
(func (export "f64.store") (f64.store (i32.const 1) (f64.const nan:0x4000000000000)))
(func (export "i64.store") (i64.store (i32.const 1) (i64.const 0x7ff4000000000000)))
(func (export "reset") (i64.store (i32.const 1) (i64.const 0)))
)`);
// ./test/core/float_memory.wast:92
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:93
assert_return(
() => invoke($3, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:94
invoke($3, `reset`, []);
// ./test/core/float_memory.wast:95
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:96
assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:97
invoke($3, `f64.store`, []);
// ./test/core/float_memory.wast:98
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:99
assert_return(
() => invoke($3, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:100
invoke($3, `reset`, []);
// ./test/core/float_memory.wast:101
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:102
assert_return(() => invoke($3, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:103
invoke($3, `i64.store`, []);
// ./test/core/float_memory.wast:104
assert_return(() => invoke($3, `i64.load`, []), [value("i64", 9219994337134247936n)]);
// ./test/core/float_memory.wast:105
assert_return(
() => invoke($3, `f64.load`, []),
[bytes("f64", [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf4, 0x7f])],
);
// ./test/core/float_memory.wast:109
let $4 = instantiate(`(module
(memory (data "\\01\\00\\d0\\7f"))
(func (export "f32.load") (result f32) (f32.load (i32.const 0)))
(func (export "i32.load") (result i32) (i32.load (i32.const 0)))
(func (export "f32.store") (f32.store (i32.const 0) (f32.const nan:0x500001)))
(func (export "i32.store") (i32.store (i32.const 0) (i32.const 0x7fd00001)))
(func (export "reset") (i32.store (i32.const 0) (i32.const 0)))
)`);
// ./test/core/float_memory.wast:119
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
// ./test/core/float_memory.wast:120
assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]);
// ./test/core/float_memory.wast:121
invoke($4, `reset`, []);
// ./test/core/float_memory.wast:122
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:123
assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:124
invoke($4, `f32.store`, []);
// ./test/core/float_memory.wast:125
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
// ./test/core/float_memory.wast:126
assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]);
// ./test/core/float_memory.wast:127
invoke($4, `reset`, []);
// ./test/core/float_memory.wast:128
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 0)]);
// ./test/core/float_memory.wast:129
assert_return(() => invoke($4, `f32.load`, []), [value("f32", 0)]);
// ./test/core/float_memory.wast:130
invoke($4, `i32.store`, []);
// ./test/core/float_memory.wast:131
assert_return(() => invoke($4, `i32.load`, []), [value("i32", 2144337921)]);
// ./test/core/float_memory.wast:132
assert_return(() => invoke($4, `f32.load`, []), [bytes("f32", [0x1, 0x0, 0xd0, 0x7f])]);
// ./test/core/float_memory.wast:134
let $5 = instantiate(`(module
(memory (data "\\01\\00\\00\\00\\00\\00\\fc\\7f"))
(func (export "f64.load") (result f64) (f64.load (i32.const 0)))
(func (export "i64.load") (result i64) (i64.load (i32.const 0)))
(func (export "f64.store") (f64.store (i32.const 0) (f64.const nan:0xc000000000001)))
(func (export "i64.store") (i64.store (i32.const 0) (i64.const 0x7ffc000000000001)))
(func (export "reset") (i64.store (i32.const 0) (i64.const 0)))
)`);
// ./test/core/float_memory.wast:144
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]);
// ./test/core/float_memory.wast:145
assert_return(
() => invoke($5, `f64.load`, []),
[bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])],
);
// ./test/core/float_memory.wast:146
invoke($5, `reset`, []);
// ./test/core/float_memory.wast:147
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:148
assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:149
invoke($5, `f64.store`, []);
// ./test/core/float_memory.wast:150
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]);
// ./test/core/float_memory.wast:151
assert_return(
() => invoke($5, `f64.load`, []),
[bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])],
);
// ./test/core/float_memory.wast:152
invoke($5, `reset`, []);
// ./test/core/float_memory.wast:153
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 0n)]);
// ./test/core/float_memory.wast:154
assert_return(() => invoke($5, `f64.load`, []), [value("f64", 0)]);
// ./test/core/float_memory.wast:155
invoke($5, `i64.store`, []);
// ./test/core/float_memory.wast:156
assert_return(() => invoke($5, `i64.load`, []), [value("i64", 9222246136947933185n)]);
// ./test/core/float_memory.wast:157
assert_return(
() => invoke($5, `f64.load`, []),
[bytes("f64", [0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x7f])],
);

View File

@@ -1 +0,0 @@
|jit-test| skip-if: true

View File

@@ -1,454 +0,0 @@
"use strict";
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!wasmIsSupported()) {
quit();
}
function partialOobWriteMayWritePartialData() {
let arm_native = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator");
let arm64_native = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator");
return arm_native || arm64_native;
}
let native_arm = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator");
let native_arm64 = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator");
function bytes(type, bytes) {
var typedBuffer = new Uint8Array(bytes);
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
}
function value(type, value) {
return new WebAssembly.Global({
value: type,
mutable: false,
}, value);
}
function i8x16(elements) {
let typedBuffer = new Uint8Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i16x8(elements) {
let typedBuffer = new Uint16Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i32x4(elements) {
let typedBuffer = new Uint32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i64x2(elements) {
let typedBuffer = new BigUint64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f32x4(elements) {
let typedBuffer = new Float32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f64x2(elements) {
let typedBuffer = new Float64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function either(...arr) {
return new EitherVariants(arr);
}
class F32x4Pattern {
constructor(x, y, z, w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
}
class F64x2Pattern {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class RefWithType {
constructor(type) {
this.type = type;
}
formatExpected() {
return `RefWithType(${this.type})`;
}
test(refGlobal) {
try {
new WebAssembly.Global({value: this.type}, refGlobal.value);
return true;
} catch (err) {
assertEq(err instanceof TypeError, true, `wrong type of error when creating global: ${err}`);
assertEq(!!err.message.match(/can only pass/), true, `wrong type of error when creating global: ${err}`);
return false;
}
}
}
// ref.extern values created by spec tests will be JS objects of the form
// { [externsym]: <number> }. Other externref values are possible to observe
// if extern.convert_any is used.
let externsym = Symbol("externref");
function externref(s) {
return { [externsym]: s };
}
function is_externref(x) {
return (x !== null && externsym in x) ? 1 : 0;
}
function is_funcref(x) {
return typeof x === "function" ? 1 : 0;
}
function eq_externref(x, y) {
return x === y ? 1 : 0;
}
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
class ExternRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.extern ${this.n}`;
}
test(global) {
// the global's value can either be an externref or just a plain old JS number
let result = global.value;
if (typeof global.value === "object" && externsym in global.value) {
result = global.value[externsym];
}
return result === this.n;
}
}
// ref.host values created by spectests will be whatever the JS API does to
// convert the given value to anyref. It should implicitly be like any.convert_extern.
function hostref(v) {
const { internalizeNum } = new WebAssembly.Instance(
new WebAssembly.Module(wasmTextToBinary(`(module
(func (import "test" "coerce") (param i32) (result anyref))
(func (export "internalizeNum") (param i32) (result anyref)
(call 0 (local.get 0))
)
)`)),
{ "test": { "coerce": x => x } },
).exports;
return internalizeNum(v);
}
class HostRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.host ${this.n}`;
}
test(externrefGlobal) {
assertEq(externsym in externrefGlobal.value, true, `HostRefResult only works with externref inputs`);
return externrefGlobal.value[externsym] === this.n;
}
}
let spectest = {
externref: externref,
is_externref: is_externref,
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
print_f64_f64: console.log.bind(console),
print_f32: console.log.bind(console),
print_f64: console.log.bind(console),
global_i32: 666,
global_i64: 666n,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({
initial: 10,
maximum: 20,
element: "anyfunc",
}),
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
};
let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
}
function instantiate(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
assertEq(
global instanceof WebAssembly.Global,
true,
"expected a WebAssembly.Global",
);
return global;
}
function assert_trap(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.RuntimeError) {
return;
}
err.message = `expected trap (${message}): ${err.message}`;
throw err;
}
}
let StackOverflow;
try {
(function f() {
1 + f();
})();
} catch (e) {
StackOverflow = e.constructor;
}
function assert_exhaustion(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof StackOverflow) {
return;
}
err.message = `expected exhaustion (${message}): ${err.message}`;
throw err;
}
}
function assert_invalid(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected invalid module (${message}): ${err.message}`;
throw err;
}
}
function assert_unlinkable(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected an unlinkable module (${message}): ${err.message}`;
throw err;
}
}
function assert_malformed(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (
err instanceof TypeError ||
err instanceof SyntaxError ||
err instanceof WebAssembly.CompileError ||
err instanceof WebAssembly.LinkError
) {
return;
}
err.message = `expected a malformed module (${message}): ${err.message}`;
throw err;
}
}
function assert_exception(thunk) {
let thrown = false;
try {
thunk();
} catch (err) {
thrown = true;
}
assertEq(thrown, true, "expected an exception to be thrown");
}
function assert_return(thunk, expected) {
let results = thunk();
if (results === undefined) {
results = [];
} else if (!Array.isArray(results)) {
results = [results];
}
if (!Array.isArray(expected)) {
expected = [expected];
}
if (!compareResults(results, expected)) {
let got = results.map((x) => formatResult(x)).join(", ");
let wanted = expected.map((x) => formatExpected(x)).join(", ");
assertEq(
`[${got}]`,
`[${wanted}]`,
);
assertEq(true, false, `${got} !== ${wanted}`);
}
}
function formatResult(result) {
if (typeof (result) === "object") {
return wasmGlobalToString(result);
} else {
return `${result}`;
}
}
function formatExpected(expected) {
if (
expected === `f32_canonical_nan` ||
expected === `f32_arithmetic_nan` ||
expected === `f64_canonical_nan` ||
expected === `f64_arithmetic_nan`
) {
return expected;
} else if (expected instanceof F32x4Pattern) {
return `f32x4(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
}, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`;
} else if (expected instanceof F64x2Pattern) {
return `f64x2(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
})`;
} else if (expected instanceof EitherVariants) {
return expected.formatExpected();
} else if (expected instanceof RefWithType) {
return expected.formatExpected();
} else if (expected instanceof ExternRefResult) {
return expected.formatExpected();
} else if (expected instanceof HostRefResult) {
return expected.formatExpected();
} else if (typeof (expected) === "object") {
return wasmGlobalToString(expected);
} else {
throw new Error("unknown expected result");
}
}
class EitherVariants {
constructor(arr) {
this.arr = arr;
}
matches(v) {
return this.arr.some((e) => compareResult(v, e));
}
formatExpected() {
return `either(${this.arr.map(formatExpected).join(", ")})`;
}
}
function compareResults(results, expected) {
if (results.length !== expected.length) {
return false;
}
for (let i in results) {
if (expected[i] instanceof EitherVariants) {
return expected[i].matches(results[i]);
}
if (!compareResult(results[i], expected[i])) {
return false;
}
}
return true;
}
function compareResult(result, expected) {
if (
expected === `canonical_nan` ||
expected === `arithmetic_nan`
) {
return wasmGlobalIsNaN(result, expected);
} else if (expected === null) {
return result.value === null;
} else if (expected instanceof F32x4Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f32x4", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w);
} else if (expected instanceof F64x2Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f64x2", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y);
} else if (expected instanceof RefWithType) {
return expected.test(result);
} else if (expected instanceof ExternRefResult) {
return expected.test(result);
} else if (expected instanceof HostRefResult) {
return expected.test(result);
} else if (typeof (expected) === "object") {
return wasmGlobalsEqual(result, expected);
} else {
throw new Error("unknown expected result");
}
}

View File

@@ -1,390 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/memory.wast
// ./test/core/memory.wast:3
let $0 = instantiate(`(module (memory 0))`);
// ./test/core/memory.wast:4
let $1 = instantiate(`(module (memory 1))`);
// ./test/core/memory.wast:5
let $2 = instantiate(`(module (memory 0 0))`);
// ./test/core/memory.wast:6
let $3 = instantiate(`(module (memory 0 1))`);
// ./test/core/memory.wast:7
let $4 = instantiate(`(module (memory 1 256))`);
// ./test/core/memory.wast:8
let $5 = instantiate(`(module (memory 0 65536))`);
// ./test/core/memory.wast:10
let $6 = instantiate(`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:11
assert_return(() => invoke($6, `memsize`, []), [value("i32", 0)]);
// ./test/core/memory.wast:12
let $7 = instantiate(`(module (memory (data "")) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:13
assert_return(() => invoke($7, `memsize`, []), [value("i32", 0)]);
// ./test/core/memory.wast:14
let $8 = instantiate(`(module (memory (data "x")) (func (export "memsize") (result i32) (memory.size)))`);
// ./test/core/memory.wast:15
assert_return(() => invoke($8, `memsize`, []), [value("i32", 1)]);
// ./test/core/memory.wast:17
assert_invalid(() => instantiate(`(module (data (i32.const 0)))`), `unknown memory`);
// ./test/core/memory.wast:18
assert_invalid(() => instantiate(`(module (data (i32.const 0) ""))`), `unknown memory`);
// ./test/core/memory.wast:19
assert_invalid(() => instantiate(`(module (data (i32.const 0) "x"))`), `unknown memory`);
// ./test/core/memory.wast:21
assert_invalid(
() => instantiate(`(module (func (drop (f32.load (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:25
assert_invalid(
() => instantiate(`(module (func (f32.store (i32.const 0) (f32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory.wast:29
assert_invalid(
() => instantiate(`(module (func (drop (i32.load8_s (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:33
assert_invalid(
() => instantiate(`(module (func (i32.store8 (i32.const 0) (i32.const 0))))`),
`unknown memory`,
);
// ./test/core/memory.wast:37
assert_invalid(
() => instantiate(`(module (func (drop (memory.size))))`),
`unknown memory`,
);
// ./test/core/memory.wast:41
assert_invalid(
() => instantiate(`(module (func (drop (memory.grow (i32.const 0)))))`),
`unknown memory`,
);
// ./test/core/memory.wast:47
assert_invalid(
() => instantiate(`(module (memory 1 0))`),
`size minimum must not be greater than maximum`,
);
// ./test/core/memory.wast:51
assert_invalid(
() => instantiate(`(module (memory 65537))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:55
assert_invalid(
() => instantiate(`(module (memory 2147483648))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:59
assert_invalid(
() => instantiate(`(module (memory 4294967295))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:63
assert_invalid(
() => instantiate(`(module (memory 0 65537))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:67
assert_invalid(
() => instantiate(`(module (memory 0 2147483648))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:71
assert_invalid(
() => instantiate(`(module (memory 0 4294967295))`),
`memory size must be at most 65536 pages (4GiB)`,
);
// ./test/core/memory.wast:76
assert_malformed(
() => instantiate(`(memory 0x1_0000_0000) `),
`i32 constant out of range`,
);
// ./test/core/memory.wast:80
assert_malformed(
() => instantiate(`(memory 0x1_0000_0000 0x1_0000_0000) `),
`i32 constant out of range`,
);
// ./test/core/memory.wast:84
assert_malformed(
() => instantiate(`(memory 0 0x1_0000_0000) `),
`i32 constant out of range`,
);
// ./test/core/memory.wast:89
let $9 = instantiate(`(module
(memory 1)
(data (i32.const 0) "ABC\\a7D") (data (i32.const 20) "WASM")
;; Data section
(func (export "data") (result i32)
(i32.and
(i32.and
(i32.and
(i32.eq (i32.load8_u (i32.const 0)) (i32.const 65))
(i32.eq (i32.load8_u (i32.const 3)) (i32.const 167))
)
(i32.and
(i32.eq (i32.load8_u (i32.const 6)) (i32.const 0))
(i32.eq (i32.load8_u (i32.const 19)) (i32.const 0))
)
)
(i32.and
(i32.and
(i32.eq (i32.load8_u (i32.const 20)) (i32.const 87))
(i32.eq (i32.load8_u (i32.const 23)) (i32.const 77))
)
(i32.and
(i32.eq (i32.load8_u (i32.const 24)) (i32.const 0))
(i32.eq (i32.load8_u (i32.const 1023)) (i32.const 0))
)
)
)
)
;; Memory cast
(func (export "cast") (result f64)
(i64.store (i32.const 8) (i64.const -12345))
(if
(f64.eq
(f64.load (i32.const 8))
(f64.reinterpret_i64 (i64.const -12345))
)
(then (return (f64.const 0)))
)
(i64.store align=1 (i32.const 9) (i64.const 0))
(i32.store16 align=1 (i32.const 15) (i32.const 16453))
(f64.load align=1 (i32.const 9))
)
;; Sign and zero extending memory loads
(func (export "i32_load8_s") (param $$i i32) (result i32)
(i32.store8 (i32.const 8) (local.get $$i))
(i32.load8_s (i32.const 8))
)
(func (export "i32_load8_u") (param $$i i32) (result i32)
(i32.store8 (i32.const 8) (local.get $$i))
(i32.load8_u (i32.const 8))
)
(func (export "i32_load16_s") (param $$i i32) (result i32)
(i32.store16 (i32.const 8) (local.get $$i))
(i32.load16_s (i32.const 8))
)
(func (export "i32_load16_u") (param $$i i32) (result i32)
(i32.store16 (i32.const 8) (local.get $$i))
(i32.load16_u (i32.const 8))
)
(func (export "i64_load8_s") (param $$i i64) (result i64)
(i64.store8 (i32.const 8) (local.get $$i))
(i64.load8_s (i32.const 8))
)
(func (export "i64_load8_u") (param $$i i64) (result i64)
(i64.store8 (i32.const 8) (local.get $$i))
(i64.load8_u (i32.const 8))
)
(func (export "i64_load16_s") (param $$i i64) (result i64)
(i64.store16 (i32.const 8) (local.get $$i))
(i64.load16_s (i32.const 8))
)
(func (export "i64_load16_u") (param $$i i64) (result i64)
(i64.store16 (i32.const 8) (local.get $$i))
(i64.load16_u (i32.const 8))
)
(func (export "i64_load32_s") (param $$i i64) (result i64)
(i64.store32 (i32.const 8) (local.get $$i))
(i64.load32_s (i32.const 8))
)
(func (export "i64_load32_u") (param $$i i64) (result i64)
(i64.store32 (i32.const 8) (local.get $$i))
(i64.load32_u (i32.const 8))
)
)`);
// ./test/core/memory.wast:177
assert_return(() => invoke($9, `data`, []), [value("i32", 1)]);
// ./test/core/memory.wast:178
assert_return(() => invoke($9, `cast`, []), [value("f64", 42)]);
// ./test/core/memory.wast:180
assert_return(() => invoke($9, `i32_load8_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory.wast:181
assert_return(() => invoke($9, `i32_load8_u`, [-1]), [value("i32", 255)]);
// ./test/core/memory.wast:182
assert_return(() => invoke($9, `i32_load16_s`, [-1]), [value("i32", -1)]);
// ./test/core/memory.wast:183
assert_return(() => invoke($9, `i32_load16_u`, [-1]), [value("i32", 65535)]);
// ./test/core/memory.wast:185
assert_return(() => invoke($9, `i32_load8_s`, [100]), [value("i32", 100)]);
// ./test/core/memory.wast:186
assert_return(() => invoke($9, `i32_load8_u`, [200]), [value("i32", 200)]);
// ./test/core/memory.wast:187
assert_return(() => invoke($9, `i32_load16_s`, [20000]), [value("i32", 20000)]);
// ./test/core/memory.wast:188
assert_return(() => invoke($9, `i32_load16_u`, [40000]), [value("i32", 40000)]);
// ./test/core/memory.wast:190
assert_return(() => invoke($9, `i32_load8_s`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory.wast:191
assert_return(() => invoke($9, `i32_load8_s`, [878104047]), [value("i32", -17)]);
// ./test/core/memory.wast:192
assert_return(() => invoke($9, `i32_load8_u`, [-19110589]), [value("i32", 67)]);
// ./test/core/memory.wast:193
assert_return(() => invoke($9, `i32_load8_u`, [878104047]), [value("i32", 239)]);
// ./test/core/memory.wast:194
assert_return(() => invoke($9, `i32_load16_s`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory.wast:195
assert_return(() => invoke($9, `i32_load16_s`, [878104047]), [value("i32", -12817)]);
// ./test/core/memory.wast:196
assert_return(() => invoke($9, `i32_load16_u`, [-19110589]), [value("i32", 25923)]);
// ./test/core/memory.wast:197
assert_return(() => invoke($9, `i32_load16_u`, [878104047]), [value("i32", 52719)]);
// ./test/core/memory.wast:199
assert_return(() => invoke($9, `i64_load8_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:200
assert_return(() => invoke($9, `i64_load8_u`, [-1n]), [value("i64", 255n)]);
// ./test/core/memory.wast:201
assert_return(() => invoke($9, `i64_load16_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:202
assert_return(() => invoke($9, `i64_load16_u`, [-1n]), [value("i64", 65535n)]);
// ./test/core/memory.wast:203
assert_return(() => invoke($9, `i64_load32_s`, [-1n]), [value("i64", -1n)]);
// ./test/core/memory.wast:204
assert_return(() => invoke($9, `i64_load32_u`, [-1n]), [value("i64", 4294967295n)]);
// ./test/core/memory.wast:206
assert_return(() => invoke($9, `i64_load8_s`, [100n]), [value("i64", 100n)]);
// ./test/core/memory.wast:207
assert_return(() => invoke($9, `i64_load8_u`, [200n]), [value("i64", 200n)]);
// ./test/core/memory.wast:208
assert_return(() => invoke($9, `i64_load16_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory.wast:209
assert_return(() => invoke($9, `i64_load16_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory.wast:210
assert_return(() => invoke($9, `i64_load32_s`, [20000n]), [value("i64", 20000n)]);
// ./test/core/memory.wast:211
assert_return(() => invoke($9, `i64_load32_u`, [40000n]), [value("i64", 40000n)]);
// ./test/core/memory.wast:213
assert_return(() => invoke($9, `i64_load8_s`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory.wast:214
assert_return(() => invoke($9, `i64_load8_s`, [3771275841602506223n]), [value("i64", -17n)]);
// ./test/core/memory.wast:215
assert_return(() => invoke($9, `i64_load8_u`, [-81985529755441853n]), [value("i64", 67n)]);
// ./test/core/memory.wast:216
assert_return(() => invoke($9, `i64_load8_u`, [3771275841602506223n]), [value("i64", 239n)]);
// ./test/core/memory.wast:217
assert_return(() => invoke($9, `i64_load16_s`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory.wast:218
assert_return(() => invoke($9, `i64_load16_s`, [3771275841602506223n]), [value("i64", -12817n)]);
// ./test/core/memory.wast:219
assert_return(() => invoke($9, `i64_load16_u`, [-81985529755441853n]), [value("i64", 25923n)]);
// ./test/core/memory.wast:220
assert_return(() => invoke($9, `i64_load16_u`, [3771275841602506223n]), [value("i64", 52719n)]);
// ./test/core/memory.wast:221
assert_return(() => invoke($9, `i64_load32_s`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory.wast:222
assert_return(() => invoke($9, `i64_load32_s`, [3771275841602506223n]), [value("i64", -1732588049n)]);
// ./test/core/memory.wast:223
assert_return(() => invoke($9, `i64_load32_u`, [-81985529755441853n]), [value("i64", 1446274371n)]);
// ./test/core/memory.wast:224
assert_return(() => invoke($9, `i64_load32_u`, [3771275841602506223n]), [value("i64", 2562379247n)]);
// ./test/core/memory.wast:228
assert_malformed(
() => instantiate(`(memory $$foo 1) (memory $$foo 1) `),
`duplicate memory`,
);
// ./test/core/memory.wast:232
assert_malformed(
() => instantiate(`(import "" "" (memory $$foo 1)) (memory $$foo 1) `),
`duplicate memory`,
);
// ./test/core/memory.wast:236
assert_malformed(
() => instantiate(`(import "" "" (memory $$foo 1)) (import "" "" (memory $$foo 1)) `),
`duplicate memory`,
);

View File

@@ -1,773 +0,0 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/memory_grow.wast
// ./test/core/memory_grow.wast:1
let $0 = instantiate(`(module
(memory 0)
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);
// ./test/core/memory_grow.wast:6
assert_return(() => invoke($0, `grow`, [0]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:7
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:8
assert_return(() => invoke($0, `grow`, [0]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:9
assert_return(() => invoke($0, `grow`, [2]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:10
assert_return(() => invoke($0, `grow`, [800]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:11
assert_return(() => invoke($0, `grow`, [65536]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:12
assert_return(() => invoke($0, `grow`, [64736]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:13
assert_return(() => invoke($0, `grow`, [1]), [value("i32", 803)]);
// ./test/core/memory_grow.wast:15
let $1 = instantiate(`(module
(memory 0 10)
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
)`);
// ./test/core/memory_grow.wast:20
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:21
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:22
assert_return(() => invoke($1, `grow`, [1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:23
assert_return(() => invoke($1, `grow`, [2]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:24
assert_return(() => invoke($1, `grow`, [6]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:25
assert_return(() => invoke($1, `grow`, [0]), [value("i32", 10)]);
// ./test/core/memory_grow.wast:26
assert_return(() => invoke($1, `grow`, [1]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:27
assert_return(() => invoke($1, `grow`, [65536]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:32
let $2 = instantiate(`(module
(memory 1)
(func (export "grow") (param i32) (result i32)
(memory.grow (local.get 0))
)
(func (export "check-memory-zero") (param i32 i32) (result i32)
(local i32)
(local.set 2 (i32.const 1))
(block
(loop
(local.set 2 (i32.load8_u (local.get 0)))
(br_if 1 (i32.ne (local.get 2) (i32.const 0)))
(br_if 1 (i32.ge_u (local.get 0) (local.get 1)))
(local.set 0 (i32.add (local.get 0) (i32.const 1)))
(br_if 0 (i32.le_u (local.get 0) (local.get 1)))
)
)
(local.get 2)
)
)`);
// ./test/core/memory_grow.wast:53
assert_return(() => invoke($2, `check-memory-zero`, [0, 65535]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:54
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:55
assert_return(() => invoke($2, `check-memory-zero`, [65536, 131071]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:56
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:57
assert_return(() => invoke($2, `check-memory-zero`, [131072, 196607]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:58
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:59
assert_return(() => invoke($2, `check-memory-zero`, [196608, 262143]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:60
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:61
assert_return(() => invoke($2, `check-memory-zero`, [262144, 327679]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:62
assert_return(() => invoke($2, `grow`, [1]), [value("i32", 5)]);
// ./test/core/memory_grow.wast:63
assert_return(() => invoke($2, `check-memory-zero`, [327680, 393215]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:68
let $3 = instantiate(`(module
(memory 0)
(func (export "load_at_zero") (result i32) (i32.load (i32.const 0)))
(func (export "store_at_zero") (i32.store (i32.const 0) (i32.const 2)))
(func (export "load_at_page_size") (result i32)
(i32.load (i32.const 0x10000))
)
(func (export "store_at_page_size")
(i32.store (i32.const 0x10000) (i32.const 3))
)
(func (export "grow") (param i32) (result i32) (memory.grow (local.get 0)))
(func (export "size") (result i32) (memory.size))
)`);
// ./test/core/memory_grow.wast:85
assert_return(() => invoke($3, `size`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:86
assert_trap(() => invoke($3, `store_at_zero`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:87
assert_trap(() => invoke($3, `load_at_zero`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:88
assert_trap(() => invoke($3, `store_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:89
assert_trap(() => invoke($3, `load_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:90
assert_return(() => invoke($3, `grow`, [1]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:91
assert_return(() => invoke($3, `size`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:92
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:93
assert_return(() => invoke($3, `store_at_zero`, []), []);
// ./test/core/memory_grow.wast:94
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:95
assert_trap(() => invoke($3, `store_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:96
assert_trap(() => invoke($3, `load_at_page_size`, []), `out of bounds memory access`);
// ./test/core/memory_grow.wast:97
assert_return(() => invoke($3, `grow`, [4]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:98
assert_return(() => invoke($3, `size`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:99
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:100
assert_return(() => invoke($3, `store_at_zero`, []), []);
// ./test/core/memory_grow.wast:101
assert_return(() => invoke($3, `load_at_zero`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:102
assert_return(() => invoke($3, `load_at_page_size`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:103
assert_return(() => invoke($3, `store_at_page_size`, []), []);
// ./test/core/memory_grow.wast:104
assert_return(() => invoke($3, `load_at_page_size`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:109
let $4 = instantiate(`(module
(memory (export "mem1") 2 5)
(memory (export "mem2") 0)
)`);
// ./test/core/memory_grow.wast:113
register($4, `M`);
// ./test/core/memory_grow.wast:115
let $5 = instantiate(`(module
(memory $$mem1 (import "M" "mem1") 1 6)
(memory $$mem2 (import "M" "mem2") 0)
(memory $$mem3 3)
(memory $$mem4 4 5)
(func (export "size1") (result i32) (memory.size $$mem1))
(func (export "size2") (result i32) (memory.size $$mem2))
(func (export "size3") (result i32) (memory.size $$mem3))
(func (export "size4") (result i32) (memory.size $$mem4))
(func (export "grow1") (param i32) (result i32)
(memory.grow $$mem1 (local.get 0))
)
(func (export "grow2") (param i32) (result i32)
(memory.grow $$mem2 (local.get 0))
)
(func (export "grow3") (param i32) (result i32)
(memory.grow $$mem3 (local.get 0))
)
(func (export "grow4") (param i32) (result i32)
(memory.grow $$mem4 (local.get 0))
)
)`);
// ./test/core/memory_grow.wast:140
assert_return(() => invoke($5, `size1`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:141
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:142
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:143
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:145
assert_return(() => invoke($5, `grow1`, [1]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:146
assert_return(() => invoke($5, `size1`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:147
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:148
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:149
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:151
assert_return(() => invoke($5, `grow1`, [2]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:152
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:153
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:154
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:155
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:157
assert_return(() => invoke($5, `grow1`, [1]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:158
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:159
assert_return(() => invoke($5, `size2`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:160
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:161
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:163
assert_return(() => invoke($5, `grow2`, [10]), [value("i32", 0)]);
// ./test/core/memory_grow.wast:164
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:165
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);
// ./test/core/memory_grow.wast:166
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:167
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:169
assert_return(() => invoke($5, `grow3`, [268435456]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:170
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:171
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);
// ./test/core/memory_grow.wast:172
assert_return(() => invoke($5, `size3`, []), [value("i32", 3)]);
// ./test/core/memory_grow.wast:173
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:175
assert_return(() => invoke($5, `grow3`, [3]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:176
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:177
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);
// ./test/core/memory_grow.wast:178
assert_return(() => invoke($5, `size3`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:179
assert_return(() => invoke($5, `size4`, []), [value("i32", 4)]);
// ./test/core/memory_grow.wast:181
assert_return(() => invoke($5, `grow4`, [1]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:182
assert_return(() => invoke($5, `grow4`, [1]), [value("i32", -1)]);
// ./test/core/memory_grow.wast:183
assert_return(() => invoke($5, `size1`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:184
assert_return(() => invoke($5, `size2`, []), [value("i32", 10)]);
// ./test/core/memory_grow.wast:185
assert_return(() => invoke($5, `size3`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:186
assert_return(() => invoke($5, `size4`, []), [value("i32", 5)]);
// ./test/core/memory_grow.wast:191
let $6 = instantiate(`(module
(memory 1)
(func (export "as-br-value") (result i32)
(block (result i32) (br 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_if-cond")
(block (br_if 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_if-value") (result i32)
(block (result i32)
(drop (br_if 0 (memory.grow (i32.const 0)) (i32.const 1))) (i32.const 7)
)
)
(func (export "as-br_if-value-cond") (result i32)
(block (result i32)
(drop (br_if 0 (i32.const 6) (memory.grow (i32.const 0)))) (i32.const 7)
)
)
(func (export "as-br_table-index")
(block (br_table 0 0 0 (memory.grow (i32.const 0))))
)
(func (export "as-br_table-value") (result i32)
(block (result i32)
(br_table 0 0 0 (memory.grow (i32.const 0)) (i32.const 1)) (i32.const 7)
)
)
(func (export "as-br_table-value-index") (result i32)
(block (result i32)
(br_table 0 0 (i32.const 6) (memory.grow (i32.const 0))) (i32.const 7)
)
)
(func (export "as-return-value") (result i32)
(return (memory.grow (i32.const 0)))
)
(func (export "as-if-cond") (result i32)
(if (result i32) (memory.grow (i32.const 0))
(then (i32.const 0)) (else (i32.const 1))
)
)
(func (export "as-if-then") (result i32)
(if (result i32) (i32.const 1)
(then (memory.grow (i32.const 0))) (else (i32.const 0))
)
)
(func (export "as-if-else") (result i32)
(if (result i32) (i32.const 0)
(then (i32.const 0)) (else (memory.grow (i32.const 0)))
)
)
(func (export "as-select-first") (param i32 i32) (result i32)
(select (memory.grow (i32.const 0)) (local.get 0) (local.get 1))
)
(func (export "as-select-second") (param i32 i32) (result i32)
(select (local.get 0) (memory.grow (i32.const 0)) (local.get 1))
)
(func (export "as-select-cond") (result i32)
(select (i32.const 0) (i32.const 1) (memory.grow (i32.const 0)))
)
(func $$f (param i32 i32 i32) (result i32) (i32.const -1))
(func (export "as-call-first") (result i32)
(call $$f (memory.grow (i32.const 0)) (i32.const 2) (i32.const 3))
)
(func (export "as-call-mid") (result i32)
(call $$f (i32.const 1) (memory.grow (i32.const 0)) (i32.const 3))
)
(func (export "as-call-last") (result i32)
(call $$f (i32.const 1) (i32.const 2) (memory.grow (i32.const 0)))
)
(type $$sig (func (param i32 i32 i32) (result i32)))
(table funcref (elem $$f))
(func (export "as-call_indirect-first") (result i32)
(call_indirect (type $$sig)
(memory.grow (i32.const 0)) (i32.const 2) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-mid") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (memory.grow (i32.const 0)) (i32.const 3) (i32.const 0)
)
)
(func (export "as-call_indirect-last") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (memory.grow (i32.const 0)) (i32.const 0)
)
)
(func (export "as-call_indirect-index") (result i32)
(call_indirect (type $$sig)
(i32.const 1) (i32.const 2) (i32.const 3) (memory.grow (i32.const 0))
)
)
(func (export "as-local.set-value") (local i32)
(local.set 0 (memory.grow (i32.const 0)))
)
(func (export "as-local.tee-value") (result i32) (local i32)
(local.tee 0 (memory.grow (i32.const 0)))
)
(global $$g (mut i32) (i32.const 0))
(func (export "as-global.set-value") (local i32)
(global.set $$g (memory.grow (i32.const 0)))
)
(func (export "as-load-address") (result i32)
(i32.load (memory.grow (i32.const 0)))
)
(func (export "as-loadN-address") (result i32)
(i32.load8_s (memory.grow (i32.const 0)))
)
(func (export "as-store-address")
(i32.store (memory.grow (i32.const 0)) (i32.const 7))
)
(func (export "as-store-value")
(i32.store (i32.const 2) (memory.grow (i32.const 0)))
)
(func (export "as-storeN-address")
(i32.store8 (memory.grow (i32.const 0)) (i32.const 7))
)
(func (export "as-storeN-value")
(i32.store16 (i32.const 2) (memory.grow (i32.const 0)))
)
(func (export "as-unary-operand") (result i32)
(i32.clz (memory.grow (i32.const 0)))
)
(func (export "as-binary-left") (result i32)
(i32.add (memory.grow (i32.const 0)) (i32.const 10))
)
(func (export "as-binary-right") (result i32)
(i32.sub (i32.const 10) (memory.grow (i32.const 0)))
)
(func (export "as-test-operand") (result i32)
(i32.eqz (memory.grow (i32.const 0)))
)
(func (export "as-compare-left") (result i32)
(i32.le_s (memory.grow (i32.const 0)) (i32.const 10))
)
(func (export "as-compare-right") (result i32)
(i32.ne (i32.const 10) (memory.grow (i32.const 0)))
)
(func (export "as-memory.grow-size") (result i32)
(memory.grow (memory.grow (i32.const 0)))
)
)`);
// ./test/core/memory_grow.wast:349
assert_return(() => invoke($6, `as-br-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:351
assert_return(() => invoke($6, `as-br_if-cond`, []), []);
// ./test/core/memory_grow.wast:352
assert_return(() => invoke($6, `as-br_if-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:353
assert_return(() => invoke($6, `as-br_if-value-cond`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:355
assert_return(() => invoke($6, `as-br_table-index`, []), []);
// ./test/core/memory_grow.wast:356
assert_return(() => invoke($6, `as-br_table-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:357
assert_return(() => invoke($6, `as-br_table-value-index`, []), [value("i32", 6)]);
// ./test/core/memory_grow.wast:359
assert_return(() => invoke($6, `as-return-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:361
assert_return(() => invoke($6, `as-if-cond`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:362
assert_return(() => invoke($6, `as-if-then`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:363
assert_return(() => invoke($6, `as-if-else`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:365
assert_return(() => invoke($6, `as-select-first`, [0, 1]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:366
assert_return(() => invoke($6, `as-select-second`, [0, 0]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:367
assert_return(() => invoke($6, `as-select-cond`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:369
assert_return(() => invoke($6, `as-call-first`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:370
assert_return(() => invoke($6, `as-call-mid`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:371
assert_return(() => invoke($6, `as-call-last`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:373
assert_return(() => invoke($6, `as-call_indirect-first`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:374
assert_return(() => invoke($6, `as-call_indirect-mid`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:375
assert_return(() => invoke($6, `as-call_indirect-last`, []), [value("i32", -1)]);
// ./test/core/memory_grow.wast:376
assert_trap(() => invoke($6, `as-call_indirect-index`, []), `undefined element`);
// ./test/core/memory_grow.wast:378
assert_return(() => invoke($6, `as-local.set-value`, []), []);
// ./test/core/memory_grow.wast:379
assert_return(() => invoke($6, `as-local.tee-value`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:380
assert_return(() => invoke($6, `as-global.set-value`, []), []);
// ./test/core/memory_grow.wast:382
assert_return(() => invoke($6, `as-load-address`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:383
assert_return(() => invoke($6, `as-loadN-address`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:384
assert_return(() => invoke($6, `as-store-address`, []), []);
// ./test/core/memory_grow.wast:385
assert_return(() => invoke($6, `as-store-value`, []), []);
// ./test/core/memory_grow.wast:386
assert_return(() => invoke($6, `as-storeN-address`, []), []);
// ./test/core/memory_grow.wast:387
assert_return(() => invoke($6, `as-storeN-value`, []), []);
// ./test/core/memory_grow.wast:389
assert_return(() => invoke($6, `as-unary-operand`, []), [value("i32", 31)]);
// ./test/core/memory_grow.wast:391
assert_return(() => invoke($6, `as-binary-left`, []), [value("i32", 11)]);
// ./test/core/memory_grow.wast:392
assert_return(() => invoke($6, `as-binary-right`, []), [value("i32", 9)]);
// ./test/core/memory_grow.wast:394
assert_return(() => invoke($6, `as-test-operand`, []), [value("i32", 0)]);
// ./test/core/memory_grow.wast:396
assert_return(() => invoke($6, `as-compare-left`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:397
assert_return(() => invoke($6, `as-compare-right`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:399
assert_return(() => invoke($6, `as-memory.grow-size`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:404
let $7 = instantiate(`(module
(memory $$mem1 1)
(memory $$mem2 2)
(func (export "grow1") (param i32) (result i32)
(memory.grow $$mem1 (local.get 0))
)
(func (export "grow2") (param i32) (result i32)
(memory.grow $$mem2 (local.get 0))
)
(func (export "size1") (result i32) (memory.size $$mem1))
(func (export "size2") (result i32) (memory.size $$mem2))
)`);
// ./test/core/memory_grow.wast:419
assert_return(() => invoke($7, `size1`, []), [value("i32", 1)]);
// ./test/core/memory_grow.wast:420
assert_return(() => invoke($7, `size2`, []), [value("i32", 2)]);
// ./test/core/memory_grow.wast:421
assert_return(() => invoke($7, `grow1`, [3]), [value("i32", 1)]);
// ./test/core/memory_grow.wast:422
assert_return(() => invoke($7, `grow1`, [4]), [value("i32", 4)]);
// ./test/core/memory_grow.wast:423
assert_return(() => invoke($7, `grow1`, [1]), [value("i32", 8)]);
// ./test/core/memory_grow.wast:424
assert_return(() => invoke($7, `grow2`, [1]), [value("i32", 2)]);
// ./test/core/memory_grow.wast:425
assert_return(() => invoke($7, `grow2`, [1]), [value("i32", 3)]);
// ./test/core/memory_grow.wast:430
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-i32-vs-f32 (result i32)
(memory.grow (f32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:439
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32 (result i32)
(memory.grow)
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:448
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-block (result i32)
(i32.const 0)
(block (result i32) (memory.grow))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:458
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-loop (result i32)
(i32.const 0)
(loop (result i32) (memory.grow))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:468
assert_invalid(
() => instantiate(`(module
(memory 0)
(func $$type-size-empty-vs-i32-in-then (result i32)
(i32.const 0) (i32.const 0)
(if (result i32) (then (memory.grow)))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:479
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-result-i32-vs-empty
(memory.grow (i32.const 1))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:488
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-size-f32-vs-i32 (result i32)
(memory.grow (f32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:498
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-result-i32-vs-empty
(memory.grow (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/memory_grow.wast:507
assert_invalid(
() => instantiate(`(module
(memory 1)
(func $$type-result-i32-vs-f32 (result f32)
(memory.grow (i32.const 0))
)
)`),
`type mismatch`,
);

View File

@@ -1,295 +0,0 @@
// |jit-test| skip-if: !wasmSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/simd/simd_load.wast
// ./test/core/simd/simd_load.wast:3
let $0 = instantiate(`(module
(memory 1)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f\\00\\01\\02\\03")
(func (export "v128.load") (result v128)
(v128.load (i32.const 0))
)
)`);
// ./test/core/simd/simd_load.wast:11
assert_return(
() => invoke($0, `v128.load`, []),
[
i8x16([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf]),
],
);
// ./test/core/simd/simd_load.wast:12
assert_return(
() => invoke($0, `v128.load`, []),
[i16x8([0x100, 0x302, 0x504, 0x706, 0x908, 0xb0a, 0xd0c, 0xf0e])],
);
// ./test/core/simd/simd_load.wast:13
assert_return(() => invoke($0, `v128.load`, []), [i32x4([0x3020100, 0x7060504, 0xb0a0908, 0xf0e0d0c])]);
// ./test/core/simd/simd_load.wast:18
let $1 = instantiate(`(module (memory 1)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f\\00\\01\\02\\03")
(func (export "as-i8x16_extract_lane_s-value/0") (result i32)
(i8x16.extract_lane_s 0 (v128.load (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:24
assert_return(() => invoke($1, `as-i8x16_extract_lane_s-value/0`, []), [value("i32", 0)]);
// ./test/core/simd/simd_load.wast:26
let $2 = instantiate(`(module (memory 1)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f\\00\\01\\02\\03")
(func (export "as-i8x16.eq-operand") (result v128)
(i8x16.eq (v128.load offset=0 (i32.const 0)) (v128.load offset=16 (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:32
assert_return(() => invoke($2, `as-i8x16.eq-operand`, []), [i32x4([0xffffffff, 0x0, 0x0, 0x0])]);
// ./test/core/simd/simd_load.wast:34
let $3 = instantiate(`(module (memory 1)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f\\00\\01\\02\\03")
(func (export "as-v128.not-operand") (result v128)
(v128.not (v128.load (i32.const 0)))
)
(func (export "as-i8x16.all_true-operand") (result i32)
(i8x16.all_true (v128.load (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:43
assert_return(
() => invoke($3, `as-v128.not-operand`, []),
[i32x4([0xfcfdfeff, 0xf8f9fafb, 0xf4f5f6f7, 0xf0f1f2f3])],
);
// ./test/core/simd/simd_load.wast:44
assert_return(() => invoke($3, `as-i8x16.all_true-operand`, []), [value("i32", 0)]);
// ./test/core/simd/simd_load.wast:46
let $4 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA")
(data (offset (i32.const 16)) "\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB\\BB")
(data (offset (i32.const 32)) "\\F0\\F0\\F0\\F0\\FF\\FF\\FF\\FF\\00\\00\\00\\00\\FF\\00\\FF\\00")
(func (export "as-v128.bitselect-operand") (result v128)
(v128.bitselect (v128.load (i32.const 0)) (v128.load (i32.const 16)) (v128.load (i32.const 32)))
)
)`);
// ./test/core/simd/simd_load.wast:54
assert_return(
() => invoke($4, `as-v128.bitselect-operand`, []),
[i32x4([0xabababab, 0xaaaaaaaa, 0xbbbbbbbb, 0xbbaabbaa])],
);
// ./test/core/simd/simd_load.wast:56
let $5 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA")
(func (export "as-i8x16.shl-operand") (result v128)
(i8x16.shl (v128.load (i32.const 0)) (i32.const 1))
)
)`);
// ./test/core/simd/simd_load.wast:62
assert_return(
() => invoke($5, `as-i8x16.shl-operand`, []),
[i32x4([0x54545454, 0x54545454, 0x54545454, 0x54545454])],
);
// ./test/core/simd/simd_load.wast:64
let $6 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00")
(data (offset (i32.const 16)) "\\03\\00\\00\\00\\03\\00\\00\\00\\03\\00\\00\\00\\03\\00\\00\\00")
(func (export "as-add/sub-operand") (result v128)
;; 2 2 2 2 + 3 3 3 3 = 5 5 5 5
;; 5 5 5 5 - 3 3 3 3 = 2 2 2 2
(i8x16.sub
(i8x16.add (v128.load (i32.const 0)) (v128.load (i32.const 16)))
(v128.load (i32.const 16))
)
)
)`);
// ./test/core/simd/simd_load.wast:76
assert_return(() => invoke($6, `as-add/sub-operand`, []), [i32x4([0x2, 0x2, 0x2, 0x2])]);
// ./test/core/simd/simd_load.wast:78
let $7 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\00\\00\\00\\43\\00\\00\\80\\3f\\66\\66\\e6\\3f\\00\\00\\80\\bf") ;; 128 1.0 1.8 -1
(data (offset (i32.const 16)) "\\00\\00\\00\\40\\00\\00\\00\\40\\00\\00\\00\\40\\00\\00\\00\\40") ;; 2.0 2.0 2.0 2.0
(func (export "as-f32x4.mul-operand") (result v128)
(f32x4.mul (v128.load (i32.const 0)) (v128.load (i32.const 16)))
)
)`);
// ./test/core/simd/simd_load.wast:85
assert_return(
() => invoke($7, `as-f32x4.mul-operand`, []),
[
new F32x4Pattern(
value("f32", 256),
value("f32", 2),
value("f32", 3.6),
value("f32", -2),
),
],
);
// ./test/core/simd/simd_load.wast:87
let $8 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff\\ff") ;; 1111 ...
(func (export "as-f32x4.abs-operand") (result v128)
(f32x4.abs (v128.load (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:93
assert_return(
() => invoke($8, `as-f32x4.abs-operand`, []),
[i32x4([0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff])],
);
// ./test/core/simd/simd_load.wast:95
let $9 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA\\AA")
(data (offset (i32.const 16)) "\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00")
(func (export "as-f32x4.min-operand") (result v128)
(f32x4.min (v128.load (i32.const 0)) (v128.load offset=16 (i32.const 1)))
)
)`);
// ./test/core/simd/simd_load.wast:102
assert_return(
() => invoke($9, `as-f32x4.min-operand`, []),
[i32x4([0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa])],
);
// ./test/core/simd/simd_load.wast:104
let $10 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\00\\00\\00\\43\\00\\00\\80\\3f\\66\\66\\e6\\3f\\00\\00\\80\\bf") ;; 128 1.0 1.8 -1
(func (export "as-i32x4.trunc_sat_f32x4_s-operand") (result v128)
(i32x4.trunc_sat_f32x4_s (v128.load (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:110
assert_return(
() => invoke($10, `as-i32x4.trunc_sat_f32x4_s-operand`, []),
[i32x4([0x80, 0x1, 0x1, 0xffffffff])],
);
// ./test/core/simd/simd_load.wast:112
let $11 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00\\02\\00\\00\\00")
(func (export "as-f32x4.convert_i32x4_u-operand") (result v128)
(f32x4.convert_i32x4_u (v128.load (i32.const 0)))
)
)`);
// ./test/core/simd/simd_load.wast:118
assert_return(
() => invoke($11, `as-f32x4.convert_i32x4_u-operand`, []),
[
new F32x4Pattern(
value("f32", 2),
value("f32", 2),
value("f32", 2),
value("f32", 2),
),
],
);
// ./test/core/simd/simd_load.wast:120
let $12 = instantiate(`(module (memory 1)
(data (offset (i32.const 0)) "\\64\\65\\66\\67\\68\\69\\6a\\6b\\6c\\6d\\6e\\6f\\70\\71\\72\\73") ;; 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
(data (offset (i32.const 16)) "\\0f\\0e\\0d\\0c\\0b\\0a\\09\\08\\07\\06\\05\\04\\03\\02\\01\\00") ;; 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
(func (export "as-i8x16.swizzle-operand") (result v128)
(i8x16.swizzle (v128.load (i32.const 0)) (v128.load offset=15 (i32.const 1)))
)
)`);
// ./test/core/simd/simd_load.wast:127
assert_return(
() => invoke($12, `as-i8x16.swizzle-operand`, []),
[
i8x16([0x73, 0x72, 0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x66, 0x65, 0x64]),
],
);
// ./test/core/simd/simd_load.wast:129
let $13 = instantiate(`(module (memory 1)
(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f\\00\\01\\02\\03")
(func (export "as-br-value") (result v128)
(block (result v128) (br 0 (v128.load (i32.const 0))))
)
)`);
// ./test/core/simd/simd_load.wast:135
assert_return(() => invoke($13, `as-br-value`, []), [i32x4([0x3020100, 0x7060504, 0xb0a0908, 0xf0e0d0c])]);
// ./test/core/simd/simd_load.wast:140
assert_malformed(
() => instantiate(`(memory 1) (func (local v128) (drop (v128.load8 (i32.const 0)))) `),
`unknown operator`,
);
// ./test/core/simd/simd_load.wast:147
assert_malformed(
() => instantiate(`(memory 1) (func (local v128) (drop (v128.load16 (i32.const 0)))) `),
`unknown operator`,
);
// ./test/core/simd/simd_load.wast:154
assert_malformed(
() => instantiate(`(memory 1) (func (local v128) (drop (v128.load32 (i32.const 0)))) `),
`unknown operator`,
);
// ./test/core/simd/simd_load.wast:165
assert_invalid(
() => instantiate(`(module (memory 1) (func (local v128) (drop (v128.load (f32.const 0)))))`),
`type mismatch`,
);
// ./test/core/simd/simd_load.wast:169
assert_invalid(
() => instantiate(`(module (memory 1) (func (local v128) (block (br_if 0 (v128.load (i32.const 0))))))`),
`type mismatch`,
);
// ./test/core/simd/simd_load.wast:173
assert_invalid(
() => instantiate(`(module (memory 1) (func (local v128) (v128.load (i32.const 0))))`),
`type mismatch`,
);
// ./test/core/simd/simd_load.wast:181
assert_invalid(
() => instantiate(`(module (memory 1) (func (drop (v128.load (local.get 2)))))`),
`unknown local 2`,
);
// ./test/core/simd/simd_load.wast:185
assert_invalid(
() => instantiate(`(module (memory 1) (func (drop (v128.load))))`),
`type mismatch`,
);

View File

@@ -1,238 +0,0 @@
// |jit-test| skip-if: !wasmSimdEnabled()
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/simd/simd_store.wast
// ./test/core/simd/simd_store.wast:3
let $0 = instantiate(`(module
(memory 1)
(func (export "v128.store_i8x16") (result v128)
(v128.store (i32.const 0) (v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15))
(v128.load (i32.const 0))
)
(func (export "v128.store_i16x8") (result v128)
(v128.store (i32.const 0) (v128.const i16x8 0 1 2 3 4 5 6 7))
(v128.load (i32.const 0))
)
(func (export "v128.store_i16x8_2") (result v128)
(v128.store (i32.const 0) (v128.const i16x8 012_345 012_345 012_345 012_345 012_345 012_345 012_345 012_345))
(v128.load (i32.const 0))
)
(func (export "v128.store_i16x8_3") (result v128)
(v128.store (i32.const 0) (v128.const i16x8 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234 0x0_1234))
(v128.load (i32.const 0))
)
(func (export "v128.store_i32x4") (result v128)
(v128.store (i32.const 0) (v128.const i32x4 0 1 2 3))
(v128.load (i32.const 0))
)
(func (export "v128.store_i32x4_2") (result v128)
(v128.store (i32.const 0) (v128.const i32x4 0_123_456_789 0_123_456_789 0_123_456_789 0_123_456_789))
(v128.load (i32.const 0))
)
(func (export "v128.store_i32x4_3") (result v128)
(v128.store (i32.const 0) (v128.const i32x4 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678 0x0_1234_5678))
(v128.load (i32.const 0))
)
(func (export "v128.store_f32x4") (result v128)
(v128.store (i32.const 0) (v128.const f32x4 0 1 2 3))
(v128.load (i32.const 0))
)
)`);
// ./test/core/simd/simd_store.wast:40
assert_return(
() => invoke($0, `v128.store_i8x16`, []),
[
i8x16([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf]),
],
);
// ./test/core/simd/simd_store.wast:41
assert_return(() => invoke($0, `v128.store_i16x8`, []), [i16x8([0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7])]);
// ./test/core/simd/simd_store.wast:42
assert_return(
() => invoke($0, `v128.store_i16x8_2`, []),
[i16x8([0x3039, 0x3039, 0x3039, 0x3039, 0x3039, 0x3039, 0x3039, 0x3039])],
);
// ./test/core/simd/simd_store.wast:43
assert_return(
() => invoke($0, `v128.store_i16x8_3`, []),
[i16x8([0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234])],
);
// ./test/core/simd/simd_store.wast:44
assert_return(() => invoke($0, `v128.store_i32x4`, []), [i32x4([0x0, 0x1, 0x2, 0x3])]);
// ./test/core/simd/simd_store.wast:45
assert_return(
() => invoke($0, `v128.store_i32x4_2`, []),
[i32x4([0x75bcd15, 0x75bcd15, 0x75bcd15, 0x75bcd15])],
);
// ./test/core/simd/simd_store.wast:46
assert_return(
() => invoke($0, `v128.store_i32x4_3`, []),
[i32x4([0x12345678, 0x12345678, 0x12345678, 0x12345678])],
);
// ./test/core/simd/simd_store.wast:47
assert_return(
() => invoke($0, `v128.store_f32x4`, []),
[
new F32x4Pattern(
value("f32", 0),
value("f32", 1),
value("f32", 2),
value("f32", 3),
),
],
);
// ./test/core/simd/simd_store.wast:52
let $1 = instantiate(`(module
(memory 1)
(func (export "as-block-value")
(block (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)))
)
(func (export "as-loop-value")
(loop (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)))
)
(func (export "as-br-value")
(block (br 0 (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0))))
)
(func (export "as-br_if-value")
(block
(br_if 0 (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)) (i32.const 1))
)
)
(func (export "as-br_if-value-cond")
(block
(br_if 0 (i32.const 6) (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)))
)
)
(func (export "as-br_table-value")
(block
(br_table 0 (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)) (i32.const 1))
)
)
(func (export "as-return-value")
(return (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0)))
)
(func (export "as-if-then")
(if (i32.const 1) (then (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0))))
)
(func (export "as-if-else")
(if (i32.const 0) (then) (else (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0))))
)
)`);
// ./test/core/simd/simd_store.wast:89
assert_return(() => invoke($1, `as-block-value`, []), []);
// ./test/core/simd/simd_store.wast:90
assert_return(() => invoke($1, `as-loop-value`, []), []);
// ./test/core/simd/simd_store.wast:91
assert_return(() => invoke($1, `as-br-value`, []), []);
// ./test/core/simd/simd_store.wast:92
assert_return(() => invoke($1, `as-br_if-value`, []), []);
// ./test/core/simd/simd_store.wast:93
assert_return(() => invoke($1, `as-br_if-value-cond`, []), []);
// ./test/core/simd/simd_store.wast:94
assert_return(() => invoke($1, `as-br_table-value`, []), []);
// ./test/core/simd/simd_store.wast:95
assert_return(() => invoke($1, `as-return-value`, []), []);
// ./test/core/simd/simd_store.wast:96
assert_return(() => invoke($1, `as-if-then`, []), []);
// ./test/core/simd/simd_store.wast:97
assert_return(() => invoke($1, `as-if-else`, []), []);
// ./test/core/simd/simd_store.wast:102
assert_malformed(
() => instantiate(`(memory 1) (func (v128.store8 (i32.const 0) (v128.const i32x4 0 0 0 0))) `),
`unknown operator`,
);
// ./test/core/simd/simd_store.wast:109
assert_malformed(
() => instantiate(`(memory 1) (func (v128.store16 (i32.const 0) (v128.const i32x4 0 0 0 0))) `),
`unknown operator`,
);
// ./test/core/simd/simd_store.wast:116
assert_malformed(
() => instantiate(`(memory 1) (func (v128.store32 (i32.const 0) (v128.const i32x4 0 0 0 0))) `),
`unknown operator`,
);
// ./test/core/simd/simd_store.wast:127
assert_invalid(
() => instantiate(`(module (memory 1) (func (v128.store (f32.const 0) (v128.const i32x4 0 0 0 0))))`),
`type mismatch`,
);
// ./test/core/simd/simd_store.wast:131
assert_invalid(
() => instantiate(`(module (memory 1) (func (local v128) (block (br_if 0 (v128.store)))))`),
`type mismatch`,
);
// ./test/core/simd/simd_store.wast:135
assert_invalid(
() => instantiate(`(module (memory 1) (func (result v128) (v128.store (i32.const 0) (v128.const i32x4 0 0 0 0))))`),
`type mismatch`,
);
// ./test/core/simd/simd_store.wast:143
assert_invalid(
() => instantiate(`(module (memory 0)
(func $$v128.store-1st-arg-empty
(v128.store (v128.const i32x4 0 0 0 0))
)
)`),
`type mismatch`,
);
// ./test/core/simd/simd_store.wast:151
assert_invalid(
() => instantiate(`(module (memory 0)
(func $$v128.store-2nd-arg-empty
(v128.store (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/simd/simd_store.wast:159
assert_invalid(
() => instantiate(`(module (memory 0)
(func $$v128.store-arg-empty
(v128.store)
)
)`),
`type mismatch`,
);

View File

@@ -1 +0,0 @@
|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled()

View File

@@ -1 +0,0 @@
|jit-test| skip-if: true

View File

@@ -1,445 +0,0 @@
"use strict";
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
if (!wasmIsSupported()) {
quit();
}
function bytes(type, bytes) {
var typedBuffer = new Uint8Array(bytes);
return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer);
}
function value(type, value) {
return new WebAssembly.Global({
value: type,
mutable: false,
}, value);
}
function i8x16(elements) {
let typedBuffer = new Uint8Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i16x8(elements) {
let typedBuffer = new Uint16Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i32x4(elements) {
let typedBuffer = new Uint32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function i64x2(elements) {
let typedBuffer = new BigUint64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f32x4(elements) {
let typedBuffer = new Float32Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function f64x2(elements) {
let typedBuffer = new Float64Array(elements);
return wasmGlobalFromArrayBuffer("v128", typedBuffer.buffer);
}
function either(...arr) {
return new EitherVariants(arr);
}
class F32x4Pattern {
constructor(x, y, z, w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
}
}
class F64x2Pattern {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class RefWithType {
constructor(type) {
this.type = type;
}
formatExpected() {
return `RefWithType(${this.type})`;
}
test(refGlobal) {
try {
new WebAssembly.Global({value: this.type}, refGlobal.value);
return true;
} catch (err) {
assertEq(err instanceof TypeError, true, `wrong type of error when creating global: ${err}`);
assertEq(!!err.message.match(/can only pass/), true, `wrong type of error when creating global: ${err}`);
return false;
}
}
}
// ref.extern values created by spec tests will be JS objects of the form
// { [externsym]: <number> }. Other externref values are possible to observe
// if extern.convert_any is used.
let externsym = Symbol("externref");
function externref(s) {
return { [externsym]: s };
}
function is_externref(x) {
return (x !== null && externsym in x) ? 1 : 0;
}
function is_funcref(x) {
return typeof x === "function" ? 1 : 0;
}
function eq_externref(x, y) {
return x === y ? 1 : 0;
}
function eq_funcref(x, y) {
return x === y ? 1 : 0;
}
class ExternRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.extern ${this.n}`;
}
test(global) {
// the global's value can either be an externref or just a plain old JS number
let result = global.value;
if (typeof global.value === "object" && externsym in global.value) {
result = global.value[externsym];
}
return result === this.n;
}
}
// ref.host values created by spectests will be whatever the JS API does to
// convert the given value to anyref. It should implicitly be like any.convert_extern.
function hostref(v) {
const { internalizeNum } = new WebAssembly.Instance(
new WebAssembly.Module(wasmTextToBinary(`(module
(func (import "test" "coerce") (param i32) (result anyref))
(func (export "internalizeNum") (param i32) (result anyref)
(call 0 (local.get 0))
)
)`)),
{ "test": { "coerce": x => x } },
).exports;
return internalizeNum(v);
}
class HostRefResult {
constructor(n) {
this.n = n;
}
formatExpected() {
return `ref.host ${this.n}`;
}
test(externrefGlobal) {
assertEq(externsym in externrefGlobal.value, true, `HostRefResult only works with externref inputs`);
return externrefGlobal.value[externsym] === this.n;
}
}
let spectest = {
externref: externref,
is_externref: is_externref,
is_funcref: is_funcref,
eq_externref: eq_externref,
eq_funcref: eq_funcref,
print: console.log.bind(console),
print_i32: console.log.bind(console),
print_i32_f32: console.log.bind(console),
print_f64_f64: console.log.bind(console),
print_f32: console.log.bind(console),
print_f64: console.log.bind(console),
global_i32: 666,
global_i64: 666n,
global_f32: 666,
global_f64: 666,
table: new WebAssembly.Table({
initial: 10,
maximum: 20,
element: "anyfunc",
}),
memory: new WebAssembly.Memory({ initial: 1, maximum: 2 }),
};
let linkage = {
spectest,
};
function getInstance(instanceish) {
if (typeof instanceish === "string") {
assertEq(
instanceish in linkage,
true,
`'${instanceish}'' must be registered`,
);
return linkage[instanceish];
}
return instanceish;
}
function instantiate(source) {
let bytecode = wasmTextToBinary(source);
let module = new WebAssembly.Module(bytecode);
let instance = new WebAssembly.Instance(module, linkage);
return instance.exports;
}
function register(instanceish, name) {
linkage[name] = getInstance(instanceish);
}
function invoke(instanceish, field, params) {
let func = getInstance(instanceish)[field];
assertEq(func instanceof Function, true, "expected a function");
return wasmLosslessInvoke(func, ...params);
}
function get(instanceish, field) {
let global = getInstance(instanceish)[field];
assertEq(
global instanceof WebAssembly.Global,
true,
"expected a WebAssembly.Global",
);
return global;
}
function assert_trap(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.RuntimeError) {
return;
}
err.message = `expected trap (${message}): ${err.message}`;
throw err;
}
}
let StackOverflow;
try {
(function f() {
1 + f();
})();
} catch (e) {
StackOverflow = e.constructor;
}
function assert_exhaustion(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof StackOverflow) {
return;
}
err.message = `expected exhaustion (${message}): ${err.message}`;
throw err;
}
}
function assert_invalid(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected invalid module (${message}): ${err.message}`;
throw err;
}
}
function assert_unlinkable(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (err instanceof WebAssembly.LinkError || err instanceof WebAssembly.CompileError) {
return;
}
err.message = `expected an unlinkable module (${message}): ${err.message}`;
throw err;
}
}
function assert_malformed(thunk, message) {
try {
thunk();
throw new Error(`got no error`);
} catch (err) {
if (
err instanceof TypeError ||
err instanceof SyntaxError ||
err instanceof WebAssembly.CompileError ||
err instanceof WebAssembly.LinkError
) {
return;
}
err.message = `expected a malformed module (${message}): ${err.message}`;
throw err;
}
}
function assert_exception(thunk) {
let thrown = false;
try {
thunk();
} catch (err) {
thrown = true;
}
assertEq(thrown, true, "expected an exception to be thrown");
}
function assert_return(thunk, expected) {
let results = thunk();
if (results === undefined) {
results = [];
} else if (!Array.isArray(results)) {
results = [results];
}
if (!Array.isArray(expected)) {
expected = [expected];
}
if (!compareResults(results, expected)) {
let got = results.map((x) => formatResult(x)).join(", ");
let wanted = expected.map((x) => formatExpected(x)).join(", ");
assertEq(
`[${got}]`,
`[${wanted}]`,
);
assertEq(true, false, `${got} !== ${wanted}`);
}
}
function formatResult(result) {
if (typeof (result) === "object") {
return wasmGlobalToString(result);
} else {
return `${result}`;
}
}
function formatExpected(expected) {
if (
expected === `f32_canonical_nan` ||
expected === `f32_arithmetic_nan` ||
expected === `f64_canonical_nan` ||
expected === `f64_arithmetic_nan`
) {
return expected;
} else if (expected instanceof F32x4Pattern) {
return `f32x4(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
}, ${formatExpected(expected.z)}, ${formatExpected(expected.w)})`;
} else if (expected instanceof F64x2Pattern) {
return `f64x2(${formatExpected(expected.x)}, ${
formatExpected(expected.y)
})`;
} else if (expected instanceof EitherVariants) {
return expected.formatExpected();
} else if (expected instanceof RefWithType) {
return expected.formatExpected();
} else if (expected instanceof ExternRefResult) {
return expected.formatExpected();
} else if (expected instanceof HostRefResult) {
return expected.formatExpected();
} else if (typeof (expected) === "object") {
return wasmGlobalToString(expected);
} else {
throw new Error("unknown expected result");
}
}
class EitherVariants {
constructor(arr) {
this.arr = arr;
}
matches(v) {
return this.arr.some((e) => compareResult(v, e));
}
formatExpected() {
return `either(${this.arr.map(formatExpected).join(", ")})`;
}
}
function compareResults(results, expected) {
if (results.length !== expected.length) {
return false;
}
for (let i in results) {
if (expected[i] instanceof EitherVariants) {
return expected[i].matches(results[i]);
}
if (!compareResult(results[i], expected[i])) {
return false;
}
}
return true;
}
function compareResult(result, expected) {
if (
expected === `canonical_nan` ||
expected === `arithmetic_nan`
) {
return wasmGlobalIsNaN(result, expected);
} else if (expected === null) {
return result.value === null;
} else if (expected instanceof F32x4Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f32x4", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 1), expected.y) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 2), expected.z) &&
compareResult(wasmGlobalExtractLane(result, "f32x4", 3), expected.w);
} else if (expected instanceof F64x2Pattern) {
return compareResult(
wasmGlobalExtractLane(result, "f64x2", 0),
expected.x,
) &&
compareResult(wasmGlobalExtractLane(result, "f64x2", 1), expected.y);
} else if (expected instanceof RefWithType) {
return expected.test(result);
} else if (expected instanceof ExternRefResult) {
return expected.test(result);
} else if (expected instanceof HostRefResult) {
return expected.test(result);
} else if (typeof (expected) === "object") {
return wasmGlobalsEqual(result, expected);
} else {
throw new Error("unknown expected result");
}
}

View File

@@ -0,0 +1,171 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/gc/array_init_data.wast
// ./test/core/gc/array_init_data.wast:5
assert_invalid(
() => instantiate(`(module
(type $$a (array i8))
(data $$d1 "a")
(func (export "array.init_data-immutable") (param $$1 (ref $$a))
(array.init_data $$a $$d1 (local.get $$1) (i32.const 0) (i32.const 0) (i32.const 0))
)
)`),
`array is immutable`,
);
// ./test/core/gc/array_init_data.wast:18
assert_invalid(
() => instantiate(`(module
(type $$a (array (mut funcref)))
(data $$d1 "a")
(func (export "array.init_data-invalid-1") (param $$1 (ref $$a))
(array.init_data $$a $$d1 (local.get $$1) (i32.const 0) (i32.const 0) (i32.const 0))
)
)`),
`array type is not numeric or vector`,
);
// ./test/core/gc/array_init_data.wast:31
let $0 = instantiate(`(module
(type $$arr8 (array i8))
(type $$arr8_mut (array (mut i8)))
(type $$arr16_mut (array (mut i16)))
(global $$g_arr8 (ref $$arr8) (array.new $$arr8 (i32.const 10) (i32.const 12)))
(global $$g_arr8_mut (mut (ref $$arr8_mut)) (array.new_default $$arr8_mut (i32.const 12)))
(global $$g_arr16_mut (ref $$arr16_mut) (array.new_default $$arr16_mut (i32.const 6)))
(data $$d1 "abcdefghijkl")
(func (export "array_get_nth") (param $$1 i32) (result i32)
(array.get_u $$arr8_mut (global.get $$g_arr8_mut) (local.get $$1))
)
(func (export "array_get_nth_i16") (param $$1 i32) (result i32)
(array.get_u $$arr16_mut (global.get $$g_arr16_mut) (local.get $$1))
)
(func (export "array_init_data-null")
(array.init_data $$arr8_mut $$d1 (ref.null $$arr8_mut) (i32.const 0) (i32.const 0) (i32.const 0))
)
(func (export "array_init_data") (param $$1 i32) (param $$2 i32) (param $$3 i32)
(array.init_data $$arr8_mut $$d1 (global.get $$g_arr8_mut) (local.get $$1) (local.get $$2) (local.get $$3))
)
(func (export "array_init_data_i16") (param $$1 i32) (param $$2 i32) (param $$3 i32)
(array.init_data $$arr16_mut $$d1 (global.get $$g_arr16_mut) (local.get $$1) (local.get $$2) (local.get $$3))
)
(func (export "drop_segs")
(data.drop $$d1)
)
)`);
// ./test/core/gc/array_init_data.wast:68
assert_trap(() => invoke($0, `array_init_data-null`, []), `null array reference`);
// ./test/core/gc/array_init_data.wast:71
assert_trap(() => invoke($0, `array_init_data`, [13, 0, 0]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:72
assert_trap(() => invoke($0, `array_init_data`, [0, 13, 0]), `out of bounds memory access`);
// ./test/core/gc/array_init_data.wast:75
assert_trap(() => invoke($0, `array_init_data`, [0, 0, 13]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:76
assert_trap(() => invoke($0, `array_init_data`, [0, 0, 13]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:77
assert_trap(() => invoke($0, `array_init_data_i16`, [0, 0, 7]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:80
assert_return(() => invoke($0, `array_init_data`, [12, 0, 0]), []);
// ./test/core/gc/array_init_data.wast:81
assert_return(() => invoke($0, `array_init_data`, [0, 12, 0]), []);
// ./test/core/gc/array_init_data.wast:82
assert_return(() => invoke($0, `array_init_data_i16`, [0, 6, 0]), []);
// ./test/core/gc/array_init_data.wast:85
assert_return(() => invoke($0, `array_get_nth`, [0]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:86
assert_return(() => invoke($0, `array_get_nth`, [5]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:87
assert_return(() => invoke($0, `array_get_nth`, [11]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:88
assert_trap(() => invoke($0, `array_get_nth`, [12]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:89
assert_return(() => invoke($0, `array_get_nth_i16`, [0]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:90
assert_return(() => invoke($0, `array_get_nth_i16`, [2]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:91
assert_return(() => invoke($0, `array_get_nth_i16`, [5]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:92
assert_trap(() => invoke($0, `array_get_nth_i16`, [6]), `out of bounds array access`);
// ./test/core/gc/array_init_data.wast:95
assert_return(() => invoke($0, `array_init_data`, [4, 2, 2]), []);
// ./test/core/gc/array_init_data.wast:96
assert_return(() => invoke($0, `array_get_nth`, [3]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:97
assert_return(() => invoke($0, `array_get_nth`, [4]), [value("i32", 99)]);
// ./test/core/gc/array_init_data.wast:98
assert_return(() => invoke($0, `array_get_nth`, [5]), [value("i32", 100)]);
// ./test/core/gc/array_init_data.wast:99
assert_return(() => invoke($0, `array_get_nth`, [6]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:101
assert_return(() => invoke($0, `array_init_data_i16`, [2, 5, 2]), []);
// ./test/core/gc/array_init_data.wast:102
assert_return(() => invoke($0, `array_get_nth_i16`, [1]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:103
assert_return(() => invoke($0, `array_get_nth_i16`, [2]), [value("i32", 26470)]);
// ./test/core/gc/array_init_data.wast:104
assert_return(() => invoke($0, `array_get_nth_i16`, [3]), [value("i32", 26984)]);
// ./test/core/gc/array_init_data.wast:105
assert_return(() => invoke($0, `array_get_nth_i16`, [4]), [value("i32", 0)]);
// ./test/core/gc/array_init_data.wast:108
assert_return(() => invoke($0, `drop_segs`, []), []);
// ./test/core/gc/array_init_data.wast:109
assert_return(() => invoke($0, `array_init_data`, [0, 0, 0]), []);
// ./test/core/gc/array_init_data.wast:110
assert_trap(() => invoke($0, `array_init_data`, [0, 0, 1]), `out of bounds memory access`);

View File

@@ -0,0 +1,149 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/gc/array_init_elem.wast
// ./test/core/gc/array_init_elem.wast:5
assert_invalid(
() => instantiate(`(module
(type $$a (array funcref))
(elem $$e1 funcref)
(func (export "array.init_elem-immutable") (param $$1 (ref $$a))
(array.init_elem $$a $$e1 (local.get $$1) (i32.const 0) (i32.const 0) (i32.const 0))
)
)`),
`array is immutable`,
);
// ./test/core/gc/array_init_elem.wast:18
assert_invalid(
() => instantiate(`(module
(type $$a (array (mut i8)))
(elem $$e1 funcref)
(func (export "array.init_elem-invalid-1") (param $$1 (ref $$a))
(array.init_elem $$a $$e1 (local.get $$1) (i32.const 0) (i32.const 0) (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/gc/array_init_elem.wast:31
assert_invalid(
() => instantiate(`(module
(type $$a (array (mut funcref)))
(elem $$e1 externref)
(func (export "array.init_elem-invalid-2") (param $$1 (ref $$a))
(array.init_elem $$a $$e1 (local.get $$1) (i32.const 0) (i32.const 0) (i32.const 0))
)
)`),
`type mismatch`,
);
// ./test/core/gc/array_init_elem.wast:44
let $0 = instantiate(`(module
(type $$t_f (func))
(type $$arrref (array (ref $$t_f)))
(type $$arrref_mut (array (mut funcref)))
(global $$g_arrref (ref $$arrref) (array.new $$arrref (ref.func $$dummy) (i32.const 12)))
(global $$g_arrref_mut (ref $$arrref_mut) (array.new_default $$arrref_mut (i32.const 12)))
(table $$t 1 funcref)
(elem $$e1 func $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy $$dummy)
(func $$dummy
)
(func (export "array_call_nth") (param $$1 i32)
(table.set $$t (i32.const 0) (array.get $$arrref_mut (global.get $$g_arrref_mut) (local.get $$1)))
(call_indirect $$t (i32.const 0))
)
(func (export "array_init_elem-null")
(array.init_elem $$arrref_mut $$e1 (ref.null $$arrref_mut) (i32.const 0) (i32.const 0) (i32.const 0))
)
(func (export "array_init_elem") (param $$1 i32) (param $$2 i32) (param $$3 i32)
(array.init_elem $$arrref_mut $$e1 (global.get $$g_arrref_mut) (local.get $$1) (local.get $$2) (local.get $$3))
)
(func (export "drop_segs")
(elem.drop $$e1)
)
)`);
// ./test/core/gc/array_init_elem.wast:78
assert_trap(() => invoke($0, `array_init_elem-null`, []), `null array reference`);
// ./test/core/gc/array_init_elem.wast:81
assert_trap(() => invoke($0, `array_init_elem`, [13, 0, 0]), `out of bounds array access`);
// ./test/core/gc/array_init_elem.wast:82
assert_trap(() => invoke($0, `array_init_elem`, [0, 13, 0]), `out of bounds table access`);
// ./test/core/gc/array_init_elem.wast:85
assert_trap(() => invoke($0, `array_init_elem`, [0, 0, 13]), `out of bounds array access`);
// ./test/core/gc/array_init_elem.wast:86
assert_trap(() => invoke($0, `array_init_elem`, [0, 0, 13]), `out of bounds array access`);
// ./test/core/gc/array_init_elem.wast:89
assert_return(() => invoke($0, `array_init_elem`, [12, 0, 0]), []);
// ./test/core/gc/array_init_elem.wast:90
assert_return(() => invoke($0, `array_init_elem`, [0, 12, 0]), []);
// ./test/core/gc/array_init_elem.wast:93
assert_trap(() => invoke($0, `array_call_nth`, [0]), `uninitialized element`);
// ./test/core/gc/array_init_elem.wast:94
assert_trap(() => invoke($0, `array_call_nth`, [5]), `uninitialized element`);
// ./test/core/gc/array_init_elem.wast:95
assert_trap(() => invoke($0, `array_call_nth`, [11]), `uninitialized element`);
// ./test/core/gc/array_init_elem.wast:96
assert_trap(() => invoke($0, `array_call_nth`, [12]), `out of bounds array access`);
// ./test/core/gc/array_init_elem.wast:99
assert_return(() => invoke($0, `array_init_elem`, [2, 3, 2]), []);
// ./test/core/gc/array_init_elem.wast:100
assert_trap(() => invoke($0, `array_call_nth`, [1]), `uninitialized element`);
// ./test/core/gc/array_init_elem.wast:101
assert_return(() => invoke($0, `array_call_nth`, [2]), []);
// ./test/core/gc/array_init_elem.wast:102
assert_return(() => invoke($0, `array_call_nth`, [3]), []);
// ./test/core/gc/array_init_elem.wast:103
assert_trap(() => invoke($0, `array_call_nth`, [4]), `uninitialized element`);
// ./test/core/gc/array_init_elem.wast:106
assert_return(() => invoke($0, `drop_segs`, []), []);
// ./test/core/gc/array_init_elem.wast:107
assert_return(() => invoke($0, `array_init_elem`, [0, 0, 0]), []);
// ./test/core/gc/array_init_elem.wast:108
assert_trap(() => invoke($0, `array_init_elem`, [0, 0, 1]), `out of bounds table access`);

View File

@@ -884,3 +884,18 @@ assert_invalid(
() => instantiate(`(module (func $$large-label (br_if 0x10000001 (i32.const 1))))`),
`unknown label`,
);
// ./test/core/br_if.wast:667
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param (ref null $$t)) (result funcref) (local.get 0))
(func (result funcref)
(ref.null $$t)
(i32.const 0)
(br_if 0) ;; only leaves funcref on the stack
(call $$f)
)
)`),
`type mismatch`,
);

View File

@@ -335,3 +335,20 @@ assert_invalid(
)`),
`type mismatch`,
);
// ./test/core/gc/br_on_cast.wast:271
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param (ref null $$t)) (result funcref) (local.get 0))
(func (param funcref) (result funcref funcref)
(ref.null $$t)
(local.get 0)
(br_on_cast 0 funcref (ref $$t)) ;; only leaves two funcref's on the stack
(drop)
(call $$f)
(local.get 0)
)
)`),
`type mismatch`,
);

View File

@@ -350,3 +350,20 @@ assert_invalid(
)`),
`type mismatch`,
);
// ./test/core/gc/br_on_cast_fail.wast:286
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param (ref null $$t)) (result funcref) (local.get 0))
(func (param funcref) (result funcref funcref)
(ref.null $$t)
(local.get 0)
(br_on_cast_fail 0 funcref (ref $$t)) ;; only leaves two funcref's on the stack
(drop)
(call $$f)
(local.get 0)
)
)`),
`type mismatch`,
);

View File

@@ -99,3 +99,19 @@ assert_return(() => invoke($2, `args-null`, [3]), [value("i32", 3)]);
// ./test/core/br_on_non_null.wast:73
assert_return(() => invoke($2, `args-f`, [3]), [value("i32", 9)]);
// ./test/core/br_on_non_null.wast:77
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param (ref null $$t)) (result funcref) (local.get 0))
(func (param funcref) (result funcref funcref)
(ref.null $$t)
(local.get 0)
(br_on_non_null 0) ;; only leaves a funcref on the stack
(call $$f)
(local.get 0)
)
)`),
`type mismatch`,
);

View File

@@ -92,3 +92,19 @@ assert_return(() => invoke($2, `args-null`, [3]), [value("i32", 3)]);
// ./test/core/br_on_null.wast:66
assert_return(() => invoke($2, `args-f`, [3]), [value("i32", 9)]);
// ./test/core/br_on_null.wast:81
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param (ref null $$t)) (result funcref) (local.get 0))
(func (param funcref) (result funcref)
(ref.null $$t)
(local.get 0)
(br_on_null 0) ;; only leaves two funcref's on the stack
(drop)
(call $$f)
)
)`),
`type mismatch`,
);

View File

@@ -116,7 +116,7 @@ assert_return(() => invoke($0, `run`, [0]), [value("i32", 0)]);
assert_return(() => invoke($0, `run`, [3]), [value("i32", -9)]);
// ./test/core/call_ref.wast:97
assert_trap(() => invoke($0, `null`, []), `null function`);
assert_trap(() => invoke($0, `null`, []), `null function reference`);
// ./test/core/call_ref.wast:99
assert_return(() => invoke($0, `fac`, [0n]), [value("i64", 1n)]);
@@ -273,3 +273,14 @@ assert_invalid(
)`),
`type mismatch`,
);
// ./test/core/call_ref.wast:210
assert_invalid(
() => instantiate(`(module
(type $$t (func))
(func $$f (param $$r funcref)
(call_ref $$t (local.get $$r))
)
)`),
`type mismatch`,
);

View File

@@ -19,16 +19,33 @@
let $0 = instantiate(`(module;;comment
)`);
// ./test/core/comments.wast:56:11
// ./test/core/comments.wast:57:11
let $1 = instantiate(`(module(;comment;)
(;comment;))`);
// ./test/core/comments.wast:66
// ./test/core/comments.wast:67
let $2 = instantiate(`(module
(;comment(;nested(;further;)nested;)comment;)
)`);
// ./test/core/comments.wast:75
// ./test/core/comments.wast:76
let $3 = instantiate(`(module
(;comment;;comment(;nested;)comment;)
)`);
// ./test/core/comments.wast:83:8
let $4 = instantiate(`(func (export "f1") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) (func (export "f2") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) (func (export "f3") (result i32) (i32.const 1) ;; comment
(return (i32.const 2))
) `);
// ./test/core/comments.wast:104
assert_return(() => invoke($4, `f1`, []), [value("i32", 2)]);
// ./test/core/comments.wast:105
assert_return(() => invoke($4, `f2`, []), [value("i32", 2)]);
// ./test/core/comments.wast:106

View File

@@ -0,0 +1,582 @@
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// ./test/core/data.wast
// ./test/core/data.wast:5
let $0 = instantiate(`(module
(memory $$m 1)
(data (i32.const 0))
(data (i32.const 1) "a" "" "bcd")
(data (offset (i32.const 0)))
(data (offset (i32.const 0)) "" "a" "bc" "")
(data (memory 0) (i32.const 0))
(data (memory 0x0) (i32.const 1) "a" "" "bcd")
(data (memory 0x000) (offset (i32.const 0)))
(data (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
(data (memory $$m) (i32.const 0))
(data (memory $$m) (i32.const 1) "a" "" "bcd")
(data (memory $$m) (offset (i32.const 0)))
(data (memory $$m) (offset (i32.const 0)) "" "a" "bc" "")
(data $$d1 (i32.const 0))
(data $$d2 (i32.const 1) "a" "" "bcd")
(data $$d3 (offset (i32.const 0)))
(data $$d4 (offset (i32.const 0)) "" "a" "bc" "")
(data $$d5 (memory 0) (i32.const 0))
(data $$d6 (memory 0x0) (i32.const 1) "a" "" "bcd")
(data $$d7 (memory 0x000) (offset (i32.const 0)))
(data $$d8 (memory 0) (offset (i32.const 0)) "" "a" "bc" "")
(data $$d9 (memory $$m) (i32.const 0))
(data $$d10 (memory $$m) (i32.const 1) "a" "" "bcd")
(data $$d11 (memory $$m) (offset (i32.const 0)))
(data $$d12 (memory $$m) (offset (i32.const 0)) "" "a" "bc" "")
)`);
// ./test/core/data.wast:36
let $1 = instantiate(`(module
(memory 1)
(data (i32.const 0) "a")
)`);
// ./test/core/data.wast:40
let $2 = instantiate(`(module
(import "spectest" "memory" (memory 1))
(data (i32.const 0) "a")
)`);
// ./test/core/data.wast:45
let $3 = instantiate(`(module
(memory 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")
)`);
// ./test/core/data.wast:53
let $4 = instantiate(`(module
(import "spectest" "memory" (memory 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")
)`);
// ./test/core/data.wast:63
let $5 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(memory 1)
(data (global.get 0) "a")
)`);
// ./test/core/data.wast:68
let $6 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(import "spectest" "memory" (memory 1))
(data (global.get 0) "a")
)`);
// ./test/core/data.wast:74
let $7 = instantiate(`(module
(global $$g (import "spectest" "global_i32") i32)
(memory 1)
(data (global.get $$g) "a")
)`);
// ./test/core/data.wast:79
let $8 = instantiate(`(module
(global $$g (import "spectest" "global_i32") i32)
(import "spectest" "memory" (memory 1))
(data (global.get $$g) "a")
)`);
// ./test/core/data.wast:85
let $9 = instantiate(`(module (memory 1) (global i32 (i32.const 0)) (data (global.get 0) "a"))`);
// ./test/core/data.wast:86
let $10 = instantiate(`(module (memory 1) (global $$g i32 (i32.const 0)) (data (global.get $$g) "a"))`);
// ./test/core/data.wast:91
let $11 = instantiate(`(module
(memory 1)
(data (i32.const 0) "a")
(data (i32.const 0xffff) "b")
)`);
// ./test/core/data.wast:96
let $12 = instantiate(`(module
(import "spectest" "memory" (memory 1))
(data (i32.const 0) "a")
(data (i32.const 0xffff) "b")
)`);
// ./test/core/data.wast:102
let $13 = instantiate(`(module
(memory 2)
(data (i32.const 0x1_ffff) "a")
)`);
// ./test/core/data.wast:107
let $14 = instantiate(`(module
(memory 0)
(data (i32.const 0))
)`);
// ./test/core/data.wast:111
let $15 = instantiate(`(module
(import "spectest" "memory" (memory 0))
(data (i32.const 0))
)`);
// ./test/core/data.wast:116
let $16 = instantiate(`(module
(memory 0 0)
(data (i32.const 0))
)`);
// ./test/core/data.wast:121
let $17 = instantiate(`(module
(memory 1)
(data (i32.const 0x1_0000) "")
)`);
// ./test/core/data.wast:126
let $18 = instantiate(`(module
(memory 0)
(data (i32.const 0) "" "")
)`);
// ./test/core/data.wast:130
let $19 = instantiate(`(module
(import "spectest" "memory" (memory 0))
(data (i32.const 0) "" "")
)`);
// ./test/core/data.wast:135
let $20 = instantiate(`(module
(memory 0 0)
(data (i32.const 0) "" "")
)`);
// ./test/core/data.wast:140
let $21 = instantiate(`(module
(import "spectest" "memory" (memory 0))
(data (i32.const 0) "a")
)`);
// ./test/core/data.wast:145
let $22 = instantiate(`(module
(import "spectest" "memory" (memory 0 3))
(data (i32.const 0) "a")
)`);
// ./test/core/data.wast:150
let $23 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(import "spectest" "memory" (memory 0))
(data (global.get 0) "a")
)`);
// ./test/core/data.wast:156
let $24 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(import "spectest" "memory" (memory 0 3))
(data (global.get 0) "a")
)`);
// ./test/core/data.wast:162
let $25 = instantiate(`(module
(import "spectest" "memory" (memory 0))
(data (i32.const 1) "a")
)`);
// ./test/core/data.wast:167
let $26 = instantiate(`(module
(import "spectest" "memory" (memory 0 3))
(data (i32.const 1) "a")
)`);
// ./test/core/data.wast:174
let $27 = instantiate(`(module
(memory 1)
(data (i32.add (i32.const 0) (i32.const 42)))
)`);
// ./test/core/data.wast:179
let $28 = instantiate(`(module
(memory 1)
(data (i32.sub (i32.const 42) (i32.const 0)))
)`);
// ./test/core/data.wast:184
let $29 = instantiate(`(module
(memory 1)
(data (i32.mul (i32.const 1) (i32.const 2)))
)`);
// ./test/core/data.wast:191
let $30 = instantiate(`(module
(global (import "spectest" "global_i32") i32)
(memory 1)
(data (i32.mul
(i32.const 2)
(i32.add
(i32.sub (global.get 0) (i32.const 1))
(i32.const 2)
)
)
)
)`);
// ./test/core/data.wast:206
assert_trap(
() => instantiate(`(module
(memory 0)
(data (i32.const 0) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:214
assert_trap(
() => instantiate(`(module
(memory 0 0)
(data (i32.const 0) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:222
assert_trap(
() => instantiate(`(module
(memory 0 1)
(data (i32.const 0) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:229
assert_trap(
() => instantiate(`(module
(memory 0)
(data (i32.const 1))
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:236
assert_trap(
() => instantiate(`(module
(memory 0 1)
(data (i32.const 1))
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:253
assert_trap(
() => instantiate(`(module
(global (import "spectest" "global_i32") i32)
(memory 0)
(data (global.get 0) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:262
assert_trap(
() => instantiate(`(module
(memory 1 2)
(data (i32.const 0x1_0000) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:269
assert_trap(
() => instantiate(`(module
(import "spectest" "memory" (memory 1))
(data (i32.const 0x1_0000) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:277
assert_trap(
() => instantiate(`(module
(memory 2)
(data (i32.const 0x2_0000) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:285
assert_trap(
() => instantiate(`(module
(memory 2 3)
(data (i32.const 0x2_0000) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:293
assert_trap(
() => instantiate(`(module
(memory 1)
(data (i32.const -1) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:300
assert_trap(
() => instantiate(`(module
(import "spectest" "memory" (memory 1))
(data (i32.const -1) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:308
assert_trap(
() => instantiate(`(module
(memory 2)
(data (i32.const -100) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:315
assert_trap(
() => instantiate(`(module
(import "spectest" "memory" (memory 1))
(data (i32.const -100) "a")
)`),
`out of bounds memory access`,
);
// ./test/core/data.wast:325
assert_invalid(
() => instantiate(`(module
(data (i32.const 0) "")
)`),
`unknown memory`,
);
// ./test/core/data.wast:333
assert_invalid(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\03\\01" ;; memory section
"\\00\\00" ;; memory 0
"\\0b\\07\\01" ;; data section
"\\02\\01\\41\\00\\0b" ;; active data segment 0 for memory 1
"\\00" ;; empty vec(byte)
)`),
`unknown memory 1`,
);
// ./test/core/data.wast:346
assert_invalid(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\0b\\06\\01" ;; data section
"\\00\\41\\00\\0b" ;; active data segment 0 for memory 0
"\\00" ;; empty vec(byte)
)`),
`unknown memory 0`,
);
// ./test/core/data.wast:357
assert_invalid(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\0b\\07\\01" ;; data section
"\\02\\01\\41\\00\\0b" ;; active data segment 0 for memory 1
"\\00" ;; empty vec(byte)
)`),
`unknown memory 1`,
);
// ./test/core/data.wast:369
assert_invalid(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\05\\03\\01" ;; memory section
"\\00\\00" ;; memory 0
"\\0b\\45\\01" ;; data section
"\\02" ;; active segment
"\\01" ;; memory index
"\\41\\00\\0b" ;; offset constant expression
"\\3e" ;; vec(byte) length
"\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f"
"\\10\\11\\12\\13\\14\\15\\16\\17\\18\\19\\1a\\1b\\1c\\1d\\1e\\1f"
"\\20\\21\\22\\23\\24\\25\\26\\27\\28\\29\\2a\\2b\\2c\\2d\\2e\\2f"
"\\30\\31\\32\\33\\34\\35\\36\\37\\38\\39\\3a\\3b\\3c\\3d"
)`),
`unknown memory 1`,
);
// ./test/core/data.wast:391
assert_invalid(
() => instantiate(`(module binary
"\\00asm" "\\01\\00\\00\\00"
"\\0b\\45\\01" ;; data section
"\\02" ;; active segment
"\\01" ;; memory index
"\\41\\00\\0b" ;; offset constant expression
"\\3e" ;; vec(byte) length
"\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f"
"\\10\\11\\12\\13\\14\\15\\16\\17\\18\\19\\1a\\1b\\1c\\1d\\1e\\1f"
"\\20\\21\\22\\23\\24\\25\\26\\27\\28\\29\\2a\\2b\\2c\\2d\\2e\\2f"
"\\30\\31\\32\\33\\34\\35\\36\\37\\38\\39\\3a\\3b\\3c\\3d"
)`),
`unknown memory 1`,
);
// ./test/core/data.wast:410
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (i64.const 0))
)`),
`type mismatch`,
);
// ./test/core/data.wast:418
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (ref.null func))
)`),
`type mismatch`,
);
// ./test/core/data.wast:426
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (offset (;empty instruction sequence;)))
)`),
`type mismatch`,
);
// ./test/core/data.wast:434
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (offset (i32.const 0) (i32.const 0)))
)`),
`type mismatch`,
);
// ./test/core/data.wast:442
assert_invalid(
() => instantiate(`(module
(global (import "test" "global-i32") i32)
(memory 1)
(data (offset (global.get 0) (global.get 0)))
)`),
`type mismatch`,
);
// ./test/core/data.wast:451
assert_invalid(
() => instantiate(`(module
(global (import "test" "global-i32") i32)
(memory 1)
(data (offset (global.get 0) (i32.const 0)))
)`),
`type mismatch`,
);
// ./test/core/data.wast:460
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (i32.ctz (i32.const 0)))
)`),
`constant expression required`,
);
// ./test/core/data.wast:468
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (nop))
)`),
`constant expression required`,
);
// ./test/core/data.wast:476
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (offset (nop) (i32.const 0)))
)`),
`constant expression required`,
);
// ./test/core/data.wast:484
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (offset (i32.const 0) (nop)))
)`),
`constant expression required`,
);
// ./test/core/data.wast:492
assert_invalid(
() => instantiate(`(module
(global $$g (import "test" "g") (mut i32))
(memory 1)
(data (global.get $$g))
)`),
`constant expression required`,
);
// ./test/core/data.wast:501
assert_invalid(
() => instantiate(`(module
(memory 1)
(data (global.get 0))
)`),
`unknown global 0`,
);
// ./test/core/data.wast:509
assert_invalid(
() => instantiate(`(module
(global (import "test" "global-i32") i32)
(memory 1)
(data (global.get 1))
)`),
`unknown global 1`,
);
// ./test/core/data.wast:518
assert_invalid(
() => instantiate(`(module
(global (import "test" "global-mut-i32") (mut i32))
(memory 1)
(data (global.get 0))
)`),
`constant expression required`,
);

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More