Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r52561:8d501fff9677
Date: 2012-02-16 18:24 +0100
http://bitbucket.org/pypy/pypy/changeset/8d501fff9677/
Log: handle hint(stm_write) like stm_writebarrier.
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -151,8 +151,8 @@
generator.throw().
"""
self = hint(self, stm_write=True)
- hint(self.locals_stack_w, stm_write=True)
- hint(self.cells, stm_immutable=True)
+ #hint(self.locals_stack_w, stm_write=True) -- later
+ #hint(self.cells, stm_immutable=True) -- later
# the following 'assert' is an annotation hint: it hides from
# the annotator all methods that are defined in PyFrame but
# overridden in the {,Host}FrameClass subclasses of PyFrame.
diff --git a/pypy/translator/stm/localtracker.py
b/pypy/translator/stm/localtracker.py
--- a/pypy/translator/stm/localtracker.py
+++ b/pypy/translator/stm/localtracker.py
@@ -23,8 +23,11 @@
assert isinstance(variable, Variable)
for src in self.gsrc[variable]:
if isinstance(src, SpaceOperation):
- if src.opname not in RETURNS_LOCAL_POINTER:
- return False
+ if src.opname in RETURNS_LOCAL_POINTER:
+ continue
+ if src.opname == 'hint' and 'stm_write' in src.args[1].value:
+ continue
+ return False
elif isinstance(src, Constant):
if src.value: # a NULL pointer is still valid as local
return False
diff --git a/pypy/translator/stm/test/test_localtracker.py
b/pypy/translator/stm/test/test_localtracker.py
--- a/pypy/translator/stm/test/test_localtracker.py
+++ b/pypy/translator/stm/test/test_localtracker.py
@@ -210,6 +210,15 @@
self.translate(f, [int])
self.check(['x'])
+ def test_hint_stm_write(self):
+ z = X(42)
+ def f(n):
+ x = hint(z, stm_write=True)
+ _see(x, 'x')
+ #
+ self.translate(f, [int])
+ self.check(['x'])
+
S = lltype.GcStruct('S', ('n', lltype.Signed))
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
@@ -32,13 +32,17 @@
x.n = n + 2
x.sub = n + 1
x.n *= 2
+ if n < 10:
+ return x.n
+ else:
+ return 0
#
graph = get_graph(f1, [int])
pre_insert_stm_writebarrier(graph)
if option.view:
graph.show()
# weak test: check that there are exactly two stm_writebarrier inserted.
- # one should be for 'x.n = n', and one should cover both field assignments
- # to the Z instance.
+ # one should be for 'x.n = n', one should cover both field assignments
+ # to the Z instance, and the 3rd one is in the block 'x.n *= 2'.
sum = summary(graph)
assert sum['stm_writebarrier'] == 3
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
@@ -163,6 +163,13 @@
stt_malloc_nonmovable = stt_malloc
stt_malloc_nonmovable_varsize = stt_malloc
+ def stt_hint(self, newoperations, op):
+ if 'stm_write' in op.args[1].value:
+ op = SpaceOperation('stm_writebarrier', [op.args[0]], op.result)
+ self.stt_stm_writebarrier(newoperations, op)
+ return
+ newoperations.append(op)
+
def transform_graph(graph):
# for tests: only transforms one graph
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit