[pypy-svn] pypy default: bumping the extended_arg_count is not equivalent to reresolving jump targets

gutworth commits-noreply at bitbucket.org
Wed May 4 00:10:06 CEST 2011


Author: Benjamin Peterson <benjamin at python.org>
Branch: 
Changeset: r43872:edd199709433
Date: 2011-05-03 17:11 -0500
http://bitbucket.org/pypy/pypy/changeset/edd199709433/

Log:	bumping the extended_arg_count is not equivalent to reresolving jump
	targets

	This should fix issue #713.

diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -286,6 +286,7 @@
         while True:
             extended_arg_count = 0
             offset = 0
+            force_redo = False
             # Calculate the code offset of each block.
             for block in blocks:
                 block.offset = offset
@@ -313,7 +314,7 @@
                                     instr.has_jump = False
                                     # The size of the code changed,
                                     # we have to trigger another pass
-                                    extended_arg_count += 1
+                                    force_redo = True
                                     continue
                         if absolute:
                             jump_arg = target.offset
@@ -322,7 +323,7 @@
                         instr.arg = jump_arg
                         if jump_arg > 0xFFFF:
                             extended_arg_count += 1
-            if extended_arg_count == last_extended_arg_count:
+            if extended_arg_count == last_extended_arg_count and not force_redo:
                 break
             else:
                 last_extended_arg_count = extended_arg_count
diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -73,6 +73,10 @@
     def error_test(self, source, exc_type):
         py.test.raises(exc_type, self.simple_test, source, None, None)
 
+    def test_issue_713(self):
+        func = "def f(_=2): return (_ if _ else _) if False else _"
+        yield self.st, func, "f()", 2
+
     def test_long_jump(self):
         func = """def f(x):
     y = 0


More information about the Pypy-commit mailing list