Author: Armin Rigo <[email protected]>
Branch: stmgc-static-barrier
Changeset: r66159:89a6e347857d
Date: 2013-08-15 07:54 +0200
http://bitbucket.org/pypy/pypy/changeset/89a6e347857d/
Log: Prebuilt objects cannot be stubs.
diff --git a/rpython/translator/stm/test/test_writebarrier.py
b/rpython/translator/stm/test/test_writebarrier.py
--- a/rpython/translator/stm/test/test_writebarrier.py
+++ b/rpython/translator/stm/test/test_writebarrier.py
@@ -25,7 +25,7 @@
res = self.interpret(f1, [-5])
assert res == 42
assert len(self.writemode) == 0
- assert self.barriers == ['A2R']
+ assert self.barriers == ['I2R']
def test_simple_write(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed))
@@ -38,7 +38,7 @@
self.interpret(f1, [4])
assert x1.foo == 4
assert len(self.writemode) == 1
- assert self.barriers == ['A2W']
+ assert self.barriers == ['I2W']
def test_multiple_reads(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed),
@@ -59,7 +59,7 @@
res = self.interpret(f1, [4])
assert res == -81
assert len(self.writemode) == 0
- assert self.barriers == ['A2R']
+ assert self.barriers == ['I2R']
def test_malloc(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed))
@@ -82,7 +82,7 @@
self.interpret(f1, [4])
assert len(self.writemode) == 2
- assert self.barriers == ['A2W', 'V2W']
+ assert self.barriers == ['I2W', 'V2W']
def test_repeat_read_barrier_after_malloc(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed))
@@ -96,7 +96,7 @@
self.interpret(f1, [4])
assert len(self.writemode) == 1
- assert self.barriers == ['A2R']
+ assert self.barriers == ['I2R']
def test_write_may_alias(self):
X = lltype.GcStruct('X', ('foo', lltype.Signed))
@@ -291,7 +291,39 @@
return y
res = self.interpret(f1, [10])
- assert self.barriers == ['A2W', 'V2W']
+ assert self.barriers == ['I2W', 'V2W']
+
+ def test_read_immutable(self):
+ class Foo:
+ _immutable_ = True
+
+ def f1(n):
+ x = Foo()
+ if n > 1:
+ x.foo = n
+ return x.foo
+
+ res = self.interpret(f1, [4])
+ assert res == 4
+ assert self.barriers == ['a2w', 'a2i']
+
+ def test_read_immutable_prebuilt(self):
+ class Foo:
+ _immutable_ = True
+ x1 = Foo()
+ x1.foo = 42
+ x2 = Foo()
+ x2.foo = 81
+
+ def f1(n):
+ if n > 1:
+ return x2.foo
+ else:
+ return x1.foo
+
+ res = self.interpret(f1, [4])
+ assert res == 81
+ assert self.barriers == []
external_release_gil = rffi.llexternal('external_release_gil', [], lltype.Void,
diff --git a/rpython/translator/stm/test/transform_support.py
b/rpython/translator/stm/test/transform_support.py
--- a/rpython/translator/stm/test/transform_support.py
+++ b/rpython/translator/stm/test/transform_support.py
@@ -35,7 +35,7 @@
if not p:
return None
if p._solid:
- return 'A' # allocated with immortal=True
+ return 'I' # allocated with immortal=True
raise AssertionError("unknown category on %r" % (p,))
def interpret(self, fn, args):
diff --git a/rpython/translator/stm/writebarrier.py
b/rpython/translator/stm/writebarrier.py
--- a/rpython/translator/stm/writebarrier.py
+++ b/rpython/translator/stm/writebarrier.py
@@ -53,7 +53,11 @@
graphinfo = stmtransformer.write_analyzer.compute_graph_info(graph)
def get_category(v):
- return category.get(v, 'A')
+ if isinstance(v, Constant):
+ default = 'I' # prebuilt objects cannot be stubs
+ else:
+ default = 'A'
+ return category.get(v, default)
def get_category_or_null(v):
if isinstance(v, Constant) and not v.value:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit