Developing a Python JIT and have trouble

Deborah Swanson python at deborahswanson.net
Fri Mar 31 21:34:02 EDT 2017


Yuheng Zou wrote, on Friday, March 31, 2017 6:52 AM
> 
> I am building a Python JIT, so I want to change the 
> interp->eval_frame to my own function.
> 
> I built a C++ library which contains EvalFrame function, and 
> then use dlopen and dlsym to use it. It looks like this:
> 
> extern "C" PyObject *EvalFrame(PyFrameObject *f, int throwflag) {
>     return _PyEval_EvalFrameDefault(f, throwflag);
> }
> I added following code to Python/pylifecycle.c at function 
> _Py_InitializeEx_Private(Python version is 3.6.1):
> 
> void *pyjit = NULL;
> pyjit = dlopen("../cmake-build-debug/libPubbon.dylib", 0);
> if (pyjit != NULL) {
>     interp->eval_frame = (_PyFrameEvalFunction)dlsym(pyjit, 
> "EvalFrame");
>     //interp->eval_frame = _PyEval_EvalFrameDefault;
> } 
> Then something strange happened. I used LLDB to trace the 
> variables. When it ran at EvalFrame, the address of f pointer 
> didn't change, but f->f_lineno changed.
> 
> Then when I ran python.exe, I got Segmentation Fault.
> 
> Why the address of the pointer didn't change, but the context change?
> 
> I am working on Mac OS X and Python 3.6.1. I want to know how 
> to replace _PyEval_EvalFrameDefault in interp->eval_frame 
> with my own function.

Hi Yuheng,

There might be some C coders on this list, maybe even a few who are
proficient in both C & Python. But this list is predominantly made up of
Python coders, and you may not get a reply. Personally, I don't know C
well enough nor am I familiar with the EvalFrame you mention to respond
to your question.

Shiboya




More information about the Python-list mailing list