pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:1:   /* -  * $Id: interpret_functions.h,v 1.73 2001/07/09 16:25:27 grubba Exp $ +  * $Id: interpret_functions.h,v 1.74 2001/07/10 16:52:03 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:127:    free_svalue(Pike_sp-1);    Pike_sp[-1] = tmp;    print_return_value();   });      OPCODE0(F_FLOAT, "push float", {    /* FIXME, this opcode uses 'pc' which is not allowed.. */    Pike_sp->type=PIKE_T_FLOAT;    MEMCPY((void *)&Pike_sp->u.float_number, pc, sizeof(FLOAT_TYPE));    pc += DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(FLOAT_TYPE)); +  FETCH;    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_sp++;    print_return_value();
pike.git/src/interpret_functions.h:807:    --Pike_mark_sp;   });      OPCODE0(F_POP_TO_MARK, "pop to mark", {    pop_n_elems(Pike_sp - *--Pike_mark_sp);   });      /* These opcodes are only used when running with -d. The reason for    * the two aliases is mainly to keep the indentation in asm debug    * output. */ - OPCODE0(F_CLEANUP_SYNCH_MARK, "cleanup synch mark", { -  OPCODE0_TAIL(F_POP_SYNCH_MARK, "pop synch mark", { + OPCODE0_TAIL(F_CLEANUP_SYNCH_MARK, "cleanup synch mark", { +  OPCODE0(F_POP_SYNCH_MARK, "pop synch mark", {    if (*--Pike_mark_sp != Pike_sp && d_flag) {    ptrdiff_t should = *Pike_mark_sp - Pike_interpreter.evaluator_stack;    ptrdiff_t is = Pike_sp - Pike_interpreter.evaluator_stack;    if (Pike_sp - *Pike_mark_sp > 0) /* not always same as Pike_sp > *Pike_mark_sp */    /* Some attempt to recover, just to be able to report the backtrace. */    pop_n_elems(Pike_sp - *Pike_mark_sp);    fatal("Stack out of synch - should be %ld, is %ld.\n",    DO_NOT_WARN((long)should), DO_NOT_WARN((long)is));    }    });
pike.git/src/interpret_functions.h:999:    {    case 1:    /* There was a return inside the evaluated code */    goto do_dumb_return;    case 2:    pc = Pike_fp->pc;    break;    default:    pc += GET_JUMP();    } +  FETCH;   });      OPCODE0(F_ESCAPE_CATCH, "escape catch", {    Pike_fp->pc = pc;    return -2;   });      OPCODE0(F_THROW_ZERO, "throw(0)", {    push_int(0);    f_throw(1);
pike.git/src/interpret_functions.h:1021:   OPCODE1(F_SWITCH, "switch", {    INT32 tmp;    tmp=switch_lookup(Pike_fp->context.prog->    constants[arg1].sval.u.array,Pike_sp-1);    pc = DO_IF_ELSE_COMPUTED_GOTO(pc, (PIKE_OPCODE_T *)    DO_ALIGN(pc,((ptrdiff_t)sizeof(INT32))));    pc += (tmp>=0 ? 1+tmp*2 : 2*~tmp) *    DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32));    if(*(INT32*)pc < 0) fast_check_threads_etc(7);    pc += *(INT32*)pc; +  FETCH;    pop_stack();   });      OPCODE1(F_SWITCH_ON_INDEX, "switch on index", {    INT32 tmp;    struct svalue s;    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);    pc = DO_IF_ELSE_COMPUTED_GOTO(pc, (PIKE_OPCODE_T *)    DO_ALIGN(pc,((ptrdiff_t)sizeof(INT32))));    pc += (tmp>=0 ? 1+tmp*2 : 2*~tmp) *    DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32));    if(*(INT32*)pc < 0) fast_check_threads_etc(7);    pc+=*(INT32*)pc; -  +  FETCH;   });      OPCODE2(F_SWITCH_ON_LOCAL, "switch on local", {    INT32 tmp;    tmp=switch_lookup(Pike_fp->context.prog->    constants[arg2].sval.u.array,Pike_fp->locals + arg1);    pc = DO_IF_ELSE_COMPUTED_GOTO(pc, (PIKE_OPCODE_T *)    DO_ALIGN(pc,((ptrdiff_t)sizeof(INT32))));    pc += (tmp>=0 ? 1+tmp*2 : 2*~tmp) *    DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32));    if(*(INT32*)pc < 0) fast_check_threads_etc(7);    pc+=*(INT32*)pc; -  +  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       /* FIXME: Does this need bignum tests? /Fixed - Hubbe */
pike.git/src/interpret_functions.h:1122:    pop_n_elems(2);    SKIPJUMP();    }   });      OPCODE0_JUMP(F_FOREACH, "foreach", { /* array, lvalue, X, i */    if(Pike_sp[-4].type != PIKE_T_ARRAY)    PIKE_ERROR("foreach", "Bad argument 1.\n", Pike_sp-3, 1);    if(Pike_sp[-1].u.integer < Pike_sp[-4].u.array->size)    { -  fast_check_threads_etc(10); +     if(Pike_sp[-1].u.integer < 0)    Pike_error("Foreach loop variable is negative!\n");    assign_lvalue(Pike_sp-3, Pike_sp[-4].u.array->item + Pike_sp[-1].u.integer); -  pc += GET_JUMP(); +  DOJUMP();    Pike_sp[-1].u.integer++;    }else{    SKIPJUMP();    }   });      OPCODE0(F_MAKE_ITERATOR, "Iterator", {    extern void f_Iterator(INT32);    f_Iterator(1);   });      OPCODE0_JUMP(F_NEW_FOREACH, "foreach++", { /* iterator, lvalue, lvalue */    extern int foreach_iterate(struct object *o);       if(Pike_sp[-5].type != PIKE_T_OBJECT)    PIKE_ERROR("foreach", "Bad argument 1.\n", Pike_sp-3, 1);    if(foreach_iterate(Pike_sp[-5].u.object))    { -  fast_check_threads_etc(10); -  pc+=GET_JUMP(); +  DOJUMP();    }else{    SKIPJUMP();    }   });          CASE(F_RETURN_LOCAL);    {    INT32 val = GET_ARG();   #if defined(PIKE_DEBUG) && defined(GC2)
pike.git/src/interpret_functions.h:1204:   #endif       /* fall through */       CASE(F_DUMB_RETURN);    do_dumb_return:    if(Pike_fp -> flags & PIKE_FRAME_RETURN_INTERNAL)    {    int f=Pike_fp->flags;    low_return(); +  pc=Pike_fp->pc; +  FETCH;    if(f & PIKE_FRAME_RETURN_POP)    pop_stack(); -  pc=Pike_fp->pc; +     DONE;    }    return -1;      OPCODE0(F_NEGATE, "unary minus", {    if(Pike_sp[-1].type == PIKE_T_INT)    {    DO_IF_BIGNUM(    if(INT_TYPE_NEG_OVERFLOW(Pike_sp[-1].u.integer))    {
pike.git/src/interpret_functions.h:1460:    tmp.u.string=Pike_fp->context.prog->strings[arg1];    tmp.subtype=0;    index_no_free(&tmp2, Pike_sp-1, &tmp);    free_svalue(Pike_sp-1);    Pike_sp[-1]=tmp2;    print_return_value();   });       CASE(F_POS_INT_INDEX);    push_int(GET_ARG()); +  FETCH;    print_return_value();    goto do_index;       CASE(F_NEG_INT_INDEX);    push_int(-(ptrdiff_t)GET_ARG());    print_return_value();       CASE(F_INDEX);    do_index:    {
pike.git/src/interpret_functions.h:1613:   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=pc; \ -  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; \ +     pc=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=pc; \ -  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL | PIKE_FRAME_RETURN_POP; \ +     pc=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); \    pc=Pike_fp->pc; \ -  +  FETCH; \    unlink_previous_frame(); \    }else{ \    goto do_dumb_return; \    } \   }); \    \   OP(PIKE_CONCAT(F_MARK_,OPCODE),"mark, " NAME, { \    if(low_mega_apply(TYPE,0, \    ARG2, ARG3)) \    { \    Pike_fp->next->pc=pc; \ -  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; \ +     pc=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=pc; \ -  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL | PIKE_FRAME_RETURN_POP; \ +     pc=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); \    pc=Pike_fp->pc; \ -  +  FETCH; \    unlink_previous_frame(); \    }else{ \    goto do_dumb_return; \    } \   })         MKAPPLY(OPCODE1,CALL_LFUN,"call lfun",APPLY_LOW,    Pike_fp->current_object,    (void *)(arg1+Pike_fp->context.identifier_level));
pike.git/src/interpret_functions.h:1780:    */    if(Pike_fp->current_object->prog != Pike_fp->context.prog)    {    pc += 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=pc; -  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; +     pc=Pike_fp->pc; -  +  FETCH; +  Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL; +  } else { +  FETCH;    }    DONE;    }       /* FALL THROUGH */       /* Assume that the number of arguments is correct */    /* FIXME: Use new recursion stuff */    OPCODE0_TAILJUMP(F_RECUR, "recur", {    instr = 0;
pike.git/src/interpret_functions.h:1834:    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 = pc + DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); +  pc=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_fp->pc = pc + DO_IF_ELSE_COMPUTED_GOTO(1, sizeof(INT32)); +     Pike_fp=new_frame; -  pc=addr; +     new_frame->flags=PIKE_FRAME_RETURN_INTERNAL;    if (opcode) {    /* F_RECUR_AND_POP */    new_frame->flags|=PIKE_FRAME_RETURN_POP;    }    });    });   });      /* Assume that the number of arguments is correct */
pike.git/src/interpret_functions.h:1886:    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); +  pc=addr; +  FETCH;    Pike_sp += num_locals - args;       DO_IF_DEBUG({    if(Pike_sp != Pike_fp->locals + Pike_fp->num_locals)    fatal("Sp whacked!\n");    }); -  -  pc=addr; +    });      OPCODE0(F_BREAKPOINT, "breakpoint", {    extern void o_breakpoint(void); -  o_breakpoint(); +     pc--; -  +  FETCH; +  o_breakpoint();   });      OPCODE0(F_THIS_OBJECT, "this_object", {    if(Pike_fp)    {    ref_push_object(Pike_fp->current_object);    }else{    push_int(0);    }   });