[pypy-svn] pypy default: Test and improvement. Also a fix for another case, but it's hard to test.

arigo commits-noreply at bitbucket.org
Thu Mar 24 19:34:31 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r42908:8caf8ba85fc3
Date: 2011-03-24 18:47 +0100
http://bitbucket.org/pypy/pypy/changeset/8caf8ba85fc3/

Log:	Test and improvement. Also a fix for another case, but it's hard to
	test.

diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -2066,6 +2066,23 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_dont_force_setfield_around_copystrcontent(self):
+        ops = """
+        [p0, i0, p1, i1, i2]
+        setfield_gc(p0, i1, descr=valuedescr)
+        copystrcontent(p0, i0, p1, i1, i2)
+        escape()
+        jump(p0, i0, p1, i1, i2)
+        """
+        expected = """
+        [p0, i0, p1, i1, i2]
+        copystrcontent(p0, i0, p1, i1, i2)
+        setfield_gc(p0, i1, descr=valuedescr)
+        escape()
+        jump(p0, i0, p1, i1, i2)
+        """
+        self.optimize_loop(ops, expected)
+
     def test_duplicate_getarrayitem_1(self):
         ops = """
         [p1]

diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -220,11 +220,15 @@
             self.optimizer.pendingfields = self.force_lazy_setfields_for_guard()
             return
         opnum = op.getopnum()
-        if (opnum == rop.SETFIELD_GC or
-            opnum == rop.SETFIELD_RAW or
-            opnum == rop.SETARRAYITEM_GC or
-            opnum == rop.SETARRAYITEM_RAW or
-            opnum == rop.DEBUG_MERGE_POINT):
+        if (opnum == rop.SETFIELD_GC or        # handled specially
+            opnum == rop.SETFIELD_RAW or       # no effect on GC struct/array
+            opnum == rop.SETARRAYITEM_GC or    # handled specially
+            opnum == rop.SETARRAYITEM_RAW or   # no effect on GC struct
+            opnum == rop.STRSETITEM or         # no effect on GC struct/array
+            opnum == rop.UNICODESETITEM or     # no effect on GC struct/array
+            opnum == rop.DEBUG_MERGE_POINT or  # no effect whatsoever
+            opnum == rop.COPYSTRCONTENT or     # no effect on GC struct/array
+            opnum == rop.COPYUNICODECONTENT):  # no effect on GC struct/array
             return
         assert opnum != rop.CALL_PURE
         if (opnum == rop.CALL or
@@ -257,10 +261,7 @@
                     # ^^^ we only need to force this field; the other fields
                     # of virtualref_info and virtualizable_info are not gcptrs.
                 return
-            self.force_all_lazy_setfields()
-        elif op.is_final() or (not we_are_translated() and
-                               op.getopnum() < 0):   # escape() operations
-            self.force_all_lazy_setfields()
+        self.force_all_lazy_setfields()
         self.clean_caches()
 
 
@@ -303,12 +304,10 @@
         newoperations[-1] = prevop
 
     def force_all_lazy_setfields(self):
-        if len(self._lazy_setfields) > 0:
-            for cf in self._lazy_setfields:
-                if not we_are_translated():
-                    assert cf in self.cached_fields.values()
-                cf.force_lazy_setfield(self)
-            del self._lazy_setfields[:]
+        for cf in self._lazy_setfields:
+            if not we_are_translated():
+                assert cf in self.cached_fields.values()
+            cf.force_lazy_setfield(self)
 
     def force_lazy_setfields_for_guard(self):
         pendingfields = []


More information about the Pypy-commit mailing list