Changeset 205364 in webkit
- Timestamp:
- Sep 2, 2016 12:49:09 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r205361 r205364 1 2016-09-02 Caio Lima <ticaiolima@gmail.com> 2 3 Register usage optimization in mathIC when LHS and RHS are constants isn't configured correctly 4 https://bugs.webkit.org/show_bug.cgi?id=160802 5 6 Reviewed by Saam Barati. 7 8 This patch is fixing a broken mechanism of MathIC that avoids allocate 9 a register to LHS or RHS if one of these operands are proven as valid 10 constant for JIT*Generator. In previous implementation, even if the 11 JIT*Generator was not using an operand register because it was proven as a 12 constant, compileMathIC and emitICFast were allocating a register for 13 it. This was broken because mathIC->isLeftOperandValidConstant and 14 mathIC->isLeftOperandValidConstant were being called before its Generator be 15 properly initialized. We changed this mechanism to enable Generators write 16 their validConstant rules using static methods isLeftOperandValidConstant(SnippetOperand) 17 and isRightOperandValidConstant(SnippetOperand). 18 19 * dfg/DFGSpeculativeJIT.cpp: 20 (JSC::DFG::SpeculativeJIT::compileMathIC): 21 * jit/JITAddGenerator.h: 22 (JSC::JITAddGenerator::JITAddGenerator): 23 (JSC::JITAddGenerator::isLeftOperandValidConstant): 24 (JSC::JITAddGenerator::isRightOperandValidConstant): 25 * jit/JITArithmetic.cpp: 26 (JSC::JIT::emitMathICFast): 27 * jit/JITMathIC.h: 28 * jit/JITMulGenerator.h: 29 (JSC::JITMulGenerator::JITMulGenerator): 30 (JSC::JITMulGenerator::isLeftOperandValidConstant): 31 (JSC::JITMulGenerator::isRightOperandValidConstant): 32 * jit/JITSubGenerator.h: 33 (JSC::JITSubGenerator::isLeftOperandValidConstant): 34 (JSC::JITSubGenerator::isRightOperandValidConstant): 35 1 36 2016-09-02 JF Bastien <jfbastien@apple.com> 2 37 -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r205112 r205364 3472 3472 3473 3473 ASSERT(!leftOperand.isConst() || !rightOperand.isConst()); 3474 3475 if (!mathIC->isLeftOperandValidConstant()) { 3474 ASSERT(!(Generator::isLeftOperandValidConstant(leftOperand) && Generator::isRightOperandValidConstant(rightOperand))); 3475 3476 if (!Generator::isLeftOperandValidConstant(leftOperand)) { 3476 3477 left = JSValueOperand(this, leftChild); 3477 3478 leftRegs = left->jsValueRegs(); 3478 3479 } 3479 if (! mathIC->isRightOperandValidConstant()) {3480 if (!Generator::isRightOperandValidConstant(rightOperand)) { 3480 3481 right = JSValueOperand(this, rightChild); 3481 3482 rightRegs = right->jsValueRegs(); … … 3512 3513 auto innerLeftRegs = leftRegs; 3513 3514 auto innerRightRegs = rightRegs; 3514 if ( mathIC->isLeftOperandValidConstant()) {3515 if (Generator::isLeftOperandValidConstant(leftOperand)) { 3515 3516 innerLeftRegs = resultRegs; 3516 3517 m_jit.moveValue(leftChild->asJSValue(), innerLeftRegs); 3517 } else if ( mathIC->isRightOperandValidConstant()) {3518 } else if (Generator::isRightOperandValidConstant(rightOperand)) { 3518 3519 innerRightRegs = resultRegs; 3519 3520 m_jit.moveValue(rightChild->asJSValue(), innerRightRegs); … … 3543 3544 }); 3544 3545 } else { 3545 if ( mathIC->isLeftOperandValidConstant()) {3546 if (Generator::isLeftOperandValidConstant(leftOperand)) { 3546 3547 left = JSValueOperand(this, leftChild); 3547 3548 leftRegs = left->jsValueRegs(); 3548 } else if ( mathIC->isRightOperandValidConstant()) {3549 } else if (Generator::isRightOperandValidConstant(rightOperand)) { 3549 3550 right = JSValueOperand(this, rightChild); 3550 3551 rightRegs = right->jsValueRegs(); -
trunk/Source/JavaScriptCore/jit/JITAddGenerator.h
r203786 r205364 40 40 class JITAddGenerator { 41 41 public: 42 JITAddGenerator() 43 { } 42 JITAddGenerator() { } 44 43 45 44 JITAddGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand, … … 64 63 bool generateFastPath(CCallHelpers&, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool shouldEmitProfiling); 65 64 66 bool isLeftOperandValidConstant() const { return m_leftOperand.isConstInt32(); } 67 bool isRightOperandValidConstant() const { return m_rightOperand.isConstInt32(); } 65 static bool isLeftOperandValidConstant(SnippetOperand leftOperand) { return leftOperand.isPositiveConstInt32(); } 66 static bool isRightOperandValidConstant(SnippetOperand rightOperand) { return rightOperand.isPositiveConstInt32(); } 67 68 68 ArithProfile* arithProfile() const { return m_arithProfile; } 69 69 -
trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp
r203979 r205364 735 735 RELEASE_ASSERT(!leftOperand.isConst() || !rightOperand.isConst()); 736 736 737 if (!mathIC->isLeftOperandValidConstant()) 737 mathIC->m_generator = Generator(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs, fpRegT0, fpRegT1, scratchGPR, scratchFPR, arithProfile); 738 739 ASSERT(!(Generator::isLeftOperandValidConstant(leftOperand) && Generator::isRightOperandValidConstant(rightOperand))); 740 741 if (!Generator::isLeftOperandValidConstant(leftOperand)) 738 742 emitGetVirtualRegister(op1, leftRegs); 739 if (! mathIC->isRightOperandValidConstant())743 if (!Generator::isRightOperandValidConstant(rightOperand)) 740 744 emitGetVirtualRegister(op2, rightRegs); 741 745 … … 745 749 746 750 MathICGenerationState& mathICGenerationState = m_instructionToMathICGenerationState.add(currentInstruction, MathICGenerationState()).iterator->value; 747 748 mathIC->m_generator = Generator(leftOperand, rightOperand, resultRegs, leftRegs, rightRegs, fpRegT0, fpRegT1, scratchGPR, scratchFPR, arithProfile);749 751 750 752 bool generatedInlineCode = mathIC->generateInline(*this, mathICGenerationState); … … 802 804 rightOperand.setConstInt32(getOperandConstantInt(op2)); 803 805 804 if (mathIC->isLeftOperandValidConstant()) 806 ASSERT(!(Generator::isLeftOperandValidConstant(leftOperand) && Generator::isRightOperandValidConstant(rightOperand))); 807 808 if (Generator::isLeftOperandValidConstant(leftOperand)) 805 809 emitGetVirtualRegister(op1, leftRegs); 806 if (mathIC->isRightOperandValidConstant())810 else if (Generator::isRightOperandValidConstant(rightOperand)) 807 811 emitGetVirtualRegister(op2, rightRegs); 808 812 -
trunk/Source/JavaScriptCore/jit/JITMathIC.h
r205283 r205364 59 59 CodeLocationLabel slowPathStartLocation() { return m_inlineStart.labelAtOffset(m_deltaFromStartToSlowPathStart); } 60 60 CodeLocationCall slowPathCallLocation() { return m_inlineStart.callAtOffset(m_deltaFromStartToSlowPathCallLocation); } 61 62 bool isLeftOperandValidConstant() const { return m_generator.isLeftOperandValidConstant(); } 63 bool isRightOperandValidConstant() const { return m_generator.isRightOperandValidConstant(); } 64 61 65 62 bool generateInline(CCallHelpers& jit, MathICGenerationState& state, bool shouldEmitProfiling = true) 66 63 { -
trunk/Source/JavaScriptCore/jit/JITMulGenerator.h
r203786 r205364 39 39 class JITMulGenerator { 40 40 public: 41 JITMulGenerator() { } 41 JITMulGenerator() 42 { } 42 43 43 44 JITMulGenerator(SnippetOperand leftOperand, SnippetOperand rightOperand, … … 62 63 bool generateFastPath(CCallHelpers&, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowJumpList, bool shouldEmitProfiling); 63 64 64 bool isLeftOperandValidConstant() const { return m_leftOperand.isPositiveConstInt32(); }65 bool isRightOperandValidConstant() const { return m_rightOperand.isPositiveConstInt32(); }66 65 static bool isLeftOperandValidConstant(SnippetOperand leftOperand) { return leftOperand.isPositiveConstInt32(); } 66 static bool isRightOperandValidConstant(SnippetOperand rightOperand) { return rightOperand.isPositiveConstInt32(); } 67 67 68 ArithProfile* arithProfile() const { return m_arithProfile; } 68 69 -
trunk/Source/JavaScriptCore/jit/JITSubGenerator.h
r203979 r205364 60 60 bool generateFastPath(CCallHelpers&, CCallHelpers::JumpList& endJumpList, CCallHelpers::JumpList& slowPathJumpList, bool shouldEmitProfiling); 61 61 62 bool isLeftOperandValidConstant() const { return false; } 63 bool isRightOperandValidConstant() const { return false; } 62 static bool isLeftOperandValidConstant(SnippetOperand) { return false; } 63 static bool isRightOperandValidConstant(SnippetOperand) { return false; } 64 64 65 ArithProfile* arithProfile() const { return m_arithProfile; } 65 66
Note: See TracChangeset
for help on using the changeset viewer.