Armin Rigo avatar Armin Rigo committed 48357e1

fix for 123cde0fe60f

Comments (0)

Files changed (2)

rpython/jit/metainterp/optimizeopt/virtualize.py

     _attrs_ = ('keybox', 'source_op', '_cached_vinfo')
     box = None
     level = optimizer.LEVEL_NONNULL
+    is_about_raw = False
     _cached_vinfo = None
 
     def __init__(self, keybox, source_op=None):
 
 
 class VRawBufferValue(AbstractVArrayValue):
+    is_about_raw = True
 
     def __init__(self, cpu, logops, size, keybox, source_op):
         AbstractVirtualValue.__init__(self, keybox, source_op)
 
 
 class VRawSliceValue(AbstractVirtualValue):
+    is_about_raw = True
 
     def __init__(self, rawbuffer_value, offset, keybox, source_op):
         AbstractVirtualValue.__init__(self, keybox, source_op)
         offsetbox = self.get_constant_box(op.getarg(1))
         if value.is_virtual() and offsetbox is not None:
             offset = offsetbox.getint()
-            if isinstance(value, VRawBufferValue):
-                self.make_virtual_raw_slice(value, offset, op.result, op)
-                return
-            elif isinstance(value, VRawSliceValue):
-                offset = offset + value.offset
-                self.make_virtual_raw_slice(value.rawbuffer_value, offset, op.result, op)
-                return
+            # the following check is constant-folded to False if the
+            # translation occurs without any VRawXxxValue instance around
+            if value.is_about_raw:
+                if isinstance(value, VRawBufferValue):
+                    self.make_virtual_raw_slice(value, offset, op.result, op)
+                    return
+                elif isinstance(value, VRawSliceValue):
+                    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):

rpython/jit/metainterp/resume.py

 
 class AbstractVirtualInfo(object):
     kind = REF
+    is_about_raw = False
     #def allocate(self, decoder, index):
     #    raise NotImplementedError
     def equals(self, fieldnums):
 
     def debug_prints(self):
         raise NotImplementedError
-        
+
 
 class AbstractVirtualStructInfo(AbstractVirtualInfo):
     def __init__(self, fielddescrs):
 
 class VRawBufferStateInfo(AbstractVirtualInfo):
     kind = INT
+    is_about_raw = True
     
     def __init__(self, size, offsets, descrs):
         self.size = size
         assert self.virtuals_cache is not None
         v = self.virtuals_cache.get_int(index)
         if not v:
-            v = self.rd_virtuals[index].allocate_int(self, index)
+            v = self.rd_virtuals[index]
+            assert v.is_about_raw and isinstance(v, VRawBufferStateInfo)
+            v = v.allocate_int(self, index)
             ll_assert(v == self.virtuals_cache.get_int(index), "resume.py: bad cache")
         return v
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.