Author: Armin Rigo <[email protected]>
Branch: hpy
Changeset: r98084:f3ead38c0c67
Date: 2019-11-17 00:29 +0100
http://bitbucket.org/pypy/pypy/changeset/f3ead38c0c67/

Log:    Translation fixes. Try following these specialize.memo() if you can!

diff --git a/pypy/module/hpy_universal/interp_hpy.py 
b/pypy/module/hpy_universal/interp_hpy.py
--- a/pypy/module/hpy_universal/interp_hpy.py
+++ b/pypy/module/hpy_universal/interp_hpy.py
@@ -1,6 +1,7 @@
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rdynload import dlopen, dlsym, DLOpenError
+from rpython.rlib.objectmodel import specialize
 
 from pypy.interpreter.gateway import unwrap_spec
 from pypy.interpreter.error import raise_import_error
@@ -16,10 +17,13 @@
     # and handle exceptions properly
     def decorate(fn):
         ll_functype = lltype.Ptr(lltype.FuncType(argtypes, restype))
-        def get_llhelper(space):
+        @specialize.memo()
+        def make_wrapper(space):
             def wrapper(*args):
                 return fn(space, *args)
-            return llhelper(ll_functype, wrapper)
+            return wrapper
+        def get_llhelper(space):
+            return llhelper(ll_functype, make_wrapper(space))
         fn.get_llhelper = get_llhelper
         return fn
     return decorate
diff --git a/pypy/module/hpy_universal/state.py 
b/pypy/module/hpy_universal/state.py
--- a/pypy/module/hpy_universal/state.py
+++ b/pypy/module/hpy_universal/state.py
@@ -1,14 +1,27 @@
 import os
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.annlowlevel import llhelper
+from rpython.rlib.unroll import unrolling_iterable
+from rpython.rlib.objectmodel import specialize
 from pypy.module.hpy_universal import llapi
 
+CONTEXT_NAMES = unrolling_iterable(llapi.HPyContext.TO._names)
+DUMMY_FUNC = lltype.FuncType([], lltype.Void)
+
[email protected]()
+def make_missing_function(name):
+    def missing_function():
+        print ("oops! calling the slot '%s', "
+               "which is not implemented" % (name,))
+        os._exit(1)
+    return missing_function
+
 
 class State:
     def __init__(self, space):
         "NOT_RPYTHON"
         self.space = space
-        self.ctx = lltype.nullptr(rffi.VOIDP.TO)
+        self.ctx = lltype.nullptr(llapi.HPyContext.TO)
 
     def setup(self):
         if self.ctx:
@@ -16,13 +29,9 @@
 
         self.ctx = llapi._HPy_GetGlobalCtx()
 
-        DUMMY_FUNC = lltype.FuncType([], lltype.Void)
-        for name in llapi.HPyContext.TO._names:
+        for name in CONTEXT_NAMES:
             if name != 'ctx_version':
-                def missing_function(name=name):
-                    print ("oops! calling the slot %r, which is not 
implemented"
-                           % (name,))
-                    os._exit(1)
+                missing_function = make_missing_function(name)
                 funcptr = llhelper(lltype.Ptr(DUMMY_FUNC), missing_function)
                 setattr(self.ctx, name, rffi.cast(rffi.VOIDP, funcptr))
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to