Author: Armin Rigo <[email protected]>
Branch: stm
Changeset: r51714:0774830dfdeb
Date: 2012-01-24 15:29 +0100
http://bitbucket.org/pypy/pypy/changeset/0774830dfdeb/
Log: Use _stm_access_directly_ to mean that all field accesses should be
direct. Should be combined with some form of locking.
diff --git a/pypy/translator/stm/llstminterp.py
b/pypy/translator/stm/llstminterp.py
--- a/pypy/translator/stm/llstminterp.py
+++ b/pypy/translator/stm/llstminterp.py
@@ -66,7 +66,8 @@
def opstm_getfield(self, struct, fieldname):
STRUCT = lltype.typeOf(struct).TO
- if STRUCT._immutable_field(fieldname):
+ if (STRUCT._immutable_field(fieldname) or
+ 'stm_access_directly' in STRUCT._hints):
# immutable field reads are always allowed
return LLFrame.op_getfield(self, struct, fieldname)
elif STRUCT._gckind == 'raw':
@@ -80,7 +81,8 @@
def opstm_setfield(self, struct, fieldname, newvalue):
STRUCT = lltype.typeOf(struct).TO
- if STRUCT._immutable_field(fieldname):
+ if (STRUCT._immutable_field(fieldname) or
+ 'stm_access_directly' in STRUCT._hints):
# immutable field writes (i.e. initializing writes) should
# always be fine, because they should occur into newly malloced
# structures
diff --git a/pypy/translator/stm/test/test_transform.py
b/pypy/translator/stm/test/test_transform.py
--- a/pypy/translator/stm/test/test_transform.py
+++ b/pypy/translator/stm/test/test_transform.py
@@ -141,6 +141,19 @@
assert summary(graph) == {'setinteriorfield': 1}
res = eval_stm_graph(interp, graph, [p], stm_mode="regular_transaction")
+def test_getfield_access_directly():
+ class P:
+ x = 42
+ _stm_access_directly_ = True
+ def func():
+ p = P()
+ p.x += 1
+ interp, graph = get_interpreter(func, [])
+ transform_graph(graph)
+ assert summary(graph) == {'malloc': 1, 'cast_pointer': 1,
+ 'getfield': 1, 'setfield': 3, 'int_add': 1}
+ res = eval_stm_graph(interp, graph, [], stm_mode="regular_transaction")
+
def test_unsupported_operation():
def func(n):
n += 1
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
@@ -112,7 +112,8 @@
STRUCT = op.args[0].concretetype.TO
if op.result.concretetype is lltype.Void:
op1 = op
- elif STRUCT._immutable_field(op.args[1].value):
+ elif (STRUCT._immutable_field(op.args[1].value) or
+ 'stm_access_directly' in STRUCT._hints):
op1 = op
elif STRUCT._gckind == 'raw':
turn_inevitable(newoperations, "getfield-raw")
@@ -125,7 +126,8 @@
STRUCT = op.args[0].concretetype.TO
if op.args[2].concretetype is lltype.Void:
op1 = op
- elif STRUCT._immutable_field(op.args[1].value):
+ elif (STRUCT._immutable_field(op.args[1].value) or
+ 'stm_access_directly' in STRUCT._hints):
op1 = op
elif STRUCT._gckind == 'raw':
turn_inevitable(newoperations, "setfield-raw")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit