haikuwebkit/PerformanceTests/BigIntBench/value-mul-type-propagation.js

40 lines
606 B
JavaScript
Raw Permalink Normal View History

[BigInt] Add ValueMul into DFG https://bugs.webkit.org/show_bug.cgi?id=186175 Reviewed by Yusuke Suzuki. JSTests: * stress/big-int-mul-jit-osr.js: Added. * stress/big-int-mul-jit-untyped.js: Added. * stress/value-mul-fixup-int32-big-int.js: Added. PerformanceTests: * BigIntBench/big-int-simple-mul.js: Added. * BigIntBench/value-mul-type-propagation.js: Added. Source/JavaScriptCore: This patch is adding a new DFG node called ValueMul. This node is responsible to handle multiplication operations that can result into non-number values. We emit such node during DFGByteCodeParser when the operands are not numbers. During FixupPhase, we change this operation to ArithMul if we can speculate Number/Boolean operands. The BigInt specialization shows a small progression: noSpec changes big-int-simple-mul 18.8090+-1.0435 ^ 17.4305+-0.2673 ^ definitely 1.0791x faster * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGBackwardsPropagationPhase.cpp: (JSC::DFG::BackwardsPropagationPhase::propagate): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::makeSafe): (JSC::DFG::ByteCodeParser::parseBlock): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupMultiplication): (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGNode.h: (JSC::DFG::Node::arithNodeFlags): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileValueMul): (JSC::DFG::SpeculativeJIT::compileArithMul): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGValidate.cpp: * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileValueMul): (JSC::FTL::DFG::LowerDFGToB3::compileArithMul): Canonical link: https://commits.webkit.org/207140@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-12-10 21:11:43 +00:00
//@ runBigIntEnabled
function assert(a, e) {
if (a !== e)
throw new Error("Bad!");
}
function foo(o) {
let c;
do {
let a = 2 * o;
o.bigInt = true;
let b = 1n * o;
for (let i = 0; i < 10000; i++) {
c = i;
}
let d = b * o;
c = a * d;
} while(false);
}
noInline(foo);
let o = {
valueOf: function () {
return this.bigInt ? 2n : 2;
}
}
for (let i = 0; i < 1000; i++) {
try {
o.bigInt = false;
foo(o);
} catch(e) {
assert(e instanceof TypeError, true);
}
}