[pypy-commit] pypy stmgc-c4: Starting to adapt rpython/rlib.py: become_inevitable(),
arigo
noreply at buildbot.pypy.org
Sun Jun 30 19:58:33 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c4
Changeset: r65125:5e8273640041
Date: 2013-06-30 19:58 +0200
http://bitbucket.org/pypy/pypy/changeset/5e8273640041/
Log: Starting to adapt rpython/rlib.py: become_inevitable(),
should_break_transaction()
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -1,24 +1,15 @@
-import thread, weakref
-from rpython.rlib.debug import ll_assert, fatalerror
-from rpython.rlib.objectmodel import keepalive_until_here, specialize
-from rpython.rlib.objectmodel import we_are_translated
-from rpython.rlib.rposix import get_errno, set_errno
-from rpython.rtyper.lltypesystem import lltype, llmemory, rffi, rclass, rstr
+from rpython.rlib.objectmodel import we_are_translated, specialize
+from rpython.rtyper.lltypesystem import lltype
from rpython.rtyper.lltypesystem.lloperation import llop
-from rpython.rtyper.annlowlevel import cast_instance_to_base_ptr, llhelper
-from rpython.rtyper.annlowlevel import cast_base_ptr_to_instance
from rpython.rtyper.extregistry import ExtRegistryEntry
-def is_inevitable():
- return we_are_translated() and stmgcintf.StmOperations.is_inevitable()
-
def become_inevitable():
llop.stm_become_inevitable(lltype.Void)
def should_break_transaction():
return we_are_translated() and (
- stmgcintf.StmOperations.should_break_transaction())
+ llop.stm_should_break_transaction(lltype.Bool))
def set_transaction_length(length):
stmgcintf.StmOperations.set_transaction_length(length)
diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -435,6 +435,7 @@
'stm_pop_root_into': LLOp(),
'stm_commit_transaction': LLOp(),
'stm_begin_inevitable_transaction': LLOp(),
+ 'stm_should_break_transaction': LLOp(sideeffects=False),
# __________ address operations __________
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -597,6 +597,7 @@
OP_STM_ID = _OP_STM
OP_STM_COMMIT_TRANSACTION = _OP_STM
OP_STM_BEGIN_INEVITABLE_TRANSACTION = _OP_STM
+ OP_STM_SHOULD_BREAK_TRANSACTION = _OP_STM
def OP_PTR_NONZERO(self, op):
diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py
--- a/rpython/translator/stm/funcgen.py
+++ b/rpython/translator/stm/funcgen.py
@@ -119,6 +119,10 @@
def stm_begin_inevitable_transaction(funcgen, op):
return 'stm_begin_inevitable_transaction();'
+def stm_should_break_transaction(funcgen, op):
+ result = funcgen.expr(op.result)
+ return '%s = stm_should_break_transaction();' % (result,)
+
def op_stm(funcgen, op):
func = globals()[op.opname]
diff --git a/rpython/translator/stm/test/test_ztranslated.py b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -79,6 +79,22 @@
cbuilder.cmdexec('')
# assert did not crash
+ def test_become_inevitable(self):
+ def entry_point(argv):
+ rstm.become_inevitable()
+ return 0
+ t, cbuilder = self.compile(entry_point)
+ cbuilder.cmdexec('')
+ # assert did not crash
+
+ def test_should_break_transaction(self):
+ def entry_point(argv):
+ print '<', int(rstm.should_break_transaction()), '>'
+ return 0
+ t, cbuilder = self.compile(entry_point)
+ data = cbuilder.cmdexec('')
+ assert '< 1 >\n' in data
+
def test_targetdemo(self):
t, cbuilder = self.compile(targetdemo2.entry_point)
data, dataerr = cbuilder.cmdexec('4 5000', err=True,
More information about the pypy-commit
mailing list