@@ -3586,49 +3586,47 @@ static void
35863586assemble_jump_offsets (struct assembler * a , struct compiler * c )
35873587{
35883588 basicblock * b ;
3589- int bsize , totsize , extended_arg_count , last_extended_arg_count = 0 ;
3589+ int bsize , totsize , extended_arg_count = 0 , last_extended_arg_count ;
35903590 int i ;
35913591
35923592 /* Compute the size of each block and fixup jump args.
35933593 Replace block pointer with position in bytecode. */
3594- start :
3595- totsize = 0 ;
3596- for (i = a -> a_nblocks - 1 ; i >= 0 ; i -- ) {
3597- b = a -> a_postorder [i ];
3598- bsize = blocksize (b );
3599- b -> b_offset = totsize ;
3600- totsize += bsize ;
3601- }
3602- extended_arg_count = 0 ;
3603- for (b = c -> u -> u_blocks ; b != NULL ; b = b -> b_list ) {
3604- bsize = b -> b_offset ;
3605- for (i = 0 ; i < b -> b_iused ; i ++ ) {
3606- struct instr * instr = & b -> b_instr [i ];
3607- /* Relative jumps are computed relative to
3608- the instruction pointer after fetching
3609- the jump instruction.
3610- */
3611- bsize += instrsize (instr );
3612- if (instr -> i_jabs )
3613- instr -> i_oparg = instr -> i_target -> b_offset ;
3614- else if (instr -> i_jrel ) {
3615- int delta = instr -> i_target -> b_offset - bsize ;
3616- instr -> i_oparg = delta ;
3594+ do {
3595+ totsize = 0 ;
3596+ for (i = a -> a_nblocks - 1 ; i >= 0 ; i -- ) {
3597+ b = a -> a_postorder [i ];
3598+ bsize = blocksize (b );
3599+ b -> b_offset = totsize ;
3600+ totsize += bsize ;
3601+ }
3602+ last_extended_arg_count = extended_arg_count ;
3603+ extended_arg_count = 0 ;
3604+ for (b = c -> u -> u_blocks ; b != NULL ; b = b -> b_list ) {
3605+ bsize = b -> b_offset ;
3606+ for (i = 0 ; i < b -> b_iused ; i ++ ) {
3607+ struct instr * instr = & b -> b_instr [i ];
3608+ /* Relative jumps are computed relative to
3609+ the instruction pointer after fetching
3610+ the jump instruction.
3611+ */
3612+ bsize += instrsize (instr );
3613+ if (instr -> i_jabs )
3614+ instr -> i_oparg = instr -> i_target -> b_offset ;
3615+ else if (instr -> i_jrel ) {
3616+ int delta = instr -> i_target -> b_offset - bsize ;
3617+ instr -> i_oparg = delta ;
3618+ }
3619+ else
3620+ continue ;
3621+ if (instr -> i_oparg > 0xffff )
3622+ extended_arg_count ++ ;
36173623 }
3618- else
3619- continue ;
3620- if (instr -> i_oparg > 0xffff )
3621- extended_arg_count ++ ;
36223624 }
3623- }
36243625
36253626 /* XXX: This is an awful hack that could hurt performance, but
36263627 on the bright side it should work until we come up
36273628 with a better solution.
36283629
3629- In the meantime, should the goto be dropped in favor
3630- of a loop?
3631-
36323630 The issue is that in the first loop blocksize() is called
36333631 which calls instrsize() which requires i_oparg be set
36343632 appropriately. There is a bootstrap problem because
@@ -3639,10 +3637,7 @@ assemble_jump_offsets(struct assembler *a, struct compiler *c)
36393637 ones in jump instructions. So this should converge
36403638 fairly quickly.
36413639 */
3642- if (last_extended_arg_count != extended_arg_count ) {
3643- last_extended_arg_count = extended_arg_count ;
3644- goto start ;
3645- }
3640+ } while (last_extended_arg_count != extended_arg_count );
36463641}
36473642
36483643static PyObject *
0 commit comments