Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r66862:97ea6facc2a3
Date: 2013-09-09 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/97ea6facc2a3/

Log:    Handle gc_writebarrier in stm/writebarrier.py

diff --git a/rpython/memory/gctransform/framework.py 
b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -745,6 +745,7 @@
                   resultvar=op.result)
 
     def gct_gc_writebarrier(self, hop):
+        assert not self.translator.config.stm  # removed by stm/writebarrier.py
         if self.write_barrier_ptr is None:
             return
         op = hop.spaceop
@@ -897,6 +898,7 @@
             gen_zero_gc_pointers(TYPE, v_ob, hop.llops)
 
     def gct_gc_writebarrier_before_copy(self, hop):
+        assert not self.translator.config.stm  # should not be produced if stm
         op = hop.spaceop
         if not hasattr(self, 'wb_before_copy_ptr'):
             # no write barrier needed in that case
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
@@ -521,6 +521,15 @@
         self.interpret(f1, [])
         assert self.barriers == ['a2i']
 
+    def test_llop_gc_writebarrier(self):
+        FOO = lltype.GcStruct('FOO')
+        x = lltype.malloc(FOO, immortal=True)
+        def f1():
+            llop.gc_writebarrier(lltype.Void, x)
+
+        self.interpret(f1, [])
+        assert self.barriers == ['I2W']
+
 
 external_release_gil = rffi.llexternal('external_release_gil', [], lltype.Void,
                                        _callable=lambda: None,
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
@@ -165,3 +165,9 @@
 
     def op_stm_begin_inevitable_transaction(self):
         self.transaction_break()
+
+    def op_gc_writebarrier(self, p):
+        raise Exception("should have been removed")
+
+    def op_gc_writebarrier_before_copy(self, p):
+        raise Exception("should not be produced at all")
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
@@ -113,6 +113,9 @@
             elif op.opname == 'weakref_deref':
                 # 'weakref_deref' needs an immutable read barrier
                 wants_a_barrier[op] = 'I'
+
+            elif op.opname == 'gc_writebarrier':
+                wants_a_barrier[op] = 'W'
         #
         self.wants_a_barrier = wants_a_barrier
         self.expand_comparison = expand_comparison
@@ -196,6 +199,8 @@
                     newoperations.append(newop)
                     ren.newvar = w
                     ren.category = to
+                if op.opname == 'gc_writebarrier':
+                    continue   # remove after inserting 'stm_barrier'
             #
             newop = SpaceOperation(op.opname,
                                    [renamings_get(v) for v in op.args],
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to