Debian Codegraph @

rpython/jit/metainterp/test/test_threadlocal.py

raw symbols SCIP
1 import py
2 from rpython.rlib import rthread
3 from rpython.jit.metainterp.test.support import LLJitMixin
4 from rpython.rtyper.lltypesystem import lltype
5 from rpython.rtyper.lltypesystem.lloperation import llop
6
7
8 class ThreadLocalTest(object):
9
10 def test_threadlocalref_get(self):
11 tlfield = rthread.ThreadLocalField(lltype.Signed, 'foobar_test_')
12
13 def f():
14 tlfield.setraw(0x544c)
15 return tlfield.getraw()
16
17 res = self.interp_operations(f, [])
18 assert res == 0x544c
19
20 def test_threadlocalref_get_char(self):
21 tlfield = rthread.ThreadLocalField(lltype.Char, 'foobar_test_char_')
22
23 def f():
24 tlfield.setraw('\x92')
25 return ord(tlfield.getraw())
26
27 res = self.interp_operations(f, [])
28 assert res == 0x92
29
30 def test_threadlocalref_get_loopinvariant(self):
31 tlfield = rthread.ThreadLocalField(lltype.Signed, 'foobar_test_', True)
32
33 def f():
34 tlfield.setraw(0x544c)
35 return tlfield.getraw() + tlfield.getraw()
36
37 res = self.interp_operations(f, [])
38 assert res == 0x544c * 2
39 self.check_operations_history(call_loopinvariant_i=1)
40
41 class TestLLtype(ThreadLocalTest, LLJitMixin):
42 pass