[pypy-commit] pypy default: Add jitting to C callbacks only on demand, not systematically. The RPython callback must have
arigo
noreply at buildbot.pypy.org
Sun Jan 13 14:38:32 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r60028:ad1b2b6d8ced
Date: 2013-01-13 14:41 +0100
http://bitbucket.org/pypy/pypy/changeset/ad1b2b6d8ced/
Log: Add jitting to C callbacks only on demand, not systematically. The
RPython callback must have _callback_hook_="somestring". Might fix
issue #1363, caused by the callback hook getting in the way of the
shadowstack for the thread's bootstrapper.
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
@@ -201,3 +201,4 @@
callback.write_error_return_value(ll_res)
if ec is not None:
cerrno.restore_errno_from(ec)
+invoke_callback._callback_hook_ = "CFFI"
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -312,6 +312,7 @@
""" % locals())
exec str(src)
+ callback._callback_hook_ = "XML_" + name
c_name = 'XML_Set' + name
callback_type = lltype.Ptr(lltype.FuncType(
@@ -340,6 +341,7 @@
else:
result = 1
return rffi.cast(rffi.INT, result)
+UnknownEncodingHandlerData_callback._callback_hook_ = None # no jit needed
callback_type = lltype.Ptr(lltype.FuncType(
[rffi.VOIDP, rffi.CCHARP, XML_Encoding_Ptr], rffi.INT))
XML_SetUnknownEncodingHandler = expat_external(
diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py
--- a/pypy/rlib/clibffi.py
+++ b/pypy/rlib/clibffi.py
@@ -431,6 +431,7 @@
"""
userdata = rffi.cast(USERDATA_P, ll_userdata)
userdata.callback(ll_args, ll_res, userdata)
+ll_callback._callback_hook_ = "CLIBFFI"
class StackCheckError(ValueError):
message = None
diff --git a/pypy/rpython/lltypesystem/rffi.py b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -279,14 +279,16 @@
callable_name = getattr(callable, '__name__', '?')
if callbackholder is not None:
callbackholder.callbacks[callable] = True
- callable_name_descr = str(callable).replace('"', '\\"')
args = ', '.join(['a%d' % i for i in range(len(TP.TO.ARGS))])
+ invoke_hook = getattr(callable, '_callback_hook_', None)
+ assert invoke_hook is None or isinstance(invoke_hook, str)
+
source = py.code.Source(r"""
def inner_wrapper(%(args)s):
- if aroundstate is not None:
+ if invoke_hook is not None and aroundstate is not None:
callback_hook = aroundstate.callback_hook
if callback_hook:
- callback_hook(llstr("%(callable_name_descr)s"))
+ callback_hook(llstr(invoke_hook))
return callable(%(args)s)
inner_wrapper._never_inline_ = True
More information about the pypy-commit
mailing list