@@ -21,6 +21,7 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame;
2121#define sym_new_const _Py_uop_sym_new_const
2222#define sym_new_null _Py_uop_sym_new_null
2323#define sym_matches_type _Py_uop_sym_matches_type
24+ #define sym_has_type _Py_uop_sym_has_type
2425#define sym_set_null _Py_uop_sym_set_null
2526#define sym_set_non_null _Py_uop_sym_set_non_null
2627#define sym_set_type _Py_uop_sym_set_type
@@ -36,6 +37,8 @@ optimize_to_bool(
3637 _Py_UopsSymbol * value ,
3738 _Py_UopsSymbol * * result_ptr );
3839
40+ extern void
41+ eliminate_pop_guard (_PyUOpInstruction * this_instr , bool exit )
3942
4043static int
4144dummy_func (void ) {
@@ -557,7 +560,45 @@ dummy_func(void) {
557560 (void )iter ;
558561 }
559562
563+ op (_GUARD_IS_TRUE_POP , (flag -- )) {
564+ if (sym_is_const (flag )) {
565+ PyObject * value = sym_get_const (flag );
566+ assert (value != NULL );
567+ eliminate_pop_guard (this_instr , value != Py_True );
568+ }
569+ }
570+
571+ op (_GUARD_IS_FALSE_POP , (flag -- )) {
572+ if (sym_is_const (flag )) {
573+ PyObject * value = sym_get_const (flag );
574+ assert (value != NULL );
575+ eliminate_pop_guard (this_instr , value != Py_False );
576+ }
577+ }
578+
579+ op (_GUARD_IS_NONE_POP , (flag -- )) {
580+ if (sym_is_const (flag )) {
581+ PyObject * value = sym_get_const (flag );
582+ assert (value != NULL );
583+ eliminate_pop_guard (this_instr , !Py_IsNone (value ));
584+ }
585+ else if (sym_has_type (flag )) {
586+ assert (!sym_matches_type (flag , & _PyNone_Type ));
587+ eliminate_pop_guard (this_instr , true);
588+ }
589+ }
560590
591+ op (_GUARD_IS_NOT_NONE_POP , (flag -- )) {
592+ if (sym_is_const (flag )) {
593+ PyObject * value = sym_get_const (flag );
594+ assert (value != NULL );
595+ eliminate_pop_guard (this_instr , Py_IsNone (value ));
596+ }
597+ else if (sym_has_type (flag )) {
598+ assert (!sym_matches_type (flag , & _PyNone_Type ));
599+ eliminate_pop_guard (this_instr , false);
600+ }
601+ }
561602
562603
563604// END BYTECODES //
0 commit comments