Commits

Armin Rigo  committed de414b6

Insert the stm_read() barriers at the correct time

  • Participants
  • Parent commits 1783f38
  • Branches stmgc-c7

Comments (0)

Files changed (5)

File rpython/rtyper/lltypesystem/lloperation.py

     #  must be no gc-var access afterwards anyway)
     'stm_register_thread_local': LLOp(),
     'stm_unregister_thread_local': LLOp(),
+    'stm_read':               LLOp(),
     'stm_write':              LLOp(),
     'stm_can_move':           LLOp(),
     'stm_allocate_tid':       LLOp(sideeffects=False, canmallocgc=True),

File rpython/translator/c/genc.py

                               sandbox=self.config.translation.sandbox)
         self.db = db
 
-        if self.config.translation.stm:
-            stmtransformer.transform_after_gc()
-
         # give the gc a chance to register interest in the start-up functions it
         # need (we call this for its side-effects of db.get())
         list(db.gcpolicy.gc_startup_code())
         exports.clear()
         db.complete()
 
+        if self.config.translation.stm:
+            stmtransformer.transform_after_gc()
+
         self.collect_compilation_info(db)
         return db
 

File rpython/translator/stm/funcgen.py

 def stm_unregister_thread_local(funcgen, op):
     return 'stm_unregister_thread_local(&stm_thread_local);'
 
+def stm_read(funcgen, op):
+    assert isinstance(op.args[0].concretetype, lltype.Ptr)
+    assert op.args[0].concretetype.TO._gckind == 'gc'
+    arg0 = funcgen.expr(op.args[0])
+    return 'stm_read((object_t *)%s);' % (arg0,)
+
 def stm_write(funcgen, op):
     assert isinstance(op.args[0].concretetype, lltype.Ptr)
     assert op.args[0].concretetype.TO._gckind == 'gc'

File rpython/translator/stm/readbarrier.py

             if op.opname in READ_OPS and is_gc_ptr(op.args[0].concretetype):
                 v_none = varoftype(lltype.Void)
                 newops.append(SpaceOperation('stm_read', [op.args[0]], v_none))
+                transformer.read_barrier_counts += 1
             newops.append(op)
         block.operations = newops

File rpython/translator/stm/transform.py

 
     def transform(self):
         assert not hasattr(self.translator, 'stm_transformation_applied')
-        self.start_log()
+        self.start_log(1)
         self.transform_jit_driver()
-        self.transform_read_barrier()
         self.transform_turn_inevitable()
-        self.print_logs()
+        self.print_logs(1)
         self.translator.stm_transformation_applied = True
 
     def transform_after_gc(self):
+        self.start_log(2)
         self.transform_threadlocalref()
-        self.print_logs_after_gc()
+        self.transform_read_barrier()
+        self.print_logs(2)
 
     def transform_read_barrier(self):
         self.read_barrier_counts = 0
         for graph in self.translator.graphs:
             insert_stm_read_barrier(self, graph)
-        log("%d read barriers inserted" % (self.read_barrier_counts,))
+        log.info("%d read barriers inserted" % (self.read_barrier_counts,))
 
     def transform_turn_inevitable(self):
         for graph in self.translator.graphs:
             reorganize_around_jit_driver(self, graph)
 
     def transform_threadlocalref(self):
+        return #XXX XXX XXX
         transform_tlref(self.translator)
 
-    def start_log(self):
-        log.info("Software Transactional Memory transformation")
+    def start_log(self, step):
+        log.info("Software Transactional Memory transformation, step %d"
+                 % step)
 
-    def print_logs(self):
-        log.info("Software Transactional Memory transformation applied")
-
-    def print_logs_after_gc(self):
-        log.info("Software Transactional Memory transformation-after-gc done")
+    def print_logs(self, step):
+        log.info("Software Transactional Memory transformation, step %d, "
+                 "applied" % step)