[pypy-svn] r23016 - in pypy/branch/genc-gc-refactoring: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Feb 4 01:37:22 CET 2006


Author: cfbolz
Date: Sat Feb  4 01:37:21 2006
New Revision: 23016

Modified:
   pypy/branch/genc-gc-refactoring/funcgen.py
   pypy/branch/genc-gc-refactoring/gc.py
   pypy/branch/genc-gc-refactoring/test/test_newgc.py
Log:
remove the insertion of the write barrier by genc, since this is now part of
the gc graph transformations. all genc tests pass again.


Modified: pypy/branch/genc-gc-refactoring/funcgen.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/funcgen.py	(original)
+++ pypy/branch/genc-gc-refactoring/funcgen.py	Sat Feb  4 01:37:21 2006
@@ -424,9 +424,7 @@
     def generic_set(self, op, targetexpr):
         newvalue = self.expr(op.args[2], special_case_void=False)
         result = ['%s = %s;' % (targetexpr, newvalue)]
-        # insert write barrier
         T = self.lltypemap(op.args[2])
-        self.gcpolicy.write_barrier(result, newvalue, T, targetexpr)
         result = '\n'.join(result)
         if T is Void:
             result = '/* %s */' % result

Modified: pypy/branch/genc-gc-refactoring/gc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/gc.py	(original)
+++ pypy/branch/genc-gc-refactoring/gc.py	Sat Feb  4 01:37:21 2006
@@ -105,20 +105,6 @@
             return self.push_alive(expr, T)
         return ''
 
-    def write_barrier(self, result, newvalue, T, targetexpr):  
-        decrefstmt = self.pop_alive('prev', T)
-        increfstmt = self.push_alive(newvalue, T)
-        if increfstmt:
-            result.append(increfstmt)
-        if decrefstmt:
-            result.insert(0, '%s = %s;' % (
-                cdecl(self.db.gettype(T), 'prev'),
-                targetexpr))
-            result.append(decrefstmt)
-            result[:] = ['\t%s' % line for line in result]
-            result[0] = '{' + result[0]
-            result.append('}')
-
     def generic_dealloc(self, expr, T):
         db = self.db
         if isinstance(T, Ptr) and T._needsgc():
@@ -341,8 +327,6 @@
 
 class BoehmGcPolicy(BasicGcPolicy):
 
-    write_barrier = RefcountingGcPolicy.write_barrier.im_func
-
     generic_dealloc = RefcountingGcPolicy.generic_dealloc.im_func
 
     deallocator_lines = RefcountingGcPolicy.deallocator_lines.im_func

Modified: pypy/branch/genc-gc-refactoring/test/test_newgc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/test/test_newgc.py	(original)
+++ pypy/branch/genc-gc-refactoring/test/test_newgc.py	Sat Feb  4 01:37:21 2006
@@ -106,3 +106,25 @@
     fn = compile_func(f, [int])
     assert fn(1) == 1
 #    assert fn(0) == 0 #XXX this should work but it's not my fault
+
+def test_write_barrier():
+    S = lltype.GcStruct("S", ('x', lltype.Signed))
+    T = lltype.GcStruct("T", ('s', lltype.Ptr(S)))
+    def f(x):
+        s = lltype.malloc(S)
+        s.x = 0
+        s1 = lltype.malloc(S)
+        s1.x = 1
+        s2 = lltype.malloc(S)
+        s2.x = 2
+        t = lltype.malloc(T)
+        t.s = s
+        if x:
+            t.s = s1
+        else:
+            t.s = s2
+        return t.s.x + s.x + s1.x + s2.x
+    fn = compile_func(f, [int])
+    assert fn(1) == 4
+    assert fn(0) == 5
+



More information about the Pypy-commit mailing list