// |jit-test| skip-if: getPrefValue("wasm_lazy_tiering") // TODO: skip lazy tiering temporarily to avoid a timeout
load(libdir + "wasm-binary.js");
// Replace this with a string like 'non-null (ref $s1) -> (ref any) -> (ref any)' to test exactly one specific case. Makes debugging easier. const specificTest = '';
// All the concrete subtype relationships present in the preamble. // [x, y] means x <: y. const subtypes = [
['$s2', '$s1'],
['$a2', '$a1'],
['$ft2', '$ft1'],
['$ft4', '$ft3'],
];
function isSubtype(src, dest) { if (src.name === dest.name) { returntrue;
} for (const [src2, dest2] of subtypes) { if (src.name === src2 && dest.name === dest2) { returntrue;
}
} returnfalse;
}
let numCases = 0;
// This will generate an enormous pile of test cases. All of these should be valid, // as in passing WebAssembly.validate, but some may not be good casts at runtime. for (const typeSet of typeSets) { for (const start of typeSet) { for (const middle of typeSet) { for (const end of typeSet) { for (const [nullable0, nullable1, nullable2] of nullables) { for (const makeNull of [true, false]) { const concrete0 = !!start.make; const concrete1 = !!middle.make; const concrete2 = !!end.make;
if (!concrete0 && !makeNull) { // We can only start with null values for abstract types continue;
}
if (!nullable0 && makeNull) { // Can't use null as a valid value for a non-nullable type continue;
}
numCases += 1;
let good1 = true;
let good2 = true;
// Null values will fail casts to non-nullable types if (makeNull) { if (!nullable1) {
good1 = false;
} if (!nullable2) {
good2 = false;
}
}
// Bottom types can't represent non-null, so this will always fail if (!makeNull) { if (middle.none) {
good1 = false;
} if (end.none) {
good2 = false;
}
}
// Concrete values are subject to subtyping relationships if (!makeNull) { if (concrete1 && !isSubtype(start, middle)) {
good1 = false;
} if (concrete2 && !isSubtype(start, end)) {
good2 = false;
}
}
let emoji1 = good1 ? '✅' : '❌';
let emoji2 = good2 ? '✅' : '❌';
try { // The casts are split up so the stack trace will show you which cast is failing. const {
make,
cast1, cast2,
test1, test2,
branch1, branch2,
branchfail1, branchfail2,
} = wasmEvalText(moduleText).exports;
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.