pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:1:   /* -  * $Id: interpret_functions.h,v 1.77 2001/07/17 17:50:38 grubba Exp $ +  * $Id: interpret_functions.h,v 1.78 2001/07/18 11:36:01 grubba Exp $    *    * Opcode definitions for the interpreter.    */      #include "global.h"      #undef CJUMP   #undef AUTO_BIGNUM_LOOP_TEST   #undef LOOP   #undef COMPARISON
pike.git/src/interpret_functions.h:75:   #else /* !PIKE_DEBUG */      #define GET_JUMP() LOW_GET_JUMP()   #define SKIPJUMP() LOW_SKIPJUMP()      #endif /* PIKE_DEBUG */      #define DOJUMP() do { \    INT32 tmp; \    tmp = GET_JUMP(); \ -  PROG_COUNTER += tmp; \ +  SET_PROG_COUNTER(PROG_COUNTER + tmp); \    FETCH; \    if(tmp < 0) \    fast_check_threads_etc(6); \    } while(0)      #endif /* OVERRIDE_JUMPS */         /* WARNING:    * The surgeon general has stated that define code blocks    * without do{}while() can be hazardous to your health.    * However, in this case it is required to handle break    * properly. -Hubbe    */   #undef DO_DUMB_RETURN   #define DO_DUMB_RETURN { \    if(Pike_fp -> flags & PIKE_FRAME_RETURN_INTERNAL) \    { \    int f=Pike_fp->flags; \    low_return(); \ -  PROG_COUNTER=Pike_fp->pc; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    if(f & PIKE_FRAME_RETURN_POP) \    pop_stack(); \    DONE; \    } \    INTER_RETURN; \   }      #undef DO_RETURN   #ifndef PIKE_DEBUG
pike.git/src/interpret_functions.h:217:    index_no_free(&tmp, Pike_sp-1, &tmp2);    }    free_svalue(Pike_sp-1);    Pike_sp[-1] = tmp;    print_return_value();   });      OPCODE0(F_FLOAT, "push float", {    /* FIXME, this opcode uses 'PROG_COUNTER' which is not allowed.. */    MEMCPY((void *)&Pike_sp->u.float_number, PROG_COUNTER, sizeof(FLOAT_TYPE)); -  PROG_COUNTER += DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(FLOAT_TYPE)); +  SET_PROG_COUNTER(PROG_COUNTER + +  DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(FLOAT_TYPE)));    FETCH;    Pike_sp->type=PIKE_T_FLOAT;    Pike_sp++;   });      OPCODE1(F_LFUN, "local function", {    Pike_sp->u.object=Pike_fp->current_object;    add_ref(Pike_fp->current_object);    Pike_sp->subtype=arg1+Pike_fp->context.identifier_level;    Pike_sp->type=PIKE_T_FUNCTION;
pike.git/src/interpret_functions.h:1087:    }   });      OPCODE0_JUMP(F_CATCH, "catch", {    switch (o_catch(PROG_COUNTER+DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32))))    {    case 1:    /* There was a return inside the evaluated code */    DO_DUMB_RETURN;    case 2: -  PROG_COUNTER = Pike_fp->pc; +  SET_PROG_COUNTER(Pike_fp->pc);    break;    default: -  PROG_COUNTER += GET_JUMP(); +  SET_PROG_COUNTER(PROG_COUNTER + GET_JUMP());    }    FETCH;   });      OPCODE0(F_ESCAPE_CATCH, "escape catch", {    Pike_fp->pc = PROG_COUNTER;    INTER_ESCAPE_CATCH;   });      OPCODE0(F_THROW_ZERO, "throw(0)", {    push_int(0);    f_throw(1);   });      OPCODE1(F_SWITCH, "switch", {    INT32 tmp; -  +  PIKE_OPCODE_T *addr = PROG_COUNTER;    tmp=switch_lookup(Pike_fp->context.prog->    constants[arg1].sval.u.array,Pike_sp-1); -  PROG_COUNTER = DO_IF_ELSE_COMPUTED_GOTO(PROG_COUNTER, (PIKE_OPCODE_T *) -  DO_ALIGN(PROG_COUNTER,((ptrdiff_t)sizeof(INT32)))); -  PROG_COUNTER += (tmp>=0 ? 1+tmp*2 : 2*~tmp) * -  DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); -  if(*(INT32*)PROG_COUNTER < 0) fast_check_threads_etc(7); -  PROG_COUNTER += *(INT32*)PROG_COUNTER; +  addr = DO_IF_ELSE_COMPUTED_GOTO(addr, (PIKE_OPCODE_T *) +  DO_ALIGN(addr,((ptrdiff_t)sizeof(INT32)))); +  addr = (PIKE_OPCODE_T *)(((INT32 *)addr) + (tmp>=0 ? 1+tmp*2 : 2*~tmp)); +  if(*(INT32*)addr < 0) fast_check_threads_etc(7); +  SET_PROG_COUNTER(addr + *(INT32*)addr);    FETCH;    pop_stack();   });      OPCODE1(F_SWITCH_ON_INDEX, "switch on index", {    INT32 tmp;    struct svalue s; -  +  PIKE_OPCODE_T *addr = PROG_COUNTER;    index_no_free(&s,Pike_sp-2,Pike_sp-1);    Pike_sp++[0]=s;       tmp=switch_lookup(Pike_fp->context.prog->    constants[arg1].sval.u.array,Pike_sp-1);    pop_n_elems(3); -  PROG_COUNTER = DO_IF_ELSE_COMPUTED_GOTO(PROG_COUNTER, (PIKE_OPCODE_T *) -  DO_ALIGN(PROG_COUNTER,((ptrdiff_t)sizeof(INT32)))); -  PROG_COUNTER += (tmp>=0 ? 1+tmp*2 : 2*~tmp) * -  DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); -  if(*(INT32*)PROG_COUNTER < 0) fast_check_threads_etc(7); -  PROG_COUNTER+=*(INT32*)PROG_COUNTER; +  addr = DO_IF_ELSE_COMPUTED_GOTO(addr, (PIKE_OPCODE_T *) +  DO_ALIGN(addr,((ptrdiff_t)sizeof(INT32)))); +  addr = (PIKE_OPCODE_T *)(((INT32 *)addr) + (tmp>=0 ? 1+tmp*2 : 2*~tmp)); +  if(*(INT32*)addr < 0) fast_check_threads_etc(7); +  SET_PROG_COUNTER(addr + *(INT32*)addr);    FETCH;   });      OPCODE2(F_SWITCH_ON_LOCAL, "switch on local", {    INT32 tmp; -  +  PIKE_OPCODE_T *addr = PROG_COUNTER;    tmp=switch_lookup(Pike_fp->context.prog->    constants[arg2].sval.u.array,Pike_fp->locals + arg1); -  PROG_COUNTER = DO_IF_ELSE_COMPUTED_GOTO(PROG_COUNTER, (PIKE_OPCODE_T *) -  DO_ALIGN(PROG_COUNTER,((ptrdiff_t)sizeof(INT32)))); -  PROG_COUNTER += (tmp>=0 ? 1+tmp*2 : 2*~tmp) * -  DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); -  if(*(INT32*)PROG_COUNTER < 0) fast_check_threads_etc(7); -  PROG_COUNTER+=*(INT32*)PROG_COUNTER; +  addr = DO_IF_ELSE_COMPUTED_GOTO(addr, (PIKE_OPCODE_T *) +  DO_ALIGN(addr,((ptrdiff_t)sizeof(INT32)))); +  addr = (PIKE_OPCODE_T *)(((INT32 *)addr) + (tmp>=0 ? 1+tmp*2 : 2*~tmp)); +  if(*(INT32*)addr < 0) fast_check_threads_etc(7); +  SET_PROG_COUNTER(addr + *(INT32*)addr);    FETCH;   });         #ifdef AUTO_BIGNUM   #define AUTO_BIGNUM_LOOP_TEST(X,Y) INT_TYPE_ADD_OVERFLOW(X,Y)   #else   #define AUTO_BIGNUM_LOOP_TEST(X,Y) 0   #endif   
pike.git/src/interpret_functions.h:1688:      OPCODE1(F_SSCANF, "sscanf", {    o_sscanf(arg1);   });      #define MKAPPLY(OP,OPCODE,NAME,TYPE, ARG2, ARG3) \   OP(PIKE_CONCAT(F_,OPCODE),NAME, { \   if(low_mega_apply(TYPE,DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)), \    ARG2, ARG3)) \   { \ -  Pike_fp->next->pc=PROG_COUNTER; \ -  PROG_COUNTER=Pike_fp->pc; \ +  Pike_fp->next->pc=PROG_COUNTER; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; \   } \   }); \    \   OP(PIKE_CONCAT3(F_,OPCODE,_AND_POP),NAME " & pop", { \    if(low_mega_apply(TYPE, DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)), \    ARG2, ARG3)) \    { \    Pike_fp->next->pc=PROG_COUNTER; \ -  PROG_COUNTER=Pike_fp->pc; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL | PIKE_FRAME_RETURN_POP; \    }else{ \    pop_stack(); \    } \   }); \    \   OP(PIKE_CONCAT3(F_,OPCODE,_AND_RETURN),NAME " & return", { \    if(low_mega_apply(TYPE,DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)), \    ARG2,ARG3)) \    { \    DO_IF_DEBUG(Pike_fp->next->pc=0); \ -  PROG_COUNTER=Pike_fp->pc; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    unlink_previous_frame(); \    }else{ \    DO_DUMB_RETURN; \    } \   }); \    \   OP(PIKE_CONCAT(F_MARK_,OPCODE),"mark, " NAME, { \    if(low_mega_apply(TYPE,0, \    ARG2, ARG3)) \    { \    Pike_fp->next->pc=PROG_COUNTER; \ -  PROG_COUNTER=Pike_fp->pc; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; \    } \   }); \    \   OP(PIKE_CONCAT3(F_MARK_,OPCODE,_AND_POP),"mark, " NAME " & pop", { \    if(low_mega_apply(TYPE, 0, \    ARG2, ARG3)) \    { \ -  Pike_fp->next->pc=PROG_COUNTER; \ -  PROG_COUNTER=Pike_fp->pc; \ +  Pike_fp->next->pc=PROG_COUNTER; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL | PIKE_FRAME_RETURN_POP; \    }else{ \    pop_stack(); \    } \   }); \    \   OP(PIKE_CONCAT3(F_MARK_,OPCODE,_AND_RETURN),"mark, " NAME " & return", { \    if(low_mega_apply(TYPE,0, \    ARG2,ARG3)) \    { \    DO_IF_DEBUG(Pike_fp->next->pc=0); \ -  PROG_COUNTER=Pike_fp->pc; \ +  SET_PROG_COUNTER(Pike_fp->pc); \    FETCH; \    unlink_previous_frame(); \    }else{ \    DO_DUMB_RETURN; \    } \   })         MKAPPLY(OPCODE1,CALL_LFUN,"call lfun",APPLY_LOW,    Pike_fp->current_object,
pike.git/src/interpret_functions.h:1855:      /* Assume that the number of arguments is correct */   OPCODE1_JUMP(F_COND_RECUR, "recur if not overloaded", {    /* FIXME:    * this test should actually test if this function is    * overloaded or not. Currently it only tests if    * this context is inherited or not.    */    if(Pike_fp->current_object->prog != Pike_fp->context.prog)    { -  PROG_COUNTER += DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); +  SET_PROG_COUNTER(PROG_COUNTER + +  DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)));    if(low_mega_apply(APPLY_LOW,    DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)),    Pike_fp->current_object,    (void *)(arg1+Pike_fp->context.identifier_level)))    {    Pike_fp->next->pc=PROG_COUNTER; -  PROG_COUNTER=Pike_fp->pc; +  SET_PROG_COUNTER(Pike_fp->pc);    FETCH;    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL;    } else {    FETCH;    }    DONE;    }       /* FALL THROUGH */   
pike.git/src/interpret_functions.h:1916:    new_frame->num_args,    DO_IF_ELSE_COMPUTED_GOTO((ptrdiff_t)addr[-1],    EXTRACT_UCHAR(addr-1)));       if(t_flag > 3)    fprintf(stderr,"- Allocating %d extra locals.\n",    new_frame->num_locals - new_frame->num_args);    });       Pike_fp->pc = PROG_COUNTER + DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); -  PROG_COUNTER=addr; +  SET_PROG_COUNTER(addr);    FETCH;       clear_svalues(Pike_sp, new_frame->num_locals - new_frame->num_args);    Pike_sp += new_frame->num_locals - new_frame->args;       if(new_frame->scope) add_ref(new_frame->scope);    add_ref(new_frame->current_object);    add_ref(new_frame->context.prog);    if(new_frame->context.parent)    add_ref(new_frame->context.parent);
pike.git/src/interpret_functions.h:1960:    DO_NOT_WARN((INT32)(Pike_sp - new_frame->locals));    new_frame->save_mark_sp = Pike_mark_sp;    new_frame->mark_sp_base = Pike_mark_sp;       addr = PROG_COUNTER+GET_JUMP();    new_frame->num_locals =    DO_IF_ELSE_COMPUTED_GOTO((ptrdiff_t)addr[-2],    EXTRACT_UCHAR(addr-2));       DO_IF_DEBUG({ -  if(new_frame->num_args != -  DO_IF_ELSE_COMPUTED_GOTO((ptrdiff_t)addr[-1], -  EXTRACT_UCHAR(addr-1))) +  if(new_frame->num_args != (ptrdiff_t)addr[-1])    fatal("Wrong number of arguments in F_RECUR %d!=%d\n",    new_frame->num_args,    DO_IF_ELSE_COMPUTED_GOTO((ptrdiff_t)addr[-1],    EXTRACT_UCHAR(addr-1)));       if(t_flag > 3)    fprintf(stderr,"- Allocating %d extra locals.\n",    new_frame->num_locals - new_frame->num_args);    });    -  Pike_fp->pc = PROG_COUNTER + DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); -  PROG_COUNTER=addr; +  Pike_fp->pc = (PIKE_OPCODE_T *)(((INT32 *)PROG_COUNTER) + 1); +  SET_PROG_COUNTER(addr);    FETCH;       clear_svalues(Pike_sp, new_frame->num_locals - new_frame->num_args);    Pike_sp += new_frame->num_locals - new_frame->args;       if(new_frame->scope) add_ref(new_frame->scope);    add_ref(new_frame->current_object);    add_ref(new_frame->context.prog);    if(new_frame->context.parent)    add_ref(new_frame->context.parent);
pike.git/src/interpret_functions.h:2022:    DO_IF_DEBUG({    if (Pike_sp < Pike_fp->locals + args)    fatal("Pike_sp (%p) < Pike_fp->locals (%p) + args (%d)\n",    Pike_sp, Pike_fp->locals, args);    });    assign_svalues(Pike_fp->locals, Pike_sp-args, args, BIT_MIXED);    pop_n_elems(Pike_sp - (Pike_fp->locals + args));    }       clear_svalues(Pike_sp, num_locals - args); -  PROG_COUNTER=addr; +  SET_PROG_COUNTER(addr);    FETCH;    Pike_sp += num_locals - args;       DO_IF_DEBUG({    if(Pike_sp != Pike_fp->locals + Pike_fp->num_locals)    fatal("Sp whacked!\n");    });   });      OPCODE0(F_BREAKPOINT, "breakpoint", {    extern void o_breakpoint(void); -  PROG_COUNTER--; +  SET_PROG_COUNTER(PROG_COUNTER-1);    FETCH;    o_breakpoint();   });      OPCODE0(F_THIS_OBJECT, "this_object", {    if(Pike_fp)    {    ref_push_object(Pike_fp->current_object);    }else{    push_int(0);