Title: [119299] trunk
Revision
119299
Author
[email protected]
Date
2012-06-01 16:18:59 -0700 (Fri, 01 Jun 2012)

Log Message

DFG should not emit unnecessary speculation checks when performing an int32 to double conversion on
a value that is proved to be a number, predicted to be an int32, but not proved to be an int32
https://bugs.webkit.org/show_bug.cgi?id=88146

Reviewed by Gavin Barraclough.

Source/_javascript_Core: 

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileInt32ToDouble):

LayoutTests: 

* fast/js/dfg-int32-to-double-on-known-number-expected.txt: Added.
* fast/js/dfg-int32-to-double-on-known-number.html: Added.
* fast/js/script-tests/dfg-int32-to-double-on-known-number.js: Added.
(foo.bar):
(foo):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119298 => 119299)


--- trunk/LayoutTests/ChangeLog	2012-06-01 23:18:21 UTC (rev 119298)
+++ trunk/LayoutTests/ChangeLog	2012-06-01 23:18:59 UTC (rev 119299)
@@ -1,3 +1,17 @@
+2012-06-01  Filip Pizlo  <[email protected]>
+
+        DFG should not emit unnecessary speculation checks when performing an int32 to double conversion on
+        a value that is proved to be a number, predicted to be an int32, but not proved to be an int32
+        https://bugs.webkit.org/show_bug.cgi?id=88146
+
+        Reviewed by Gavin Barraclough.
+
+        * fast/js/dfg-int32-to-double-on-known-number-expected.txt: Added.
+        * fast/js/dfg-int32-to-double-on-known-number.html: Added.
+        * fast/js/script-tests/dfg-int32-to-double-on-known-number.js: Added.
+        (foo.bar):
+        (foo):
+
 2012-06-01  Tony Chang  <[email protected]>
 
         rename -webkit-flex-pack and -webkit-flex-line-pack to -webkit-justify-content and -webkit-align-content

Added: trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number-expected.txt (0 => 119299)


--- trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number-expected.txt	2012-06-01 23:18:59 UTC (rev 119299)
@@ -0,0 +1,209 @@
+Tests that we don't emit unnecessary speculation checks when performing an int32 to double conversion on a value that is proved to be a number, predicted to be an int32, but not proved to be an int32.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS foo({f:5}, 42.5) is 52.5
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number.html (0 => 119299)


--- trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number.html	                        (rev 0)
+++ trunk/LayoutTests/fast/js/dfg-int32-to-double-on-known-number.html	2012-06-01 23:18:59 UTC (rev 119299)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/js/script-tests/dfg-int32-to-double-on-known-number.js (0 => 119299)


--- trunk/LayoutTests/fast/js/script-tests/dfg-int32-to-double-on-known-number.js	                        (rev 0)
+++ trunk/LayoutTests/fast/js/script-tests/dfg-int32-to-double-on-known-number.js	2012-06-01 23:18:59 UTC (rev 119299)
@@ -0,0 +1,20 @@
+description(
+"Tests that we don't emit unnecessary speculation checks when performing an int32 to double conversion on a value that is proved to be a number, predicted to be an int32, but not proved to be an int32."
+);
+
+function foo(a, b) {
+    var x = a.f;
+    var y;
+    function bar() {
+        return y;
+    }
+    var z = x + b;
+    y = x;
+    if (z > 1)
+        return y + b + bar();
+    else
+        return 72;
+}
+
+for (var i = 0; i < 200; ++i)
+    shouldBe("foo({f:5}, 42.5)", "52.5");

Modified: trunk/Source/_javascript_Core/ChangeLog (119298 => 119299)


--- trunk/Source/_javascript_Core/ChangeLog	2012-06-01 23:18:21 UTC (rev 119298)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-06-01 23:18:59 UTC (rev 119299)
@@ -1,5 +1,16 @@
 2012-06-01  Filip Pizlo  <[email protected]>
 
+        DFG should not emit unnecessary speculation checks when performing an int32 to double conversion on
+        a value that is proved to be a number, predicted to be an int32, but not proved to be an int32
+        https://bugs.webkit.org/show_bug.cgi?id=88146
+
+        Reviewed by Gavin Barraclough.
+
+        * dfg/DFGSpeculativeJIT.cpp:
+        (JSC::DFG::SpeculativeJIT::compileInt32ToDouble):
+
+2012-06-01  Filip Pizlo  <[email protected]>
+
         DFG constant folding search for the last local access skips the immediately previous local access
         https://bugs.webkit.org/show_bug.cgi?id=88141
 

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (119298 => 119299)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-06-01 23:18:21 UTC (rev 119298)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2012-06-01 23:18:59 UTC (rev 119299)
@@ -1850,9 +1850,11 @@
     JITCompiler::Jump isInteger = m_jit.branchPtr(
         MacroAssembler::AboveOrEqual, op1GPR, GPRInfo::tagTypeNumberRegister);
     
-    speculationCheck(
-        BadType, JSValueRegs(op1GPR), node.child1(),
-        m_jit.branchTestPtr(MacroAssembler::Zero, op1GPR, GPRInfo::tagTypeNumberRegister));
+    if (!isNumberPrediction(m_state.forNode(node.child1()).m_type)) {
+        speculationCheck(
+            BadType, JSValueRegs(op1GPR), node.child1(),
+            m_jit.branchTestPtr(MacroAssembler::Zero, op1GPR, GPRInfo::tagTypeNumberRegister));
+    }
     
     m_jit.move(op1GPR, tempGPR);
     unboxDouble(tempGPR, resultFPR);
@@ -1872,9 +1874,11 @@
     JITCompiler::Jump isInteger = m_jit.branch32(
         MacroAssembler::Equal, op1TagGPR, TrustedImm32(JSValue::Int32Tag));
     
-    speculationCheck(
-        BadType, JSValueRegs(op1TagGPR, op1PayloadGPR), node.child1(),
-        m_jit.branch32(MacroAssembler::AboveOrEqual, op1TagGPR, TrustedImm32(JSValue::LowestTag)));
+    if (!isNumberPrediction(m_state.forNode(node.child1()).m_type)) {
+        speculationCheck(
+            BadType, JSValueRegs(op1TagGPR, op1PayloadGPR), node.child1(),
+            m_jit.branch32(MacroAssembler::AboveOrEqual, op1TagGPR, TrustedImm32(JSValue::LowestTag)));
+    }
     
     unboxDouble(op1TagGPR, op1PayloadGPR, resultFPR, tempFPR);
     JITCompiler::Jump done = m_jit.jump();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to