Commits

Armin Rigo committed de0e05b

A test and small fixes for gc_writebarrier in stm.

Comments (0)

Files changed (4)

rpython/memory/gctransform/framework.py

                   resultvar=op.result)
 
     def gct_gc_writebarrier(self, hop):
-        # this operation is removed by stm/writebarrier.py
-        assert not self.translator.config.translation.stm
-        if self.write_barrier_ptr is None:
+        if self.write_barrier_ptr is None:   # incl. in case of stm
             return
         op = hop.spaceop
         v_addr = op.args[0]

rpython/translator/stm/inevitable.py

     'weakref_create', 'weakref_deref',
     'stm_threadlocalref_get', 'stm_threadlocalref_set',
     'stm_threadlocalref_count', 'stm_threadlocalref_addr',
-    'jit_assembler_call',
+    'jit_assembler_call', 'gc_writebarrier',
     ])
 ALWAYS_ALLOW_OPERATIONS |= set(lloperation.enum_tryfold_ops())
 

rpython/translator/stm/test/test_ztranslated.py

         match = re.search(r"(\d+) mallocs left", dataerr)
         assert match
         assert int(match.group(1)) < 20
+
+    def test_gc_writebarrier(self):
+        class X(object):
+            pass
+        prebuilt = X()
+        prebuilt.foo = 42
+
+        def main(argv):
+            llop.gc_writebarrier(lltype.Void, prebuilt)
+            debug_print(objectmodel.current_object_addr_as_int(prebuilt))
+            prebuilt.foo = 43
+            debug_print(objectmodel.current_object_addr_as_int(prebuilt))
+            return 0
+
+        t, cbuilder = self.compile(main)
+        data, dataerr = cbuilder.cmdexec('', err=True)
+        lines = dataerr.split('\n')
+        assert lines[0] == lines[1]

rpython/translator/stm/writebarrier.py

                     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],