[pypy-svn] r46588 - in pypy/dist/pypy: module/thread rlib rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Fri Sep 14 19:50:40 CEST 2007
Author: arigo
Date: Fri Sep 14 19:50:38 2007
New Revision: 46588
Modified:
pypy/dist/pypy/module/thread/gil.py
pypy/dist/pypy/rlib/objectmodel.py
pypy/dist/pypy/rpython/lltypesystem/rffi.py
Log:
Trying to convince the exception transformer to not put
a check at the end of the call to before().
Modified: pypy/dist/pypy/module/thread/gil.py
==============================================================================
--- pypy/dist/pypy/module/thread/gil.py (original)
+++ pypy/dist/pypy/module/thread/gil.py Fri Sep 14 19:50:38 2007
@@ -80,6 +80,8 @@
spacestate = SpaceState()
def before_external_call():
+ # this function must not raise, in such a way that the exception
+ # transformer knows that it cannot raise!
spacestate.GIL.release()
def after_external_call():
Modified: pypy/dist/pypy/rlib/objectmodel.py
==============================================================================
--- pypy/dist/pypy/rlib/objectmodel.py (original)
+++ pypy/dist/pypy/rlib/objectmodel.py Fri Sep 14 19:50:38 2007
@@ -155,9 +155,13 @@
# NOTE: the hooks are cleared during translation! To be effective
# in a compiled program they must be set at run-time.
from pypy.rpython.lltypesystem import rffi
+ rffi.aroundstate.before = before
+ rffi.aroundstate.after = after
+ # the 'aroundstate' contains regular function and not ll pointers to them,
+ # but let's call llhelper() anyway to force their annotation
from pypy.rpython.annlowlevel import llhelper
- rffi.aroundstate.before = llhelper(rffi.AroundFnPtr, before)
- rffi.aroundstate.after = llhelper(rffi.AroundFnPtr, after)
+ llhelper(rffi.AroundFnPtr, before)
+ llhelper(rffi.AroundFnPtr, after)
class UnboxedValue(object):
Modified: pypy/dist/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rffi.py Fri Sep 14 19:50:38 2007
@@ -86,11 +86,11 @@
before = aroundstate.before
after = aroundstate.after
if before: before()
- try:
- result = funcptr(*real_args)
- finally:
- if invoke_around_handlers:
- if after: after()
+ # NB. it is essential that no exception checking occurs after
+ # the call to before(), because we don't have the GIL any more!
+ result = funcptr(*real_args)
+ if invoke_around_handlers:
+ if after: after()
if stringpolicy == 'fullauto':
for i, tp in unrolling_arg_tps:
if tp is CCHARP:
@@ -104,8 +104,8 @@
AroundFnPtr = lltype.Ptr(lltype.FuncType([], lltype.Void))
class AroundState:
def _freeze_(self):
- self.before = lltype.nullptr(AroundFnPtr.TO)
- self.after = lltype.nullptr(AroundFnPtr.TO)
+ self.before = None # or a regular RPython function
+ self.after = None # or a regular RPython function
return False
aroundstate = AroundState()
aroundstate._freeze_()
More information about the Pypy-commit
mailing list