pike.git / src / peep.c

version» Context lines:

pike.git/src/peep.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: peep.c,v 1.107 2006/02/27 12:12:47 mast Exp $ + || $Id: peep.c,v 1.108 2006/09/05 12:09:15 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "program.h"   #include "las.h"   #include "docode.h"   #include "pike_embed.h"   #include "pike_error.h"
pike.git/src/peep.c:62:   }      void exit_bytecode(void)   {    ptrdiff_t e, length;    p_instr *c;       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);    -  for(e=0;e<length;e++) free_string(c->file); +  for(e=0;e<length;e++) { +  free_string(dmalloc_touch_named(struct pike_string *, c[e].file, +  "exit_bytecode")); + #ifdef PIKE_DEBUG +  c[e].file = (void *)(ptrdiff_t)~0; + #endif +  }       toss_buffer(&instrbuf);   }      ptrdiff_t insert_opcode2(unsigned int f,    INT32 b,    INT32 c,    INT32 current_line,    struct pike_string *current_file)   {
pike.git/src/peep.c:90:    p=(p_instr *)low_make_buf_space(sizeof(p_instr), &instrbuf);         #ifdef PIKE_DEBUG    if(!instrbuf.s.len)    Pike_fatal("Low make buf space failed!!!!!!\n");   #endif       p->opcode=f;    p->line=current_line; -  copy_shared_string(p->file, current_file); +  copy_shared_string(p->file, dmalloc_touch_named(struct pike_string *, +  current_file, +  "insert_opcode"));    p->arg=b;    p->arg2=c;       return p - (p_instr *)instrbuf.s.str;   }      ptrdiff_t insert_opcode1(unsigned int f,    INT32 b,    INT32 current_line,    struct pike_string *current_file)
pike.git/src/peep.c:186: Inside #if defined(PIKE_PORTABLE_BYTECODE)
   /* No need to do this for constant evaluations. */    if (store_linenumbers) {    p_wchar2 *current_tripple;    struct pike_string *previous_file = NULL;    int previous_line = 0;    ptrdiff_t num_linedirectives = 0;       /* Count the number of F_FILENAME/F_LINE pseudo-ops we need to add. */    for (e=0; e < length; e++) {    if (c[e].file != previous_file) { -  previous_file = c[e].file; +  previous_file = dmalloc_touch_named(struct pike_string *, +  c[e].file, "prev_file");    num_linedirectives++;    }    if (c[e].line != previous_line) {    previous_line = c[e].line;    num_linedirectives++;    }    }       /* fprintf(stderr, "length:%d directives:%d\n",    * length, num_linedirectives);
pike.git/src/peep.c:210: Inside #if defined(PIKE_PORTABLE_BYTECODE)
   2))) {    Pike_fatal("Failed to allocate wide string of length %d 3*(%d + %d).\n",    3*(length+num_linedirectives), length, num_linedirectives);    }    previous_file = NULL;    previous_line = 0;    current_tripple = STR2(tripples);    for (e = 0; e < length; e++) {    if (c[e].file != previous_file) {    current_tripple[0] = F_FILENAME; -  current_tripple[1] = store_prog_string(c[e].file); +  current_tripple[1] = +  store_prog_string(dmalloc_touch_named(struct pike_string *, +  c[e].file, +  "store_prog_string"));    current_tripple[2] = 0;    current_tripple += 3; -  previous_file = c[e].file; +  previous_file = dmalloc_touch_named(struct pike_string *, +  c[e].file, "prev_file");    }    if (c[e].line != previous_line) {    current_tripple[0] = F_LINE;    current_tripple[1] = c[e].line;    current_tripple[2] = 0;    current_tripple += 3;    previous_line = c[e].line;    }    current_tripple[0] = c[e].opcode;    current_tripple[1] = c[e].arg;
pike.git/src/peep.c:363:    continue;       case TWOO(F_LOR, F_RETURN):    c[e].opcode=F_RETURN_IF_TRUE;    goto pointer_opcode_done;       case TWOO(F_BRANCH, F_RETURN):    case TWOO(F_BRANCH, F_RETURN_0):    case TWOO(F_BRANCH, F_RETURN_1):    case TWOO(F_BRANCH, F_RETURN_LOCAL): -  if(c[e].file) free_string(c[e].file); +  if(c[e].file) { +  free_string(dmalloc_touch_named(struct pike_string *, +  c[e].file, "branch_opt 1")); +  }    c[e]=c[tmp]; -  if(c[e].file) add_ref(c[e].file); +  if(c[e].file) { +  add_ref(dmalloc_touch_named(struct pike_string *, +  c[e].file, "branch_opt 2")); +  }    goto pointer_opcode_done;    }    break;    }   #ifdef PIKE_DEBUG    if (c[e].arg < 0 || c[e].arg > max_label)    Pike_fatal ("Invalid index into uses: %d\n", c[e].arg);   #endif    uses[c[e].arg]++;    }
pike.git/src/peep.c:465: Inside #if defined(PIKE_DEBUG)
   if (c->opcode == F_POP_SYNCH_MARK) synch_depth--;    fprintf(stderr, "===%4d %4lx %*s", c->line,    DO_NOT_WARN((unsigned long)PIKE_PC), synch_depth, "");    dump_instr(c);    fprintf(stderr,"\n");    if (c->opcode == F_SYNCH_MARK) synch_depth++;    }   #endif       if(store_linenumbers) { -  store_linenumber(c->line, c->file); +  store_linenumber(c->line, dmalloc_touch_named(struct pike_string *, +  c->file, +  "store_line"));   #ifdef PIKE_DEBUG    if (c->opcode < F_MAX_OPCODE)    ADD_COMPILED(c->opcode);   #endif /* PIKE_DEBUG */    }       switch(c->opcode)    {    case F_NOP:    case F_NOTREACHED:
pike.git/src/peep.c:758: Inside #if defined(PIKE_DEBUG)
     #ifdef PIKE_DEBUG    if(!hasarg2(f) && b)    Pike_fatal("hasarg2(%d /*%s */) is wrong!\n",f,get_f_name(f));   #endif       p=(p_instr *)low_make_buf_space(sizeof(p_instr), &instrbuf);       if(fifo_len)    { +  debug_malloc_touch_named(p[-fifo_len].file, "insopt2");    MEMMOVE(p-fifo_len+1,p-fifo_len,fifo_len*sizeof(p_instr));    p-=fifo_len;    }      #ifdef PIKE_DEBUG    if(!instrbuf.s.len)    Pike_fatal("Low make buf space failed!!!!!!\n");   #endif       p->opcode=f;    p->line=cl; -  copy_shared_string(p->file, cf); +  copy_shared_string(p->file, dmalloc_touch_named(struct pike_string *, +  cf, "insopt2"));    p->arg=a;    p->arg2=b;       return p - (p_instr *)instrbuf.s.str;   }      static INLINE ptrdiff_t insopt1(int f, INT32 a, int cl, struct pike_string *cf)   {   #ifdef PIKE_DEBUG    if(!hasarg(f) && a)
pike.git/src/peep.c:797: Inside #if defined(PIKE_DEBUG)
  {   #ifdef PIKE_DEBUG    if(hasarg(f))    Pike_fatal("hasarg(%d /* %s */) is wrong!\n",f,get_f_name(f));   #endif    return insopt2(f,0,0,cl, cf);   }      static void debug(void)   { -  if(fifo_len > (long)instrbuf.s.len / (long)sizeof(p_instr)) +  if(fifo_len > (long)instrbuf.s.len / (long)sizeof(p_instr)) { +  fprintf(stderr, "DEBUG: Shrinking fifo_len from %d to %d\n", +  fifo_len, (long)instrbuf.s.len / (long)sizeof(p_instr));    fifo_len=(long)instrbuf.s.len / (long)sizeof(p_instr); -  +  }   #ifdef PIKE_DEBUG    if(eye < 0)    Pike_fatal("Popped beyond start of code.\n");       if(instrbuf.s.len)    {    p_instr *p;    p=(p_instr *)low_make_buf_space(0, &instrbuf);    if(!p[-1].file)    Pike_fatal("No file name on last instruction!\n");
pike.git/src/peep.c:893: Inside #if defined(PIKE_DEBUG)
   if((long)d > (long)instrbuf.s.len / (long)sizeof(p_instr))    Pike_fatal("Popping out of instructions.\n");   #endif       /* FIXME: It looks like the fifo could be optimized.    * /grubba 2000-11-21 (in Versailles)    */       p=(p_instr *)low_make_buf_space(0, &instrbuf);    p-=fifo_len; -  for(e=0;e<d;e++) free_string(p[e].file); +  for(e=0;e<d;e++) { +  free_string(dmalloc_touch_named(struct pike_string *, p[e].file, +  "pop_n_opcodes")); +  }    fifo_len-=d; -  if(fifo_len) MEMMOVE(p,p+d,fifo_len*sizeof(p_instr)); +  if(fifo_len) { + #ifdef PIKE_DEBUG +  int i = fifo_len; +  while (i) { +  debug_malloc_touch_named(p[d + --i].file, "pop_n_opcodes"); +  } + #endif +  MEMMOVE(p,p+d,fifo_len*sizeof(p_instr)); +  }    n-=d;    low_make_buf_space(-((INT32)sizeof(p_instr))*d, &instrbuf);    }    eye+=n;   }    - #define DO_OPTIMIZATION_PREQUEL(topop) do { \ -  struct pike_string *cf; \ -  INT32 cl=instr(0)->line; \ -  \ -  DO_IF_DEBUG( \ -  if(a_flag>5) \ -  { \ -  int e; \ -  fprintf(stderr,"PEEP at %d:",cl); \ -  for(e=0;e<topop;e++) \ -  { \ -  fprintf(stderr," "); \ -  dump_instr(instr(e)); \ -  } \ -  fprintf(stderr," => "); \ -  } \ -  ) \ -  \ -  copy_shared_string(cf,instr(0)->file); \ -  pop_n_opcodes(topop) +     - #define DO_OPTIMIZATION_POSTQUEL(q) \ -  fifo_len+=q; \ -  free_string(cf); \ -  debug(); \ -  \ -  DO_IF_DEBUG( \ -  if(a_flag>5) \ -  { \ -  int e; \ -  for(e=0;e<q;e++) \ -  { \ -  fprintf(stderr," "); \ -  dump_instr(instr(e)); \ -  } \ -  fprintf(stderr,"\n"); \ -  } \ -  ) \ -  \ -  /* Note: The 5 below is the longest \ -  * match prefix in the ruleset\ -  */ \ -  fifo_len += q + 5; \ -  } while(0) +     -  +    static void do_optimization(int topop, ...)   {    va_list arglist;    int q=0;    int oplen; -  +  struct pike_string *cf; +  INT32 cl=instr(0)->line;    -  DO_OPTIMIZATION_PREQUEL(topop); + #ifdef PIKE_DEBUG +  if(a_flag>5) +  { +  int e; +  fprintf(stderr,"PEEP at %d:",cl); +  for(e=0;e<topop;e++) +  { +  fprintf(stderr," "); +  dump_instr(instr(e)); +  } +  fprintf(stderr," => "); +  } + #endif    -  +  copy_shared_string(cf,dmalloc_touch_named(struct pike_string *, +  instr(0)->file, +  "do_optimization")); +  pop_n_opcodes(topop); +     va_start(arglist, topop);       while((oplen = va_arg(arglist, int)))    {    q++;    switch(oplen)    {   #ifdef PIKE_DEBUG    default:    Pike_fatal("Unsupported argument number: %d\n", oplen);
pike.git/src/peep.c:997:    int j=va_arg(arglist, int);    int k=va_arg(arglist, int);    insopt2(i,j,k,cl,cf);    }    break;    }    }       va_end(arglist);    -  DO_OPTIMIZATION_POSTQUEL(q); +  /*fifo_len+=q;*/ +  free_string(dmalloc_touch_named(struct pike_string *, cf, +  "do_optimization")); +  debug(); +  + #ifdef PIKE_DEBUG +  if(a_flag>5) +  { +  int e; +  for(e=0;e<q;e++) +  { +  fprintf(stderr," "); +  dump_instr(instr(e));    } -  +  fprintf(stderr,"\n"); +  } + #endif    -  +  /* Note: The 5 below is the longest +  * match prefix in the ruleset +  */ +  /*fifo_len += q + 5;*/ + } +    #include "peep_engine.c"      static int asm_opt(void)   {    int relabel = 0;      #ifdef PIKE_DEBUG    if(a_flag > 3)    {    p_instr *c;
pike.git/src/peep.c:1055: Inside #if defined(PIKE_DEBUG)
   dump_instr(instr(e));    }    fprintf(stderr,"\n");    }   #endif       relabel |= low_asm_opt();    advance();    }    -  for(eye=0;eye<len;eye++) free_string(instructions[eye].file); +  for(eye=0;eye<len;eye++) { +  free_string(dmalloc_touch_named(struct pike_string *, +  instructions[eye].file, +  "clearing eye")); +  }    free((char *)instructions);      #ifdef PIKE_DEBUG    if(a_flag > 4)    {    p_instr *c;    ptrdiff_t e, length;    int synch_depth = 0;       c=(p_instr *)instrbuf.s.str;