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.100 2004/08/24 16:56:32 grubba Exp $ + || $Id: peep.c,v 1.101 2004/08/25 09:36:47 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "program.h"   #include "las.h"   #include "docode.h"   #include "main.h"   #include "pike_error.h"
pike.git/src/peep.c:18:   #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"   #include "pikecode.h"    - RCSID("$Id: peep.c,v 1.100 2004/08/24 16:56:32 grubba Exp $"); + RCSID("$Id: peep.c,v 1.101 2004/08/25 09:36:47 grubba Exp $");      static void asm_opt(void);      dynamic_buffer instrbuf;      #ifdef PIKE_DEBUG   static int hasarg(int opcode)   {    return instrs[opcode-F_OFFSET].flags & I_HASARG;   }
pike.git/src/peep.c:139:    p=(p_instr *)instrbuf.s.str;    p[instr].arg=arg;   }      #ifndef FLUSH_CODE_GENERATOR_STATE   #define FLUSH_CODE_GENERATOR_STATE()   #endif      /**** Bytecode Generator *****/    - static int reoptimize; + static int relabel;      INT32 assemble(int store_linenumbers)   {    INT32 entry_point;    INT32 max_label=-1,tmp;    INT32 *labels, *jumps, *uses;    ptrdiff_t e, length;    p_instr *c;   #ifdef PIKE_PORTABLE_BYTECODE    struct pike_string *tripples = NULL;   #endif /* PIKE_PORTABLE_BYTECODE */   #ifdef PIKE_DEBUG    INT32 max_pointer=-1;    int synch_depth = 0;    size_t fun_start = Pike_compiler->new_program->num_program;   #endif    -  reoptimize=!(debug_options & NO_PEEP_OPTIMIZING); -  +     c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);      #ifdef PIKE_DEBUG    if((a_flag > 1 && store_linenumbers) || a_flag > 2)    {    for (e = 0; e < length; e++) {    if (c[e].opcode == F_POP_SYNCH_MARK) synch_depth--;    fprintf(stderr, "~~~%4d %4lx %*s", c[e].line,    DO_NOT_WARN((unsigned long)e), synch_depth, "");
pike.git/src/peep.c:287: Inside #if defined(PIKE_DEBUG)
      Pike_fatal("Reference to undefined label %d > %d\n",    max_pointer, max_label);    }   #endif /* PIKE_DEBUG */       labels=(INT32 *)xalloc(sizeof(INT32) * 3 * (max_label+2));    jumps = labels + max_label + 2;    uses = jumps + max_label + 2;    -  while(reoptimize) +  int reoptimize = relabel = !(debug_options & NO_PEEP_OPTIMIZING); +  +  while(relabel)    { -  reoptimize=0; +  /* First do the relabel pass. */    for(e=0;e<=max_label;e++)    {    labels[e]=jumps[e]=-1;    uses[e]=0;    }       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);    for(e=0;e<length;e++)    if(c[e].opcode == F_LABEL && c[e].arg>=0) {
pike.git/src/peep.c:369:    uses[c[e].arg]++;    }    pointer_opcode_done:;    }       for(e=0;e<=max_label;e++)    {    if(!uses[e] && labels[e]>=0)    {    c[labels[e]].opcode=F_NOP; -  reoptimize++; +  reoptimize = 1;    }    }    -  asm_opt(); +  relabel = 0;       if(!reoptimize) break; -  +  +  /* Then do the optimize pass. */ +  +  asm_opt(); +  +  reoptimize = 0; +  +  if (!relabel) break; +    #if 1   #ifdef PIKE_DEBUG    if (a_flag > 3)    fprintf(stderr, "Rerunning optimizer.\n");   #endif   #else /* !1 */ -  reoptimize=0; +  relabel = 0;   #endif /* 1 */    }       /* Time to create the actual bytecode. */       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);       for(e=0;e<=max_label;e++) labels[e]=jumps[e]=-1;   
pike.git/src/peep.c:900:    int e; \    for(e=0;e<q;e++) \    { \    fprintf(stderr," "); \    dump_instr(instr(e)); \    } \    fprintf(stderr,"\n"); \    } \    ) \    \ -  fifo_len += q + 3; \ +  /* 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;       DO_OPTIMIZATION_PREQUEL(topop);
pike.git/src/peep.c:955:    insopt2(i,j,k,cl,cf);    }    break;    }    }       va_end(arglist);       DO_OPTIMIZATION_POSTQUEL(q);    -  reoptimize++; +  relabel = 1;   }      #include "peep_engine.c"      static void asm_opt(void)   {   #ifdef PIKE_DEBUG    if(a_flag > 3)    {    p_instr *c;