Author: Antonio Cuni <[email protected]>
Branch: refactor-call_release_gil
Changeset: r63169:841ab5d999ac
Date: 2013-04-09 16:49 +0100
http://bitbucket.org/pypy/pypy/changeset/841ab5d999ac/

Log:    dont' crash if the result kind is not supported: instead, we just
        disable the optimization

diff --git a/rpython/jit/metainterp/test/test_fficall.py 
b/rpython/jit/metainterp/test/test_fficall.py
--- a/rpython/jit/metainterp/test/test_fficall.py
+++ b/rpython/jit/metainterp/test/test_fficall.py
@@ -45,7 +45,7 @@
 
 class FfiCallTests(object):
 
-    def _run(self, atypes, rtype, avalues, rvalue):
+    def _run(self, atypes, rtype, avalues, rvalue, 
expected_call_release_gil=1):
         cif_description = get_description(atypes, rtype)
 
         def verify(*args):
@@ -108,7 +108,7 @@
                 res = float2longlong(res)
             assert res == rvalue or (res, rvalue) == (654321, None)
             self.check_operations_history(call_may_force=0,
-                                          call_release_gil=1)
+                                          
call_release_gil=expected_call_release_gil)
 
     def test_simple_call_int(self):
         self._run([types.signed] * 2, types.signed, [456, 789], -42)
@@ -128,6 +128,11 @@
         b = r_longlong(maxint32) + 2
         self._run([types.slonglong] * 2, types.slonglong, [a, b], a)
 
+    def test_simple_call_longdouble(self):
+        # longdouble is not supported, so we expect NOT to generate a 
call_release_gil
+        self._run([types.longdouble] * 2, types.longdouble, [12.3, 45.6], 78.9,
+                  expected_call_release_gil=0)
+
     def test_returns_none(self):
         self._run([types.signed] * 2, types.void, [456, 789], None)
 
diff --git a/rpython/rlib/jit_libffi.py b/rpython/rlib/jit_libffi.py
--- a/rpython/rlib/jit_libffi.py
+++ b/rpython/rlib/jit_libffi.py
@@ -114,7 +114,13 @@
         result = jit_ffi_call_impl_int(cif_description, func_addr, 
exchange_buffer)
         jit_ffi_save_result('int', cif_description, exchange_buffer, result)
     else:
-        assert False, 'Unsupported result kind'
+        # the result kind is not supported: we disable the jit_ffi_call
+        # optimization by calling directly jit_ffi_call_impl_any, so the JIT
+        # does not see any libffi_call oopspec.
+        #
+        # Since call_release_gil is not generated, there is no need to
+        # jit_ffi_save_result
+        jit_ffi_call_impl_any(cif_description, func_addr, exchange_buffer)
 
 
 # we must return a NonConstant else we get the constant -1 as the result of
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to