[pypy-commit] pypy default: try to jit this test

fijal noreply at buildbot.pypy.org
Sat Jan 5 19:12:27 CET 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r59752:da42f8f19188
Date: 2013-01-05 20:11 +0200
http://bitbucket.org/pypy/pypy/changeset/da42f8f19188/

Log:	try to jit this test

diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -1,9 +1,11 @@
-import py
+
+import ctypes, math
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.jit.metainterp.test.support import LLJitMixin
 from pypy.rlib import jit
 from pypy.rlib.jit_libffi import types, CIF_DESCRIPTION, FFI_TYPE_PP
 from pypy.rlib.unroll import unrolling_iterable
+from pypy.rlib.rarithmetic import intmask
 
 
 def get_description(atypes, rtype):
@@ -103,4 +105,39 @@
 
 
 class TestFfiCall(FfiCallTests, LLJitMixin):
-    pass
+    def test_jit_fii_vref(self):
+        from pypy.rlib import clibffi
+        from pypy.rlib.jit_libffi import jit_ffi_prep_cif, jit_ffi_call
+
+        math_sin = intmask(ctypes.cast(ctypes.CDLL(None).sin,
+                                       ctypes.c_void_p).value)
+        math_sin = rffi.cast(rffi.VOIDP, math_sin)
+
+        def f():
+            cd = lltype.malloc(CIF_DESCRIPTION, 1, flavor='raw')
+            cd.abi = clibffi.FFI_DEFAULT_ABI
+            cd.nargs = 1
+            cd.rtype = clibffi.cast_type_to_ffitype(rffi.DOUBLE)
+            atypes = lltype.malloc(clibffi.FFI_TYPE_PP.TO, 1, flavor='raw')
+            atypes[0] = clibffi.cast_type_to_ffitype(rffi.DOUBLE)
+            cd.atypes = atypes
+            cd.exchange_size = 64    # 64 bytes of exchange data
+            cd.exchange_result = 24
+            cd.exchange_result_libffi = 24
+            cd.exchange_args[0] = 16
+            #
+            jit_ffi_prep_cif(cd)
+            #
+            assert rffi.sizeof(rffi.DOUBLE) == 8
+            exb = lltype.malloc(rffi.DOUBLEP.TO, 8, flavor='raw')
+            exb[2] = 1.23
+            jit_ffi_call(cd, math_sin, rffi.cast(rffi.CCHARP, exb))
+            res = exb[3]
+            lltype.free(exb, flavor='raw')
+            #
+            lltype.free(atypes, flavor='raw')
+            lltype.free(cd, flavor='raw')
+            return res
+            #
+        res = self.interp_operations(f, [])
+        assert res == math.sin(1.23)
diff --git a/pypy/rlib/jit_libffi.py b/pypy/rlib/jit_libffi.py
--- a/pypy/rlib/jit_libffi.py
+++ b/pypy/rlib/jit_libffi.py
@@ -1,4 +1,4 @@
-import sys
+
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.rlib import clibffi, jit
 


More information about the pypy-commit mailing list