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.84 2002/11/12 11:40:08 grubba Exp $ + || $Id: peep.c,v 1.85 2003/09/26 13:20:33 grubba Exp $   */      #include "global.h"   #include "language.h"   #include "stralloc.h"   #include "dynamic_buffer.h"   #include "program.h"   #include "las.h"   #include "docode.h"   #include "main.h"
pike.git/src/peep.c:19:   #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.84 2002/11/12 11:40:08 grubba Exp $"); + RCSID("$Id: peep.c,v 1.85 2003/09/26 13:20:33 grubba 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:142:   }      #ifndef FLUSH_CODE_GENERATOR_STATE   #define FLUSH_CODE_GENERATOR_STATE()   #endif      /**** Bytecode Generator *****/      void assemble(void)   { -  INT32 max_label,tmp; +  INT32 max_label=-1,tmp;    INT32 *labels, *jumps, *uses;    ptrdiff_t e, length;    p_instr *c;    int reoptimize=!(debug_options & NO_PEEP_OPTIMIZING);   #ifdef PIKE_DEBUG -  +  int max_pointer=-1;    int synch_depth = 0;    size_t fun_start = Pike_compiler->new_program->num_program;   #endif       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);      #ifdef PIKE_DEBUG -  for (e = 0; e < length; e++) { +     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, "");    dump_instr(c+e);    fprintf(stderr,"\n");    if (c[e].opcode == F_SYNCH_MARK) synch_depth++;    } -  +  if (synch_depth) { +  Pike_fatal("Unbalanced sync_mark/pop_sync_mark: %d\n", +  synch_depth);    } -  +  }   #endif    -  max_label=-1; -  for(e=0;e<length;e++,c++) -  if(c->opcode == F_LABEL) +  for(e=0;e<length;e++,c++) { +  if(c->opcode == F_LABEL) {    if(c->arg > max_label)    max_label = c->arg; -  +  } + #ifdef PIKE_DEBUG +  else if (instrs[c->opcode - F_OFFSET].flags & I_POINTER) { +  if (c->arg > max_pointer) +  max_pointer = c->arg; +  } + #endif /* PIKE_DEBUG */ +  }    -  + #ifdef PIKE_DEBUG +  if (max_pointer > max_label) { +  fprintf(stderr, +  "Reference to undefined label %d > %d\n" +  "Bad instructions are marked with '***':\n", +  max_pointer, max_label); +  c=(p_instr *)instrbuf.s.str; +  for(e=0;e<length;e++,c++) { +  if (c->opcode == F_POP_SYNCH_MARK) synch_depth--; +  fprintf(stderr, " * %4d %4lx ", +  c->line, DO_NOT_WARN((unsigned long)e)); +  dump_instr(c); +  if ((instrs[c->opcode - F_OFFSET].flags & I_POINTER) && +  (c->arg > max_label)) { +  fprintf(stderr, " ***\n"); +  } else { +  fprintf(stderr, "\n"); +  } +  if (c->opcode == F_SYNCH_MARK) synch_depth++; +  } +  +  Pike_fatal("Reference to undefined label %d > %d\n", +  max_pointer, max_label); +  } + #endif /* PIKE_DEBUG */ +     labels=(INT32 *)xalloc(sizeof(INT32) * (max_label+2));    jumps=(INT32 *)xalloc(sizeof(INT32) * (max_label+2));    uses=(INT32 *)xalloc(sizeof(INT32) * (max_label+2));       while(reoptimize)    {    reoptimize=0;    for(e=0;e<=max_label;e++)    {    labels[e]=jumps[e]=-1;