Author: fijal
Branch: compress-numbering
Changeset: r80883:d1ffcc38ac2c
Date: 2015-11-24 12:52 +0200
http://bitbucket.org/pypy/pypy/changeset/d1ffcc38ac2c/

Log:    whack at test_resume more

diff --git a/rpython/jit/metainterp/resume.py b/rpython/jit/metainterp/resume.py
--- a/rpython/jit/metainterp/resume.py
+++ b/rpython/jit/metainterp/resume.py
@@ -204,9 +204,9 @@
 
 UNASSIGNED = tag(-1 << 13, TAGBOX)
 UNASSIGNEDVIRTUAL = tag(-1 << 13, TAGVIRTUAL)
-NULLREF = tag(-1, TAGCONST)
-UNINITIALIZED = tag(-2, TAGCONST)   # used for uninitialized string characters
-
+NULLREF = tag(0, TAGCONST)
+UNINITIALIZED = tag(1, TAGCONST)   # used for uninitialized string characters
+TAG_CONST_OFFSET = 2
 
 class NumberingState(object):
     def __init__(self):
@@ -260,7 +260,7 @@
         return self._newconst(const)
 
     def _newconst(self, const):
-        result = tag(len(self.consts), TAGCONST)
+        result = tag(len(self.consts) + TAG_CONST_OFFSET, TAGCONST)
         self.consts.append(const)
         return result
 
@@ -1143,6 +1143,7 @@
         return [self.decode_ref(numb.nums[i]) for i in range(end)]
 
     def consume_vref_and_vable_boxes(self, vinfo, ginfo):
+        xxxx
         numb = self.cur_numb
         self.cur_numb = numb.prev
         if vinfo is not None:
@@ -1294,7 +1295,7 @@
             if tagged_eq(tagged, NULLREF):
                 box = self.cpu.ts.CONST_NULL
             else:
-                box = self.consts[num]
+                box = self.consts[num - TAG_CONST_OFFSET]
         elif tag == TAGVIRTUAL:
             if kind == INT:
                 box = self.getvirtual_int(num)
@@ -1604,7 +1605,7 @@
     def decode_int(self, tagged):
         num, tag = untag(tagged)
         if tag == TAGCONST:
-            return self.consts[num].getint()
+            return self.consts[num - TAG_CONST_OFFSET].getint()
         elif tag == TAGINT:
             return num
         elif tag == TAGVIRTUAL:
@@ -1620,7 +1621,7 @@
         if tag == TAGCONST:
             if tagged_eq(tagged, NULLREF):
                 return self.cpu.ts.NULLREF
-            return self.consts[num].getref_base()
+            return self.consts[num - TAG_CONST_OFFSET].getref_base()
         elif tag == TAGVIRTUAL:
             return self.getvirtual_ptr(num)
         else:
@@ -1632,7 +1633,7 @@
     def decode_float(self, tagged):
         num, tag = untag(tagged)
         if tag == TAGCONST:
-            return self.consts[num].getfloatstorage()
+            return self.consts[num - TAG_CONST_OFFSET].getfloatstorage()
         else:
             assert tag == TAGBOX
             if num < 0:
diff --git a/rpython/jit/metainterp/resumecode.py 
b/rpython/jit/metainterp/resumecode.py
--- a/rpython/jit/metainterp/resumecode.py
+++ b/rpython/jit/metainterp/resumecode.py
@@ -30,6 +30,7 @@
        numb.prev_index = rffi.cast(rffi.USHORT, prev_index)
        index = 0
        for item in lst:
+               assert item >= 0
                if item <= 128:
                        numb.code[index] = rffi.cast(rffi.UCHAR, item)
                        index += 1
diff --git a/rpython/jit/metainterp/test/test_resume.py 
b/rpython/jit/metainterp/test/test_resume.py
--- a/rpython/jit/metainterp/test/test_resume.py
+++ b/rpython/jit/metainterp/test/test_resume.py
@@ -10,7 +10,7 @@
      VArrayInfoNotClear, VStrPlainInfo, VStrConcatInfo, VStrSliceInfo,\
      VUniPlainInfo, VUniConcatInfo, VUniSliceInfo, Snapshot, FrameInfo,\
      capture_resumedata, ResumeDataLoopMemo, UNASSIGNEDVIRTUAL, INT,\
-     annlowlevel, PENDINGFIELDSP, unpack_uint
+     annlowlevel, PENDINGFIELDSP, unpack_uint, TAG_CONST_OFFSET
 from rpython.jit.metainterp.resumecode import unpack_numbering,\
      create_numbering, NULL_NUMBER
 
@@ -282,15 +282,18 @@
     numb = create_numbering(nums, NULL_NUMBER, 0)
     return numb
 
+def tagconst(i):
+    return tag(i + TAG_CONST_OFFSET, TAGCONST)
+
 def test_simple_read():
     #b1, b2, b3 = [BoxInt(), InputArgRef(), BoxInt()]
     c1, c2, c3 = [ConstInt(111), ConstInt(222), ConstInt(333)]
     storage = Storage()
     storage.rd_consts = [c1, c2, c3]
-    numb = Numbering([tag(0, TAGBOX), tag(0, TAGCONST),
+    numb = Numbering([tag(0, TAGBOX), tagconst(0),
                        NULLREF, tag(0, TAGBOX), tag(1, TAGBOX)] +
-                       [tag(1, TAGCONST), tag(2, TAGCONST)] + [0, 0] + 
-                       [tag(0, TAGBOX), tag(1, TAGBOX), tag(2, TAGBOX)] + [0, 
0])
+                       [tagconst(1), tagconst(2)] + 
+                       [tag(0, TAGBOX), tag(1, TAGBOX), tag(2, TAGBOX)])
     storage.rd_numb = numb
     storage.rd_count = 3
     #
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to