[pypy-commit] pypy default: Move the non-optimizable part of callbacks outside the JIT
arigo
noreply at buildbot.pypy.org
Sun Oct 4 15:54:17 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r79975:9c043c7d1a7b
Date: 2015-10-04 15:54 +0200
http://bitbucket.org/pypy/pypy/changeset/9c043c7d1a7b/
Log: Move the non-optimizable part of callbacks outside the JIT
diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py
--- a/pypy/module/_cffi_backend/ccallback.py
+++ b/pypy/module/_cffi_backend/ccallback.py
@@ -178,7 +178,8 @@
@jit.dont_look_inside
-def _handle_applevel_exception(space, callback, e, ll_res, extra_line):
+def _handle_applevel_exception(callback, e, ll_res, extra_line):
+ space = callback.space
callback.write_error_return_value(ll_res)
if callback.w_onerror is None:
callback.print_error(e, extra_line)
@@ -199,8 +200,16 @@
extra_line="\nDuring the call to 'onerror', "
"another exception occurred:\n\n")
+ at jit.jit_callback("CFFI")
+def py_invoke_callback(callback, ll_res, ll_args):
+ extra_line = ''
+ try:
+ w_res = callback.invoke(ll_args)
+ extra_line = "Trying to convert the result back to C:\n"
+ callback.convert_result(ll_res, w_res)
+ except OperationError, e:
+ _handle_applevel_exception(callback, e, ll_res, extra_line)
- at jit.jit_callback("CFFI")
def _invoke_callback(ffi_cif, ll_res, ll_args, ll_userdata):
""" Callback specification.
ffi_cif - something ffi specific, don't care
@@ -228,13 +237,7 @@
space = callback.space
try:
must_leave = space.threadlocals.try_enter_thread(space)
- extra_line = ''
- try:
- w_res = callback.invoke(ll_args)
- extra_line = "Trying to convert the result back to C:\n"
- callback.convert_result(ll_res, w_res)
- except OperationError, e:
- _handle_applevel_exception(space, callback, e, ll_res, extra_line)
+ py_invoke_callback(callback, ll_res, ll_args)
#
except Exception, e:
# oups! last-level attempt to recover.
More information about the pypy-commit
mailing list