Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Snippefy op_add for the baseline JIT.
https://bugs.webkit.org/show_bug.cgi?id=150129 Reviewed by Geoffrey Garen and Saam Barati. Performance is neutral for both 32-bit and 64-bit on X86_64. * CMakeLists.txt: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/JIT.h: (JSC::JIT::getOperandConstantInt): - Move getOperandConstantInt() from the JSVALUE64 section to the common section because the snippet needs it. * jit/JITAddGenerator.cpp: Added. (JSC::JITAddGenerator::generateFastPath): * jit/JITAddGenerator.h: Added. (JSC::JITAddGenerator::JITAddGenerator): (JSC::JITAddGenerator::endJumpList): (JSC::JITAddGenerator::slowPathJumpList): - JITAddGenerator implements an optimization for the case where 1 of the 2 operands is a constant int32_t. It does not implement an optimization for the case where both operands are constant int32_t. This is because: 1. For the baseline JIT, the ASTBuilder will fold the 2 constants together. 2. For the DFG, the AbstractInterpreter will also fold the 2 constants. Hence, such an optimization path (for 2 constant int32_t operands) would never be taken, and is why we won't implement it. * jit/JITArithmetic.cpp: (JSC::JIT::compileBinaryArithOp): (JSC::JIT::compileBinaryArithOpSlowCase): - Removed op_add cases. These are no longer used by the op_add emitters. (JSC::JIT::emit_op_add): (JSC::JIT::emitSlow_op_add): - Moved out from the JSVALUE64 section to the common section, and reimplemented using the snippet. * jit/JITArithmetic32_64.cpp: (JSC::JIT::emitBinaryDoubleOp): (JSC::JIT::emit_op_add): Deleted. (JSC::JIT::emitAdd32Constant): Deleted. (JSC::JIT::emitSlow_op_add): Deleted. - Remove 32-bit specific version of op_add. The snippet serves both 32-bit and 64-bit implementations. * jit/JITInlines.h: (JSC::JIT::getOperandConstantInt): - Move getOperandConstantInt() from the JSVALUE64 section to the common section because the snippet needs it. Canonical link: https://commits.webkit.org/168997@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
402 additions
and 206 deletions.
- +1 −0 Source/JavaScriptCore/CMakeLists.txt
- +56 −1 Source/JavaScriptCore/ChangeLog
- +2 −0 Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
- +6 −0 Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
- +8 −0 Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
- +2 −3 Source/JavaScriptCore/jit/JIT.h
- +130 −0 Source/JavaScriptCore/jit/JITAddGenerator.cpp
- +95 −0 Source/JavaScriptCore/jit/JITAddGenerator.h
- +97 −74 Source/JavaScriptCore/jit/JITArithmetic.cpp
- +0 −123 Source/JavaScriptCore/jit/JITArithmetic32_64.cpp
- +5 −5 Source/JavaScriptCore/jit/JITInlines.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,130 @@ | ||
/* | ||
* Copyright (C) 2015 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#if ENABLE(JIT) | ||
#include "JITAddGenerator.h" | ||
|
||
namespace JSC { | ||
|
||
void JITAddGenerator::generateFastPath(CCallHelpers& jit) | ||
{ | ||
ASSERT(m_scratchGPR != InvalidGPRReg); | ||
ASSERT(m_scratchGPR != m_left.payloadGPR()); | ||
ASSERT(m_scratchGPR != m_right.payloadGPR()); | ||
#if ENABLE(JSVALUE32_64) | ||
ASSERT(m_scratchGPR != m_left.tagGPR());x | ||
ASSERT(m_scratchGPR != m_right.tagGPR()); | ||
ASSERT(m_scratchFPR != InvalidFPRReg); | ||
#endif | ||
|
||
if (!m_leftType.mightBeNumber() || !m_rightType.mightBeNumber()) { | ||
m_slowPathJumpList.append(jit.jump()); | ||
return; | ||
} | ||
|
||
if (m_operandsConstness == RightIsConstInt32) { | ||
// Try to do intVar + intConstant. | ||
CCallHelpers::Jump notInt32 = jit.branchIfNotInt32(m_left); | ||
|
||
m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, m_left.payloadGPR(), CCallHelpers::Imm32(m_rightConstInt32), m_scratchGPR)); | ||
|
||
jit.boxInt32(m_scratchGPR, m_result); | ||
m_endJumpList.append(jit.jump()); | ||
|
||
if (!jit.supportsFloatingPoint()) { | ||
m_slowPathJumpList.append(notInt32); | ||
return; | ||
} | ||
|
||
// Try to do doubleVar + double(intConstant). | ||
notInt32.link(&jit); | ||
if (!m_leftType.definitelyIsNumber()) | ||
m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR)); | ||
|
||
jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR); | ||
|
||
jit.move(CCallHelpers::Imm32(m_rightConstInt32), m_scratchGPR); | ||
jit.convertInt32ToDouble(m_scratchGPR, m_rightFPR); | ||
|
||
// Fall thru to doubleVar + doubleVar. | ||
|
||
} else { | ||
ASSERT(m_operandsConstness == NeitherAreConstInt32); | ||
CCallHelpers::Jump leftNotInt; | ||
CCallHelpers::Jump rightNotInt; | ||
|
||
// Try to do intVar + intVar. | ||
leftNotInt = jit.branchIfNotInt32(m_left); | ||
rightNotInt = jit.branchIfNotInt32(m_right); | ||
|
||
m_slowPathJumpList.append(jit.branchAdd32(CCallHelpers::Overflow, m_right.payloadGPR(), m_left.payloadGPR(), m_scratchGPR)); | ||
|
||
jit.boxInt32(m_scratchGPR, m_result); | ||
m_endJumpList.append(jit.jump()); | ||
|
||
if (!jit.supportsFloatingPoint()) { | ||
m_slowPathJumpList.append(leftNotInt); | ||
m_slowPathJumpList.append(rightNotInt); | ||
return; | ||
} | ||
|
||
leftNotInt.link(&jit); | ||
if (!m_leftType.definitelyIsNumber()) | ||
m_slowPathJumpList.append(jit.branchIfNotNumber(m_left, m_scratchGPR)); | ||
if (!m_rightType.definitelyIsNumber()) | ||
m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR)); | ||
|
||
jit.unboxDoubleNonDestructive(m_left, m_leftFPR, m_scratchGPR, m_scratchFPR); | ||
CCallHelpers::Jump rightIsDouble = jit.branchIfNotInt32(m_right); | ||
|
||
jit.convertInt32ToDouble(m_right.payloadGPR(), m_rightFPR); | ||
CCallHelpers::Jump rightWasInteger = jit.jump(); | ||
|
||
rightNotInt.link(&jit); | ||
if (!m_rightType.definitelyIsNumber()) | ||
m_slowPathJumpList.append(jit.branchIfNotNumber(m_right, m_scratchGPR)); | ||
|
||
jit.convertInt32ToDouble(m_left.payloadGPR(), m_leftFPR); | ||
|
||
rightIsDouble.link(&jit); | ||
jit.unboxDoubleNonDestructive(m_right, m_rightFPR, m_scratchGPR, m_scratchFPR); | ||
|
||
rightWasInteger.link(&jit); | ||
|
||
// Fall thru to doubleVar + doubleVar. | ||
} | ||
|
||
// Do doubleVar + doubleVar. | ||
jit.addDouble(m_rightFPR, m_leftFPR); | ||
jit.boxDouble(m_leftFPR, m_result); | ||
|
||
m_endJumpList.append(jit.jump()); | ||
} | ||
|
||
} // namespace JSC | ||
|
||
#endif // ENABLE(JIT) |
Oops, something went wrong.