function get(arr, loc, len) {
let res = []; for ( let i=0; i < len; i++ ) {
res.push(arr[loc+i]);
} return res;
}
function getUnaligned(arr, width, loc, len) {
assertEq(arr.constructor, Uint8Array);
assertEq(width <= 4, true);
let res = []; for ( let i=0; i < len; i++ ) {
let x = 0; for ( let j=width-1; j >=0; j-- )
x = (x << 8) | arr[loc+i*width+j];
res.push(x);
} 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];
}
}
}
function setUnaligned(arr, width, loc, vals) {
assertEq(arr.constructor, Uint8Array);
assertEq(width <= 4, true); for ( let i=0; i < vals.length; i++ ) {
let x = vals[i]; for ( let j=0 ; j < width ; j++ ) {
arr[loc+i*width + j] = x & 255;
x >>= 8;
}
}
}
function equal(a, b) { return a === b || isNaN(a) && isNaN(b);
}
function upd(xs, at, val) {
let ys = Array.from(xs);
ys[at] = val; return ys;
}
// The following operations are not always generalized fully, they are just // functional enough for the existing test cases to pass.
function sign_extend(n, bits) { if (bits < 32) {
n = Number(n); return (n << (32 - bits)) >> (32 - bits);
} if (typeof n == "bigint") { if (bits == 32) return Number(n & 0xFFFF_FFFFn) | 0;
assertEq(bits, 64);
n = (n & 0xFFFF_FFFF_FFFF_FFFFn) if (n > 0x7FFF_FFFF_FFFF_FFFFn) return n - 0x1_0000_0000_0000_0000n; return n;
}
assertEq(bits, 32); return n|0;
}
function zero_extend(n, bits) { if (bits < 32) { return n & ((1 << bits) - 1);
} if (n < 0)
n = 0x100000000 + n; return n;
}
function signed_saturate(z, bits) {
let min = -(1 << (bits-1)); if (z <= min) { return min;
}
let max = (1 << (bits-1)) - 1; if (z > max) { return max;
} return z;
}
function unsigned_saturate(z, bits) { if (z <= 0) { return 0;
}
let max = (1 << bits) - 1; if (z > max) { return max;
} return z;
}
function shl(count, width) { if (width == 64) {
count = BigInt(count); return (v) => {
v = BigInt(v); if (v < 0)
v = (1n << 64n) + v;
let r = (v << count) & ((1n << 64n) - 1n); if (r & (1n << 63n))
r = -((1n << 64n) - r); return r;
}
} else { return (v) => {
let mask = (width == 32) ? -1 : ((1 << width) - 1); return (v << count) & mask;
}
}
}
function popcount(n) {
n = n - ((n >> 1) & 0x55555555)
n = (n & 0x33333333) + ((n >> 2) & 0x33333333) return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24
}
function jsValueToWasmName(x) { if (typeof x == "number") { if (x == 0) return 1 / x < 0 ? "-0" : "0"; if (isNaN(x)) return"+nan"; if (!isFinite(x)) return (x < 0 ? "-" : "+") + "inf";
} return x;
}
// For each input array, a set of arrays of the proper length for v128, with // values in range but possibly of the wrong signedness (eg, for Int8Array, 128 // is in range but is really -128). Also a unary operator `rectify` that // transforms the value to the proper sign and bitwidth.
// Tidy up all the inputs for ( let A of [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, BigInt64Array,
Float32Array, Float64Array]) {
A.inputs = A.inputs.map((xs) => xs.map(A.rectify));
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 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.