@@ -1222,6 +1222,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
1222
1222
return NULL ;
1223
1223
}
1224
1224
1225
+ /* a global write only dummy variable */
1226
+ char _dont_optimise_away_slp_eval_frame_functions ;
1227
+
1225
1228
PyObject *
1226
1229
slp_eval_frame_noval (PyFrameObject * f , int throwflag , PyObject * retval )
1227
1230
{
@@ -1231,9 +1234,8 @@ slp_eval_frame_noval(PyFrameObject *f, int throwflag, PyObject *retval)
1231
1234
* it serves as a marker whether we expect a value or
1232
1235
* not, and it makes debugging a little easier.
1233
1236
*/
1234
- Py_XINCREF ( f ); /* fool the link optimizer */
1237
+ _dont_optimise_away_slp_eval_frame_functions = 1 ;
1235
1238
r = slp_eval_frame_value (f , throwflag , retval );
1236
- Py_XDECREF (f );
1237
1239
return r ;
1238
1240
}
1239
1241
@@ -1247,9 +1249,8 @@ slp_eval_frame_iter(PyFrameObject *f, int throwflag, PyObject *retval)
1247
1249
* for_iter operation. In this case we need to handle
1248
1250
* null without error as valid result.
1249
1251
*/
1250
- Py_XINCREF ( retval ); /* fool the link optimizer */
1252
+ _dont_optimise_away_slp_eval_frame_functions = 2 ;
1251
1253
r = slp_eval_frame_value (f , throwflag , retval );
1252
- Py_XDECREF (retval );
1253
1254
return r ;
1254
1255
}
1255
1256
@@ -1263,11 +1264,8 @@ slp_eval_frame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
1263
1264
* SETUP_WITH operation.
1264
1265
* NOTE / XXX: see above.
1265
1266
*/
1266
- Py_XINCREF (f ); /* fool the link optimizer */
1267
- Py_XINCREF (retval ); /* fool the link optimizer */
1267
+ _dont_optimise_away_slp_eval_frame_functions = 3 ;
1268
1268
r = slp_eval_frame_value (f , throwflag , retval );
1269
- Py_XDECREF (retval );
1270
- Py_XDECREF (f );
1271
1269
return r ;
1272
1270
}
1273
1271
@@ -1281,11 +1279,8 @@ slp_eval_frame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
1281
1279
* WITH_CLEANUP operation.
1282
1280
* NOTE / XXX: see above.
1283
1281
*/
1284
- Py_XINCREF (f ); /* fool the link optimizer */
1285
- Py_XINCREF (f ); /* fool the link optimizer */
1282
+ _dont_optimise_away_slp_eval_frame_functions = 4 ;
1286
1283
r = slp_eval_frame_value (f , throwflag , retval );
1287
- Py_XDECREF (f );
1288
- Py_XDECREF (f );
1289
1284
return r ;
1290
1285
}
1291
1286
0 commit comments