@@ -139,6 +139,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
139139 PyInterpreterState * interp = _PyInterpreterState_GET ();
140140 PyObject * builtins = frame -> f_builtins ;
141141 if (builtins != interp -> builtins ) {
142+ OPT_STAT_INC (remove_globals_builtins_changed );
142143 return 1 ;
143144 }
144145 PyObject * globals = frame -> f_globals ;
@@ -170,6 +171,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
170171 switch (opcode ) {
171172 case _GUARD_BUILTINS_VERSION :
172173 if (incorrect_keys (inst , builtins )) {
174+ OPT_STAT_INC (remove_globals_incorrect_keys );
173175 return 0 ;
174176 }
175177 if (interp -> rare_events .builtin_dict >= _Py_MAX_ALLOWED_BUILTINS_MODIFICATIONS ) {
@@ -190,6 +192,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
190192 break ;
191193 case _GUARD_GLOBALS_VERSION :
192194 if (incorrect_keys (inst , globals )) {
195+ OPT_STAT_INC (remove_globals_incorrect_keys );
193196 return 0 ;
194197 }
195198 uint64_t watched_mutations = get_mutations (globals );
@@ -238,6 +241,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
238241 globals = func -> func_globals ;
239242 builtins = func -> func_builtins ;
240243 if (builtins != interp -> builtins ) {
244+ OPT_STAT_INC (remove_globals_builtins_changed );
241245 return 1 ;
242246 }
243247 break ;
@@ -358,6 +362,7 @@ optimize_uops(
358362
359363 _Py_UOpsContext context ;
360364 _Py_UOpsContext * ctx = & context ;
365+ uint32_t opcode = UINT16_MAX ;
361366
362367 if (_Py_uop_abstractcontext_init (ctx ) < 0 ) {
363368 goto out_of_space ;
@@ -374,8 +379,7 @@ optimize_uops(
374379 this_instr ++ ) {
375380
376381 int oparg = this_instr -> oparg ;
377- uint32_t opcode = this_instr -> opcode ;
378-
382+ opcode = this_instr -> opcode ;
379383 _Py_UopsSymbol * * stack_pointer = ctx -> frame -> stack_pointer ;
380384
381385#ifdef Py_DEBUG
@@ -410,6 +414,9 @@ optimize_uops(
410414error :
411415 DPRINTF (3 , "\n" );
412416 DPRINTF (1 , "Encountered error in abstract interpreter\n" );
417+ if (opcode <= MAX_UOP_ID ) {
418+ OPT_ERROR_IN_OPCODE (opcode );
419+ }
413420 _Py_uop_abstractcontext_fini (ctx );
414421 return -1 ;
415422
0 commit comments