[pypy-commit] pypy stm-thread: Raising exceptions around the stm callback is not supported.
arigo
noreply at buildbot.pypy.org
Mon May 7 10:38:49 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread
Changeset: r54924:dc885ae0a05a
Date: 2012-05-07 10:38 +0200
http://bitbucket.org/pypy/pypy/changeset/dc885ae0a05a/
Log: Raising exceptions around the stm callback is not supported. Fix
this by explicitly saving and re-raising exceptions for now.
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -91,20 +91,29 @@
def dispatch_with_stm(self, next_instr):
self.last_instr = intmask(next_instr)
- try:
- rstm.perform_transaction(pyframe.PyFrame._dispatch_stm_transaction,
- pyframe.PyFrame, self)
- except ExitFrame:
- return self.popvalue()
- assert 0, "should not be reachable"
+ rstm.perform_transaction(pyframe.PyFrame._dispatch_stm_transaction,
+ self.space.FrameClass, self)
+ e = self.__reraise
+ if e is None:
+ return self.popvalue() # normal exit path
+ else:
+ self.__reraise = None
+ raise self.__reraise # re-raise the exception we got
def _dispatch_stm_transaction(self, retry_counter):
- co_code = self.pycode.co_code
- next_instr = r_uint(self.last_instr)
- ec = self.space.getexecutioncontext()
- next_instr = self.handle_bytecode(co_code, next_instr, ec)
- self.last_instr = intmask(next_instr)
- return 1 # loop again, unless interrupted by an ExitFrame
+ try:
+ co_code = self.pycode.co_code
+ next_instr = r_uint(self.last_instr)
+ ec = self.space.getexecutioncontext()
+ next_instr = self.handle_bytecode(co_code, next_instr, ec)
+ self.last_instr = intmask(next_instr)
+ return 1 # loop
+ except ExitFrame:
+ self.__reraise = None
+ return 0 # stop looping
+ except Exception, e:
+ self.__reraise = e
+ return 0 # stop looping
def handle_bytecode(self, co_code, next_instr, ec):
try:
diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -1,6 +1,6 @@
import threading
from pypy.translator.stm import stmgcintf
-from pypy.rlib.debug import ll_assert
+from pypy.rlib.debug import ll_assert, fatalerror
from pypy.rlib.objectmodel import keepalive_until_here, specialize
from pypy.rlib.objectmodel import we_are_translated
from pypy.rpython.lltypesystem import lltype, llmemory, rffi, rclass
@@ -54,8 +54,9 @@
arg = cast_base_ptr_to_instance(argcls, llarg)
try:
res = func(arg, retry_counter)
- finally:
- llop.stm_stop_transaction(lltype.Void)
+ except:
+ fatalerror("no exception allowed in stm_callback")
+ llop.stm_stop_transaction(lltype.Void)
return res
return _stm_callback
More information about the pypy-commit
mailing list