Author: Remi Meier <[email protected]>
Branch: stmgc-c7
Changeset: r71488:2eecc075280f
Date: 2014-05-13 14:10 +0200
http://bitbucket.org/pypy/pypy/changeset/2eecc075280f/

Log:    fix to really not become inevitable before pure raw_loads (hopefully
        not breaking anything)

diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py
--- a/rpython/rtyper/llinterp.py
+++ b/rpython/rtyper/llinterp.py
@@ -1009,7 +1009,7 @@
 
     op_raw_memmove = op_raw_memcopy # this is essentially the same here
 
-    def op_raw_load(self, RESTYPE, addr, offset):
+    def op_raw_load(self, RESTYPE, addr, offset, pure=False):
         checkadr(addr)
         if isinstance(offset, int):
             from rpython.rtyper.lltypesystem import rffi
diff --git a/rpython/translator/stm/inevitable.py 
b/rpython/translator/stm/inevitable.py
--- a/rpython/translator/stm/inevitable.py
+++ b/rpython/translator/stm/inevitable.py
@@ -43,13 +43,13 @@
     # and it doesn't use the hint 'stm_dont_track_raw_accesses', then they
     # turn inevitable.
     TYPE = op.args[0].concretetype
+    if is_immutable(op):
+        return False
     if not isinstance(TYPE, lltype.Ptr):
         return True     # raw_load or raw_store with a number or address
     S = TYPE.TO
     if S._gckind == 'gc':
         return False
-    if is_immutable(op):
-        return False
     if S._hints.get('stm_dont_track_raw_accesses', False):
         return False
     return not fresh_mallocs.is_fresh_malloc(op.args[0])
diff --git a/rpython/translator/stm/test/test_inevitable.py 
b/rpython/translator/stm/test/test_inevitable.py
--- a/rpython/translator/stm/test/test_inevitable.py
+++ b/rpython/translator/stm/test/test_inevitable.py
@@ -255,3 +255,27 @@
 
         res = self.interpret_inevitable(f, [2])
         assert res is None
+
+    def test_raw_load_nonpure(self):
+        X = lltype.Struct('X', ('foo', lltype.Signed))
+        x1 = lltype.malloc(X, immortal=True)
+        x1.foo = 42
+
+        def f1():
+            return llop.raw_load(
+                lltype.Signed, llmemory.cast_ptr_to_adr(x1), 0, False)
+
+        res = self.interpret_inevitable(f1, [])
+        assert res == 'raw_load'
+
+    def test_raw_load_pure(self):
+        X = lltype.Struct('X', ('foo', lltype.Signed))
+        x1 = lltype.malloc(X, immortal=True)
+        x1.foo = 42
+
+        def f1():
+            return llop.raw_load(
+                lltype.Signed, llmemory.cast_ptr_to_adr(x1), 0, True)
+
+        res = self.interpret_inevitable(f1, [])
+        assert res is None
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to