@@ -841,10 +841,13 @@ STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) {
841
841
}
842
842
}
843
843
844
+ // Ensures all unsettled registers that hold Python values are copied to the
845
+ // concrete Python stack. All registers are then free to use.
844
846
STATIC void need_reg_all (emit_t * emit ) {
845
847
for (int i = 0 ; i < emit -> stack_size ; i ++ ) {
846
848
stack_info_t * si = & emit -> stack_info [i ];
847
849
if (si -> kind == STACK_REG ) {
850
+ DEBUG_printf (" reg(%u) to local(%u)\n" , si -> data .u_reg , emit -> stack_start + i );
848
851
si -> kind = STACK_VALUE ;
849
852
emit_native_mov_state_reg (emit , emit -> stack_start + i , si -> data .u_reg );
850
853
}
@@ -871,16 +874,13 @@ STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_i
871
874
}
872
875
}
873
876
877
+ // Copies all unsettled registers and immediates that are Python values into the
878
+ // concrete Python stack. This ensures the concrete Python stack holds valid
879
+ // values for the current stack_size.
880
+ // This function may clobber REG_TEMP0.
874
881
STATIC void need_stack_settled (emit_t * emit ) {
875
882
DEBUG_printf (" need_stack_settled; stack_size=%d\n" , emit -> stack_size );
876
- for (int i = 0 ; i < emit -> stack_size ; i ++ ) {
877
- stack_info_t * si = & emit -> stack_info [i ];
878
- if (si -> kind == STACK_REG ) {
879
- DEBUG_printf (" reg(%u) to local(%u)\n" , si -> data .u_reg , emit -> stack_start + i );
880
- si -> kind = STACK_VALUE ;
881
- emit_native_mov_state_reg (emit , emit -> stack_start + i , si -> data .u_reg );
882
- }
883
- }
883
+ need_reg_all (emit );
884
884
for (int i = 0 ; i < emit -> stack_size ; i ++ ) {
885
885
stack_info_t * si = & emit -> stack_info [i ];
886
886
if (si -> kind == STACK_IMM ) {
0 commit comments