1. Pypy
  2. Untitled project
  3. pypy

Commits

Remi Meier  committed eb21e73

non-gc arrays mustn't get a barrier (getarraysize)

  • Participants
  • Parent commits 5f17275
  • Branches stmgc-c4

Comments (0)

Files changed (2)

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

View file
         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)

File rpython/translator/stm/writebarrier.py

View file
                 # 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