[pypy-svn] pypy jit-short-preamble: Make getfield kill setfields

hakanardo commits-noreply at bitbucket.org
Fri Jan 14 08:36:46 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short-preamble
Changeset: r40654:dd0db4bfb587
Date: 2011-01-13 21:21 +0100
http://bitbucket.org/pypy/pypy/changeset/dd0db4bfb587/

Log:	Make getfield kill setfields

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
@@ -4588,6 +4588,27 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_let_getfield_kill_setfields(self):
+        ops = """
+        [p0]
+        p1 = getfield_gc(p0, descr=valuedescr)
+        setfield_gc(p0, p1, descr=valuedescr)
+        setfield_gc(p0, p1, descr=valuedescr)
+        setfield_gc(p0, p0, descr=valuedescr)        
+        jump(p0)
+        """
+        preamble = """
+        [p0]
+        p1 = getfield_gc(p0, descr=valuedescr)
+        setfield_gc(p0, p0, descr=valuedescr)                
+        jump(p0)
+        """
+        expected = """
+        [p0]
+        jump(p0)
+        """
+        self.optimize_loop(ops, expected, preamble)
+
     def test_inputargs_added_by_forcing_jumpargs(self):
         # FXIME: Can this occur?
         ops = """
@@ -5237,6 +5258,7 @@
         # more generally, supporting non-constant but virtual cases is
         # not obvious, because of the exception UnicodeDecodeError that
         # can be raised by ll_str2unicode()
+        
 
 
 

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
@@ -280,10 +280,12 @@
     def optimize_SETFIELD_GC(self, op):
         value = self.getvalue(op.getarg(0))
         fieldvalue = self.getvalue(op.getarg(1))
-        self.force_lazy_setfield_if_necessary(op, value, write=True)
-        self.lazy_setfields[op.getdescr()] = op
-        # remember the result of future reads of the field
-        self.cache_field_value(op.getdescr(), value, fieldvalue, write=True)
+        cached_fieldvalue = self.read_cached_field(op.getdescr(), value)
+        if fieldvalue is not cached_fieldvalue:
+            self.force_lazy_setfield_if_necessary(op, value, write=True)
+            self.lazy_setfields[op.getdescr()] = op
+            # remember the result of future reads of the field
+            self.cache_field_value(op.getdescr(), value, fieldvalue, write=True)
 
     def optimize_GETARRAYITEM_GC(self, op):
         value = self.getvalue(op.getarg(0))


More information about the Pypy-commit mailing list