Author: Manuel Jacob
Branch: kill-running_on_llinterp
Changeset: r68971:c7a94af00283
Date: 2014-01-28 01:45 +0100
http://bitbucket.org/pypy/pypy/changeset/c7a94af00283/

Log:    Readd some of the wrapper logic because we might get a lltype
        funcptr as lltypeimpl. In any of these cases we also get
        lltypefakeimpl, that's why it worked before this branch (a wrapper
        was generated if both lltypeimpl and lltypefakeimpl were given).

diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -5,6 +5,7 @@
 from rpython.annotator.signature import annotation
 
 import py, sys
+from types import FunctionType
 
 class extdef(object):
 
@@ -162,6 +163,20 @@
         impl = getattr(self, method_name, None)
         fakeimpl = getattr(self, fake_method_name, self.instance)
         if impl:
+            if not isinstance(impl, FunctionType):
+                # We can't add the _fakeimpl attribute on lltype function ptrs,
+                # so instead we create a wrapper with that attribute.
+                from rpython.tool.sourcetools import func_with_new_name
+                # Using '*args' is delicate because this wrapper is also
+                # created for init-time functions like llarena.arena_malloc
+                # which are called before the GC is fully initialized
+                args = ', '.join(['arg%d' % i for i in range(len(args_ll))])
+                d = {'original_impl': impl, '__name__': __name__}
+                exec py.code.compile("""
+                    def ll_wrapper(%s):
+                        return original_impl(%s)
+                """ % (args, args)) in d
+                impl = func_with_new_name(d['ll_wrapper'], name + '_wrapper')
             if rtyper.annotator.translator.config.translation.sandbox:
                 impl._dont_inline_ = True
             # store some attributes to the 'impl' function, where
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to