Author: Remi Meier <remi.me...@gmail.com> Branch: stmgc-c4 Changeset: r67926:eb21e739cefa Date: 2013-11-10 12:05 +0100 http://bitbucket.org/pypy/pypy/changeset/eb21e739cefa/
Log: non-gc arrays mustn't get a barrier (getarraysize) 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 @@ -28,6 +28,27 @@ assert len(self.writemode) == 0 assert self.barriers == ['I2R'] + def test_array_size(self): + array_gc = lltype.GcArray(('z', lltype.Signed)) + array_nongc = lltype.Array(('z', lltype.Signed)) + Q = lltype.GcStruct('Q', + ('gc', lltype.Ptr(array_gc)), + ('raw', lltype.Ptr(array_nongc))) + q = lltype.malloc(Q, immortal=True) + q.gc = lltype.malloc(array_gc, n=3, flavor='gc', immortal=True) + q.raw = lltype.malloc(array_nongc, n=5, flavor='raw', immortal=True) + def f1(n): + if n == 1: + return len(q.gc) + else: + return len(q.raw) + res = self.interpret(f1, [1]) + assert self.barriers == ['I2R', 'a2i'] + res = self.interpret(f1, [0]) + assert self.barriers == ['I2R'] + + + def test_simple_read_2(self): X = lltype.GcStruct('X', ('foo', lltype.Signed)) x2 = lltype.malloc(X, immortal=True) 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 @@ -85,7 +85,8 @@ # field even on a stub pass - elif op.opname in ('getarraysize', 'getinteriorarraysize'): + elif (op.opname in ('getarraysize', 'getinteriorarraysize') and + is_gc_ptr(op.args[0].concretetype)): # XXX: or (is_getter and is_immutable(op))): # we can't leave getarraysize or the immutable getfields # fully unmodified: we need at least immut_read_barrier _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit