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