Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r54819:c0274354141e
Date: 2012-04-30 11:14 +0200
http://bitbucket.org/pypy/pypy/changeset/c0274354141e/
Log: Add a direct low-level operation stm_is_enabled().
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
@@ -399,6 +399,7 @@
# direct_calls and maybe several casts, but it looks less heavy-weight
# to keep them as operations until the genc stage)
+ 'stm_is_enabled': LLOp(canrun=True), # sideeffects:
test_lltyped.py
'stm_getfield': LLOp(sideeffects=False, canrun=True),
'stm_getarrayitem': LLOp(sideeffects=False, canrun=True),
'stm_getinteriorfield': LLOp(sideeffects=False, canrun=True),
diff --git a/pypy/rpython/lltypesystem/opimpl.py
b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -623,16 +623,8 @@
from pypy.rlib.rtimer import read_timestamp
return read_timestamp()
-def op_stm_descriptor_init():
- # for direct testing only
- xxx
- from pypy.translator.stm import stmgcintf
- stmgcintf.StmOperations.set_tls(llmemory.NULL, 0)
-
-def op_stm_descriptor_done():
- xxx
- from pypy.translator.stm import stmgcintf
- stmgcintf.StmOperations.del_tls()
+def op_stm_is_enabled():
+ return False
def op_stm_start_transaction():
pass
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -259,3 +259,5 @@
#define OP_GC_GET_RPY_TYPE_INDEX(x, r) r = -1
#define OP_GC_IS_RPY_INSTANCE(x, r) r = 0
#define OP_GC_DUMP_RPY_HEAP(fd, r) r = 0
+
+#define OP_STM_IS_ENABLED(r) r = 0
diff --git a/pypy/translator/c/test/test_lltyped.py
b/pypy/translator/c/test/test_lltyped.py
--- a/pypy/translator/c/test/test_lltyped.py
+++ b/pypy/translator/c/test/test_lltyped.py
@@ -903,3 +903,16 @@
return rstring_to_float(s)
fn = self.getcompiled(llf, [int])
assert fn(0) == 42.3
+
+ def test_stm_is_enabled(self):
+ from pypy.rpython.lltypesystem import lltype
+ from pypy.rpython.lltypesystem.lloperation import llop
+ # note that right now the situation of lloperation is a bit messy.
+ # stm_is_enabled is not "sideeffects=False" because otherwise
+ # it is constant-folded away by backendopt/constfold.py.
+ assert llop.stm_is_enabled.sideeffects == True
+ #
+ def llf(i):
+ return int(llop.stm_is_enabled(lltype.Bool))
+ fn = self.getcompiled(llf, [int])
+ assert fn(0) == 0
diff --git a/pypy/translator/stm/test/targetdemo.py
b/pypy/translator/stm/test/targetdemo.py
--- a/pypy/translator/stm/test/targetdemo.py
+++ b/pypy/translator/stm/test/targetdemo.py
@@ -1,4 +1,5 @@
-from pypy.rpython.lltypesystem import rffi
+from pypy.rpython.lltypesystem import lltype, rffi
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib import rstm
from pypy.rlib.debug import debug_print, ll_assert
@@ -95,6 +96,7 @@
def entry_point(argv):
print "hello world"
+ assert llop.stm_is_enabled(lltype.Bool)
if len(argv) > 1:
glob.NUM_THREADS = int(argv[1])
if len(argv) > 2:
diff --git a/pypy/translator/stm/transform.py b/pypy/translator/stm/transform.py
--- a/pypy/translator/stm/transform.py
+++ b/pypy/translator/stm/transform.py
@@ -162,6 +162,11 @@
self.count_write_barrier += 1
newoperations.append(op)
+ def stt_stm_is_enabled(self, newoperations, op):
+ c_True = Constant(True, lltype.Bool)
+ op = SpaceOperation('same_as', [c_True], op.result)
+ newoperations.append(op)
+
def stt_malloc(self, newoperations, op):
flags = op.args[1].value
if flags['flavor'] == 'gc':
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit