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 324320 ad1e7fdc44b303e0a1bfe0e546ace9e71192598a
parent 324319 8986592ec95420af9ef332aeb5b471a7396dbb7f
child 324321 192d80d2d1def1fafcc9039eae4b021779f82639
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1246229
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)