// Used to ensure tests will trigger Wasm Jit stub code. var threshold = 2 * getJitCompilerOptions()["ion.warmup.trigger"] + 10; function testWithJit(f) { for (var i = 0; i < threshold; i++) {
f();
}
}
function testRet() { var f = wasmEvalText(`(module
(func (export "f") (result i64) (i64.const 66))
)`).exports.f;
testWithJit(() => {
assertEq(typeof f(), "bigint", "should return a bigint");
assertEq(f(), 66n, "should return the correct value");
});
}
function testId() { var exports = wasmEvalText(`(module
(func (export "f") (param i64 i64) (result i64)
(local.get 0)
)
(func (export "f2") (param i64 i64) (result i64)
(local.get 1)
)
)`).exports; var f = exports.f; var f2 = exports.f2;
// Test functions with many parameters to stress ABI cases. We want to test // spilled arguments both under and over the Ion call inlining limit. function testManyArgs() { var f1 = wasmEvalText(`(module
(func (export "f")
(param i64 i64 i64 i64 i64 i64 i64 i64)
(result i64)
(local.get 0)
(local.get 1)
(local.get 2)
(local.get 3)
(local.get 4)
(local.get 5)
(local.get 6)
(local.get 7)
(i64.add)
(i64.add)
(i64.add)
(i64.add)
(i64.add)
(i64.add)
(i64.add)
)
)`).exports.f;
function testGlobalBadImportLiteral() {
assertErrorMessage(
() =>
wasmEvalText(
`(module
(import"g""a" (global $a i64))
(export "a" (global $a))
)`,
{ g: { a: 1 } }
),
WebAssembly.LinkError, "import object field 'a' is not a BigInt"
);
assertErrorMessage(
() =>
wasmEvalText(
`(module
(import"g""a" (global $a i64))
(export "a" (global $a))
)`,
{ g: { a: "foo" } }
),
WebAssembly.LinkError, "import object field 'a' is not a BigInt"
);
}
// This exercises error code paths that were added due to BigInt/I64 // conversion, though the test does not directly deal with I64 types. function testGlobalBadImportNumber() {
assertErrorMessage(
() =>
wasmEvalText(
`(module
(import"g""a" (global $a i32))
(export "a" (global $a))
)`,
{ g: { a: 1n } }
),
WebAssembly.LinkError, "import object field 'a' is not a Number"
);
assertErrorMessage(
() =>
wasmEvalText(
`(module
(import"g""a" (global $a i32))
(export "a" (global $a))
)`,
{ g: { a: "foo" } }
),
WebAssembly.LinkError, "import object field 'a' is not a Number"
);
}
function testI64Global() { var global = new WebAssembly.Global({ value: "i64", mutable: true });
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.