[pypy-commit] pypy virtual-raw-mallocs: implement forcing of virtual raw slices

antocuni noreply at buildbot.pypy.org
Wed Dec 19 10:57:31 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: virtual-raw-mallocs
Changeset: r59505:9d9e80fe4895
Date: 2012-12-19 10:39 +0100
http://bitbucket.org/pypy/pypy/changeset/9d9e80fe4895/

Log:	implement forcing of virtual raw slices

diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -1845,6 +1845,32 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_virtual_raw_slice_force(self):
+        ops = """
+        [i0, i1]
+        i2 = call('malloc', 10, descr=raw_malloc_descr)
+        setarrayitem_raw(i2, 0, 42, descr=rawarraydescr_char)
+        i3 = int_add(i2, 1) # get a slice of the original buffer
+        setarrayitem_raw(i3, 4, 4242, descr=rawarraydescr_char) # write to the slice
+        label('foo')
+        escape(i3)
+        jump(i0, i1)
+        """
+        expected = """
+        [i0, i1]
+        label('foo')
+        # these ops are generated by VirtualRawBufferValue._really_force
+        i2 = call('malloc', 10, descr=raw_malloc_descr)
+        setarrayitem_raw(i2, 0, 42, descr=rawarraydescr_char)
+        i3 = int_add(i2, 5) # 1+4*sizeof(char)
+        setarrayitem_raw(i3, 0, 4242, descr=rawarraydescr_char)
+        # this is generated by VirtualRawSliceValue._really_force
+        i4 = int_add(i2, 1)
+        escape(i4)
+        jump(i0, i1)
+        """
+        self.optimize_loop(ops, expected)
+
 
     def test_duplicate_getfield_1(self):
         ops = """
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -416,7 +416,13 @@
         self.offset = offset
 
     def _really_force(self, optforce):
-        import pdb;pdb.set_trace()
+        op = self.source_op
+        assert op is not None
+        if not we_are_translated():
+            op.name = 'FORCE ' + self.source_op.name
+        self.box = self.source_op.result
+        self.rawbuffer_value.force_box(optforce)
+        optforce.emit_operation(op)
 
     def setitem_raw(self, offset, length, descr, value):
         self.rawbuffer_value.setitem_raw(self.offset+offset, length, descr, value)


More information about the pypy-commit mailing list