@@ -43,12 +43,13 @@ extern int
4343optimize_to_bool (
4444 _PyUOpInstruction * this_instr ,
4545 JitOptContext * ctx ,
46+ int * out_len ,
4647 JitOptSymbol * value ,
4748 JitOptSymbol * * result_ptr ,
4849 bool insert_mode );
4950
5051extern void
51- eliminate_pop_guard (_PyUOpInstruction * this_instr , JitOptContext * ctx , bool exit );
52+ eliminate_pop_guard (_PyUOpInstruction * this_instr , JitOptContext * ctx , int * out_len , bool exit );
5253
5354extern PyCodeObject * get_code (_PyUOpInstruction * op );
5455
@@ -57,6 +58,7 @@ dummy_func(void) {
5758
5859 PyCodeObject * co ;
5960 int oparg ;
61+ int out_len ;
6062 JitOptSymbol * flag ;
6163 JitOptSymbol * left ;
6264 JitOptSymbol * right ;
@@ -381,36 +383,36 @@ dummy_func(void) {
381383 }
382384
383385 op (_TO_BOOL , (value -- res )) {
384- int already_bool = optimize_to_bool (this_instr , ctx , value , & res , false);
386+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & res , false);
385387 if (!already_bool ) {
386388 res = sym_new_truthiness (ctx , value , true);
387389 }
388390 }
389391
390392 op (_TO_BOOL_BOOL , (value -- value )) {
391- int already_bool = optimize_to_bool (this_instr , ctx , value , & value , false);
393+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & value , false);
392394 if (!already_bool ) {
393395 sym_set_type (value , & PyBool_Type );
394396 }
395397 }
396398
397399 op (_TO_BOOL_INT , (value -- res )) {
398- int already_bool = optimize_to_bool (this_instr , ctx , value , & res , false);
400+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & res , false);
399401 if (!already_bool ) {
400402 sym_set_type (value , & PyLong_Type );
401403 res = sym_new_truthiness (ctx , value , true);
402404 }
403405 }
404406
405407 op (_TO_BOOL_LIST , (value -- res )) {
406- int already_bool = optimize_to_bool (this_instr , ctx , value , & res , false);
408+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & res , false);
407409 if (!already_bool ) {
408410 res = sym_new_type (ctx , & PyBool_Type );
409411 }
410412 }
411413
412414 op (_TO_BOOL_NONE , (value -- res )) {
413- int already_bool = optimize_to_bool (this_instr , ctx , value , & res , false);
415+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & res , false);
414416 if (!already_bool ) {
415417 sym_set_const (value , Py_None );
416418 res = sym_new_const (ctx , Py_False );
@@ -436,7 +438,7 @@ dummy_func(void) {
436438 }
437439
438440 op (_TO_BOOL_STR , (value -- res , v )) {
439- int already_bool = optimize_to_bool (this_instr , ctx , value , & res , true);
441+ int already_bool = optimize_to_bool (this_instr , ctx , & out_len , value , & res , true);
440442 v = value ;
441443 if (!already_bool ) {
442444 res = sym_new_truthiness (ctx , value , true);
@@ -693,7 +695,7 @@ dummy_func(void) {
693695 (void )descr ;
694696 PyTypeObject * type = (PyTypeObject * )sym_get_const (ctx , owner );
695697 PyObject * name = get_co_name (ctx , oparg >> 1 );
696- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
698+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
697699 _POP_TOP_LOAD_CONST_INLINE_BORROW ,
698700 _POP_TOP_LOAD_CONST_INLINE );
699701 }
@@ -702,7 +704,7 @@ dummy_func(void) {
702704 (void )descr ;
703705 PyTypeObject * type = sym_get_type (owner );
704706 PyObject * name = get_co_name (ctx , oparg >> 1 );
705- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
707+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
706708 _POP_TOP_LOAD_CONST_INLINE_BORROW ,
707709 _POP_TOP_LOAD_CONST_INLINE );
708710 }
@@ -711,7 +713,7 @@ dummy_func(void) {
711713 (void )descr ;
712714 PyTypeObject * type = sym_get_type (owner );
713715 PyObject * name = get_co_name (ctx , oparg >> 1 );
714- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
716+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
715717 _POP_TOP_LOAD_CONST_INLINE_BORROW ,
716718 _POP_TOP_LOAD_CONST_INLINE );
717719 }
@@ -720,7 +722,7 @@ dummy_func(void) {
720722 (void )descr ;
721723 PyTypeObject * type = sym_get_type (owner );
722724 PyObject * name = get_co_name (ctx , oparg >> 1 );
723- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
725+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
724726 _LOAD_CONST_UNDER_INLINE_BORROW ,
725727 _LOAD_CONST_UNDER_INLINE );
726728 self = owner ;
@@ -730,7 +732,7 @@ dummy_func(void) {
730732 (void )descr ;
731733 PyTypeObject * type = sym_get_type (owner );
732734 PyObject * name = get_co_name (ctx , oparg >> 1 );
733- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
735+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
734736 _LOAD_CONST_UNDER_INLINE_BORROW ,
735737 _LOAD_CONST_UNDER_INLINE );
736738 self = owner ;
@@ -740,7 +742,7 @@ dummy_func(void) {
740742 (void )descr ;
741743 PyTypeObject * type = sym_get_type (owner );
742744 PyObject * name = get_co_name (ctx , oparg >> 1 );
743- attr = lookup_attr (ctx , dependencies , this_instr , type , name ,
745+ attr = lookup_attr (ctx , dependencies , this_instr , & out_len , type , name ,
744746 _LOAD_CONST_UNDER_INLINE_BORROW ,
745747 _LOAD_CONST_UNDER_INLINE );
746748 self = owner ;
@@ -761,7 +763,7 @@ dummy_func(void) {
761763 if (sym_is_const (ctx , callable ) && sym_matches_type (callable , & PyFunction_Type )) {
762764 assert (PyFunction_Check (sym_get_const (ctx , callable )));
763765 ADD_OP (_CHECK_FUNCTION_VERSION_INLINE , 0 , func_version );
764- ctx -> tracer -> out_buffer [ctx -> tracer -> out_len - 1 ].operand1 = (uintptr_t )sym_get_const (ctx , callable );
766+ ctx -> out_buffer [out_len - 1 ].operand1 = (uintptr_t )sym_get_const (ctx , callable );
765767 }
766768 sym_set_type (callable , & PyFunction_Type );
767769 }
@@ -771,7 +773,7 @@ dummy_func(void) {
771773 PyMethodObject * method = (PyMethodObject * )sym_get_const (ctx , callable );
772774 assert (PyMethod_Check (method ));
773775 ADD_OP (_CHECK_FUNCTION_VERSION_INLINE , 0 , func_version );
774- ctx -> tracer -> out_buffer [ctx -> tracer -> out_len - 1 ].operand1 = (uintptr_t )method -> im_func ;
776+ ctx -> out_buffer [out_len - 1 ].operand1 = (uintptr_t )method -> im_func ;
775777 }
776778 sym_set_type (callable , & PyMethod_Type );
777779 }
@@ -1105,7 +1107,7 @@ dummy_func(void) {
11051107 if (sym_is_const (ctx , flag )) {
11061108 PyObject * value = sym_get_const (ctx , flag );
11071109 assert (value != NULL );
1108- eliminate_pop_guard (this_instr , ctx , value != Py_True );
1110+ eliminate_pop_guard (this_instr , ctx , & out_len , value != Py_True );
11091111 }
11101112 sym_set_const (flag , Py_True );
11111113 }
@@ -1150,7 +1152,7 @@ dummy_func(void) {
11501152 if (sym_is_const (ctx , flag )) {
11511153 PyObject * value = sym_get_const (ctx , flag );
11521154 assert (value != NULL );
1153- eliminate_pop_guard (this_instr , ctx , value != Py_False );
1155+ eliminate_pop_guard (this_instr , ctx , & out_len , value != Py_False );
11541156 }
11551157 sym_set_const (flag , Py_False );
11561158 }
@@ -1159,11 +1161,11 @@ dummy_func(void) {
11591161 if (sym_is_const (ctx , val )) {
11601162 PyObject * value = sym_get_const (ctx , val );
11611163 assert (value != NULL );
1162- eliminate_pop_guard (this_instr , ctx , !Py_IsNone (value ));
1164+ eliminate_pop_guard (this_instr , ctx , & out_len , !Py_IsNone (value ));
11631165 }
11641166 else if (sym_has_type (val )) {
11651167 assert (!sym_matches_type (val , & _PyNone_Type ));
1166- eliminate_pop_guard (this_instr , ctx , true);
1168+ eliminate_pop_guard (this_instr , ctx , & out_len , true);
11671169 }
11681170 sym_set_const (val , Py_None );
11691171 }
@@ -1172,11 +1174,11 @@ dummy_func(void) {
11721174 if (sym_is_const (ctx , val )) {
11731175 PyObject * value = sym_get_const (ctx , val );
11741176 assert (value != NULL );
1175- eliminate_pop_guard (this_instr , ctx , Py_IsNone (value ));
1177+ eliminate_pop_guard (this_instr , ctx , & out_len , Py_IsNone (value ));
11761178 }
11771179 else if (sym_has_type (val )) {
11781180 assert (!sym_matches_type (val , & _PyNone_Type ));
1179- eliminate_pop_guard (this_instr , ctx , false);
1181+ eliminate_pop_guard (this_instr , ctx , & out_len , false);
11801182 }
11811183 }
11821184
@@ -1511,7 +1513,7 @@ dummy_func(void) {
15111513 ctx -> frame -> globals_watched = true;
15121514 }
15131515 if (ctx -> frame -> globals_checked_version != version && this_instr [-1 ].opcode == _NOP ) {
1514- REPLACE_OP (& ctx -> tracer -> out_buffer [ctx -> tracer -> out_len - 1 ], _GUARD_GLOBALS_VERSION , 0 , version );
1516+ REPLACE_OP (& ctx -> out_buffer [out_len - 1 ], _GUARD_GLOBALS_VERSION , 0 , version );
15151517 ctx -> frame -> globals_checked_version = version ;
15161518 }
15171519 if (ctx -> frame -> globals_checked_version == version ) {
0 commit comments