static inline PyObject*
_PyEval_EvalFrame(PyThreadState *tstate, struct _interpreter_frame *frame, int throwflag)
{
+ if (tstate->interp->eval_frame == NULL) {
+ return _PyEval_EvalFrameDefault(tstate, frame, throwflag);
+ }
return tstate->interp->eval_frame(tstate, frame, throwflag);
}
// Check if the call can be inlined or not
PyObject *function = PEEK(oparg + 1);
- if (Py_TYPE(function) == &PyFunction_Type) {
+ if (Py_TYPE(function) == &PyFunction_Type && tstate->interp->eval_frame == NULL) {
int code_flags = ((PyCodeObject*)PyFunction_GET_CODE(function))->co_flags;
PyObject *locals = code_flags & CO_OPTIMIZED ? NULL : PyFunction_GET_GLOBALS(function);
int is_generator = code_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR);
}
STACK_SHRINK(oparg + 1);
- assert(tstate->interp->eval_frame != NULL);
// The frame has stolen all the arguments from the stack,
// so there is no need to clean them up.
Py_DECREF(function);
if (steal_args) {
// If we failed to initialize locals, make sure the caller still own all the
// arguments. Notice that we only need to increase the reference count of the
- // *valid* arguments (i.e. the ones that fit into the frame).
+ // *valid* arguments (i.e. the ones that fit into the frame).
PyCodeObject *co = (PyCodeObject*)con->fc_code;
const size_t total_args = co->co_argcount + co->co_kwonlyargcount;
for (size_t i = 0; i < Py_MIN(argcount, total_args); i++) {
if (frame == NULL) {
return NULL;
}
- assert (tstate->interp->eval_frame != NULL);
PyObject *retval = _PyEval_EvalFrame(tstate, frame, 0);
assert(_PyFrame_GetStackPointer(frame) == _PyFrame_Stackbase(frame));
if (_PyEvalFrameClearAndPop(tstate, frame)) {
PyConfig_InitPythonConfig(&interp->config);
_PyType_InitCache(interp);
- interp->eval_frame = _PyEval_EvalFrameDefault;
+ interp->eval_frame = NULL;
#ifdef HAVE_DLOPEN
#if HAVE_DECL_RTLD_NOW
interp->dlopenflags = RTLD_NOW;
_PyFrameEvalFunction
_PyInterpreterState_GetEvalFrameFunc(PyInterpreterState *interp)
{
+ if (interp->eval_frame == NULL) {
+ return _PyEval_EvalFrameDefault;
+ }
return interp->eval_frame;
}
_PyInterpreterState_SetEvalFrameFunc(PyInterpreterState *interp,
_PyFrameEvalFunction eval_frame)
{
- interp->eval_frame = eval_frame;
+ if (eval_frame == _PyEval_EvalFrameDefault) {
+ interp->eval_frame = NULL;
+ }
+ else {
+ interp->eval_frame = eval_frame;
+ }
}