Branch: Tag:

2000-12-01

2000-12-01 01:13:46 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

branch unwinding implemented, will help performance of loops using BREAK a lot

Rev: src/docode.c:1.85
Rev: src/opcodes.h:1.7
Rev: src/peep.c:1.41
Rev: src/peep.h:1.7
Rev: src/peep.in:1.42

15:   #include "bignum.h"   #include "opcodes.h"    - RCSID("$Id: peep.c,v 1.40 2000/11/28 02:19:16 hubbe Exp $"); + RCSID("$Id: peep.c,v 1.41 2000/12/01 01:13:45 hubbe Exp $");    - struct p_instr_s - { -  short opcode; -  short line; -  struct pike_string *file; -  INT32 arg; -  INT32 arg2; - }; -  - typedef struct p_instr_s p_instr; +    static void asm_opt(void);      dynamic_buffer instrbuf;
225:    INT32 *labels, *jumps, *uses;    ptrdiff_t e, length;    p_instr *c; +  int reoptimize=1;       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);
240:    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;
308:    }       for(e=0;e<=max_label;e++) +  {    if(!uses[e] && labels[e]>=0) -  +  {    c[labels[e]].opcode=F_NOP; -  +  reoptimize++; +  } +  } +  if(!reoptimize) break;       asm_opt(); -  +  reoptimize=0; +  }       c=(p_instr *)instrbuf.s.str;    length=instrbuf.s.len / sizeof(p_instr);
337:    switch(c->opcode)    {    case F_NOP: +  case F_NOTREACHED:    case F_START_FUNCTION:    break;    case F_ALIGN: