Commits

Remi Meier committed fd2553f

repeat writebarrier after possible minor collect here too

  • Participants
  • Parent commits a9400c2
  • Branches stmgc-c4

Comments (0)

Files changed (2)

File rpython/translator/stm/test/test_writebarrier.py

         assert len(self.writemode) == 1
         assert self.barriers == []
 
+    def test_repeat_write_barrier_after_malloc(self):
+        X = lltype.GcStruct('X', ('foo', lltype.Signed))
+        x1 = lltype.malloc(X, immortal=True)
+        x1.foo = 6
+        def f1(n):
+            x1.foo = n
+            lltype.malloc(X)
+            x1.foo = x1.foo + n
+
+        self.interpret(f1, [4])
+        assert len(self.writemode) == 2
+        assert self.barriers == ['G2W', 'r2w']
+
+    def test_repeat_read_barrier_after_malloc(self):
+        X = lltype.GcStruct('X', ('foo', lltype.Signed))
+        x1 = lltype.malloc(X, immortal=True)
+        x1.foo = 6
+        def f1(n):
+            i = x1.foo
+            lltype.malloc(X)
+            i = x1.foo + i
+            return i
+
+        self.interpret(f1, [4])
+        assert len(self.writemode) == 1
+        assert self.barriers == ['G2R']
+
     def test_write_may_alias(self):
         X = lltype.GcStruct('X', ('foo', lltype.Signed))
         def f1(p, q):

File rpython/translator/stm/writebarrier.py

                                 category[v] = 'O'
                 #
                 if op.opname in MALLOCS:
+                    # write barriers after a possible minor collection
+                    # are not valid anymore:
+                    for v, c in category.items():
+                        if c == 'W':
+                            category[v] = 'R'
                     category[op.result] = 'W'
 
             block.operations = newoperations