[pypy-commit] pypy py3k: Found what looks like the proper fix. It is actually important to keep

arigo noreply at buildbot.pypy.org
Sun May 31 22:30:44 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: py3k
Changeset: r77733:8befeb331d13
Date: 2015-05-31 22:30 +0200
http://bitbucket.org/pypy/pypy/changeset/8befeb331d13/

Log:	Found what looks like the proper fix. It is actually important to
	keep this StackDepthComputationError: without it, we have no
	guarantee that the stack depth is uniquely determined from the
	pycode+offset. This is a subtle requirement of the JIT.

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
@@ -395,13 +395,9 @@
         for block in blocks:
             depth = self._do_stack_depth_walk(block)
             if block.auto_inserted_return and depth != 0:
-                assert depth >= 0
-                # Disable this error for now.  On this branch the stack depth
-                # computation gives a slightly incorrect but conservative
-                # estimation of how much stack depth is actually needed.
-                #os.write(2, "StackDepthComputationError in %s at %s:%s\n" % (
-                #    self.compile_info.filename, self.name, self.first_lineno))
-                #raise StackDepthComputationError   # fatal error
+                os.write(2, "StackDepthComputationError in %s at %s:%s\n" % (
+                    self.compile_info.filename, self.name, self.first_lineno))
+                raise StackDepthComputationError   # fatal error
         return self._max_depth
 
     def _next_stack_depth_walk(self, nextblock, depth):
diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py
--- a/pypy/interpreter/astcompiler/codegen.py
+++ b/pypy/interpreter/astcompiler/codegen.py
@@ -614,7 +614,6 @@
                 # second # body
                 self.visit_sequence(handler.body)
                 self.emit_op(ops.POP_BLOCK)
-                self.emit_op(ops.POP_EXCEPT)
                 self.pop_frame_block(F_BLOCK_FINALLY, cleanup_body)
                 # finally
                 self.load_const(self.space.w_None)
@@ -634,9 +633,9 @@
                 cleanup_body = self.use_next_block()
                 self.push_frame_block(F_BLOCK_FINALLY, cleanup_body)
                 self.visit_sequence(handler.body)
-                self.emit_op(ops.POP_EXCEPT)
                 self.pop_frame_block(F_BLOCK_FINALLY, cleanup_body)
             #
+            self.emit_op(ops.POP_EXCEPT)
             self.emit_jump(ops.JUMP_FORWARD, end)
             self.use_next_block(next_except)
         self.emit_op(ops.END_FINALLY)   # this END_FINALLY will always re-raise


More information about the pypy-commit mailing list