Branch: Tag:

1998-05-12

1998-05-12 23:51:27 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

some optimizations

Rev: src/global.h:1.22
Rev: src/interpret.c:1.81
Rev: src/language.yacc:1.96
Rev: src/las.c:1.62
Rev: src/lex.c:1.53
Rev: src/peep.c:1.24
Rev: src/peep.in:1.15
Rev: src/testsuite.in:1.105

4:   ||| See the files COPYING and DISCLAIMER for more information.   \*/   #include "global.h" - RCSID("$Id: interpret.c,v 1.80 1998/04/20 18:43:08 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.81 1998/05/12 23:51:23 hubbe Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
388:    instr+=EXTRACT_UCHAR(pc++),\    (t_flag>3 ? sprintf(trace_buffer,"- Arg = %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\    instr)) + #define GET_ARG2() (\ +  instr=EXTRACT_UCHAR(pc++),\ +  (t_flag>3 ? sprintf(trace_buffer,"- Arg2= %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\ +  instr)    -  +    #else   #define GET_ARG() (instr=prefix,prefix=0,instr+EXTRACT_UCHAR(pc++)) -  + #define GET_ARG2() EXTRACT_UCHAR(pc++)   #endif      #define CASE(X) case (X)-F_OFFSET:
741:    CASE(F_2_LOCALS);    assign_svalue_no_free(sp++,fp->locals+GET_ARG());    print_return_value(); -  assign_svalue_no_free(sp++,fp->locals+GET_ARG()); +  assign_svalue_no_free(sp++,fp->locals+GET_ARG2());    print_return_value();    break;    -  +  CASE(F_LOCAL_2_LOCAL); +  { +  int tmp=GET_ARG(); +  assign_svalue(fp->locals+tmp, fp->locals+GET_ARG2()); +  break; +  }    -  +  CASE(F_LOCAL_2_GLOBAL); +  { +  INT32 tmp=GET_ARG() + fp->context.identifier_level; +  struct identifier *i; +  +  if(!fp->current_object->prog) +  error("Cannot access global variables in destructed object.\n"); +  +  i=ID_FROM_INT(fp->current_object->prog, tmp); +  if(!IDENTIFIER_IS_VARIABLE(i->identifier_flags)) +  error("Cannot assign functions or constants.\n"); +  if(i->run_time_type == T_MIXED) +  { +  assign_svalue((struct svalue *)GLOBAL_FROM_INT(tmp), fp->locals + GET_ARG2()); +  }else{ +  assign_to_short_svalue((union anything *)GLOBAL_FROM_INT(tmp), +  i->run_time_type, +  fp->locals + GET_ARG2()); +  } +  break; +  } +  +  CASE(F_GLOBAL_2_LOCAL); +  { +  INT32 tmp=GET_ARG() + fp->context.identifier_level; +  INT32 tmp2=GET_ARG2(); +  free_svalue(fp->locals + tmp2); +  low_object_index_no_free(fp->locals + tmp2, +  fp->current_object, +  tmp); +  break; +  } +     CASE(F_LOCAL_LVALUE);    sp[0].type=T_LVALUE;    sp[0].u.lval=fp->locals+GET_ARG();
1149:    DOJUMP();    break;    +  CASE(F_BRANCH_IF_NOT_LOCAL_ARROW); +  { +  struct svalue tmp; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  sp->type=T_INT; +  sp++; +  index_no_free(sp-1,fp->locals+GET_ARG2() , &tmp); +  print_return_value(); +  } +  +  /* Fall through */ +     CASE(F_BRANCH_WHEN_ZERO);    if(!IS_ZERO(sp-1))    {
1179:    }    break;    +  CASE(F_BRANCH_IF_NOT_LOCAL); +  instr=GET_ARG(); +  if(!IS_ZERO(fp->locals + instr)) +  { +  pc+=sizeof(INT32); +  }else{ +  DOJUMP(); +  } +  break; +     CJUMP(F_BRANCH_WHEN_EQ, is_eq);    CJUMP(F_BRANCH_WHEN_NE,!is_eq);    CJUMP(F_BRANCH_WHEN_LT, is_lt);
1434:    struct svalue *s=fp->locals+GET_ARG();    if(s->type == T_STRING) s->subtype=0;    sp++->type=T_INT; -  index_no_free(sp-1,fp->locals+GET_ARG(),s); +  index_no_free(sp-1,fp->locals+GET_ARG2(),s);    break;    }   
1448:    break;    }    -  CASE(F_POS_INT_INDEX); -  push_int(GET_ARG()); -  print_return_value(); -  goto do_index; +  CASE(F_GLOBAL_LOCAL_INDEX); +  { +  struct svalue tmp,*s; +  low_object_index_no_free(sp, +  fp->current_object, +  GET_ARG() + fp->context.identifier_level); +  sp++; +  s=fp->locals+GET_ARG2(); +  if(s->type == T_STRING) s->subtype=0; +  index_no_free(&tmp,sp-1,s); +  free_svalue(sp-1); +  sp[-1]=tmp; +  break; +  }    -  CASE(F_NEG_INT_INDEX); -  push_int(-GET_ARG()); +  CASE(F_LOCAL_ARROW); +  { +  struct svalue tmp; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  sp->type=T_INT; +  sp++; +  index_no_free(sp-1,fp->locals+GET_ARG2() , &tmp);    print_return_value(); -  goto do_index; +  break; +  }       CASE(F_ARROW); -  copy_shared_string(sp->u.string,fp->context.prog->strings[GET_ARG()]); -  sp->type=T_STRING; -  sp->subtype=1; -  sp++; +  { +  struct svalue tmp,tmp2; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=1; +  index_no_free(&tmp2, sp-1, &tmp); +  free_svalue(sp-1); +  sp[-1]=tmp2;    print_return_value(); -  goto do_index; +  break; +  }       CASE(F_STRING_INDEX); -  copy_shared_string(sp->u.string,fp->context.prog->strings[GET_ARG()]); -  sp->type=T_STRING; -  sp->subtype=0; -  sp++; +  { +  struct svalue tmp,tmp2; +  tmp.type=T_STRING; +  tmp.u.string=fp->context.prog->strings[GET_ARG()]; +  tmp.subtype=0; +  index_no_free(&tmp2, sp-1, &tmp); +  free_svalue(sp-1); +  sp[-1]=tmp2;    print_return_value(); -  /* Fall through */ +  break; +  }    -  +  CASE(F_POS_INT_INDEX); +  push_int(GET_ARG()); +  print_return_value(); +  goto do_index; +  +  CASE(F_NEG_INT_INDEX); +  push_int(-GET_ARG()); +  print_return_value(); +     CASE(F_INDEX);    do_index:    o_index();