[pypy-svn] pypy jitypes2: in-progress: don't try to jit calls for which we return structs by value. The test in metainterp/test/test_fficall.py mostly passes, but it still leaks memory

antocuni commits-noreply at bitbucket.org
Fri Dec 24 14:30:40 CET 2010


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: jitypes2
Changeset: r40223:a4608c3d9de1
Date: 2010-12-24 14:21 +0100
http://bitbucket.org/pypy/pypy/changeset/a4608c3d9de1/

Log:	in-progress: don't try to jit calls for which we return structs by
	value. The test in metainterp/test/test_fficall.py mostly passes,
	but it still leaks memory

diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -300,7 +300,9 @@
             i += 1
             arg = arg.next
         #
-        if _fits_into_long(RESULT):
+        if types.is_struct(self.restype):
+            res = self._do_call_raw(self.funcsym, ll_args)
+        elif _fits_into_long(RESULT):
             res = self._do_call_int(self.funcsym, ll_args)
         elif RESULT is rffi.DOUBLE:
             return self._do_call_float(self.funcsym, ll_args)
@@ -376,6 +378,11 @@
         return float(single_res)
 
     @jit.dont_look_inside
+    def _do_call_raw(self, funcsym, ll_args):
+        # same as _do_call_int, but marked as jit.dont_look_inside
+        return self._do_call(funcsym, ll_args, rffi.LONG)
+
+    @jit.dont_look_inside
     def _do_call_longlong(self, funcsym, ll_args):
         llres = self._do_call(funcsym, ll_args, rffi.LONGLONG)
         return longlong2float(llres)

diff --git a/pypy/rlib/test/test_libffi.py b/pypy/rlib/test/test_libffi.py
--- a/pypy/rlib/test/test_libffi.py
+++ b/pypy/rlib/test/test_libffi.py
@@ -427,7 +427,7 @@
         make_point = (libfoo, 'make_point', [types.slong, types.slong], ffi_point)
         #
         PTR = lltype.Ptr(rffi.CArray(rffi.LONG))
-        p = self.call(make_point, [12, 34], PTR, init_result=0)
+        p = self.call(make_point, [12, 34], PTR, init_result=lltype.nullptr(PTR.TO))
         assert p[0] == 12
         assert p[1] == 34
         lltype.free(p, flavor='raw')


More information about the Pypy-commit mailing list