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

arigo at codespeak.net arigo at codespeak.net
Sat Apr 1 16:44:34 CEST 2006


Author: arigo
Date: Sat Apr  1 16:44:33 2006
New Revision: 25207

Modified:
   pypy/dist/pypy/jit/rtimeshift.py
   pypy/dist/pypy/jit/test/test_hint_timeshift.py
Log:
(pedronis, arre, arigo)

Fixed a bug found by a test whose purpose was to show a completely
different bug, which it didn't.


Modified: pypy/dist/pypy/jit/rtimeshift.py
==============================================================================
--- pypy/dist/pypy/jit/rtimeshift.py	(original)
+++ pypy/dist/pypy/jit/rtimeshift.py	Sat Apr  1 16:44:33 2006
@@ -232,7 +232,7 @@
             return True
 
     def inlined_structs_are_compatible(self, newbox):
-        return (isinstance(newbox, VirtualRedBox) and
+        return (isinstance(newbox, VirtualRedBox) and not newbox.genvar and
                 self.typedesc.compare_content_boxes(self.content_boxes,
                                                     newbox.content_boxes))
 
@@ -323,7 +323,7 @@
             return True
 
     def inlined_structs_are_compatible(self, newbox):
-        if (isinstance(newbox, SubVirtualRedBox) and
+        if (isinstance(newbox, SubVirtualRedBox) and not newbox.is_forced() and
             self.fielddesc is newbox.fielddesc):
             return self.parentbox.inlined_structs_are_compatible(
                 newbox.parentbox)

Modified: pypy/dist/pypy/jit/test/test_hint_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_timeshift.py	(original)
+++ pypy/dist/pypy/jit/test/test_hint_timeshift.py	Sat Apr  1 16:44:33 2006
@@ -389,6 +389,26 @@
     insns, res = timeshift(ll_function, [1], [])
     assert res == 4 * 4
 
+def test_degenerated_before_return_2():
+    S = lltype.GcStruct('S', ('n', lltype.Signed))
+    T = lltype.GcStruct('T', ('s', S), ('n', lltype.Float))
+
+    def ll_function(flag):
+        t = lltype.malloc(T)
+        t.s.n = 3
+        s = lltype.malloc(S)
+        s.n = 4
+        if flag:
+            pass
+        else:
+            s = t.s
+        s.n += 1
+        return s.n * t.s.n
+    insns, res = timeshift(ll_function, [1], [])
+    assert res == 5 * 3
+    insns, res = timeshift(ll_function, [0], [])
+    assert res == 4 * 4
+
 def test_degenerated_at_return():
     S = lltype.GcStruct('S', ('n', lltype.Signed))
     T = lltype.GcStruct('T', ('s', S), ('n', lltype.Float))



More information about the Pypy-commit mailing list