Author: Alex Gaynor <[email protected]>
Branch: logging-perf
Changeset: r64547:3bca17abd500
Date: 2013-05-24 14:38 -0400
http://bitbucket.org/pypy/pypy/changeset/3bca17abd500/
Log: Write this code in a way that handles all conditions correctly. Now
to see translate and see if metainterp really marks stuff well
enough.
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -25,23 +25,35 @@
if depth < 0:
raise OperationError(space.w_ValueError,
space.wrap("frame index must not be negative"))
- return getframe(space, depth)
+ return getframe_unroll(space, depth)
@jit.look_inside_iff(lambda space, depth: jit.isconstant(depth))
-def getframe(space, depth):
+def getframe_unroll(space, depth):
ec = space.getexecutioncontext()
f = ec.gettopframe_nohidden()
+ while jit.isvirtual(f):
+ if f is None:
+ raise OperationError(space.w_ValueError,
+ space.wrap("call stack is not deep enough"))
+ if depth == 0:
+ f.mark_as_escaped()
+ return space.wrap(f)
+ depth -= 1
+ f = ec.getnextframe_nohidden(f)
+ return getframe_fallback(space, ec, depth, f)
+
+
+def getframe_fallback(space, ec, depth, f):
while True:
if f is None:
raise OperationError(space.w_ValueError,
space.wrap("call stack is not deep enough"))
if depth == 0:
- break
+ f.mark_as_escaped()
+ return space.wrap(f)
depth -= 1
f = ec.getnextframe_nohidden(f)
- f.mark_as_escaped()
- return space.wrap(f)
@unwrap_spec(new_limit="c_int")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit