Debian Codegraph @

rpython/jit/backend/riscv/test/test_fficall.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 from rpython.jit.backend.riscv.test.test_basic import JitRISCVMixin
4 from rpython.jit.metainterp.test import test_fficall
5
6
7 class TestFfiCall(JitRISCVMixin, test_fficall.FfiCallTests):
8 # for the individual tests see
9 # ====> ../../../metainterp/test/test_fficall.py
10
11 def _add_libffi_types_to_ll2types_maybe(self):
12 # This is needed by test_guard_not_forced_fails, because it produces a
13 # loop which reads the value of types.* in a variable, then a guard
14 # fail and we switch to blackhole: the problem is that at this point
15 # the blackhole interp has a real integer, but it needs to convert it
16 # back to a lltype pointer (which is handled by ll2ctypes, deeply in
17 # the logic). The workaround is to teach ll2ctypes in advance which
18 # are the addresses of the various types.* structures.
19 # Try to comment this code out and run the test to see how it fails :)
20 from rpython.rtyper.lltypesystem import rffi, lltype, ll2ctypes
21 from rpython.rlib.jit_libffi import types
22 for key, value in types.__dict__.iteritems():
23 if isinstance(value, lltype._ptr):
24 addr = rffi.cast(lltype.Signed, value)
25 ll2ctypes._int2obj[addr] = value