gh-146031: Allow keeping specialization enabled when specifying eval frame function (#146032)

Allow keeping specialization enabled when specifying eval frame function
This commit is contained in:
Dino Viehland 2026-04-16 09:44:26 -07:00 committed by GitHub
parent cecf564073
commit c0af5c024b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 196 additions and 20 deletions

View file

@ -3026,9 +3026,32 @@ _PyInterpreterState_SetEvalFrameFunc(PyInterpreterState *interp,
RARE_EVENT_INC(set_eval_frame_func);
_PyEval_StopTheWorld(interp);
interp->eval_frame = eval_frame;
// reset when evaluator is reset
interp->eval_frame_allow_specialization = 0;
_PyEval_StartTheWorld(interp);
}
void
_PyInterpreterState_SetEvalFrameAllowSpecialization(PyInterpreterState *interp,
int allow_specialization)
{
if (allow_specialization == interp->eval_frame_allow_specialization) {
return;
}
_Py_Executors_InvalidateAll(interp, 1);
RARE_EVENT_INC(set_eval_frame_func);
_PyEval_StopTheWorld(interp);
interp->eval_frame_allow_specialization = allow_specialization;
_PyEval_StartTheWorld(interp);
}
int
_PyInterpreterState_IsSpecializationEnabled(PyInterpreterState *interp)
{
return interp->eval_frame == NULL
|| interp->eval_frame_allow_specialization;
}
const PyConfig*
_PyInterpreterState_GetConfig(PyInterpreterState *interp)