[pypy-svn] r36022 - in pypy/dist/pypy/jit/timeshifter: . test

pedronis at codespeak.net pedronis at codespeak.net
Thu Dec 28 14:59:56 CET 2006


Author: pedronis
Date: Thu Dec 28 14:59:51 2006
New Revision: 36022

Modified:
   pypy/dist/pypy/jit/timeshifter/hrtyper.py
   pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
Log:
fix erasure of Char for merge point keys. with test.



Modified: pypy/dist/pypy/jit/timeshifter/hrtyper.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/hrtyper.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/hrtyper.py	Thu Dec 28 14:59:51 2006
@@ -1084,8 +1084,13 @@
             s_erased_type  = r.erased_annotation()
             r_precise_type = self.rtyper.getrepr(s_precise_type)
             r_erased_type  = self.rtyper.getrepr(s_erased_type)
-            greens_v.append(hop.llops.convertvar(v, r_precise_type,
-                                                    r_erased_type))
+            if r_precise_type.lowleveltype == lltype.Char:
+                v_green = hop.llops.genop('cast_char_to_int', [v],
+                                          resulttype = lltype.Signed)
+            else:
+                v_green = hop.llops.convertvar(v, r_precise_type, r_erased_type)
+
+            greens_v.append(v_green)
             greens_s.append(s_erased_type)
 
         v_jitstate = hop.llops.getjitstate()

Modified: pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	Thu Dec 28 14:59:51 2006
@@ -375,7 +375,7 @@
     def test_loop_folding(self):
         def ll_function(x, y):
             tot = 0
-            x = hint(x, concrete=True)        
+            x = hint(x, concrete=True)    
             while x:
                 tot += y
                 x -= 1
@@ -1210,3 +1210,20 @@
 
         res = self.timeshift(f, [4, 212], [], policy=P_NOVIRTUAL)
         assert res == 212
+
+    def test_green_char_at_merge(self):
+        def f(c, x):
+            c = chr(c)
+            c = hint(c, concrete=True)
+            if x:
+                x = 3
+            else:
+                x = 1
+            c = hint(c, variable=True)
+            return len(c*x)
+
+        res = self.timeshift(f, [ord('a'), 1], [], policy=P_NOVIRTUAL)
+        assert res == 3
+
+        res = self.timeshift(f, [ord('b'), 0], [], policy=P_NOVIRTUAL)
+        assert res == 1



More information about the Pypy-commit mailing list