1. Pypy
  2. Untitled project
  3. pypy

Commits

Antonio Cuni  committed d06cd27

make it possible to get a virtual raw slice of a virtual raw slice

  • Participants
  • Parent commits 9d9e80f
  • Branches virtual-raw-mallocs

Comments (0)

Files changed (2)

File pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py

View file
  • Ignore whitespace
         """
         self.optimize_loop(ops, expected)
 
+    def test_virtual_raw_slice_of_a_raw_slice(self):
+        ops = """
+        [i0, i1]
+        i2 = call('malloc', 10, descr=raw_malloc_descr)
+        i3 = int_add(i2, 1) # get a slice of the original buffer
+        i4 = int_add(i3, 1) # get a slice of a slice
+        setarrayitem_raw(i4, 0, i1, descr=rawarraydescr_char) # write to the slice
+        i5 = getarrayitem_raw(i2, 2, descr=rawarraydescr_char)
+        call('free', i2, descr=raw_free_descr)
+        jump(i0, i5)
+        """
+        expected = """
+        [i0, i1]
+        jump(i0, i1)
+        """
+        self.optimize_loop(ops, expected)
+
     def test_virtual_raw_slice_force(self):
         ops = """
         [i0, i1]

File pypy/jit/metainterp/optimizeopt/virtualize.py

View file
  • Ignore whitespace
             if isinstance(value, VirtualRawBufferValue):
                 self.make_virtual_raw_slice(value, offset, op.result, op)
                 return
+            elif isinstance(value, VirtualRawSliceValue):
+                offset = offset + value.offset
+                self.make_virtual_raw_slice(value.rawbuffer_value, offset, op.result, op)
+                return
         self.emit_operation(op)
 
     def optimize_ARRAYLEN_GC(self, op):