[BigInt] Add support to BigInt into ValueAdd
authorticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 01:47:27 +0000 (01:47 +0000)
committerticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Nov 2018 01:47:27 +0000 (01:47 +0000)
commit2dd5509fc19840c11194f1b6b06ebb67e25c0878
tree2a90b0e4c493463eee6440b57774f1362da3ec20
parentb66bf6612a066a8a44bca30ee02cbf84074d14d3
[BigInt] Add support to BigInt into ValueAdd
https://bugs.webkit.org/show_bug.cgi?id=186177

Reviewed by Keith Miller.

JSTests:

* stress/big-int-negate-jit.js:
* stress/value-add-big-int-and-string.js: Added.
* stress/value-add-big-int-prediction-propagation.js: Added.
* stress/value-add-big-int-untyped.js: Added.

PerformanceTests:

The idea of BigIntBench is to provide a set of microbenchmarks and
benchmarks to evaluate how fast BigInt computations are happening on
JSC implementation.

Now, we are adding microbenchmarks in this set,
but the plan is to move these tests to "JSTest/microbenchmarks" when
BigInt is enabled by default. After that, the focus of Bigint bench is
to provide a set of tests that represents real use cases of BigInt in
JS programs.

* BigIntBench/big-int-add-prediction-propagation.js: Added.
* BigIntBench/big-int-simple-add.js: Added.
* BigIntBench/big-int-simple-sub.js: Added.

Source/JavaScriptCore:

We are adding a very primitive specialization case of BigInts into ValueAdd.
When compiling a speculated version of this node to BigInt, we are currently
calling 'operationAddBigInt', a function that expects only BigInts as
parameter and effectly add numbers using JSBigInt::add. To properly
speculate BigInt operands, we changed ArithProfile to observe when
its result is a BigInt. With this new observation, we are able to identify
when ValueAdd results into a String or BigInt.

Here are some numbers for this specialization running
microbenchmarks:

big-int-simple-add                   21.5411+-1.1096  ^  15.3502+-0.7027  ^ definitely 1.4033x faster
big-int-add-prediction-propagation   13.7762+-0.5578  ^  10.8117+-0.5330  ^ definitely 1.2742x faster

* bytecode/ArithProfile.cpp:
(JSC::ArithProfile::emitObserveResult):
(JSC::ArithProfile::shouldEmitSetNonNumeric const):
(JSC::ArithProfile::shouldEmitSetBigInt const):
(JSC::ArithProfile::emitSetNonNumeric const):
(JSC::ArithProfile::emitSetBigInt const):
(WTF::printInternal):
(JSC::ArithProfile::shouldEmitSetNonNumber const): Deleted.
(JSC::ArithProfile::emitSetNonNumber const): Deleted.
* bytecode/ArithProfile.h:
(JSC::ArithProfile::observedUnaryInt):
(JSC::ArithProfile::observedUnaryNumber):
(JSC::ArithProfile::observedBinaryIntInt):
(JSC::ArithProfile::observedBinaryNumberInt):
(JSC::ArithProfile::observedBinaryIntNumber):
(JSC::ArithProfile::observedBinaryNumberNumber):
(JSC::ArithProfile::didObserveNonInt32 const):
(JSC::ArithProfile::didObserveNonNumeric const):
(JSC::ArithProfile::didObserveBigInt const):
(JSC::ArithProfile::setObservedNonNumeric):
(JSC::ArithProfile::setObservedBigInt):
(JSC::ArithProfile::observeResult):
(JSC::ArithProfile::didObserveNonNumber const): Deleted.
(JSC::ArithProfile::setObservedNonNumber): Deleted.
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::makeSafe):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGNode.h:
(JSC::DFG::Node::mayHaveNonNumericResult):
(JSC::DFG::Node::mayHaveBigIntResult):
(JSC::DFG::Node::mayHaveNonNumberResult): Deleted.
* dfg/DFGNodeFlags.cpp:
(JSC::DFG::dumpNodeFlags):
* dfg/DFGNodeFlags.h:
* dfg/DFGOperations.cpp:
* dfg/DFGOperations.h:
* dfg/DFGPredictionPropagationPhase.cpp:
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileValueAdd):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileValueAdd):
* runtime/CommonSlowPaths.cpp:
(JSC::updateArithProfileForUnaryArithOp):
(JSC::updateArithProfileForBinaryArithOp):

Tools:

* Scripts/run-jsc-benchmarks:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237972 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
JSTests/ChangeLog
JSTests/stress/big-int-negate-jit.js
JSTests/stress/value-add-big-int-and-string.js [new file with mode: 0644]
JSTests/stress/value-add-big-int-prediction-propagation.js [new file with mode: 0644]
JSTests/stress/value-add-big-int-untyped.js [new file with mode: 0644]
PerformanceTests/BigIntBench/big-int-add-prediction-propagation.js [new file with mode: 0644]
PerformanceTests/BigIntBench/big-int-simple-add.js [new file with mode: 0644]
PerformanceTests/BigIntBench/big-int-simple-sub.js [new file with mode: 0644]
PerformanceTests/ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/ArithProfile.cpp
Source/JavaScriptCore/bytecode/ArithProfile.h
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
Source/JavaScriptCore/dfg/DFGNode.h
Source/JavaScriptCore/dfg/DFGNodeFlags.cpp
Source/JavaScriptCore/dfg/DFGNodeFlags.h
Source/JavaScriptCore/dfg/DFGOperations.cpp
Source/JavaScriptCore/dfg/DFGOperations.h
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Source/JavaScriptCore/runtime/CommonSlowPaths.cpp
Tools/ChangeLog
Tools/Scripts/run-jsc-benchmarks