[pypy-svn] r69380 - in pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Nov 18 15:59:05 CET 2009


Author: cfbolz
Date: Wed Nov 18 15:59:04 2009
New Revision: 69380

Modified:
   pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py
   pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_resume.py
Log:
(pedronis, cfbolz): number virtuals and boxes that don't come from the frame
with negative numbers. Slightly funny code.


Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py	(original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/resume.py	Wed Nov 18 15:59:04 2009
@@ -262,20 +262,35 @@
         return liveboxes[:]
 
     def _number_virtuals(self, liveboxes):
-        virtuals = self.virtuals
+        prev_liveboxes_cache = 0
+        prev_virtuals_cache = 0
+        new_liveboxes = []
+        new_virtuals = []
+        new_vfieldboxes = []
         for box, tagged in self.liveboxes.iteritems():
             i, tagbits = untag(tagged)
             if tagbits == TAGBOX:
                 assert tagged_eq(tagged, UNASSIGNED)
-                self.liveboxes[box] = tag(len(liveboxes), TAGBOX)
-                liveboxes.append(box)
+                new_liveboxes.append(box)
+                index = -prev_liveboxes_cache - len(new_liveboxes)
+                self.liveboxes[box] = tag(index, TAGBOX)
             else:
                 assert tagbits == TAGVIRTUAL
                 if tagged_eq(tagged, UNASSIGNEDVIRTUAL):
                     vinfo, fieldboxes = self.vinfos_not_env[box]
-                    self.liveboxes[box] = tag(len(virtuals), TAGVIRTUAL)
-                    virtuals.append(vinfo)
-                    self.vfieldboxes.append(fieldboxes)
+                    new_virtuals.append(vinfo)
+                    new_vfieldboxes.append(fieldboxes)
+                    index = -prev_virtuals_cache - len(new_virtuals)
+                    self.liveboxes[box] = tag(index, TAGVIRTUAL)
+        new_liveboxes.reverse()
+        new_virtuals.reverse()
+        new_vfieldboxes.reverse()
+    
+        liveboxes.extend(new_liveboxes)
+        self.virtuals.extend(new_virtuals)
+        self.vfieldboxes.extend(new_vfieldboxes)
+        # xxx + cached stuff
+
         storage = self.storage
         storage.rd_virtuals = None
         if len(self.virtuals) > 0:

Modified: pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_resume.py
==============================================================================
--- pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_resume.py	(original)
+++ pypy/branch/compress-virtuals-resumedata/pypy/jit/metainterp/test/test_resume.py	Wed Nov 18 15:59:04 2009
@@ -356,7 +356,7 @@
     modifier = ResumeDataVirtualAdder(storage, memo)
     liveboxes = modifier.finish(values)
     assert len(storage.rd_virtuals) == 1
-    assert storage.rd_virtuals[0].fieldnums == [tag(len(liveboxes)-1, TAGBOX),
+    assert storage.rd_virtuals[0].fieldnums == [tag(-1, TAGBOX),
                                                 tag(0, TAGCONST)]
 
     b6 = BoxPtr()
@@ -367,9 +367,9 @@
     liveboxes2 = modifier.finish(values)
     assert len(storage2.rd_virtuals) == 2    
     assert storage2.rd_virtuals[0].fieldnums == [tag(len(liveboxes2)-1, TAGBOX),
-                                                 tag(1, TAGVIRTUAL)]
+                                                 tag(-1, TAGVIRTUAL)]
     assert storage2.rd_virtuals[1].fieldnums == [tag(2, TAGINT),
-                                                 tag(1, TAGVIRTUAL)]
+                                                 tag(-1, TAGVIRTUAL)]
 
     # now on to resuming
     metainterp = MyMetaInterp()
@@ -411,7 +411,7 @@
     modifier = ResumeDataVirtualAdder(storage, memo)
     liveboxes = modifier.finish(values)
     assert len(storage.rd_virtuals) == 1
-    assert storage.rd_virtuals[0].fieldnums == [tag(len(liveboxes)-1, TAGBOX),
+    assert storage.rd_virtuals[0].fieldnums == [tag(-1, TAGBOX),
                                                 tag(0, TAGCONST)]
 
     storage2 = Storage()
@@ -440,9 +440,9 @@
     liveboxes = modifier.finish(values)
     assert liveboxes == [b3]
     assert len(storage.rd_virtuals) == 2
-    assert storage.rd_virtuals[0].fieldnums == [tag(0, TAGBOX),
+    assert storage.rd_virtuals[0].fieldnums == [tag(-1, TAGBOX),
                                                 tag(1, TAGVIRTUAL)]
-    assert storage.rd_virtuals[1].fieldnums == [tag(0, TAGBOX),
+    assert storage.rd_virtuals[1].fieldnums == [tag(-1, TAGBOX),
                                                 tag(0, TAGVIRTUAL)]    
 
 
@@ -766,7 +766,7 @@
     b4set = [(rop.SETFIELD_GC, [b4t, b2t],     None, LLtypeMixin.nextdescr),
              (rop.SETFIELD_GC, [b4t, b3t],     None, LLtypeMixin.valuedescr),
              (rop.SETFIELD_GC, [b4t, b5t],     None, LLtypeMixin.otherdescr)]
-    if untag(modifier._gettagged(b2s))[0] == 0:
+    if untag(modifier._gettagged(b2s))[0] == -2:
         expected = [b2new, b4new] + b2set + b4set
     else:
         expected = [b4new, b2new] + b4set + b2set



More information about the Pypy-commit mailing list