Commits

Maciej Fijalkowski committed 5858ed5

Remove extra guard_not_invalidated ops

  • Participants
  • Parent commits 65472e2
  • Branches out-of-line-guards-2

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/heap.py

         # cached array items:  {descr: CachedArrayItems}
         self.cached_arrayitems = {}
         self._remove_guard_not_invalidated = False
+        self._seen_guard_not_invalidated = False
 
     def reconstruct_for_next_iteration(self, optimizer, valuemap):
         new = OptHeap()
                 effectinfo = None
             else:
                 effectinfo = op.getdescr().get_extra_info()
+            if (effectinfo is None or effectinfo.extraeffect >=
+                effectinfo.EF_FORCES_VIRTUAL_OR_VIRTUALIZABLE):
+                self._seen_guard_not_invalidated = False
             if effectinfo is not None:
                 # XXX we can get the wrong complexity here, if the lists
                 # XXX stored on effectinfo are large
         if self._remove_guard_not_invalidated:
             return
         self._remove_guard_not_invalidated = False
+        if self._seen_guard_not_invalidated:
+            return
+        self._seen_guard_not_invalidated = True
         self.emit_operation(op)
 
     def propagate_forward(self, op):

pypy/jit/metainterp/test/test_optimizeopt.py

         """
         self.optimize_loop(ops, expected, expected)
 
+    def test_remove_extra_guards_not_invalidated(self):
+        ops = """
+        []
+        guard_not_invalidated() []
+        guard_not_invalidated() []
+        jump()
+        """
+        expected = """
+        []
+        guard_not_invalidated() []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+
+    def test_call_may_force_invalidated_guards(self):
+        ops = """
+        [i0]
+        guard_not_invalidated() []
+        call_may_force(i0, descr=mayforcevirtdescr)
+        guard_not_invalidated() []
+        jump(i0)
+        """
+        expected = """
+        [i0]
+        guard_not_invalidated() []
+        call_may_force(i0, descr=mayforcevirtdescr)
+        guard_not_invalidated() []
+        jump(i0)
+        """
+        self.optimize_loop(ops, expected)
+
 ##class TestOOtype(OptimizeOptTest, OOtypeMixin):
 
 ##    def test_instanceof(self):