def create_cpython_wrapper(self, library, fndesc, env, call_helper, release_gil=False): wrapper_module = self.create_module("wrapper") fnty = self.call_conv.get_function_type(fndesc.restype, fndesc.argtypes) wrapper_callee = wrapper_module.add_function(fnty, fndesc.llvm_func_name) builder = PyCallWrapper(self, wrapper_module, wrapper_callee, fndesc, env, call_helper=call_helper, release_gil=release_gil) builder.build() library.add_ir_module(wrapper_module)
def create_cpython_wrapper(self, library, fndesc, exceptions, release_gil=False): wrapper_module = self.create_module("wrapper") fnty = self.get_function_type(fndesc) wrapper_callee = wrapper_module.add_function(fnty, fndesc.llvm_func_name) builder = PyCallWrapper(self, wrapper_module, wrapper_callee, fndesc, exceptions=exceptions, release_gil=release_gil) builder.build() library.add_ir_module(wrapper_module)
def prepare_for_call(self, func, fndesc): wrapper, api = PyCallWrapper(self, func.module, func, fndesc).build() self.optimize(func.module) if config.DUMP_OPTIMIZED: print( ("OPTIMIZED DUMP %s" % fndesc.qualified_name).center(80, '-')) print(func.module) print('=' * 80) if config.DUMP_ASSEMBLY: print(("ASSEMBLY %s" % fndesc.qualified_name).center(80, '-')) print(self.tm.emit_assembly(func.module)) print('=' * 80) # Map module.__dict__ le.dylib_add_symbol(".pymodule.dict." + fndesc.pymod.__name__, id(fndesc.pymod.__dict__)) # Code gen self.engine.add_module(func.module) baseptr = self.engine.get_pointer_to_function(func) fnptr = self.engine.get_pointer_to_function(wrapper) cfunc = _dynfunc.make_function(fndesc.pymod, fndesc.name, fndesc.doc, fnptr) if fndesc.native: self.native_funcs[cfunc] = fndesc.mangled_name, baseptr return cfunc, fnptr
def prepare_for_call(self, func, fndesc, env): wrapper, api = PyCallWrapper(self, func.module, func, fndesc, exceptions=self.exceptions).build() self.optimize(func.module) if config.DUMP_OPTIMIZED: print(("OPTIMIZED DUMP %s" % fndesc).center(80, '-')) print(func.module) print('=' * 80) if config.DUMP_ASSEMBLY: print(("ASSEMBLY %s" % fndesc).center(80, '-')) print(self.tm.emit_assembly(func.module)) print('=' * 80) # Code gen self.engine.add_module(func.module) baseptr = self.engine.get_pointer_to_function(func) fnptr = self.engine.get_pointer_to_function(wrapper) cfunc = _dynfunc.make_function(fndesc.lookup_module(), fndesc.qualname.split('.')[-1], fndesc.doc, fnptr, env) if fndesc.native: self.native_funcs[cfunc] = fndesc.mangled_name, baseptr return cfunc