Title: [184542] trunk/Source/_javascript_Core
- Revision
- 184542
- Author
- [email protected]
- Date
- 2015-05-18 21:46:26 -0700 (Mon, 18 May 2015)
Log Message
Better optimize 'if' with ternaries conditional tests.
https://bugs.webkit.org/show_bug.cgi?id=144136
Reviewed by Benjamin Poulain.
This is the last fix I'll do for this for now. BooleanToNumber(Untyped:) where the input
is proved to be either BoolInt32 or Boolean should be optimized to just masking the
lowest bit.
This is another 37% speed-up on JSRegress/slow-ternaries.
* dfg/DFGSpeculativeJIT32_64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::compile):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileBooleanToNumber):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (184541 => 184542)
--- trunk/Source/_javascript_Core/ChangeLog 2015-05-19 03:39:14 UTC (rev 184541)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-05-19 04:46:26 UTC (rev 184542)
@@ -1,3 +1,23 @@
+2015-05-18 Filip Pizlo <[email protected]>
+
+ Better optimize 'if' with ternaries conditional tests.
+ https://bugs.webkit.org/show_bug.cgi?id=144136
+
+ Reviewed by Benjamin Poulain.
+
+ This is the last fix I'll do for this for now. BooleanToNumber(Untyped:) where the input
+ is proved to be either BoolInt32 or Boolean should be optimized to just masking the
+ lowest bit.
+
+ This is another 37% speed-up on JSRegress/slow-ternaries.
+
+ * dfg/DFGSpeculativeJIT32_64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGSpeculativeJIT64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * ftl/FTLLowerDFGToLLVM.cpp:
+ (JSC::FTL::LowerDFGToLLVM::compileBooleanToNumber):
+
2015-05-18 Benjamin Poulain <[email protected]>
<rdar://problem/21003555> cloberrize() is wrong for ArithRound because it doesn't account for the arith mode
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (184541 => 184542)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2015-05-19 03:39:14 UTC (rev 184541)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2015-05-19 04:46:26 UTC (rev 184542)
@@ -3058,6 +3058,18 @@
case UntypedUse: {
JSValueOperand value(this, node->child1());
+
+ if (!m_interpreter.needsTypeCheck(node->child1(), SpecBoolInt32 | SpecBoolean)) {
+ GPRTemporary result(this);
+
+ GPRReg valueGPR = value.payloadGPR();
+ GPRReg resultGPR = result.gpr();
+
+ m_jit.move(valueGPR, resultGPR);
+ int32Result(result.gpr(), node);
+ break;
+ }
+
GPRTemporary resultTag(this);
GPRTemporary resultPayload(this);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (184541 => 184542)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2015-05-19 03:39:14 UTC (rev 184541)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2015-05-19 04:46:26 UTC (rev 184542)
@@ -3150,6 +3150,13 @@
JSValueOperand value(this, node->child1());
GPRTemporary result(this);
+ if (!m_interpreter.needsTypeCheck(node->child1(), SpecBoolInt32 | SpecBoolean)) {
+ m_jit.move(value.gpr(), result.gpr());
+ m_jit.and32(TrustedImm32(1), result.gpr());
+ int32Result(result.gpr(), node);
+ break;
+ }
+
m_jit.move(value.gpr(), result.gpr());
m_jit.xor64(TrustedImm32(static_cast<int32_t>(ValueFalse)), result.gpr());
JITCompiler::Jump isBoolean = m_jit.branchTest64(
Modified: trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (184541 => 184542)
--- trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2015-05-19 03:39:14 UTC (rev 184541)
+++ trunk/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp 2015-05-19 04:46:26 UTC (rev 184542)
@@ -1080,6 +1080,11 @@
case UntypedUse: {
LValue value = lowJSValue(m_node->child1());
+ if (!m_interpreter.needsTypeCheck(m_node->child1(), SpecBoolInt32 | SpecBoolean)) {
+ setInt32(m_out.bitAnd(m_out.castToInt32(value), m_out.int32One));
+ return;
+ }
+
LBasicBlock booleanCase = FTL_NEW_BLOCK(m_out, ("BooleanToNumber boolean case"));
LBasicBlock continuation = FTL_NEW_BLOCK(m_out, ("BooleanToNumber continuation"));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes