7951942000-04-20Fredrik Hübinette (Hubbe) 
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) #undef GET_ARG #undef GET_ARG2
388f0d2001-01-31Martin Stjernholm #undef GET_JUMP #undef SKIPJUMP
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  #ifdef PIKE_DEBUG #define GET_ARG() (backlog[backlogp].arg=(\ instr=prefix,\ prefix=0,\
610d052001-07-06Henrik Grubbström (Grubba)  instr += (pc++)[0],\
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  (t_flag>3 ? sprintf(trace_buffer,"- Arg = %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\ instr))
a96ce92000-04-19Fredrik Hübinette (Hubbe) 
c7ef072000-04-21Fredrik Hübinette (Hubbe) #define GET_ARG2() (backlog[backlogp].arg2=(\
a96ce92000-04-19Fredrik Hübinette (Hubbe)  instr=prefix2,\ prefix2=0,\
610d052001-07-06Henrik Grubbström (Grubba)  instr += (pc++)[0],\
388f0d2001-01-31Martin Stjernholm  (t_flag>3 ? sprintf(trace_buffer,"- Arg2 = %ld\n",(long)instr),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\
c7ef072000-04-21Fredrik Hübinette (Hubbe)  instr))
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
388f0d2001-01-31Martin Stjernholm #define GET_JUMP() (backlog[backlogp].arg=(\ (t_flag>3 ? sprintf(trace_buffer,"- Target = %+ld\n",(long)EXTRACT_INT(pc)),write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0),\ EXTRACT_INT(pc))) #define SKIPJUMP() (GET_JUMP(), pc+=sizeof(INT32))
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) #else
610d052001-07-06Henrik Grubbström (Grubba)  #define GET_ARG() (instr=prefix,prefix=0,instr+(pc++)[0]) #define GET_ARG2() (instr=prefix2,prefix2=0,instr+(pc++)[0])
388f0d2001-01-31Martin Stjernholm #define GET_JUMP() EXTRACT_INT(pc) #define SKIPJUMP() pc+=sizeof(INT32)
610d052001-07-06Henrik Grubbström (Grubba) 
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) #endif
388f0d2001-01-31Martin Stjernholm #define DOJUMP() \ do { int tmp; tmp=GET_JUMP(); pc+=tmp; if(tmp < 0) fast_check_threads_etc(6); }while(0)
d49add2001-04-25Fredrik Hübinette (Hubbe) #ifndef STEP_BREAK_LINE #define STEP_BREAK_LINE #endif
610d052001-07-06Henrik Grubbström (Grubba) static int eval_instruction(PIKE_OPCODE_T *pc)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) {
a96ce92000-04-19Fredrik Hübinette (Hubbe)  unsigned INT32 prefix2=0,instr, prefix=0;
a2ad152000-02-16Fredrik Hübinette (Hubbe)  debug_malloc_touch(Pike_fp);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  while(1) {
a2ad152000-02-16Fredrik Hübinette (Hubbe)  Pike_fp->pc = pc;
610d052001-07-06Henrik Grubbström (Grubba)  instr = (pc++)[0];
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
d49add2001-04-25Fredrik Hübinette (Hubbe)  STEP_BREAK_LINE
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) #ifdef PIKE_DEBUG
610d052001-07-06Henrik Grubbström (Grubba) 
388f0d2001-01-31Martin Stjernholm  if(t_flag > 2) { char *file, *f; INT32 linep;
610d052001-07-06Henrik Grubbström (Grubba)  file = get_line(pc-1,Pike_fp->context.prog,&linep);
388f0d2001-01-31Martin Stjernholm  while((f=STRCHR(file,'/'))) file=f+1; fprintf(stderr,"- %s:%4ld:(%lx): %-25s %4ld %4ld\n", file,(long)linep, DO_NOT_WARN((long)(pc-Pike_fp->context.prog->program-1)), get_f_name(instr + F_OFFSET), DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)), DO_NOT_WARN((long)(Pike_mark_sp-Pike_interpreter.mark_stack))); } if(instr + F_OFFSET < F_MAX_OPCODE) ADD_RUNNED(instr + F_OFFSET);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  if(d_flag) {
388f0d2001-01-31Martin Stjernholm  backlogp++; if(backlogp >= BACKLOG) backlogp=0; if(backlog[backlogp].program) free_program(backlog[backlogp].program); backlog[backlogp].program=Pike_fp->context.prog; add_ref(Pike_fp->context.prog); backlog[backlogp].instruction=instr; backlog[backlogp].pc=pc; backlog[backlogp].stack = Pike_sp - Pike_interpreter.evaluator_stack; backlog[backlogp].mark_stack = Pike_mark_sp - Pike_interpreter.mark_stack; #ifdef _REENTRANT backlog[backlogp].thread_id=Pike_interpreter.thread_id; #endif
dcbfa71999-05-07Fredrik Hübinette (Hubbe) #ifdef _REENTRANT
c91f892000-04-19Martin Stjernholm  CHECK_INTERPRETER_LOCK();
f077582000-07-06Fredrik Hübinette (Hubbe)  if(OBJ2THREAD(Pike_interpreter.thread_id)->state.thread_id != Pike_interpreter.thread_id) fatal("Arglebargle glop glyf, thread swap problem!\n"); if(d_flag>1 && thread_for_id(th_self()) != Pike_interpreter.thread_id) fatal("thread_for_id() (or Pike_interpreter.thread_id) failed in interpreter.h! %p != %p\n",thread_for_id(th_self()),Pike_interpreter.thread_id);
dcbfa71999-05-07Fredrik Hübinette (Hubbe) #endif
a2ad152000-02-16Fredrik Hübinette (Hubbe)  Pike_sp[0].type=99; /* an invalid type */ Pike_sp[1].type=99; Pike_sp[2].type=99; Pike_sp[3].type=99;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
17f08c2000-07-06Fredrik Hübinette (Hubbe)  if(Pike_sp<Pike_interpreter.evaluator_stack || Pike_mark_sp < Pike_interpreter.mark_stack || Pike_fp->locals>Pike_sp)
a4a1722000-12-05Per Hedbor  fatal("Stack error (generic) sp=%p/%p mark_sp=%p/%p locals=%p.\n",
c7ef072000-04-21Fredrik Hübinette (Hubbe)  Pike_sp,
f077582000-07-06Fredrik Hübinette (Hubbe)  Pike_interpreter.evaluator_stack,
17f08c2000-07-06Fredrik Hübinette (Hubbe)  Pike_mark_sp,
f077582000-07-06Fredrik Hübinette (Hubbe)  Pike_interpreter.mark_stack,
c7ef072000-04-21Fredrik Hübinette (Hubbe)  Pike_fp->locals);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
17f08c2000-07-06Fredrik Hübinette (Hubbe)  if(Pike_mark_sp > Pike_interpreter.mark_stack+Pike_stack_size)
a4a1722000-12-05Per Hedbor  fatal("Mark Stack error (overflow).\n");
f077582000-07-06Fredrik Hübinette (Hubbe) 
17f08c2000-07-06Fredrik Hübinette (Hubbe)  if(Pike_mark_sp < Pike_interpreter.mark_stack)
a4a1722000-12-05Per Hedbor  fatal("Mark Stack error (underflow).\n");
f077582000-07-06Fredrik Hübinette (Hubbe)  if(Pike_sp > Pike_interpreter.evaluator_stack+Pike_stack_size)
a4a1722000-12-05Per Hedbor  fatal("stack error (overflow).\n");
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
a96ce92000-04-19Fredrik Hübinette (Hubbe)  if(/* Pike_fp->fun>=0 && */ Pike_fp->current_object->prog &&
a2ad152000-02-16Fredrik Hübinette (Hubbe)  Pike_fp->locals+Pike_fp->num_locals > Pike_sp)
a4a1722000-12-05Per Hedbor  fatal("Stack error (stupid!).\n");
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
f077582000-07-06Fredrik Hübinette (Hubbe)  if(Pike_interpreter.recoveries && Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)
a4a1722000-12-05Per Hedbor  fatal("Stack error (underflow).\n");
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
17f08c2000-07-06Fredrik Hübinette (Hubbe)  if(Pike_mark_sp > Pike_interpreter.mark_stack && Pike_mark_sp[-1] > Pike_sp)
a4a1722000-12-05Per Hedbor  fatal("Stack error (underflow?)\n");
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  if(d_flag > 9) do_debug();
a2ad152000-02-16Fredrik Hübinette (Hubbe)  debug_malloc_touch(Pike_fp->current_object);
b040a21999-09-14Fredrik Hübinette (Hubbe)  switch(d_flag) { default: case 3:
a2ad152000-02-16Fredrik Hübinette (Hubbe)  check_object(Pike_fp->current_object);
8f29a31999-09-15Fredrik Hübinette (Hubbe) /* break; */
b040a21999-09-14Fredrik Hübinette (Hubbe)  case 2:
a2ad152000-02-16Fredrik Hübinette (Hubbe)  check_object_context(Pike_fp->current_object, Pike_fp->context.prog,
60d9872000-03-23Fredrik Hübinette (Hubbe)  CURRENT_STORAGE);
b040a21999-09-14Fredrik Hübinette (Hubbe)  case 1: case 0: break; }
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  } #endif switch(instr) { /* Support to allow large arguments */ CASE(F_PREFIX_256); prefix+=256; break; CASE(F_PREFIX_512); prefix+=512; break; CASE(F_PREFIX_768); prefix+=768; break; CASE(F_PREFIX_1024); prefix+=1024; break; CASE(F_PREFIX_24BITX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix += (pc++)[0]<<24;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  CASE(F_PREFIX_WORDX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix += (pc++)[0]<<16;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  CASE(F_PREFIX_CHARX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix += (pc++)[0]<<8;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  break;
a96ce92000-04-19Fredrik Hübinette (Hubbe)  /* Support to allow large arguments */ CASE(F_PREFIX2_256); prefix2+=256; break; CASE(F_PREFIX2_512); prefix2+=512; break; CASE(F_PREFIX2_768); prefix2+=768; break; CASE(F_PREFIX2_1024); prefix2+=1024; break; CASE(F_PREFIX2_24BITX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix2 += (pc++)[0]<<24;
a96ce92000-04-19Fredrik Hübinette (Hubbe)  CASE(F_PREFIX2_WORDX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix2 += (pc++)[0]<<16;
a96ce92000-04-19Fredrik Hübinette (Hubbe)  CASE(F_PREFIX2_CHARX256);
610d052001-07-06Henrik Grubbström (Grubba)  prefix2 += (pc++)[0]<<8;
a96ce92000-04-19Fredrik Hübinette (Hubbe)  break;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
87c7592000-04-18Fredrik Hübinette (Hubbe) #define INTERPRETER
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
610d052001-07-06Henrik Grubbström (Grubba) #define OPCODE0(OP, DESC, CODE) CASE(OP); CODE; break #define OPCODE1(OP, DESC, CODE) CASE(OP); { \ INT32 arg1=GET_ARG(); \ CODE; \ } break
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
610d052001-07-06Henrik Grubbström (Grubba) #define OPCODE2(OP, DESC, CODE) CASE(OP); { \ INT32 arg1=GET_ARG(); \ INT32 arg2=GET_ARG2(); \ CODE; \ } break
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
610d052001-07-06Henrik Grubbström (Grubba) #define OPCODE0_TAIL(OP, DESC, CODE) CASE(OP); CODE #define OPCODE1_TAIL(OP, DESC, CODE) CASE(OP); CODE #define OPCODE2_TAIL(OP, DESC, CODE) CASE(OP); CODE
7951942000-04-20Fredrik Hübinette (Hubbe) 
610d052001-07-06Henrik Grubbström (Grubba) #define OPCODE0_JUMP(OP, DESC, CODE) CASE(OP); CODE; break #define OPCODE0_TAILJUMP(OP, DESC, CODE) CASE(OP); CODE
7951942000-04-20Fredrik Hübinette (Hubbe)  /* These are something of a special case as they * requires a POINTER stored explicitly after * the instruction itself. */
610d052001-07-06Henrik Grubbström (Grubba) #define OPCODE1_JUMP(OP, DESC, CODE) CASE(OP); { \ INT32 arg1=GET_ARG(); \ CODE; \ } break #define OPCODE2_JUMP(OP, DESC, CODE) CASE(OP); { \ INT32 arg1=GET_ARG(); \ INT32 arg2=GET_ARG2(); \ CODE; \ } break #define OPCODE1_TAILJUMP(OP, DESC, CODE) CASE(OP); CODE #define OPCODE2_TAILJUMP(OP, DESC, CODE) CASE(OP); CODE
7951942000-04-20Fredrik Hübinette (Hubbe) 
87c7592000-04-18Fredrik Hübinette (Hubbe) #define BREAK break; }
a64f6b2001-01-12Martin Stjernholm #define DONE break
87c7592000-04-18Fredrik Hübinette (Hubbe) #include "interpret_functions.h"
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  default: fatal("Strange instruction %ld\n",(long)instr); } } }
7965d72001-01-24Fredrik Hübinette (Hubbe)