haikuwebkit/LayoutTests/js/dfg-mul-big-integer-with-sm...

110 lines
3.3 KiB
Plaintext
Raw Permalink Normal View History

DFG ArithMul overflow check elimination is too aggressive https://bugs.webkit.org/show_bug.cgi?id=101871 Reviewed by Oliver Hunt. Source/JavaScriptCore: The code was ignoring the fact that ((a * b) | 0) == (((a | 0) * (b | 0)) | 0) only holds if a * b < 2^53. So, I changed it to only enable the optimization when a < 2^22 and b is an int32 (and vice versa), using a super trivial peephole analysis to prove the inequality. I considered writing an epic forward flow formulation that tracks the ranges of integer values but then I thought better of it. This also rewires the ArithMul integer speculation logic. Previously, we would assume that an ArithMul was only UsedAsNumber if it escaped, and separately we would decide whether to speculate integer based on a proof of the <2^22 inequality. Now, we treat the double rounding behavior of ArithMul as if the result was UsedAsNumber even if it did not escape. Then we try to prove that double rounding cannot happen by attemping to prove that a < 2^22. This then feeds back into the decision of whether or not to speculate integer (if we fail to prove a < 2^22 then we're UsedAsNumber, and if we're also MayOverflow then that forces double speculation). No performance impact. It just fixes a bug. * dfg/DFGGraph.h: (JSC::DFG::Graph::mulShouldSpeculateInteger): * dfg/DFGPredictionPropagationPhase.cpp: (PredictionPropagationPhase): (JSC::DFG::PredictionPropagationPhase::isWithinPowerOfTwoForConstant): (JSC::DFG::PredictionPropagationPhase::isWithinPowerOfTwoNonRecursive): (JSC::DFG::PredictionPropagationPhase::isWithinPowerOfTwo): (JSC::DFG::PredictionPropagationPhase::propagate): LayoutTests: * fast/js/dfg-mul-big-integer-with-small-integer-and-bitor-expected.txt: Added. * fast/js/dfg-mul-big-integer-with-small-integer-and-bitor.html: Added. * fast/js/dfg-mul-big-integer-with-small-integer-and-detect-overflow-expected.txt: Added. * fast/js/dfg-mul-big-integer-with-small-integer-and-detect-overflow.html: Added. * fast/js/dfg-mul-big-integer-with-small-integer-expected.txt: Added. * fast/js/dfg-mul-big-integer-with-small-integer.html: Added. * fast/js/dfg-mul-big-integers-expected.txt: Added. * fast/js/dfg-mul-big-integers.html: Added. * fast/js/jsc-test-list: * fast/js/script-tests/dfg-mul-big-integer-with-small-integer-and-bitor.js: Added. (foo): * fast/js/script-tests/dfg-mul-big-integer-with-small-integer-and-detect-overflow.js: Added. (foo): * fast/js/script-tests/dfg-mul-big-integer-with-small-integer.js: Added. (foo): * fast/js/script-tests/dfg-mul-big-integers.js: Added. (foo): Canonical link: https://commits.webkit.org/120060@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-12 22:54:42 +00:00
Tests what happens when you multiply a big unknown integer with a small known integer and use the result in a bitop.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS foo(2147483647) is -65536
PASS successfullyParsed is true
TEST COMPLETE