[pypy-commit] pypy ffi-backend: Add an assert that prevents "ffi_cif" from being written in the C code

arigo noreply at buildbot.pypy.org
Tue Aug 7 15:56:54 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r56635:16860593dc11
Date: 2012-08-07 15:46 +0200
http://bitbucket.org/pypy/pypy/changeset/16860593dc11/

Log:	Add an assert that prevents "ffi_cif" from being written in the C
	code if OS_LIBFFI_CALL is never used. Fixes x86/test/test_zrpy_gc.

diff --git a/pypy/jit/codewriter/call.py b/pypy/jit/codewriter/call.py
--- a/pypy/jit/codewriter/call.py
+++ b/pypy/jit/codewriter/call.py
@@ -16,6 +16,7 @@
 
 class CallControl(object):
     virtualref_info = None     # optionally set from outside
+    has_libffi_call = False    # default value
 
     def __init__(self, cpu=None, jitdrivers_sd=[]):
         assert isinstance(jitdrivers_sd, list)   # debugging
diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -1731,6 +1731,7 @@
         if oopspec_name == 'libffi_call':
             oopspecindex = EffectInfo.OS_LIBFFI_CALL
             extraeffect = EffectInfo.EF_RANDOM_EFFECTS
+            self.callcontrol.has_libffi_call = True
         else:
             assert False, 'unsupported oopspec: %s' % oopspec_name
         return self._handle_oopspec_call(op, args, oopspecindex, extraeffect)
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1486,6 +1486,7 @@
         self.jitdrivers_sd = codewriter.callcontrol.jitdrivers_sd
         self.virtualref_info = codewriter.callcontrol.virtualref_info
         self.callinfocollection = codewriter.callcontrol.callinfocollection
+        self.has_libffi_call = codewriter.callcontrol.has_libffi_call
         #
         # store this information for fastpath of call_assembler
         # (only the paths that can actually be taken)
@@ -2539,6 +2540,10 @@
         """Generate a direct call to C code, patching the CALL_MAY_FORCE
         to jit_ffi_call() that occurred just now.
         """
+        # an 'assert' that constant-folds away the rest of this function
+        # if the codewriter didn't produce any OS_LIBFFI_CALL at all.
+        assert self.staticdata.has_libffi_call
+        #
         from pypy.rpython.lltypesystem import llmemory
         from pypy.rlib.jit_libffi import CIF_DESCRIPTION_P
         from pypy.jit.backend.llsupport.ffisupport import get_arg_descr


More information about the pypy-commit mailing list