Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (180084 => 180085)
--- trunk/Source/_javascript_Core/ChangeLog 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/ChangeLog 2015-02-13 23:08:18 UTC (rev 180085)
@@ -1,3 +1,27 @@
+2015-02-13 Benjamin Poulain <bpoul...@apple.com>
+
+ ArithSqrt should not be conditional on supportsFloatingPointSqrt
+ https://bugs.webkit.org/show_bug.cgi?id=141546
+
+ Reviewed by Geoffrey Garen and Filip Pizlo.
+
+ Just fallback to the function call in the DFG codegen.
+
+ * dfg/DFGByteCodeParser.cpp:
+ (JSC::DFG::ByteCodeParser::handleIntrinsic):
+ * dfg/DFGSpeculativeJIT.cpp:
+ (JSC::DFG::SpeculativeJIT::compileArithSqrt):
+ * dfg/DFGSpeculativeJIT.h:
+ * dfg/DFGSpeculativeJIT32_64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * dfg/DFGSpeculativeJIT64.cpp:
+ (JSC::DFG::SpeculativeJIT::compile):
+ * tests/stress/math-sqrt-basics.js: Added.
+ Basic coverage.
+
+ * tests/stress/math-sqrt-basics-disable-architecture-specific-optimizations.js: Added.
+ Same tests but forcing the function call.
+
2015-02-13 Michael Saboff <msab...@apple.com>
REGRESSION(r180060) New js/regress-141098 test crashes when LLInt is disabled.
Modified: trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (180084 => 180085)
--- trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp 2015-02-13 23:08:18 UTC (rev 180085)
@@ -1668,9 +1668,6 @@
switch (intrinsic) {
case SqrtIntrinsic:
- if (!MacroAssembler::supportsFloatingPointSqrt())
- return false;
-
set(VirtualRegister(resultOperand), addToGraph(ArithSqrt, get(virtualRegisterForArgument(1, registerOffset))));
return true;
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (180084 => 180085)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp 2015-02-13 23:08:18 UTC (rev 180085)
@@ -3543,6 +3543,23 @@
}
}
+void SpeculativeJIT::compileArithSqrt(Node* node)
+{
+ SpeculateDoubleOperand op1(this, node->child1());
+ FPRReg op1FPR = op1.fpr();
+
+ if (!MacroAssembler::supportsFloatingPointSqrt() || !Options::enableArchitectureSpecificOptimizations()) {
+ flushRegisters();
+ FPRResult result(this);
+ callOperation(sqrt, result.fpr(), op1FPR);
+ doubleResult(result.fpr(), node);
+ } else {
+ FPRTemporary result(this, op1);
+ m_jit.sqrtDouble(op1.fpr(), result.fpr());
+ doubleResult(result.fpr(), node);
+ }
+}
+
// Returns true if the compare is fused with a subsequent branch.
bool SpeculativeJIT::compare(Node* node, MacroAssembler::RelationalCondition condition, MacroAssembler::DoubleCondition doubleCondition, S_JITOperation_EJJ operation)
{
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h (180084 => 180085)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.h 2015-02-13 23:08:18 UTC (rev 180085)
@@ -2134,6 +2134,7 @@
void compileArithMul(Node*);
void compileArithDiv(Node*);
void compileArithMod(Node*);
+ void compileArithSqrt(Node*);
void compileConstantStoragePointer(Node*);
void compileGetIndexedPropertyStorage(Node*);
JITCompiler::Jump jumpForTypedArrayOutOfBounds(Node*, GPRReg baseGPR, GPRReg indexGPR);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (180084 => 180085)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp 2015-02-13 23:08:18 UTC (rev 180085)
@@ -2099,17 +2099,11 @@
}
break;
}
-
- case ArithSqrt: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRTemporary result(this, op1);
-
- m_jit.sqrtDouble(op1.fpr(), result.fpr());
-
- doubleResult(result.fpr(), node);
+
+ case ArithSqrt:
+ compileArithSqrt(node);
break;
- }
-
+
case ArithFRound: {
SpeculateDoubleOperand op1(this, node->child1());
FPRTemporary result(this, op1);
Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp (180084 => 180085)
--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2015-02-13 22:57:28 UTC (rev 180084)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT64.cpp 2015-02-13 23:08:18 UTC (rev 180085)
@@ -2240,17 +2240,11 @@
}
break;
}
-
- case ArithSqrt: {
- SpeculateDoubleOperand op1(this, node->child1());
- FPRTemporary result(this, op1);
-
- m_jit.sqrtDouble(op1.fpr(), result.fpr());
-
- doubleResult(result.fpr(), node);
+
+ case ArithSqrt:
+ compileArithSqrt(node);
break;
- }
-
+
case ArithFRound: {
SpeculateDoubleOperand op1(this, node->child1());
FPRTemporary result(this, op1);
Added: trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics-disable-architecture-specific-optimizations.js (0 => 180085)
--- trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics-disable-architecture-specific-optimizations.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics-disable-architecture-specific-optimizations.js 2015-02-13 23:08:18 UTC (rev 180085)
@@ -0,0 +1,48 @@
+//@ run("no-architecture-specific-optimizations", "--enableArchitectureSpecificOptimizations=false", *NO_CJIT_OPTIONS)
+//@ run("no-architecture-specific-optimizations-ftl", "--enableArchitectureSpecificOptimizations=false", *FTL_OPTIONS)
+
+// Basic cases of Math.sqrt().
+function sqrtOnInteger(radicand) {
+ return Math.sqrt(radicand);
+}
+noInline(sqrtOnInteger);
+
+function testSquareRoot16() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = sqrtOnInteger(16);
+ if (result !== 4)
+ throw "sqrtOnInteger(16) = " + result + ", expected 4";
+ }
+}
+testSquareRoot16();
+
+var sqrtOnIntegerNegativeNumber = sqrtOnDouble(-4);
+if (!isNaN(sqrtOnIntegerNegativeNumber))
+ throw "sqrtOnDouble(-4) = " + sqrtOnIntegerNegativeNumber + ", expected NaN";
+
+var sqrtOnIntegerFallback = sqrtOnInteger(Math.PI);
+if (sqrtOnIntegerFallback != 1.7724538509055159)
+ throw "sqrtOnInteger(Math.PI) = " + sqrtOnIntegerFallback + ", expected 1.7724538509055159";
+
+
+function sqrtOnDouble(radicand) {
+ return Math.sqrt(radicand);
+}
+noInline(sqrtOnDouble);
+
+function testSquareRootDouble() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = sqrtOnInteger(Math.LN2);
+ if (result !== 0.8325546111576977)
+ throw "sqrtOnInteger(Math.LN2) = " + result + ", expected 0.8325546111576977";
+ }
+}
+testSquareRootDouble();
+
+var sqrtOnDoubleNegativeNumber = sqrtOnDouble(-Math.PI);
+if (!isNaN(sqrtOnDoubleNegativeNumber))
+ throw "sqrtOnDouble(-Math.PI) = " + sqrtOnDoubleNegativeNumber + ", expected NaN";
+
+var sqrtOnDoubleFallback = sqrtOnDouble(4);
+if (sqrtOnDoubleFallback !== 2)
+ throw "sqrtOnDouble(4) = " + sqrtOnDoubleFallback + ", expected 2";
\ No newline at end of file
Added: trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics.js (0 => 180085)
--- trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics.js (rev 0)
+++ trunk/Source/_javascript_Core/tests/stress/math-sqrt-basics.js 2015-02-13 23:08:18 UTC (rev 180085)
@@ -0,0 +1,45 @@
+// Basic cases of Math.sqrt().
+function sqrtOnInteger(radicand) {
+ return Math.sqrt(radicand);
+}
+noInline(sqrtOnInteger);
+
+function testSquareRoot16() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = sqrtOnInteger(16);
+ if (result !== 4)
+ throw "sqrtOnInteger(16) = " + result + ", expected 4";
+ }
+}
+testSquareRoot16();
+
+var sqrtOnIntegerNegativeNumber = sqrtOnDouble(-4);
+if (!isNaN(sqrtOnIntegerNegativeNumber))
+ throw "sqrtOnDouble(-4) = " + sqrtOnIntegerNegativeNumber + ", expected NaN";
+
+var sqrtOnIntegerFallback = sqrtOnInteger(Math.PI);
+if (sqrtOnIntegerFallback != 1.7724538509055159)
+ throw "sqrtOnInteger(Math.PI) = " + sqrtOnIntegerFallback + ", expected 1.7724538509055159";
+
+
+function sqrtOnDouble(radicand) {
+ return Math.sqrt(radicand);
+}
+noInline(sqrtOnDouble);
+
+function testSquareRootDouble() {
+ for (var i = 0; i < 10000; ++i) {
+ var result = sqrtOnInteger(Math.LN2);
+ if (result !== 0.8325546111576977)
+ throw "sqrtOnInteger(Math.LN2) = " + result + ", expected 0.8325546111576977";
+ }
+}
+testSquareRootDouble();
+
+var sqrtOnDoubleNegativeNumber = sqrtOnDouble(-Math.PI);
+if (!isNaN(sqrtOnDoubleNegativeNumber))
+ throw "sqrtOnDouble(-Math.PI) = " + sqrtOnDoubleNegativeNumber + ", expected NaN";
+
+var sqrtOnDoubleFallback = sqrtOnDouble(4);
+if (sqrtOnDoubleFallback !== 2)
+ throw "sqrtOnDouble(4) = " + sqrtOnDoubleFallback + ", expected 2";
\ No newline at end of file