// Experimental opcodes. We have no text parsing support for these yet. The // tests will be cleaned up and moved into ad-hack.js if the opcodes are // adopted.
load(libdir + "wasm-binary.js");
function wasmEval(bytes, imports) { returnnew WebAssembly.Instance(new WebAssembly.Module(bytes), imports);
}
function wasmValidateAndEval(bytes, imports) {
assertEq(WebAssembly.validate(bytes), true, "test of WasmValidate.cpp"); return wasmEval(bytes, imports);
}
function get(arr, loc, len) {
let res = []; for ( let i=0; i < len; i++ ) {
res.push(arr[loc+i]);
} return res;
}
function set(arr, loc, vals) { for ( let i=0; i < vals.length; i++ ) { if (arr instanceof BigInt64Array) {
arr[loc+i] = BigInt(vals[i]);
} else {
arr[loc+i] = vals[i];
}
}
}
var mem16 = new Int16Array(ins.exports.mem.buffer); for (let [as, bs] of cross([
[1, -3, 5, -7, 11, -13, -17, 19],
[-1, 0, 16, -32, 64, 128, -1024, 0, 1],
[1,2,-32768,32767,1,4,-32768,32767]]) ) {
set(mem16, 8, as);
set(mem16, 16, bs);
ins.exports.relaxed_q15mulr_s(); const result = get(mem16, 0, 8); for (let i = 0; i < 8; i++) { const expected = (as[i] * bs[i] + 0x4000) >> 15; if (as[i] == -32768 && bs[i] == -32768) continue;
assertEq(expected, result[i], `result of ${as[i]} * ${bs[i]}`);
}
}
// Check relaxed dot product results. var ins = wasmValidateAndEval(moduleWithSections([
sigSection([v2vSig]),
declSection([0]),
memorySection(1),
exportSection([{funcIndex: 0, name: "dot_i8x16_i7x16_s"},
{memIndex: 0, name: "mem"}]),
bodySection([
funcBody({locals:[],
body: [...V128StoreExpr(0, [...V128Load(16),
...V128Load(32),
SimdPrefix, ...varU32(I16x8RelaxedDotI8x16I7x16SCode)])]})])])); var mem8 = new Int8Array(ins.exports.mem.buffer); var mem16 = new Int16Array(ins.exports.mem.buffer); var test7bit = [1, 2, 3, 4, 5, 64, 65, 127, 127, 0, 0, 1, 65, 64, 2, 3, 0, 0, 127, 127, 5, 4]; var testNeg = test7bit.concat(test7bit.map(i => ~i)); for (let ai = 0; ai < testNeg.length - 15; ai++) for (let bi = 0; bi < test7bit.length - 15; bi++) {
set(mem8, 16, testNeg.slice(ai, ai + 16));
set(mem8, 32, test7bit.slice(bi, bi + 16));
ins.exports.dot_i8x16_i7x16_s(); const result = get(mem16, 0, 8); for (let i = 0; i < 8; i++) { const expected = ((testNeg[ai + i * 2] * test7bit[bi + i * 2]) +
(testNeg[ai + i * 2 + 1] * test7bit[bi + i * 2 + 1])) | 0;
assertEq(expected, result[i]);
}
}
var ins = wasmValidateAndEval(moduleWithSections([
sigSection([v2vSig]),
declSection([0]),
memorySection(1),
exportSection([{funcIndex: 0, name: "dot_i8x16_i7x16_add_s"},
{memIndex: 0, name: "mem"}]),
bodySection([
funcBody({locals:[],
body: [...V128StoreExpr(0, [...V128Load(16),
...V128Load(32),
...V128Load(48),
SimdPrefix, ...varU32(I32x4RelaxedDotI8x16I7x16AddSCode)])]})])])); var mem8 = new Int8Array(ins.exports.mem.buffer); var mem32 = new Int32Array(ins.exports.mem.buffer); var test7bit = [1, 2, 3, 4, 5, 64, 65, 127, 127, 0, 0, 1, 65, 64, 2, 3, 0, 0, 127, 127, 5, 4]; var testNeg = test7bit.concat(test7bit.map(i => ~i)); var testAcc = [0, 12, 65336, -1, 0x10000000, -0xffffff]; for (let ai = 0; ai < testNeg.length - 15; ai++) for (let bi = 0; bi < test7bit.length - 15; bi++) for (let ci = 0; ci < testAcc.length - 3; ci++) {
set(mem8, 16, testNeg.slice(ai, ai + 16));
set(mem8, 32, test7bit.slice(bi, bi + 16));
set(mem32, 48/4, testAcc.slice(ci, ci + 4));
ins.exports.dot_i8x16_i7x16_add_s(); const result = get(mem32, 0, 4); for (let i = 0; i < 4; i++) { const a1 = (testNeg[ai + i * 4] * test7bit[bi + i * 4]) +
(testNeg[ai + i * 4 + 1] * test7bit[bi + i * 4 + 1]); const a2 = (testNeg[ai + i * 4 + 2] * test7bit[bi + i * 4 + 2]) +
(testNeg[ai + i * 4 + 3] * test7bit[bi + i * 4 + 3]); const expected = (testAcc[ci + i] + a1 + a2) | 0;
assertEq(expected, result[i]);
}
}
Messung V0.5 in Prozent
¤ 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.0.22Bemerkung:
(vorverarbeitet am 2026-09-30)
¤
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.