[pypy-commit] pypy stmgc-c4: repeat writebarrier after possible minor collect here too
Raemi
noreply at buildbot.pypy.org
Mon Jul 22 09:06:51 CEST 2013
Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r65523:fd2553f4cae2
Date: 2013-07-22 08:54 +0200
http://bitbucket.org/pypy/pypy/changeset/fd2553f4cae2/
Log: repeat writebarrier after possible minor collect here too
diff --git a/rpython/translator/stm/test/test_writebarrier.py b/rpython/translator/stm/test/test_writebarrier.py
--- a/rpython/translator/stm/test/test_writebarrier.py
+++ b/rpython/translator/stm/test/test_writebarrier.py
@@ -70,6 +70,33 @@
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):
diff --git a/rpython/translator/stm/writebarrier.py b/rpython/translator/stm/writebarrier.py
--- a/rpython/translator/stm/writebarrier.py
+++ b/rpython/translator/stm/writebarrier.py
@@ -150,6 +150,11 @@
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
More information about the pypy-commit
mailing list