blob: 7f165529608479b1d16d9c1f6311c4d1c10ebdbc [file] [edit]
//@ skip if not $jitTests
//@ runDefault("--useConcurrentJIT=0")
function assert(a, b) {
if (a !== b)
throw new Error("Bad!");
}
function negateBigInt(n) {
return -n;
}
noInline(negateBigInt);
for (let i = 0; i < testLoopCount; i++) {
assert(negateBigInt(100n), -100n);
assert(negateBigInt(-0x1fffffffffffff01n), 0x1fffffffffffff01n);
}
if (numberOfDFGCompiles(negateBigInt) > 1)
throw "Failed negateBigInt(). We should have compiled a single negate for the BigInt type.";
function negateBigIntSpecializedToInt(n) {
return -n;
}
noInline(negateBigIntSpecializedToInt);
for (let i = 0; i < testLoopCount; i++) {
negateBigIntSpecializedToInt(100);
}
assert(negateBigIntSpecializedToInt(100n), -100n);
// Testing case mixing int and BigInt speculations
function mixedSpeculationNegateBigInt(n, arr) {
return -(-(-n));
}
noInline(mixedSpeculationNegateBigInt);
for (let i = 0; i < testLoopCount; i++) {
if (i % 2)
assert(mixedSpeculationNegateBigInt(100), -100);
else
assert(mixedSpeculationNegateBigInt(-0x1fffffffffffff01n), 0x1fffffffffffff01n);
}
if (numberOfDFGCompiles(mixedSpeculationNegateBigInt) > 1)
throw "Failed mixedSpeculationNegateBigInt(). We should have compiled a single negate for the BigInt type.";