Commits

Armin Rigo committed c848ebb

Fix

Comments (0)

Files changed (2)

rpython/rlib/rstm.py

 # ____________________________________________________________
 
 class ThreadLocalReference(object):
-    _COUNT = 0
+    _COUNT = 1
 
     def __init__(self, Cls):
         "NOT_RPYTHON: must be prebuilt"

rpython/translator/stm/threadlocalref.py

 from rpython.translator.unsimplify import varoftype
 from rpython.flowspace.model import SpaceOperation, Constant
 
-#
-# Note: all this slightly messy code is to have 'stm_threadlocalref_flush'
-# which zeroes *all* thread-locals variables accessed with
-# stm_threadlocalref_{get,set}.
-#
 
 def transform_tlref(graphs):
     ids = set()
             for i in range(len(block.operations)-1, -1, -1):
                 op = block.operations[i]
                 if op.opname == 'stm_threadlocalref_set':
+                    id = op.args[0].value
+                    c_num = Constant(ids.index(id), lltype.Signed)
                     v_addr = varoftype(lltype.Ptr(ARRAY))
-                    ops = getaddr(op.args[0], v_addr)
+                    ops = getaddr(c_num, v_addr)
                     ops.append(SpaceOperation('stm_threadlocalref_llset',
                                               [v_addr, op.args[1]],
                                               op.result))
                     block.operations[i:i+1] = ops
                 elif op.opname == 'stm_threadlocalref_get':
+                    id = op.args[0].value
+                    c_num = Constant(ids.index(id), lltype.Signed)
                     v_array = varoftype(lltype.Ptr(ARRAY))
                     ops = [
                         SpaceOperation('getfield', [c_threadlocalref,
                                                     c_fieldname],
                                        v_array),
-                        SpaceOperation('getarrayitem', [v_array,
-                                                        op.args[0]],
+                        SpaceOperation('getarrayitem', [v_array, c_num],
                                        op.result)]
                     block.operations[i:i+1] = ops
                 elif op.opname == 'stm_threadlocalref_lladdr':