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.101 2004/08/25 09:36:47 grubba Exp $ + || $Id: peep.c,v 1.102 2004/08/25 12:00:08 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.101 2004/08/25 09:36:47 grubba Exp $"); + RCSID("$Id: peep.c,v 1.102 2004/08/25 12:00:08 grubba Exp $");    - static void asm_opt(void); + static int asm_opt(void);      dynamic_buffer instrbuf;      #ifdef PIKE_DEBUG   static int hasarg(int opcode)   {    return instrs[opcode-F_OFFSET].flags & I_HASARG;   }      static int hasarg2(int opcode)
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 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 -  +  int relabel; +  int reoptimize = relabel = !(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,
pike.git/src/peep.c:285: 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;    -  int reoptimize = relabel = !(debug_options & NO_PEEP_OPTIMIZING); -  +     while(relabel)    {    /* 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;
pike.git/src/peep.c:373:       for(e=0;e<=max_label;e++)    {    if(!uses[e] && labels[e]>=0)    {    c[labels[e]].opcode=F_NOP;    reoptimize = 1;    }    }    -  relabel = 0; -  +     if(!reoptimize) break;       /* Then do the optimize pass. */    -  asm_opt(); +  relabel = asm_opt();       reoptimize = 0;       if (!relabel) break;      #if 1   #ifdef PIKE_DEBUG    if (a_flag > 3)    fprintf(stderr, "Rerunning optimizer.\n");   #endif
pike.git/src/peep.c:966:    int k=va_arg(arglist, int);    insopt2(i,j,k,cl,cf);    }    break;    }    }       va_end(arglist);       DO_OPTIMIZATION_POSTQUEL(q); -  -  relabel = 1; +    }      #include "peep_engine.c"    - static void asm_opt(void) + static int asm_opt(void)   { -  +  int relabel = 0; +    #ifdef PIKE_DEBUG    if(a_flag > 3)    {    p_instr *c;    ptrdiff_t e, length;    int synch_depth = 0;       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);   
pike.git/src/peep.c:1019: Inside #if defined(PIKE_DEBUG)
   DO_NOT_WARN((long)eye),    fifo_len);    for(e=0;e<4;e++) {    fprintf(stderr," ");    dump_instr(instr(e));    }    fprintf(stderr,"\n");    }   #endif    -  low_asm_opt(); +  relabel |= low_asm_opt();    advance();    }       for(eye=0;eye<len;eye++) free_string(instructions[eye].file);    free((char *)instructions);      #ifdef PIKE_DEBUG    if(a_flag > 4)    {    p_instr *c;
pike.git/src/peep.c:1047: Inside #if defined(PIKE_DEBUG)
   for(e=0;e<length;e++,c++)    {    if (c->opcode == F_POP_SYNCH_MARK) synch_depth--;    fprintf(stderr,">>>%4d: %*s",c->line,synch_depth,"");    dump_instr(c);    fprintf(stderr,"\n");    if (c->opcode == F_SYNCH_MARK) synch_depth++;    }    }   #endif +  +  return relabel;   }