Commits

Remi Meier committed 73cb960

fix for threadlocal access. It was missing barriers and push_roots.

  • Participants
  • Parent commits eb21e73
  • Branches stmgc-c4

Comments (0)

Files changed (5)

+------------------------------------------------------------
+
+should stm_thread_local_obj always be read & writeable? would
+a write-barrier in begin_transaction be too much for small
+transactions? should we handle it specially (undolog?)
+
 ------------------------------------------------------------
 
 looking at trace of fibo.tlc (targettlc.py), there are a lot

File rpython/memory/gctransform/stmframework.py

     gct_stm_perform_transaction                     = _gct_with_roots_pushed
     gct_stm_allocate_nonmovable_int_adr             = _gct_with_roots_pushed
     gct_stm_inspect_abort_info                      = _gct_with_roots_pushed
+    gct_stm_threadlocalref_set                      = _gct_with_roots_pushed
 
 
 class StmRootWalker(BaseRootWalker):

File rpython/rtyper/lltypesystem/lloperation.py

     'stm_weakref_allocate':   LLOp(sideeffects=False, canmallocgc=True),
     
     'stm_threadlocalref_get': LLOp(sideeffects=False),
-    'stm_threadlocalref_set': LLOp(),
+    'stm_threadlocalref_set': LLOp(canmallocgc=True), # may allocate new array,
+                                                      # see threadlocalref.py
     'stm_threadlocal_get':    LLOp(sideeffects=False),
     'stm_threadlocal_set':    LLOp(),
 

File rpython/translator/stm/funcgen.py

 
 def stm_barrier(funcgen, op):
     category_change = op.args[0].value
-    frm, middle, to = category_change
+    # XXX: how to unify the stm_barrier llop generation in
+    #      writebarrier.py and threadlocalref.py?
+    if isinstance(category_change, str):
+        frm, middle, to = category_change
+    else: # rstr
+        frm, middle, to = (category_change.chars[0],
+                           category_change.chars[1],
+                           category_change.chars[2])
     assert middle == '2'
     assert frm < to
     if to == 'W':

File rpython/translator/stm/threadlocalref.py

         if not array:
             return lltype.nullptr(rclass.OBJECTPTR.TO)
         else:
+            array = llop.stm_barrier(lltype.Ptr(ARRAY), 'A2R', array)
             return array[index]
     #
     def ll_threadlocalref_set(index, newvalue):
         array = llop.stm_threadlocal_get(lltype.Ptr(ARRAY))
         if not array:
-            array = lltype.malloc(ARRAY, total)
+            array = lltype.malloc(ARRAY, total) # llop may allocate!
             llop.stm_threadlocal_set(lltype.Void, array)
+        else:
+            array = llop.stm_barrier(lltype.Ptr(ARRAY), 'A2W', array)
+            # invalidating other barriers after an llop.threadlocalref_set
+            # is not necessary since no other variable should contain
+            # a reference to stm_threadlocal_obj
         array[index] = newvalue
     #
     annhelper = annlowlevel.MixLevelHelperAnnotator(t.rtyper)