pike.git / src / peep.c

version» Context lines:

pike.git/src/peep.c:9:   #include "pike_error.h"   #include "lex.h"   #include "pike_memory.h"   #include "peep.h"   #include "dmalloc.h"   #include "stuff.h"   #include "bignum.h"   #include "opcodes.h"   #include "builtin_functions.h"   #include "constants.h" + #include "interpret.h"    - RCSID("$Id: peep.c,v 1.55 2001/07/17 06:50:35 hubbe Exp $"); + RCSID("$Id: peep.c,v 1.56 2001/07/17 08:33:23 hubbe Exp $");      static void asm_opt(void);      dynamic_buffer instrbuf;      static int hasarg(int opcode)   {    return instrs[opcode-F_OFFSET].flags & I_HASARG;   }   
pike.git/src/peep.c:144:   /* This is ugly, but since the code may be moved we cannot use    * relative addressing :(    */   #define CALL_ABSOLUTE(X) do{ \    add_to_program(0xb8); /* mov $xxx,%eax */ \    PUSH_INT(X); \    add_to_program(0xff); /* jsr *(%eax) */ \    add_to_program(0xd0); \   }while(0)    - #define RET() add_to_program(0xc3); - #define POP(X) \ -  add_to_program(0x83), /* Addl.b 0x4, %esp */ \ -  add_to_program(0xc4), \ -  add_to_program(-X) + #define UPDATE_PC() do { \ +  INT32 tmp=PC; \ +  add_to_program(0xa1 /* mov $xxxxx, %eax */); \ +  ins_int((INT32)(&Pike_interpreter.frame_pointer), add_to_program); \ +  \ +  add_to_program(0xc7); /* movl $xxxxx, yy%(eax) */ \ +  add_to_program(0x40); \ +  add_to_program(OFFSETOF(pike_frame, pc)); \ +  ins_int((INT32)tmp, add_to_program); \ + }while(0)      #endif    -  + #ifndef PIKE_USE_MACHINE_CODE + #undef UPDATE_PC + #define UPDATE_PC() + #endif      void ins_f_byte(unsigned int b)   {   #ifdef PIKE_DEBUG    if(store_linenumbers && b<F_MAX_OPCODE)    ADD_COMPILED(b);   #endif /* PIKE_DEBUG */       b-=F_OFFSET;   #ifdef PIKE_DEBUG    if(b>255)    Pike_error("Instruction too big %d\n",b);   #endif      #ifdef PIKE_USE_MACHINE_CODE - #if defined(__i386__) && defined(__GNUC__) +  do{ +  static int last_prog_id=-1; +  static int last_num_linenumbers=-1; +  if(last_prog_id != Pike_compiler->new_program->id || +  last_num_linenumbers != Pike_compiler->new_program->num_linenumbers) +  { +  last_prog_id=Pike_compiler->new_program->id; +  last_num_linenumbers = Pike_compiler->new_program->num_linenumbers; +  UPDATE_PC(); +  } +  }while(0); +     CALL_ABSOLUTE(instrs[b].address);    return;   #endif - #endif +       #ifdef HAVE_COMPUTED_GOTO    add_to_program(fcode_to_opcode[b]);   #else /* !HAVE_COMPUTED_GOTO */    add_to_program((unsigned char)b);   #endif /* HAVE_COMPUTED_GOTO */   }      static void ins_f_byte_with_arg(unsigned int a,unsigned INT32 b)   {
pike.git/src/peep.c:228:    ins_f_byte(a);    add_to_program((PIKE_OPCODE_T)b);   }      static void ins_f_byte_with_2_args(unsigned int a,    unsigned INT32 c,    unsigned INT32 b)   {   #ifdef PIKE_USE_MACHINE_CODE   #if defined(__i386__) && defined(__GNUC__) +  add_to_program(0xc7); /* movl $xxxx, (%esp) */ +  add_to_program(0x04); +  add_to_program(0x24); +  PUSH_INT(c);    add_to_program(0xc7); /* movl $xxxx, 4(%esp) */    add_to_program(0x44);    add_to_program(0x24);    add_to_program(0x04); -  PUSH_INT(c); -  ins_f_byte_with_arg(a,b); -  return +  PUSH_INT(b); +  ins_f_byte(a); +  return;   #endif   #endif      #ifdef HAVE_COMPUTED_GOTO    switch(b >> 8)    {    case 0 : break;    case 1 : ins_f_byte(F_PREFIX2_256); break;    case 2 : ins_f_byte(F_PREFIX2_512); break;    case 3 : ins_f_byte(F_PREFIX2_768); break;
pike.git/src/peep.c:387:    length=instrbuf.s.len / sizeof(p_instr);       for(e=0;e<=max_label;e++) labels[e]=jumps[e]=-1;       c=(p_instr *)instrbuf.s.str;   #ifdef PIKE_DEBUG    synch_depth = 0;   #endif    for(e=0;e<length;e++)    { +  int linenumbers_stored=0;   #ifdef PIKE_DEBUG    if((a_flag > 2 && store_linenumbers) || a_flag > 3)    {    if (c->opcode == F_POP_SYNCH_MARK) synch_depth--;    fprintf(stderr, "===%4d %4lx %*s", c->line,    DO_NOT_WARN((unsigned long)PC), synch_depth, "");    dump_instr(c);    fprintf(stderr,"\n");    if (c->opcode == F_SYNCH_MARK) synch_depth++;    }
pike.git/src/peep.c:440:    case F_LABEL:    if(c->arg == -1) break;   #ifdef PIKE_DEBUG    if(c->arg > max_label || c->arg < 0)    fatal("max_label calculation failed!\n");       if(labels[c->arg] != -1)    fatal("Duplicate label!\n");   #endif    labels[c->arg] = DO_NOT_WARN((INT32)PC); +  UPDATE_PC();    break;       case F_VOLATILE_RETURN:    ins_f_byte(F_RETURN);    break;       default:    switch(instrs[c->opcode - F_OFFSET].flags)    {    case I_ISJUMP: