Bug 1246229 - Enable DCE to remove OSR guards if their values are optimized-out. r=h4writer
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Mon, 29 Feb 2016 13:20:36 +0000
changeset 286437 ad1e7fdc44b303e0a1bfe0e546ace9e71192598a
parent 286436 8986592ec95420af9ef332aeb5b471a7396dbb7f
child 286438 192d80d2d1def1fafcc9039eae4b021779f82639
push id19612
push usergwagner@mozilla.com
push dateWed, 09 Mar 2016 16:35:37 +0000
treeherderb2g-inbound@3e95b2a351a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1246229
milestone47.0a1
Bug 1246229 - Enable DCE to remove OSR guards if their values are optimized-out. r=h4writer
js/src/jit-test/tests/ion/osr-with-optimized-out.js
js/src/jit/IonAnalysis.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/osr-with-optimized-out.js
@@ -0,0 +1,22 @@
+// |jit-test| --ion-offthread-compile=off;
+
+// We disable any off-main thread compilation, and set a definite trigger for
+// Ion compilation, such that we can garantee that we would OSR into the inner
+// loop before we reach the end of the loop.
+setJitCompilerOption("ion.warmup.trigger", 30);
+
+function f (n) {
+    while (!inIon()) {
+        var inner = 0;
+        let x = {};
+        for (var i = 0; i < n; i++) {
+            inner += inIon() == true ? 1 : 0;
+            if (inner <= 1)
+                bailout();
+        }
+        assertEq(inner != 1, true);
+    }
+}
+
+// Iterate enough to ensure that we OSR in this inner loop.
+f(300);
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -945,17 +945,19 @@ jit::EliminateDeadResumePointOperands(MI
 
     return true;
 }
 
 // Test whether |def| would be needed if it had no uses.
 bool
 js::jit::DeadIfUnused(const MDefinition* def)
 {
-    return !def->isEffectful() && !def->isGuard() && !def->isGuardRangeBailouts() &&
+    return !def->isEffectful() &&
+           (!def->isGuard() || def->block() == def->block()->graph().osrBlock()) &&
+           !def->isGuardRangeBailouts() &&
            !def->isControlInstruction() &&
            (!def->isInstruction() || !def->toInstruction()->resumePoint());
 }
 
 // Test whether |def| may be safely discarded, due to being dead or due to being
 // located in a basic block which has itself been marked for discarding.
 bool
 js::jit::IsDiscardable(const MDefinition* def)