Commits

Antonio Cuni  committed 2af85b2

kill support for rawbuffer virtualstate: we do not need to have it for optimizing cffi, and it seems to cause bugs

  • Participants
  • Parent commits 4eb0fe7
  • Branches virtual-raw-mallocs

Comments (0)

Files changed (4)

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

         call('free', i0, descr=raw_free_descr)
         i3 = call('malloc', 10, descr=raw_malloc_descr)
         setarrayitem_raw(i3, 0, i2, descr=rawarraydescr)
+        label('foo')
         jump(i3)
         """
         expected = """
-        [i1]
+        [i0]
+        i1 = getarrayitem_raw(i0, 0, descr=rawarraydescr)
         i2 = int_add(i1, 1)
-        jump(i2)
+        call('free', i0, descr=raw_free_descr)
+        label('foo')
+        i3 = call('malloc', 10, descr=raw_malloc_descr)
+        setarrayitem_raw(i3, 0, i2, descr=rawarraydescr)
+        jump(i3)
         """
         self.optimize_loop(ops, expected)
 

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

     def set_item_value(self, i, newval):
         raise NotImplementedError
 
-    def force_at_end_of_preamble(self, already_forced, optforce):
-        if self in already_forced:
-            return self
-        already_forced[self] = self
-        for index in range(self.getlength()):
-            itemval = self.get_item_value(index)
-            itemval = itemval.force_at_end_of_preamble(already_forced, optforce)
-            self.set_item_value(index, itemval)
-        return self
-
     def get_args_for_fail(self, modifier):
         if self.box is None and not modifier.already_seen_virtual(self.keybox):
             # checks for recursion: it is False unless
         assert isinstance(itemvalue, optimizer.OptValue)
         self._items[index] = itemvalue
 
+    def force_at_end_of_preamble(self, already_forced, optforce):
+        # note that this method is on VArrayValue instead of
+        # AbstractVArrayValue because we do not want to support virtualstate
+        # for rawbuffers for now
+        if self in already_forced:
+            return self
+        already_forced[self] = self
+        for index in range(self.getlength()):
+            itemval = self.get_item_value(index)
+            itemval = itemval.force_at_end_of_preamble(already_forced, optforce)
+            self.set_item_value(index, itemval)
+        return self
+
     def _really_force(self, optforce):
         assert self.source_op is not None
         if not we_are_translated():

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

     def debug_header(self, indent):
         debug_print(indent + 'VStructStateInfo(%d):' % self.position)
 
-class AbstractVArrayStateInfo(AbstractVirtualStateInfo):
+
+class VArrayStateInfo(AbstractVirtualStateInfo):
+
+    def __init__(self, arraydescr):
+        self.arraydescr = arraydescr
+
+    def _generalization_of(self, other):
+        return (isinstance(other, VArrayStateInfo) and
+            self.arraydescr is other.arraydescr)
 
     def generalization_of(self, other, renum, bad):
         assert self.position != -1
         return True
 
     def enum_forced_boxes(self, boxes, value, optimizer):
-        if not isinstance(value, self.ValueClass):
+        if not isinstance(value, virtualize.VArrayValue):
             raise BadVirtualState
         if not value.is_virtual():
             raise BadVirtualState
     def debug_header(self, indent):
         debug_print(indent + 'VArrayStateInfo(%d):' % self.position)
 
-class VArrayStateInfo(AbstractVArrayStateInfo):
-
-    ValueClass = virtualize.VArrayValue
-    
-    def __init__(self, arraydescr):
-        self.arraydescr = arraydescr
-
-    def _generalization_of(self, other):
-        return (isinstance(other, VArrayStateInfo) and
-            self.arraydescr is other.arraydescr)
 
 
 class VArrayStructStateInfo(AbstractVirtualStateInfo):
         debug_print(indent + 'VArrayStructStateInfo(%d):' % self.position)
 
 
-class VRawBufferStateInfo(AbstractVArrayStateInfo):
-
-    ValueClass = virtualize.VRawBufferValue
-    
-    def _generalization_of(self, other):
-        return isinstance(other, VRawBufferStateInfo)
-
 
 class NotVirtualStateInfo(AbstractVirtualStateInfo):
     def __init__(self, value, is_opaque=False):
         return VArrayStructStateInfo(arraydescr, fielddescrs)
 
     def make_vrawbuffer(self, size, offsets, descrs):
-        return VRawBufferStateInfo()
+        raise NotImplementedError
 
 class BoxNotProducable(Exception):
     pass

File pypy/jit/metainterp/test/test_virtual.py

         # the getarrayitem_raw is in the bridge
         self.check_resops(getarrayitem_raw=1, setarrayitem_raw=0)
 
-    def test_raw_malloc_two_iterations(self):
+    def test_raw_malloc_no_virtualstate(self):
         mydriver = JitDriver(greens=[], reds = 'auto')
         def f(n):
             res = 0
         assert f(10) == 45
         res = self.meta_interp(f, [10])
         assert res == 45
-        # the getarrayitem_raw is in the preamble
-        self.check_resops(getarrayitem_raw=1, setarrayitem_raw=0)
+        # make sure that the raw buffer is *not* virtualized because we do not
+        # support virtualstate
+        self.check_resops(getarrayitem_raw=2, setarrayitem_raw=2)
 
     def test_raw_malloc_only_chars(self):
         mydriver = JitDriver(greens=[], reds = 'auto')