[pypy-commit] pypy stm-gc: Finish it. test_ztranslated passes.

arigo noreply at buildbot.pypy.org
Thu Feb 16 17:55:19 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-gc
Changeset: r52556:1aa220474865
Date: 2012-02-16 17:55 +0100
http://bitbucket.org/pypy/pypy/changeset/1aa220474865/

Log:	Finish it. test_ztranslated passes.

diff --git a/pypy/translator/stm/localtracker.py b/pypy/translator/stm/localtracker.py
--- a/pypy/translator/stm/localtracker.py
+++ b/pypy/translator/stm/localtracker.py
@@ -5,6 +5,7 @@
 RETURNS_LOCAL_POINTER = set([
     'malloc', 'malloc_varsize', 'malloc_nonmovable',
     'malloc_nonmovable_varsize',
+    'stm_writebarrier',
     ])
 
 
diff --git a/pypy/translator/stm/transform.py b/pypy/translator/stm/transform.py
--- a/pypy/translator/stm/transform.py
+++ b/pypy/translator/stm/transform.py
@@ -28,8 +28,8 @@
         self.count_get_nonlocal  = 0
         self.count_get_immutable = 0
         self.count_set_local     = 0
-        self.count_set_nonlocal  = 0
         self.count_set_immutable = 0
+        self.count_write_barrier = 0
 
     def transform(self):
         assert not hasattr(self.translator, 'stm_transformation_applied')
@@ -53,8 +53,8 @@
         log('      not proven local: %d' % self.count_get_nonlocal)
         log('             immutable: %d' % self.count_get_immutable)
         log('set*:     proven local: %d' % self.count_set_local)
-        log('      not proven local: %d' % self.count_set_nonlocal)
         log('             immutable: %d' % self.count_set_immutable)
+        log('        write barriers: %d' % self.count_write_barrier)
         log.info("Software Transactional Memory transformation applied")
 
     def transform_block(self, block):
@@ -84,8 +84,6 @@
 
     # ----------
 
-    # ----------
-
     def transform_get(self, newoperations, op, stmopname):
         if op.result.concretetype is lltype.Void:
             newoperations.append(op)
@@ -119,20 +117,12 @@
             self.count_set_immutable += 1
             newoperations.append(op)
             return
-        if isinstance(op.args[0], Variable):
-            if self.localtracker.is_local(op.args[0]):
-                self.count_set_local += 1
-                newoperations.append(op)
-                return
-        self.count_set_nonlocal += 1
-        v_arg = op.args[0]
-        v_local = varoftype(v_arg.concretetype)
-        op0 = SpaceOperation('stm_writebarrier', [v_arg], v_local)
-        newoperations.append(op0)
-        op1 = SpaceOperation('bare_' + op.opname, [v_local] + op.args[1:],
-                             op.result)
-        newoperations.append(op1)
-        import pdb; pdb.set_trace()
+        # this is not really a transformation, but just an assertion that
+        # it work on local objects.  This should be ensured by
+        # pre_insert_stm_writebarrier().
+        assert self.localtracker.is_local(op.args[0])
+        self.count_set_local += 1
+        newoperations.append(op)
 
 
     def stt_getfield(self, newoperations, op):
@@ -153,6 +143,14 @@
     def stt_setinteriorfield(self, newoperations, op):
         self.transform_set(newoperations, op)
 
+    def stt_stm_writebarrier(self, newoperations, op):
+        if (isinstance(op.args[0], Variable) and
+            self.localtracker.is_local(op.args[0])):
+            op = SpaceOperation('same_as', op.args, op.result)
+        else:
+            self.count_write_barrier += 1
+        newoperations.append(op)
+
     def stt_malloc(self, newoperations, op):
         flags = op.args[1].value
         if flags['flavor'] == 'gc':


More information about the pypy-commit mailing list