// SIMD JS API // // As of 31 March 2020 the SIMD spec is very light on information about the JS // API, and what it has is ridden with misspellings, grammatical errors, and // apparent redundancies. The rules below represent my best effort at // understanding the intent of the spec. As far as I can tell, the rules for // v128 are intended to match the rules for i64 in the Wasm MVP.
// Hopefully, these are enough to test that various JIT stubs are generated and // used if we run the tests in a loop.
// RULE: v128 cannot cross the JS/wasm boundary as a function parameter. // // A wasm function that: // - takes or returns v128 // - was imported into wasm // - is ultimately a JS function // should always throw TypeError when called from wasm. // // Note, JIT exit stubs should be generated here because settings above should // cause the JIT to tier up.
function call_v128_param() { ins.exports.v128_param(); } function call_v128_result() { ins.exports.v128_result(); }
for ( let i = 0 ; i < 100; i++ ) {
assertErrorMessage(call_v128_param,
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(call_v128_result,
TypeError,
/cannot pass.*value.*to or from JS/);
}
// RULE: v128 cannot cross the JS/wasm boundary as a function parameter. // // A wasm function that: // - takes or returns v128 // - is exported from wasm // - is ultimately a true wasm function // should always throw TypeError when called from JS. // // Note, JIT entry stubs should be generated here because settings above should // cause the JIT to tier up.
function call_v128_param2() { ins2.exports.v128_param(); } function call_v128_result2() { ins2.exports.v128_result(); }
for ( let i = 0 ; i < 100; i++ ) {
assertErrorMessage(call_v128_param2,
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(call_v128_result2,
TypeError,
/cannot pass.*value.*to or from JS/);
}
// RULE: The rules about v128 passing into or out of a function apply even when // an imported JS function is re-exported and is then called.
var newfn = (x) => x; var ins = wasmEvalText(`
(module
(import"m""fn" (func $f (param v128) (result v128)))
(export "newfn" (func $f)))`,
{m:{fn: newfn}});
assertErrorMessage(() => ins.exports.newfn(3),
TypeError,
/cannot pass.*value.*to or from JS/);
// RULE: WebAssembly.Global of type v128 is constructable from JS with a default // value.
// RULE: WebAssembly.Global constructor for type v128 is not constructable with // or without a default value.
assertErrorMessage(() => new WebAssembly.Global({value: "v128"}, 37),
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(() => new WebAssembly.Global({value: "v128"}),
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(() => new WebAssembly.Global({value: "v128", mutable: true}),
TypeError,
/cannot pass.*value.*to or from JS/);
// RULE: WebAssembly.Global of type v128 have getters and setters that throw // TypeError when called from JS.
assertErrorMessage(() => gi.value,
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(() => gi.valueOf(),
TypeError,
/cannot pass.*value.*to or from JS/);
assertErrorMessage(() => gm.value = 0,
TypeError,
/cannot pass.*value.*to or from JS/);
Messung V0.5
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet)
¤
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.