7d7d7e1999-01-31Fredrik Hübinette (Hubbe) #undef GET_ARG #undef GET_ARG2 #ifdef PIKE_DEBUG #define GET_ARG() (backlog[backlogp].arg=(\ instr=prefix,\ prefix=0,\ 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 static int eval_instruction(unsigned char *pc) { unsigned INT32 accumulator=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;
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  instr=EXTRACT_UCHAR(pc++); #ifdef PIKE_DEBUG if(d_flag) {
dcbfa71999-05-07Fredrik Hübinette (Hubbe) #ifdef _REENTRANT #ifndef __NT__
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  if(!mt_trylock(& interpreter_lock)) fatal("Interpreter running unlocked!\n"); #endif
dcbfa71999-05-07Fredrik Hübinette (Hubbe)  if(d_flag>1 && thread_for_id(th_self()) != thread_id) fatal("thread_for_id() (or thread_id) failed in interpreter.h! %p != %p\n",thread_for_id(th_self()),thread_id); #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) 
a2ad152000-02-16Fredrik Hübinette (Hubbe)  if(Pike_sp<Pike_evaluator_stack || Pike_mark_sp < Pike_mark_stack || Pike_fp->locals>Pike_sp)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  fatal("Stack error (generic).\n");
a2ad152000-02-16Fredrik Hübinette (Hubbe)  if(Pike_sp > Pike_evaluator_stack+Pike_stack_size)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  fatal("Stack error (overflow).\n");
a2ad152000-02-16Fredrik Hübinette (Hubbe)  if(Pike_fp->fun>=0 && Pike_fp->current_object->prog && Pike_fp->locals+Pike_fp->num_locals > Pike_sp)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  fatal("Stack error (stupid!).\n");
a2ad152000-02-16Fredrik Hübinette (Hubbe)  if(recoveries && Pike_sp-Pike_evaluator_stack < recoveries->Pike_sp)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  fatal("Stack error (underflow).\n");
a2ad152000-02-16Fredrik Hübinette (Hubbe)  if(Pike_mark_sp > Pike_mark_stack && Pike_mark_sp[-1] > Pike_sp)
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  fatal("Stack error (underflow?)\n"); if(d_flag > 9) do_debug(); backlogp++; if(backlogp >= BACKLOG) backlogp=0; if(backlog[backlogp].program) free_program(backlog[backlogp].program);
a2ad152000-02-16Fredrik Hübinette (Hubbe)  backlog[backlogp].program=Pike_fp->context.prog; add_ref(Pike_fp->context.prog);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  backlog[backlogp].instruction=instr; backlog[backlogp].arg=0; backlog[backlogp].pc=pc;
e1fed61999-09-09Fredrik Hübinette (Hubbe) 
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)  } if(t_flag > 2) { char *file, *f; INT32 linep;
a2ad152000-02-16Fredrik Hübinette (Hubbe)  file=get_line(pc-1,Pike_fp->context.prog,&linep);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  while((f=STRCHR(file,'/'))) file=f+1; fprintf(stderr,"- %s:%4ld:(%lx): %-25s %4ld %4ld\n", file,(long)linep,
a2ad152000-02-16Fredrik Hübinette (Hubbe)  (long)(pc-Pike_fp->context.prog->program-1),
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  get_f_name(instr + F_OFFSET),
a2ad152000-02-16Fredrik Hübinette (Hubbe)  (long)(Pike_sp-Pike_evaluator_stack), (long)(Pike_mark_sp-Pike_mark_stack));
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  } if(instr + F_OFFSET < F_MAX_OPCODE) ADD_RUNNED(instr + F_OFFSET); #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); prefix+=EXTRACT_UCHAR(pc++)<<24; CASE(F_PREFIX_WORDX256); prefix+=EXTRACT_UCHAR(pc++)<<16; CASE(F_PREFIX_CHARX256); prefix+=EXTRACT_UCHAR(pc++)<<8; break; CASE(F_LDA); accumulator=GET_ARG(); break;
87c7592000-04-18Fredrik Hübinette (Hubbe) #define INTERPRETER
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
87c7592000-04-18Fredrik Hübinette (Hubbe) #define OPCODE0(OP,DESC) CASE(OP); { #define OPCODE1(OP,DESC) CASE(OP); { \ INT32 arg1=GET_ARG();
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
c117392000-04-18Henrik Grubbström (Grubba) #define OPCODE1ACK(OP,DESC) CASE(OP); { \ INT32 arg1=GET_ARG(); \ INT32 ack=accumulator;
87c7592000-04-18Fredrik Hübinette (Hubbe) #define OPCODE2(OP,DESC) CASE(OP); { \ INT32 arg1=GET_ARG(); \
c117392000-04-18Henrik Grubbström (Grubba)  INT32 arg2=GET_ARG2();
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
87c7592000-04-18Fredrik Hübinette (Hubbe) #define OPCODE0_TAIL(OP,DESC) CASE(OP); #define OPCODE1_TAIL(OP,DESC) CASE(OP);
c117392000-04-18Henrik Grubbström (Grubba) #define OPCODE1ACK_TAIL(OP,DESC) CASE(OP);
87c7592000-04-18Fredrik Hübinette (Hubbe) #define OPCODE2_TAIL(OP,DESC) CASE(OP);
7d7d7e1999-01-31Fredrik Hübinette (Hubbe) 
87c7592000-04-18Fredrik Hübinette (Hubbe) #define BREAK break; } #include "interpret_functions.h"
7d7d7e1999-01-31Fredrik Hübinette (Hubbe)  default: fatal("Strange instruction %ld\n",(long)instr); } } }