[pypy-svn] pypy jit-short-preamble: Take care of the case when inlining fails even if the dryrun was successfull

hakanardo commits-noreply at bitbucket.org
Sat Jan 15 09:49:25 CET 2011


Author: Hakan Ardo <hakan at debian.org>
Branch: jit-short-preamble
Changeset: r40705:d0a95652418c
Date: 2011-01-15 09:48 +0100
http://bitbucket.org/pypy/pypy/changeset/d0a95652418c/

Log:	Take care of the case when inlining fails even if the dryrun was
	successfull

diff --git a/pypy/jit/metainterp/optimizeopt/unroll.py b/pypy/jit/metainterp/optimizeopt/unroll.py
--- a/pypy/jit/metainterp/optimizeopt/unroll.py
+++ b/pypy/jit/metainterp/optimizeopt/unroll.py
@@ -543,14 +543,21 @@
             assert isinstance(descr, LoopToken)
             # FIXME: Use a tree, similar to the tree formed by the full
             # preamble and it's bridges, instead of a list to save time and
-            # memory  
+            # memory. This should also allow better behaviour in
+            # situations that the is_emittable() chain currently cant
+            # handle and the inlining fails unexpectedly belwo.
             short = descr.short_preamble
             if short:
-                for sh in short:                    
+                for sh in short:
                     if self.inline(sh.operations, sh.inputargs,
                                    op.getarglist(), dryrun=True):
-                        self.inline(sh.operations, sh.inputargs,
-                                   op.getarglist())
+                        try:
+                            self.inline(sh.operations, sh.inputargs,
+                                        op.getarglist())
+                        except InvalidLoop:
+                            debug_print("Inlining failed unexpectedly",
+                                        "jumping to preamble instead")
+                        self.emit_operation(op)
                         return
                     
                 raise RetraceLoop

diff --git a/pypy/jit/metainterp/test/test_basic.py b/pypy/jit/metainterp/test/test_basic.py
--- a/pypy/jit/metainterp/test/test_basic.py
+++ b/pypy/jit/metainterp/test/test_basic.py
@@ -2024,7 +2024,7 @@
                 myjitdriver.can_enter_jit(a=a, b=b, i=i, sa=sa)
                 myjitdriver.jit_merge_point(a=a, b=b, i=i, sa=sa)
                 if a > 0: pass
-                if 1 < b < 2: pass
+                if b < 2: pass
                 sa += a % b
                 i += 1
             return sa

diff --git a/pypy/module/pypyjit/test/test_pypy_c.py b/pypy/module/pypyjit/test/test_pypy_c.py
--- a/pypy/module/pypyjit/test/test_pypy_c.py
+++ b/pypy/module/pypyjit/test/test_pypy_c.py
@@ -1442,7 +1442,6 @@
                          count_debug_merge_point=False)
         
     def test_mod(self):
-        #py.test.skip('Results are correct, but traces 1902 times (on trunk too).')
         avalues = ('a', 'b', 7, -42, 8)
         bvalues = ['b'] + range(-10, 0) + range(1,10)
         code = ''


More information about the Pypy-commit mailing list