Changeset 181035 in webkit
- Timestamp:
- Mar 4, 2015 2:39:28 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r181019 r181035 1 2015-03-04 Benjamin Poulain <bpoulain@apple.com> 2 3 [JSC] Add a node for Math.log() 4 https://bugs.webkit.org/show_bug.cgi?id=142126 5 6 Reviewed by Geoffrey Garen. 7 8 This patch adds the DFG node ArithLog for LogIntrinsic. 9 10 Having a direct call to log has very little value by itself, the implementation 11 in DFG and FTL is a simple function call. 12 13 What is useful in ArithLog is that we know the operation is pure. 14 This allow us to hoist it out of loops when the argument is independent 15 is an invariant of the loop. 16 17 Perf wise, this patch gives: 18 -Kraken's imaging-darkroom: definitely 1.2372x faster. 19 -AsmBench's Towers.c: definitely 1.0261x faster. 20 21 * dfg/DFGAbstractInterpreterInlines.h: 22 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 23 * dfg/DFGByteCodeParser.cpp: 24 (JSC::DFG::ByteCodeParser::handleIntrinsic): 25 * dfg/DFGClobberize.h: 26 (JSC::DFG::clobberize): 27 * dfg/DFGDoesGC.cpp: 28 (JSC::DFG::doesGC): 29 * dfg/DFGFixupPhase.cpp: 30 (JSC::DFG::FixupPhase::fixupNode): 31 * dfg/DFGNodeType.h: 32 * dfg/DFGPredictionPropagationPhase.cpp: 33 (JSC::DFG::PredictionPropagationPhase::propagate): 34 (JSC::DFG::PredictionPropagationPhase::doDoubleVoting): 35 * dfg/DFGSafeToExecute.h: 36 (JSC::DFG::safeToExecute): 37 * dfg/DFGSpeculativeJIT.cpp: 38 (JSC::DFG::SpeculativeJIT::compileArithLog): 39 * dfg/DFGSpeculativeJIT.h: 40 * dfg/DFGSpeculativeJIT32_64.cpp: 41 (JSC::DFG::SpeculativeJIT::compile): 42 * dfg/DFGSpeculativeJIT64.cpp: 43 (JSC::DFG::SpeculativeJIT::compile): 44 * ftl/FTLCapabilities.cpp: 45 (JSC::FTL::canCompile): 46 * ftl/FTLIntrinsicRepository.h: 47 * ftl/FTLLowerDFGToLLVM.cpp: 48 (JSC::FTL::LowerDFGToLLVM::compileNode): 49 (JSC::FTL::LowerDFGToLLVM::compileArithLog): 50 * ftl/FTLOutput.h: 51 (JSC::FTL::Output::doubleLog): 52 * tests/stress/math-log-basics.js: Added. 53 * tests/stress/math-log-with-constants.js: Added. 54 1 55 2015-03-04 Filip Pizlo <fpizlo@apple.com> 2 56 -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r180989 r181035 790 790 if (false && child && child.isNumber()) { 791 791 setConstant(node, jsDoubleNumber(cos(child.asNumber()))); 792 break; 793 } 794 forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type)); 795 break; 796 } 797 798 case ArithLog: { 799 JSValue child = forNode(node->child1()).value(); 800 if (child && child.isNumber()) { 801 setConstant(node, jsDoubleNumber(log(child.asNumber()))); 792 802 break; 793 803 } -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r180993 r181035 1835 1835 case MaxIntrinsic: 1836 1836 return handleMinMax(resultOperand, ArithMax, registerOffset, argumentCountIncludingThis, insertChecks); 1837 1837 1838 1838 case SqrtIntrinsic: 1839 1839 case CosIntrinsic: 1840 case SinIntrinsic: { 1840 case SinIntrinsic: 1841 case LogIntrinsic: { 1841 1842 if (argumentCountIncludingThis == 1) { 1842 1843 insertChecks(); … … 1859 1860 insertChecks(); 1860 1861 set(VirtualRegister(resultOperand), addToGraph(ArithSin, get(virtualRegisterForArgument(1, registerOffset)))); 1862 return true; 1863 1864 case LogIntrinsic: 1865 insertChecks(); 1866 set(VirtualRegister(resultOperand), addToGraph(ArithLog, get(virtualRegisterForArgument(1, registerOffset)))); 1861 1867 return true; 1862 1868 -
trunk/Source/JavaScriptCore/dfg/DFGClobberize.h
r180989 r181035 134 134 case ArithSin: 135 135 case ArithCos: 136 case ArithLog: 136 137 case GetScope: 137 138 case SkipScope: -
trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp
r180989 r181035 86 86 case ArithSin: 87 87 case ArithCos: 88 case ArithLog: 88 89 case ValueAdd: 89 90 case GetById: -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r180989 r181035 357 357 case ArithFRound: 358 358 case ArithSin: 359 case ArithCos: { 359 case ArithCos: 360 case ArithLog: { 360 361 fixDoubleOrBooleanEdge(node->child1()); 361 362 node->setResult(NodeResultDouble); -
trunk/Source/JavaScriptCore/dfg/DFGNodeType.h
r180989 r181035 141 141 macro(ArithSin, NodeResultNumber) \ 142 142 macro(ArithCos, NodeResultNumber) \ 143 macro(ArithLog, NodeResultNumber) \ 143 144 \ 144 145 /* Add of values may either be arithmetic, or result in string concatenation. */\ -
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r180989 r181035 335 335 case ArithFRound: 336 336 case ArithSin: 337 case ArithCos: { 337 case ArithCos: 338 case ArithLog: { 338 339 changed |= setPrediction(SpecBytecodeDouble); 339 340 break; … … 784 785 case ArithCos: 785 786 case ArithSin: 787 case ArithLog: 786 788 if (node->child1()->shouldSpeculateNumber()) 787 789 m_graph.voteNode(node->child1(), VoteDouble, weight); -
trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h
r180989 r181035 156 156 case ArithSin: 157 157 case ArithCos: 158 case ArithLog: 158 159 case ValueAdd: 159 160 case GetById: -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r180993 r181035 3627 3627 } 3628 3628 3629 void SpeculativeJIT::compileArithLog(Node* node) 3630 { 3631 SpeculateDoubleOperand op1(this, node->child1()); 3632 FPRReg op1FPR = op1.fpr(); 3633 flushRegisters(); 3634 FPRResult result(this); 3635 callOperation(log, result.fpr(), op1FPR); 3636 doubleResult(result.fpr(), node); 3637 } 3638 3629 3639 // Returns true if the compare is fused with a subsequent branch. 3630 3640 bool SpeculativeJIT::compare(Node* node, MacroAssembler::RelationalCondition condition, MacroAssembler::DoubleCondition doubleCondition, S_JITOperation_EJJ operation) -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
r181019 r181035 2175 2175 void compileArithPow(Node*); 2176 2176 void compileArithSqrt(Node*); 2177 void compileArithLog(Node*); 2177 2178 void compileConstantStoragePointer(Node*); 2178 2179 void compileGetIndexedPropertyStorage(Node*); -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
r180993 r181035 2220 2220 break; 2221 2221 } 2222 2223 case ArithLog: 2224 compileArithLog(node); 2225 break; 2222 2226 2223 2227 case LogicalNot: -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r180993 r181035 2353 2353 break; 2354 2354 } 2355 2356 case ArithLog: 2357 compileArithLog(node); 2358 break; 2355 2359 2356 2360 case LogicalNot: -
trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp
r180989 r181035 92 92 case ArithPow: 93 93 case ArithSqrt: 94 case ArithLog: 94 95 case ArithFRound: 95 96 case ArithNegate: -
trunk/Source/JavaScriptCore/ftl/FTLIntrinsicRepository.h
r180279 r181035 44 44 macro(doublePowi, "llvm.powi.f64", functionType(doubleType, doubleType, int32)) \ 45 45 macro(doubleSqrt, "llvm.sqrt.f64", functionType(doubleType, doubleType)) \ 46 macro(doubleLog, "llvm.log.f64", functionType(doubleType, doubleType)) \ 46 47 macro(frameAddress, "llvm.frameaddress", functionType(pointerType(int8), int32)) \ 47 48 macro(mulWithOverflow32, "llvm.smul.with.overflow.i32", functionType(structType(m_context, int32, boolean), int32, int32)) \ -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp
r181019 r181035 511 511 compileArithSqrt(); 512 512 break; 513 case ArithLog: 514 compileArithLog(); 515 break; 513 516 case ArithFRound: 514 517 compileArithFRound(); … … 1719 1722 1720 1723 void compileArithSqrt() { setDouble(m_out.doubleSqrt(lowDouble(m_node->child1()))); } 1724 1725 void compileArithLog() { setDouble(m_out.doubleLog(lowDouble(m_node->child1()))); } 1721 1726 1722 1727 void compileArithFRound() -
trunk/Source/JavaScriptCore/ftl/FTLOutput.h
r180279 r181035 193 193 } 194 194 195 LValue doubleLog(LValue value) 196 { 197 return call(doubleLogIntrinsic(), value); 198 } 199 195 200 static bool hasSensibleDoubleToInt() { return isX86(); } 196 201 LValue sensibleDoubleToInt(LValue);
Note: See TracChangeset
for help on using the changeset viewer.