Author: Armin Rigo <[email protected]>
Branch: ec-threadlocal
Changeset: r72145:f8c6e69e11fb
Date: 2014-06-22 22:33 +0200
http://bitbucket.org/pypy/pypy/changeset/f8c6e69e11fb/
Log: in-progress: see comments
diff --git a/rpython/jit/codewriter/jitcode.py
b/rpython/jit/codewriter/jitcode.py
--- a/rpython/jit/codewriter/jitcode.py
+++ b/rpython/jit/codewriter/jitcode.py
@@ -117,6 +117,24 @@
raise NotImplementedError
+class ThreadLocalRefDescr(AbstractDescr):
+ # A special descr used as the extradescr in a call to a
+ # threadlocalref_get function. If the backend supports it,
+ # it can use this 'get_tlref_addr()' to get the address *in the
+ # current thread* of the thread-local variable. If, on the current
+ # platform, the "__thread" variables are implemented as an offset
+ # from some base register (e.g. %fs on x86-64), then the backend will
+ # immediately substract the current value of the base register.
+ # This gives an offset from the base register, and this can be
+ # written down in an assembler instruction to load the "__thread"
+ # variable from anywhere.
+
+ def __init__(self, opaque_id):
+ def get_tlref_addr():
+ return llop.threadlocalref_getaddr(llmemory.Address, opaque_id)
+ self.get_tlref_addr = get_tlref_addr
+
+
class LiveVarsInfo(object):
def __init__(self, live_i, live_r, live_f):
self.live_i = live_i
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -391,12 +391,14 @@
def handle_residual_call(self, op, extraargs=[], may_call_jitcodes=False,
oopspecindex=EffectInfo.OS_NONE,
- extraeffect=None):
+ extraeffect=None,
+ extradescr=None):
"""A direct_call turns into the operation 'residual_call_xxx' if it
is calling a function that we don't want to JIT. The initial args
of 'residual_call_xxx' are the function to call, and its calldescr."""
calldescr = self.callcontrol.getcalldescr(op,
oopspecindex=oopspecindex,
- extraeffect=extraeffect)
+ extraeffect=extraeffect,
+ extradescr=extradescr)
op1 = self.rewrite_call(op, 'residual_call',
[op.args[0]] + extraargs, calldescr=calldescr)
if may_call_jitcodes or self.callcontrol.calldescr_canraise(calldescr):
@@ -1906,13 +1908,16 @@
return [op0, op1]
def rewrite_op_threadlocalref_get(self, op):
+ from rpython.jit.codewriter.jitcode import ThreadLocalRefDescr
opaqueid = op.args[0].value
op1 = self.prepare_builtin_call(op, 'threadlocalref_getter', [],
extra=(opaqueid,),
extrakey=opaqueid._obj)
+ extradescr = ThreadLocalRefDescr(opaqueid)
return self.handle_residual_call(op1,
oopspecindex=EffectInfo.OS_THREADLOCALREF_GET,
- extraeffect=EffectInfo.EF_LOOPINVARIANT)
+ extraeffect=EffectInfo.EF_LOOPINVARIANT,
+ extradescr=[extradescr])
# ____________________________________________________________
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit