Branch: Tag:

2012-07-18

2012-07-18 14:35:57 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler (amd64): Changed calling convention for {jmp,call}_rel_imm*().

They now take the absolute address as argument,
since the relative offset depends on the size
of the generated opcode, which could vary.

This fixes tlib/modules/Calendar.pmod/testsuite:433,
where the second F_RETURN_IF_TRUE jumped five bytes
too short into the code generated by the first.

657:    modrm( 3, reg1, reg2 );   }    - static int jmp_rel_imm32( int rel ) + static int jmp_rel_imm32( int addr )   { -  +  int rel = addr - (PIKE_PC + 5); // counts from the next instruction    int res;    opcode( 0xe9 );    res = PIKE_PC;
666:    return res;   }    - static void jmp_rel_imm( int rel ) + static void jmp_rel_imm( int addr )   { -  +  int rel = addr - (PIKE_PC + 2); // counts from the next instruction    if(rel >= -0x80 && rel <= 0x7f )    {    opcode( 0xeb );    ib( rel );    return;    } -  jmp_rel_imm32( rel ); +  jmp_rel_imm32( addr );   }    - static void call_rel_imm32( int rel ) + static void call_rel_imm32( int addr )   { -  rel -= 5; // counts from the next instruction +  int rel = addr - (PIKE_PC + 5); // counts from the next instruction    opcode( 0xe8 );    id( rel );    sp_reg = -1;
1393:       if( !branch_check_threads_update_etc )    { -  /* Create update + call to branch_check_threds_etc */ +  /* Create update + call to branch_check_threads_etc */    if( !code_only )    jmp( &label_A );    branch_check_threads_update_etc = PIKE_PC;
1420:    /* Use C-stack for counter. We have padding added in entry */    add_mem8_imm( REG_RSP, 0, 1 );    jno( &label_B ); -  call_rel_imm32( branch_check_threads_update_etc-PIKE_PC ); +  call_rel_imm32( branch_check_threads_update_etc );    LABEL_B;    }   }
1435:   {    if( ret_for_func )    { -  jmp_rel_imm( ret_for_func - PIKE_PC ); +  jmp_rel_imm( ret_for_func );    }    else    {