@@ -761,12 +761,20 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
761
761
* so consume 3 units of C stack */
762
762
#define PY_EVAL_C_STACK_UNITS 2
763
763
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.
769
769
*/
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
770
778
# pragma optimize("t", off)
771
779
/* This setting is reversed below following _PyEval_EvalFrameDefault */
772
780
#endif
@@ -1146,7 +1154,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
1146
1154
1147
1155
}
1148
1156
1149
- #if defined( _MSC_VER ) && defined( _Py_USING_PGO ) && defined( _Py_JIT )
1157
+ #ifdef DO_NOT_OPTIMIZE_INTERP_LOOP
1150
1158
# pragma optimize("", on)
1151
1159
#endif
1152
1160
0 commit comments