[pypy-svn] r70275 - in pypy/branch/jit-delayed-write/pypy/jit/metainterp: . test

arigo at codespeak.net arigo at codespeak.net
Fri Dec 25 22:15:50 CET 2009


Author: arigo
Date: Fri Dec 25 22:15:50 2009
New Revision: 70275

Modified:
   pypy/branch/jit-delayed-write/pypy/jit/metainterp/optimizeopt.py
   pypy/branch/jit-delayed-write/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
force_all_lazy_setfields_of_nonvirtuals().
Missing: job in resume.py to handle the lazy setfields


Modified: pypy/branch/jit-delayed-write/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/jit-delayed-write/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/branch/jit-delayed-write/pypy/jit/metainterp/optimizeopt.py	Fri Dec 25 22:15:50 2009
@@ -918,7 +918,7 @@
         if op.is_ovf():
             return
         if op.is_guard():
-            self.force_all_lazy_setfields()
+            self.force_all_lazy_setfields_of_nonvirtuals()
             return
         opnum = op.opnum
         if (opnum == rop.SETFIELD_GC or
@@ -965,6 +965,16 @@
                 self.force_lazy_setfield(descr)
             del self.lazy_setfields_descrs[:]
 
+    def force_all_lazy_setfields_of_nonvirtuals(self):
+        for descr in self.lazy_setfields_descrs:
+            try:
+                op = self.lazy_setfields[descr]
+            except KeyError:
+                continue
+            fieldvalue = self.optimizer.getvalue(op.args[1])
+            if not fieldvalue.is_virtual():
+                self.force_lazy_setfield(descr)
+
     def force_lazy_setfield_if_necessary(self, op, value, write=False):
         try:
             op1 = self.lazy_setfields[op.descr]

Modified: pypy/branch/jit-delayed-write/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/branch/jit-delayed-write/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/branch/jit-delayed-write/pypy/jit/metainterp/test/test_optimizeopt.py	Fri Dec 25 22:15:50 2009
@@ -1376,7 +1376,7 @@
         """
         self.optimize_loop(ops, 'Not, Not, Not', ops)
 
-    def test_duplicate_setfield_residual_guard(self):
+    def test_duplicate_setfield_residual_guard_1(self):
         ops = """
         [p1, i1, i2, i3]
         setfield_gc(p1, i1, descr=valuedescr)
@@ -1387,6 +1387,27 @@
         """
         self.optimize_loop(ops, 'Not, Not, Not, Not', ops)
 
+    def test_duplicate_setfield_residual_guard_2(self):
+        # the difference with the previous test is that the field value is
+        # a virtual, which we try hard to keep virtual
+        ops = """
+        [p1, i2, i3]
+        p2 = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p1, p2, descr=nextdescr)
+        guard_true(i3) []
+        i4 = int_neg(i2)
+        setfield_gc(p1, NULL, descr=nextdescr)
+        jump(p1, i2, i4)
+        """
+        expected = """
+        [p1, i2, i3]
+        guard_true(i3) []
+        i4 = int_neg(i2)
+        setfield_gc(p1, NULL, descr=nextdescr)
+        jump(p1, i2, i4)
+        """
+        self.optimize_loop(ops, 'Not, Not, Not', expected)
+
     def test_duplicate_setfield_aliasing(self):
         # a case where aliasing issues (and not enough cleverness) mean
         # that we fail to remove any setfield_gc



More information about the Pypy-commit mailing list