[pypy-commit] pypy llimpl: Don't hack the funcptr in register_external()

rlamy pypy.commits at gmail.com
Sun Feb 7 15:43:35 EST 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: llimpl
Changeset: r82110:5c4c76a4b9c4
Date: 2016-02-07 20:42 +0000
http://bitbucket.org/pypy/pypy/changeset/5c4c76a4b9c4/

Log:	Don't hack the funcptr in register_external()

diff --git a/rpython/rtyper/extfunc.py b/rpython/rtyper/extfunc.py
--- a/rpython/rtyper/extfunc.py
+++ b/rpython/rtyper/extfunc.py
@@ -48,21 +48,19 @@
         if impl:
             impl = make_impl(rtyper, impl, self.safe_not_sandboxed, self.name,
                              signature_args, s_result)
-            if isinstance(impl, _ptr):
+            if hasattr(self, 'lltypefakeimpl') and rtyper.backend is llinterp_backend:
+                FT = FuncType(args_ll, ll_result)
+                obj = functionptr(FT, name, _external_name=self.name,
+                                _callable=fakeimpl)
+            elif isinstance(impl, _ptr):
                 obj = impl
             else:
-                if hasattr(self, 'lltypefakeimpl') and rtyper.backend is llinterp_backend:
-                    FT = FuncType(args_ll, ll_result)
-                    obj = functionptr(FT, name, _external_name=self.name,
-                                    _callable=fakeimpl,
-                                    _safe_not_sandboxed=self.safe_not_sandboxed)
-                else:
-                    # store some attributes to the 'impl' function, where
-                    # the eventual call to rtyper.getcallable() will find them
-                    # and transfer them to the final lltype.functionptr().
-                    impl._llfnobjattrs_ = {'_name': self.name}
-                    obj = rtyper.getannmixlevel().delayedfunction(
-                        impl, signature_args, hop.s_result)
+                # store some attributes to the 'impl' function, where
+                # the eventual call to rtyper.getcallable() will find them
+                # and transfer them to the final lltype.functionptr().
+                impl._llfnobjattrs_ = {'_name': self.name}
+                obj = rtyper.getannmixlevel().delayedfunction(
+                    impl, signature_args, hop.s_result)
         else:
             FT = FuncType(args_ll, ll_result)
             obj = functionptr(FT, name, _external_name=self.name,
@@ -94,10 +92,6 @@
     if export_name is None:
         export_name = function.__name__
 
-    if isinstance(llimpl, _ptr) and llfakeimpl:
-        llimpl._obj.__dict__['_fakeimpl'] = llfakeimpl
-        llfakeimpl = None
-
     class FunEntry(ExtFuncEntry):
         _about_ = function
         safe_not_sandboxed = sandboxsafe


More information about the pypy-commit mailing list