1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed c3d7dd9

Fixes

  • Participants
  • Parent commits 8c9539a
  • Branches stmgc-c7

Comments (0)

Files changed (3)

File rpython/jit/backend/llsupport/rewrite.py

View file
  • Ignore whitespace
 
     # ----------
 
+    def must_apply_write_barrier(self, val, v):
+        if val not in self.write_barrier_applied:
+            if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
+                                         bool(v.value)): # store a non-NULL
+                return True
+        return False
+
     def handle_write_barrier_setfield(self, op):
         val = op.getarg(0)
-        if val not in self.write_barrier_applied:
-            v = op.getarg(1)
-            if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
-                                         bool(v.value)): # store a non-NULL
-                self.gen_write_barrier(val)
-                #op = op.copy_and_change(rop.SETFIELD_RAW)
+        if self.must_apply_write_barrier(val, op.getarg(1)):
+            self.gen_write_barrier(val)
+            #op = op.copy_and_change(rop.SETFIELD_RAW)
         self.newops.append(op)
 
     def handle_write_barrier_setinteriorfield(self, op):
         val = op.getarg(0)
-        if val not in self.write_barrier_applied:
-            v = op.getarg(2)
-            if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
-                                         bool(v.value)): # store a non-NULL
-                self.gen_write_barrier(val)
-                #op = op.copy_and_change(rop.SETINTERIORFIELD_RAW)
+        if self.must_apply_write_barrier(val, op.getarg(2)):
+            self.gen_write_barrier(val)
+            #op = op.copy_and_change(rop.SETINTERIORFIELD_RAW)
         self.newops.append(op)
 
     def handle_write_barrier_setarrayitem(self, op):
         val = op.getarg(0)
-        if val not in self.write_barrier_applied:
-            v = op.getarg(2)
-            if isinstance(v, BoxPtr) or (isinstance(v, ConstPtr) and
-                                         bool(v.value)): # store a non-NULL
-                self.gen_write_barrier_array(val, op.getarg(1))
-                #op = op.copy_and_change(rop.SETARRAYITEM_RAW)
+        if self.must_apply_write_barrier(val, op.getarg(2)):
+            self.gen_write_barrier_array(val, op.getarg(1))
+            #op = op.copy_and_change(rop.SETARRAYITEM_RAW)
         self.newops.append(op)
 
     def gen_write_barrier(self, v_base):

File rpython/jit/backend/llsupport/stmrewrite.py

View file
  • Ignore whitespace
             self.read_barrier_applied[v_ptr] = None
 
 
+    def must_apply_write_barrier(self, val, v):
+        return val not in self.write_barrier_applied
+
+
     def handle_setfields(self, op):
         opnum = op.getopnum()
         descr = op.getdescr()

File rpython/jit/backend/llsupport/test/test_stmrewrite.py

View file
  • Ignore whitespace
             jump()
         """)
 
+    def test_rewrite_one_setfield_gc_i(self):
+        self.check_rewrite("""
+            [p1, i2]
+            setfield_gc(p1, i2, descr=tzdescr)
+            jump()
+        """, """
+            [p1, i2]
+            cond_call_gc_wb(p1, descr=wbdescr)
+            setfield_gc(p1, i2, descr=tzdescr)
+            jump()
+        """)
+
     def test_rewrite_setfield_gc_const(self):
         TP = lltype.GcArray(lltype.Signed)
         NULL = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.nullptr(TP))
             jump()
         """)
 
+    def test_rewrite_getfield_after_setfield(self):
+        self.check_rewrite("""
+            [p1, i2]
+            setfield_gc(p1, i2, descr=tydescr)
+            p3 = getfield_gc(p1, descr=tzdescr)
+            jump(p3)
+        """, """
+            [p1, i2]
+            cond_call_gc_wb(p1, descr=wbdescr)
+            setfield_gc(p1, i2, descr=tydescr)
+            p3 = getfield_gc(p1, descr=tzdescr)
+             jump(p3)
+        """)
+
     def test_invalidate_read_status_after_write_to_constptr(self):
         TP = lltype.GcArray(lltype.Signed)
         NULL = lltype.cast_opaque_ptr(llmemory.GCREF, lltype.nullptr(TP))
             [p0]
             p1 = same_as(ConstPtr(t))
             p2 = same_as(ConstPtr(t))
-            cond_call_stm_b(p1, descr=A2Rdescr)
             p3 = getfield_gc(p1, descr=tzdescr)
-            cond_call_stm_b(p2, descr=A2Wdescr)
+            stm_read(p1)
+            cond_call_gc_wb(p2, descr=wbdescr)
             setfield_gc(p2, p0, descr=tzdescr)
             cond_call_stm_b(p1, descr=Q2Rdescr)
             p4 = getfield_gc(p1, descr=tzdescr)