Commits

Alex Gaynor committed 4a8980d

include the fields in forced stuff on an array

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py

         """
         self.optimize_loop(ops, expected)
 
+    def test_forced_gcstruct_as_array(self):
+        ops = """
+        [i0]
+        p0 = new_array(3, descr=gcstructarraydescr)
+        setfield_gc(p0, i0, descr=gcstructarray_fielddescr)
+        escape(p0)
+        i1 = getfield_gc(p0, descr=gcstructarray_fielddescr)
+        finish(i1)
+        """
+        expected = """
+        [i0]
+        p0 = new_array(3, descr=gcstructarraydescr)
+        setfield_gc(p0, i0, descr=gcstructarray_fielddescr)
+        escape(p0)
+        i1 = getfield_gc(p0, descr=gcstructarray_fielddescr)
+        finish(i1)
+        """
+        self.optimize_loop(ops, expected)
+
 
 class TestLLtype(BaseTestOptimizeBasic, LLtypeMixin):
     pass

pypy/jit/metainterp/optimizeopt/virtualize.py

             self.source_op.name = 'FORCE ' + self.source_op.name
         optforce.emit_operation(self.source_op)
         self.box = box = self.source_op.result
+        if self._fields:
+            for ofs, value in self._fields.iteritems():
+                if value.is_null():
+                    continue
+                subbox = value.force_box(optforce)
+                op = ResOperation(rop.SETFIELD_GC, [box, subbox], None, descr=ofs)
+                optforce.emit_operation(op)
+
         for index in range(len(self._items)):
             subvalue = self._items[index]
             if subvalue is not self.constvalue: