pike.git / src / code / amd64.c

version» Context lines:

pike.git/src/code/amd64.c:43:   /* From SysV ABI for AMD64 draft 0.99.5. */   #define ARG1_REG REG_RDI   #define ARG2_REG REG_RSI   #define ARG3_REG REG_RDX   #define ARG4_REG REG_RCX   #define ARG5_REG REG_R8   #define ARG6_REG REG_R9   #endif       - #define MAX_LABEL_USES 7 + #define MAX_LABEL_USES 6   struct label {    int n_label_uses; -  +  ptrdiff_t addr;    ptrdiff_t offset[MAX_LABEL_USES];   };      static void label( struct label *l )   {    int i; -  +  if (l->addr >= 0) Pike_fatal("Label reused.\n");    for( i=0; i<l->n_label_uses; i++ )    {    int dist = PIKE_PC - (l->offset[i] + 1);    if( dist > 0x7f || dist < -0x80 )    Pike_fatal("Branch too far\n");    Pike_compiler->new_program->program[l->offset[i]] = dist;    /* fprintf( stderr, "assigning label @%x[%02x >%02x< %02x] -> %d\n", */    /* l->offset[i], */    /* Pike_compiler->new_program->program[l->offset[i]-1], */    /* Pike_compiler->new_program->program[l->offset[i]], */    /* Pike_compiler->new_program->program[l->offset[i]+1], */    /* dist ); */    }    l->n_label_uses = 0; -  +  l->addr = PIKE_PC;   }      static void modrm( int mod, int r, int m )   {    add_to_program( ((mod<<6) | ((r&0x7)<<3) | (m&0x7)) );   }      static void sib( int scale, int index, enum amd64_reg base )   {    add_to_program( (scale<<6) | ((index&0x7)<<3) | (base&0x7) );
pike.git/src/code/amd64.c:706:    else    ib( imm32 );    }   }         static void jump_rel8( struct label *res, unsigned char op )   {    opcode( op );    +  if (res->addr >= 0) { +  ib(res->addr - (PIKE_PC+1)); +  return; +  } +     if( res->n_label_uses >= MAX_LABEL_USES )    Pike_fatal( "Label used too many times\n" );    res->offset[res->n_label_uses] = PIKE_PC;    res->n_label_uses++;       ib(0);   }      static int jnz_imm_rel32( int rel )   {
pike.git/src/code/amd64.c:740:    id( rel );    return res;   }      #define jne(X) jnz(X)   #define je(X) jz(X)   static void jmp( struct label *l ) { return jump_rel8( l, 0xeb ); }   static void jnz( struct label *l ) { return jump_rel8( l, 0x75 ); }   static void jz( struct label *l ) { return jump_rel8( l, 0x74 ); }   static void jg( struct label *l ) { return jump_rel8( l, 0x7f ); } + static void jge( struct label *l ) { return jump_rel8( l, 0x7d ); }   static void jl( struct label *l ) { return jump_rel8( l, 0x7c ); } -  + static void jle( struct label *l ) { return jump_rel8( l, 0x7e ); }   static void jo( struct label *l ) { return jump_rel8( l, 0x70 ); }       - #define LABELS() struct label label_A, label_B, label_C;label_A.n_label_uses = 0;label_B.n_label_uses = 0;label_C.n_label_uses = 0; + #define LABELS() struct label label_A, label_B, label_C;label_A.addr = -1;label_A.n_label_uses = 0;label_B.addr = -1;label_B.n_label_uses = 0;label_C.addr = -1;label_C.n_label_uses = 0;   #define LABEL_A label(&label_A)   #define LABEL_B label(&label_B)   #define LABEL_C label(&label_C)      /* Machine code entry prologue.    *    * On entry:    * RDI: Pike_interpreter (ARG1_REG)    *    * During interpreting:
pike.git/src/code/amd64.c:1322:    pop(REG_R15);    pop(REG_RBP);    ret();    }    LABEL_A;       if ((b + F_OFFSET) == F_RETURN_IF_TRUE) {    /* Kludge. We must check if the ret addr is    * orig_addr + JUMP_EPILOGUE_SIZE. */    cmp_reg_reg( REG_RAX, REG_RCX ); -  je( &label_A ); +  je( &label_B );    jmp_reg(REG_RAX); -  LABEL_A; +  LABEL_B;    return;    }    }    if (flags & I_JUMP) {    jmp_reg(REG_RAX);       if (b + F_OFFSET == F_CATCH) {    upd_pointer(rel_addr - 4, PIKE_PC - rel_addr);    }    }