@@ -761,12 +761,20 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
761761 * so consume 3 units of C stack */
762762#define PY_EVAL_C_STACK_UNITS 2
763763
764- #if defined( _MSC_VER ) && defined( _Py_USING_PGO ) && defined( _Py_JIT )
765- /* _PyEval_EvalFrameDefault is too large to optimize for speed with
766- PGO on MSVC when the JIT is enabled. Disable that optimization
767- around this function only. If this is fixed upstream, we should
768- gate this on the version of MSVC.
764+
765+ /* _PyEval_EvalFrameDefault is too large to optimize for speed with PGO on MSVC
766+ when the JIT is enabled or GIL is disabled . Disable that optimization around
767+ this function only. If this is fixed upstream, we should gate this on the
768+ version of MSVC.
769769 */
770+ #if (defined(_MSC_VER ) && \
771+ defined(_Py_USING_PGO ) && \
772+ (defined(_Py_JIT ) || \
773+ defined(Py_GIL_DISABLED )))
774+ #define DO_NOT_OPTIMIZE_INTERP_LOOP
775+ #endif
776+
777+ #ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
770778# pragma optimize("t", off)
771779/* This setting is reversed below following _PyEval_EvalFrameDefault */
772780#endif
@@ -1146,7 +1154,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
11461154
11471155}
11481156
1149- #if defined( _MSC_VER ) && defined( _Py_USING_PGO ) && defined( _Py_JIT )
1157+ #ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
11501158# pragma optimize("", on)
11511159#endif
11521160
0 commit comments