Author: Armin Rigo <[email protected]>
Branch: fast-gil
Changeset: r69826:329ece4367a6
Date: 2014-03-09 13:10 +0100
http://bitbucket.org/pypy/pypy/changeset/329ece4367a6/
Log: Small refactoring in rffi. The goal is to make zrpy_releasegil_test
pass: previously, it was accidentally asking for a no-aroundstate
version.
diff --git a/rpython/rtyper/lltypesystem/rffi.py
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -218,13 +218,8 @@
freeme = arg
elif _isfunctype(TARGET) and not _isllptr(arg):
# XXX pass additional arguments
- if invoke_around_handlers:
- arg = llhelper(TARGET, _make_wrapper_for(TARGET, arg,
- callbackholder,
- aroundstate))
- else:
- arg = llhelper(TARGET, _make_wrapper_for(TARGET, arg,
- callbackholder))
+ arg = llhelper(TARGET, _make_wrapper_for(
+ TARGET, arg, invoke_around_handlers, callbackholder))
else:
SOURCE = lltype.typeOf(arg)
if SOURCE != TARGET:
@@ -263,7 +258,8 @@
def __init__(self):
self.callbacks = {}
-def _make_wrapper_for(TP, callable, callbackholder=None, aroundstate=None):
+def _make_wrapper_for(TP, callable, invoke_around_handlers=True,
+ callbackholder=None):
""" Function creating wrappers for callbacks. Note that this is
cheating as we assume constant callbacks and we just memoize wrappers
"""
@@ -279,7 +275,7 @@
args = ', '.join(['a%d' % i for i in range(len(TP.TO.ARGS))])
source = py.code.Source(r"""
def wrapper(%(args)s): # no *args - no GIL for mallocing the tuple
- if aroundstate is not None:
+ if invoke_around_handlers:
aroundstate.enter_callback()
# from now on we hold the GIL
stackcounter.stacks_counter += 1
@@ -295,7 +291,7 @@
traceback.print_exc()
result = errorcode
stackcounter.stacks_counter -= 1
- if aroundstate is not None:
+ if invoke_around_handlers:
aroundstate.leave_callback()
# here we don't hold the GIL any more. As in the wrapper() produced
# by llexternal, it is essential that no exception checking occurs
@@ -307,6 +303,7 @@
miniglobals['os'] = os
miniglobals['we_are_translated'] = we_are_translated
miniglobals['stackcounter'] = stackcounter
+ miniglobals['aroundstate'] = aroundstate
exec source.compile() in miniglobals
return miniglobals['wrapper']
_make_wrapper_for._annspecialcase_ = 'specialize:memo'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit