Author: Armin Rigo <ar...@tunes.org> Branch: ec-threadlocal Changeset: r72142:f2d50551501d Date: 2014-06-22 22:04 +0200 http://bitbucket.org/pypy/pypy/changeset/f2d50551501d/
Log: Test and fix diff --git a/rpython/jit/metainterp/test/test_threadlocal.py b/rpython/jit/metainterp/test/test_threadlocal.py new file mode 100644 --- /dev/null +++ b/rpython/jit/metainterp/test/test_threadlocal.py @@ -0,0 +1,26 @@ +import py +from rpython.jit.metainterp.test.support import LLJitMixin +from rpython.rlib.rthread import ThreadLocalReference +from rpython.rlib.jit import dont_look_inside + + +class TestThreadLocal(LLJitMixin): + + def test_threadlocalref_get(self): + class Foo: + pass + t = ThreadLocalReference(Foo) + x = Foo() + + @dont_look_inside + def setup(): + t.set(x) + + def f(): + setup() + if t.get() is x: + return 42 + return -666 + + res = self.interp_operations(f, []) + assert res == 42 diff --git a/rpython/rtyper/llinterp.py b/rpython/rtyper/llinterp.py --- a/rpython/rtyper/llinterp.py +++ b/rpython/rtyper/llinterp.py @@ -919,6 +919,17 @@ def op_stack_current(self): return 0 + def op_threadlocalref_set(self, key, value): + try: + d = self.llinterpreter.tlrefsdict + except AttributeError: + d = self.llinterpreter.tlrefsdict = {} + d[key._obj] = value + + def op_threadlocalref_get(self, key): + d = self.llinterpreter.tlrefsdict + return d[key._obj] + # __________________________________________________________ # operations on addresses _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit