diff --git a/src/pyjit/pyjit.cpp b/src/pyjit/pyjit.cpp index 1b53fdfb..1a3903c4 100644 --- a/src/pyjit/pyjit.cpp +++ b/src/pyjit/pyjit.cpp @@ -112,9 +112,9 @@ namespace xo { m.doc() = "pybind11 plugin for xo-jit"; pycaller_store::instance() - ->require_prototype(m, "double(double)"); + ->require_prototype(m, "double (*)(double)"); pycaller_store::instance() - ->require_prototype(m, "double(double,double)"); + ->require_prototype(m, "double (*)(double,double)"); //pycaller::declare_once(m); //pycaller::declare_once(m); @@ -179,28 +179,33 @@ namespace xo { * so any function type will appear to succeed here. * We cast to particular function type within the pycaller<..> template */ - auto fn_addr = llvm_addr.toPtr(); + if (llvm_addr) { + auto fn_addr = llvm_addr.get().toPtr(); - /* note: llvm_addr.toPtr<..> always succeeds, - * event if pointer refers to an object of incompatible type - * - * note: return value policy is for python to own the wrapper - * - * note: pycaller signatures need to have been introduced in advance - * (in practice determined at compile time, - * since they encode a function-signature-specific calling sequence) - * by calling pycaller_store::instance()->require_prototype(prototype); - */ + /* note: llvm_addr.toPtr<..> always succeeds, + * event if pointer refers to an object of incompatible type + * + * note: return value policy is for python to own the wrapper + * + * note: pycaller signatures need to have been introduced in advance + * (in practice determined at compile time, + * since they encode a function-signature-specific calling sequence) + * by calling pycaller_store::instance()->require_prototype(prototype); + */ - auto factory = pycaller_store::instance()->lookup_prototype(prototype); + auto factory = pycaller_store::instance()->lookup_prototype(prototype); - if (!factory) { - throw std::runtime_error(tostr("MachPipeline.lookup_fn: unknown function prototype", - xtag("p", prototype))); + if (!factory) { + throw std::runtime_error(tostr("MachPipeline.lookup_fn: unknown function prototype", + xtag("p", prototype))); + } + + return (*factory)(fn_addr); + } else { + throw std::runtime_error(tostr("MachPipeline.lookup_fn: lookup on symbol S failed", + xtag("S", symbol))); } - return (*factory)(fn_addr); - #ifdef OBSOLETE if((prototype == "double(double,double)") || (prototype == "double(*)(double,double)")) { return new pycaller(fn_addr);