Author: Armin Rigo <[email protected]>
Branch:
Changeset: r78247:7000d2a499d2
Date: 2015-06-23 08:39 +0200
http://bitbucket.org/pypy/pypy/changeset/7000d2a499d2/
Log: Issue #2069: comments and one essential fix. On one of the call
paths, a promote() was missing
diff --git a/pypy/module/_cffi_backend/ctypefunc.py
b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -143,7 +143,7 @@
@jit.unroll_safe
def _call(self, funcaddr, args_w):
space = self.space
- cif_descr = self.cif_descr
+ cif_descr = self.cif_descr # 'self' should have been promoted here
size = cif_descr.exchange_size
mustfree_max_plus_1 = 0
buffer = lltype.malloc(rffi.CCHARP.TO, size, flavor='raw')
diff --git a/pypy/module/_cffi_backend/wrapper.py
b/pypy/module/_cffi_backend/wrapper.py
--- a/pypy/module/_cffi_backend/wrapper.py
+++ b/pypy/module/_cffi_backend/wrapper.py
@@ -19,6 +19,8 @@
wrapper is callable, and the arguments it expects and returns
are directly the struct/union. Calling ffi.typeof(wrapper)
also returns the original struct/union signature.
+
+ This class cannot be used for variadic functions.
"""
_immutable_ = True
common_doc_str = 'direct call to the C function of the same name'
@@ -72,6 +74,7 @@
args_w[i] = w_arg
def descr_call(self, args_w):
+ self = jit.promote(self)
if len(args_w) != self.nargs_expected:
space = self.space
if self.nargs_expected == 0:
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
@@ -109,6 +109,11 @@
def jit_ffi_call(cif_description, func_addr, exchange_buffer):
"""Wrapper around ffi_call(). Must receive a CIF_DESCRIPTION_P that
describes the layout of the 'exchange_buffer'.
+
+ Note that this cannot be optimized if 'cif_description' is not
+ a constant for the JIT, so if it is ever possible, consider promoting
+ it. The promotion of 'cif_description' must be done earlier, before
+ the raw malloc of 'exchange_buffer'.
"""
reskind = types.getkind(cif_description.rtype)
if reskind == 'v':
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit