[pypy-commit] pypy stm-gc: Add enter/leave_transactional_mode operations.
arigo
noreply at buildbot.pypy.org
Mon Apr 9 10:19:17 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r54262:f7e7bb5d8f56
Date: 2012-04-05 12:12 +0200
http://bitbucket.org/pypy/pypy/changeset/f7e7bb5d8f56/
Log: Add enter/leave_transactional_mode operations.
diff --git a/pypy/module/transaction/interp_transaction.py b/pypy/module/transaction/interp_transaction.py
--- a/pypy/module/transaction/interp_transaction.py
+++ b/pypy/module/transaction/interp_transaction.py
@@ -269,10 +269,14 @@
@rgc.no_collect
def _run():
# --- start the threads --- don't use the GC here any more! ---
+ rstm.enter_transactional_mode()
+ #
for i in range(state.num_threads):
threadintf.start_new_thread(_run_thread)
#
state.lock_unfinished() # wait for all threads to finish
+ #
+ rstm.leave_transactional_mode()
# --- done, we can use the GC again ---
diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -50,6 +50,12 @@
if not we_are_translated():
_global_lock.release()
+def enter_transactional_mode():
+ llop.stm_enter_transactional_mode(lltype.Void)
+
+def leave_transactional_mode():
+ llop.stm_leave_transactional_mode(lltype.Void)
+
def descriptor_init():
if not we_are_translated(): _global_lock.acquire()
llop.stm_descriptor_init(lltype.Void)
diff --git a/pypy/rpython/lltypesystem/lloperation.py b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -403,6 +403,8 @@
'stm_become_inevitable': LLOp(),
'stm_descriptor_init': LLOp(canrun=True),
'stm_descriptor_done': LLOp(canrun=True),
+ 'stm_enter_transactional_mode': LLOp(),
+ 'stm_leave_transactional_mode': LLOp(),
'stm_writebarrier': LLOp(sideeffects=False),
'stm_normalize_global': LLOp(),
'stm_start_transaction': LLOp(canrun=True),
diff --git a/pypy/rpython/memory/gctransform/stmframework.py b/pypy/rpython/memory/gctransform/stmframework.py
--- a/pypy/rpython/memory/gctransform/stmframework.py
+++ b/pypy/rpython/memory/gctransform/stmframework.py
@@ -32,6 +32,12 @@
self.stm_normalize_global_ptr = getfn(
self.gcdata.gc.stm_normalize_global,
[annmodel.SomeAddress()], annmodel.SomeAddress())
+ self.stm_enter_transactional_mode_ptr = getfn(
+ self.gcdata.gc.enter_transactional_mode.im_func
+ [s_sc], annmodel.s_None)
+ self.stm_leave_transactional_mode_ptr = getfn(
+ self.gcdata.gc.leave_transactional_mode.im_func
+ [s_sc], annmodel.s_None)
self.stm_start_ptr = getfn(
self.gcdata.gc.start_transaction.im_func,
[s_gc], annmodel.s_None)
More information about the pypy-commit
mailing list