- Revision
- 204009
- Author
- commit-qu...@webkit.org
- Date
- 2016-08-01 22:02:27 -0700 (Mon, 01 Aug 2016)
Log Message
[JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
https://bugs.webkit.org/show_bug.cgi?id=160439
Patch by Benjamin Poulain <bpoul...@apple.com> on 2016-08-01
Reviewed by Filip Pizlo.
Source/_javascript_Core:
* assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::branchTest64):
* b3/air/AirOpcode.opcodes:
Fix the ARM64 codegen to lower BitImm64 without using a scratch register.
Source/WTF:
* wtf/MathExtras.h:
(getLSBSet):
This was not working at all for MacroAssembler.
Since TrustedImm32/64 are signed integers, the arithmetic shift would
never get rid of the top bit and we get an infinite loop.
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (204008 => 204009)
--- trunk/Source/_javascript_Core/ChangeLog 2016-08-02 03:59:18 UTC (rev 204008)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-08-02 05:02:27 UTC (rev 204009)
@@ -1,3 +1,15 @@
+2016-08-01 Benjamin Poulain <bpoul...@apple.com>
+
+ [JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
+ https://bugs.webkit.org/show_bug.cgi?id=160439
+
+ Reviewed by Filip Pizlo.
+
+ * assembler/MacroAssemblerARM64.h:
+ (JSC::MacroAssemblerARM64::branchTest64):
+ * b3/air/AirOpcode.opcodes:
+ Fix the ARM64 codegen to lower BitImm64 without using a scratch register.
+
2016-07-22 Filip Pizlo <fpi...@apple.com>
[B3] Fusing immediates into test instructions should work again
Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h (204008 => 204009)
--- trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h 2016-08-02 03:59:18 UTC (rev 204008)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerARM64.h 2016-08-02 05:02:27 UTC (rev 204009)
@@ -2520,8 +2520,24 @@
Jump branchTest64(ResultCondition cond, RegisterID reg, TrustedImm64 mask)
{
- move(mask, getCachedDataTempRegisterIDAndInvalidate());
- return branchTest64(cond, reg, dataTempRegister);
+ if (mask.m_value == -1) {
+ if ((cond == Zero) || (cond == NonZero))
+ return Jump(makeCompareAndBranch<64>(static_cast<ZeroCondition>(cond), reg));
+ m_assembler.tst<64>(reg, reg);
+ } else if (hasOneBitSet(mask.m_value) && ((cond == Zero) || (cond == NonZero)))
+ return Jump(makeTestBitAndBranch(reg, getLSBSet(mask.m_value), static_cast<ZeroCondition>(cond)));
+ else {
+ LogicalImmediate logicalImm = LogicalImmediate::create64(mask.m_value);
+
+ if (logicalImm.isValid()) {
+ m_assembler.tst<64>(reg, logicalImm);
+ return Jump(makeBranch(cond));
+ }
+
+ move(mask, getCachedDataTempRegisterIDAndInvalidate());
+ m_assembler.tst<64>(reg, dataTempRegister);
+ }
+ return Jump(makeBranch(cond));
}
Jump branchTest64(ResultCondition cond, Address address, RegisterID mask)
Modified: trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes (204008 => 204009)
--- trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes 2016-08-02 03:59:18 UTC (rev 204008)
+++ trunk/Source/_javascript_Core/b3/air/AirOpcode.opcodes 2016-08-02 05:02:27 UTC (rev 204009)
@@ -680,7 +680,7 @@
BranchTest32 U:G:32, U:G:32, U:G:32 /branch
ResCond, Tmp, Tmp
- x86: ResCond, Tmp, BitImm
+ ResCond, Tmp, BitImm
x86: ResCond, Addr, BitImm
x86: ResCond, Index, BitImm
@@ -688,6 +688,7 @@
# BranchTest32 in most cases where you use an immediate.
64: BranchTest64 U:G:32, U:G:64, U:G:64 /branch
ResCond, Tmp, Tmp
+ arm64: ResCond, Tmp, BitImm64
x86: ResCond, Tmp, BitImm
x86: ResCond, Addr, BitImm
x86: ResCond, Addr, Tmp
Modified: trunk/Source/WTF/ChangeLog (204008 => 204009)
--- trunk/Source/WTF/ChangeLog 2016-08-02 03:59:18 UTC (rev 204008)
+++ trunk/Source/WTF/ChangeLog 2016-08-02 05:02:27 UTC (rev 204009)
@@ -1,3 +1,16 @@
+2016-08-01 Benjamin Poulain <bpoul...@apple.com>
+
+ [JSC][ARM64] Fix branchTest32/64 taking an immediate as mask
+ https://bugs.webkit.org/show_bug.cgi?id=160439
+
+ Reviewed by Filip Pizlo.
+
+ * wtf/MathExtras.h:
+ (getLSBSet):
+ This was not working at all for MacroAssembler.
+ Since TrustedImm32/64 are signed integers, the arithmetic shift would
+ never get rid of the top bit and we get an infinite loop.
+
2016-07-29 Mark Lam <mark....@apple.com>
Make StringView capable of being passed or returned in only 2 registers.
Modified: trunk/Source/WTF/wtf/MathExtras.h (204008 => 204009)
--- trunk/Source/WTF/wtf/MathExtras.h 2016-08-02 03:59:18 UTC (rev 204008)
+++ trunk/Source/WTF/wtf/MathExtras.h 2016-08-02 05:02:27 UTC (rev 204009)
@@ -215,9 +215,11 @@
template <typename T> inline unsigned getLSBSet(T value)
{
+ typedef typename std::make_unsigned<T>::type UnsignedT;
unsigned result = 0;
- while (value >>= 1)
+ UnsignedT unsignedValue = static_cast<UnsignedT>(value);
+ while (unsignedValue >>= 1)
++result;
return result;