pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:122:      #else /* !PIKE_DEBUG */      #define GET_JUMP() (/*write_to_stderr("GET_JUMP\n", 9),*/ LOW_GET_JUMP())   #define SKIPJUMP() (/*write_to_stderr("SKIPJUMP\n", 9),*/ LOW_SKIPJUMP())      #endif /* PIKE_DEBUG */      #define DOJUMP() do { \    PIKE_OPCODE_T *addr; \ -  INT32 tmp; \ +  INT32 tmp; \    JUMP_SET_TO_PC_AT_NEXT (addr); \ -  tmp = GET_JUMP(); \ -  SET_PROG_COUNTER(addr + tmp); \ -  FETCH; \ -  if(tmp < 0) \ +  tmp = GET_JUMP(); \ +  SET_PROG_COUNTER(addr + tmp); \ +  FETCH; \ +  if(tmp < 0) \    FAST_CHECK_THREADS_ON_BRANCH(); \    } 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 these cases it is required to handle break
pike.git/src/interpret_functions.h:490:    Pike_sp++;   });      OPCODE1(F_CLEAR_2_LOCAL, "clear 2 local", 0, {    free_mixed_svalues(Pike_fp->locals + arg1, 2);    SET_SVAL(Pike_fp->locals[arg1], PIKE_T_INT, NUMBER_NUMBER, integer, 0);    SET_SVAL(Pike_fp->locals[arg1+1], PIKE_T_INT, NUMBER_NUMBER, integer, 0);   });      OPCODE1(F_CLEAR_4_LOCAL, "clear 4 local", 0, { +  struct svalue *locals = Pike_fp->locals;    int e; -  free_mixed_svalues(Pike_fp->locals + arg1, 4); +  free_mixed_svalues(locals + arg1, 4);    for(e = 0; e < 4; e++)    { -  SET_SVAL(Pike_fp->locals[arg1+e], PIKE_T_INT, NUMBER_NUMBER, integer, 0); +  SET_SVAL(locals[arg1+e], PIKE_T_INT, NUMBER_NUMBER, integer, 0);    }   });      OPCODE1(F_CLEAR_LOCAL, "clear local", 0, {    free_svalue(Pike_fp->locals + arg1);    SET_SVAL(Pike_fp->locals[arg1], PIKE_T_INT, NUMBER_NUMBER, integer, 0);   });    -  + OPCODE2(F_ADD_LOCALS_AND_POP, "local += local", 0,{ +  struct svalue *dst = Pike_fp->locals+arg1; +  struct svalue *src = Pike_fp->locals+arg2; +  if( dst->type == PIKE_T_INT +  && src->type == PIKE_T_INT +  DO_IF_BIGNUM( +  &&(!INT_TYPE_ADD_OVERFLOW(src->u.integer,dst->u.integer)))) +  { +  SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER); +  dst->u.integer += src->u.integer; +  } +  else +  { +  push_svalue( dst ); +  push_svalue( src ); +  f_add(2); +  assign_svalue( Pike_fp->locals+arg1,Pike_sp-1); +  pop_stack(); +  } + }); +  + OPCODE2(F_ADD_LOCAL_INT_AND_POP, "local += number", 0,{ +  struct svalue *dst = Pike_fp->locals+arg1; +  if( dst->type == PIKE_T_INT +  DO_IF_BIGNUM( +  &&(!INT_TYPE_ADD_OVERFLOW(dst->u.integer,arg2)))) +  { +  SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER); +  dst->u.integer += arg2; +  } +  else +  { +  push_svalue( dst ); +  push_int( arg2 ); +  f_add(2); +  assign_svalue( Pike_fp->locals+arg1,Pike_sp-1); +  pop_stack(); +  } + }); +  + OPCODE2(F_ADD_LOCAL_INT, "local += number local", 0,{ +  struct svalue *dst = Pike_fp->locals+arg1; +  if( dst->type == PIKE_T_INT +  DO_IF_BIGNUM( +  &&(!INT_TYPE_ADD_OVERFLOW(dst->u.integer,arg2)))) +  { +  SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER); +  dst->u.integer += arg2; +  push_int( dst->u.integer ); +  } +  else +  { +  push_svalue( dst ); +  push_int( arg2 ); +  f_add(2); +  assign_svalue( Pike_fp->locals+arg1,Pike_sp-1); +  } + }); +    OPCODE1(F_INC_LOCAL, "++local", I_UPDATE_SP, {    if( (TYPEOF(Pike_fp->locals[arg1]) == PIKE_T_INT)    DO_IF_BIGNUM(    && (!INT_TYPE_ADD_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1))    )    )    {    push_int(++(Pike_fp->locals[arg1].u.integer));    SET_SVAL_SUBTYPE(Pike_fp->locals[arg1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {
pike.git/src/interpret_functions.h:1014:    assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3);   });      OPCODE1(F_ASSIGN_LOCAL_AND_POP, "assign local and pop", I_UPDATE_SP, {    free_svalue(Pike_fp->locals + arg1);    move_svalue (Pike_fp->locals + arg1, Pike_sp - 1);    Pike_sp--;   });    + OPCODE2(F_ASSIGN_LOCAL_NUMBER_AND_POP, "assign local number and pop", 0, { +  free_svalue(Pike_fp->locals + arg1); +  SET_SVAL(Pike_fp->locals[arg1], PIKE_T_INT, 0, integer, arg2); + }); +    OPCODE1(F_ASSIGN_GLOBAL, "assign global", 0, {    object_low_set_index(Pike_fp->current_object,    arg1 + Pike_fp->context->identifier_level,    Pike_sp-1);   });      OPCODE1(F_ASSIGN_GLOBAL_AND_POP, "assign global and pop", I_UPDATE_SP, {    object_low_set_index(Pike_fp->current_object,    arg1 + Pike_fp->context->identifier_level,    Pike_sp-1);    pop_stack();   });    -  + OPCODE2(F_ASSIGN_GLOBAL_NUMBER_AND_POP, "assign global number and pop", 0, { +  struct svalue tmp; +  SET_SVAL(tmp,PIKE_T_INT,0,integer,arg2); +  object_low_set_index(Pike_fp->current_object, +  arg1 + Pike_fp->context->identifier_level, +  &tmp); + });    -  +    /* Stack machine stuff */      OPCODE0(F_POP_VALUE, "pop", I_UPDATE_SP, {    pop_stack();   });      OPCODE1(F_POP_N_ELEMS, "pop_n_elems", I_UPDATE_SP, {    pop_n_elems(arg1);   });   
pike.git/src/interpret_functions.h:1118:    {    /* write_to_stderr("foreach\n", 8); */    DONT_BRANCH();    }else{    DO_BRANCH();    }    pop_stack();    });   });    + OPCODE0_BRANCH(F_QUICK_BRANCH_WHEN_ZERO, "(Q) branch if zero", I_UPDATE_SP, { +  if(Pike_sp[-1].u.integer) +  { +  DONT_BRANCH(); +  }else{ +  DO_BRANCH(); +  } +  pop_stack(); +  });    -  + OPCODE0_BRANCH(F_QUICK_BRANCH_WHEN_NON_ZERO, "(Q) branch if not zero", I_UPDATE_SP, { +  if(Pike_sp[-1].u.integer) +  { +  DO_BRANCH(); +  }else{ +  DONT_BRANCH(); +  } +  pop_stack(); + }); +    OPCODE0_BRANCH(F_BRANCH_WHEN_NON_ZERO, "branch if not zero", I_UPDATE_SP, {    if(UNSAFE_IS_ZERO(Pike_sp-1))    { -  /* write_to_stderr("foreach\n", 8); */ +     DONT_BRANCH();    }else{    DO_BRANCH();    }    pop_stack();   });      OPCODE1_BRANCH(F_BRANCH_IF_TYPE_IS_NOT, "branch if type is !=", I_UPDATE_SP, {   /* fprintf(stderr,"******BRANCH IF TYPE IS NOT***** %s\n",get_name_of_type(arg1)); */    LOCAL_VAR(struct object *o);
pike.git/src/interpret_functions.h:1520:    DONT_BRANCH();    pop_2_elems();    }   });      OPCODE0_BRANCH(F_FOREACH, "foreach", 0, { /* array, lvalue, i */    if(TYPEOF(Pike_sp[-4]) != 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)    { -  if(Pike_sp[-1].u.integer < 0) +  DO_IF_DEBUG(if(Pike_sp[-1].u.integer < 0)    /* Isn't this an internal compiler error? /mast */ -  Pike_error("Foreach loop variable is negative!\n"); +  Pike_error("Foreach loop variable is negative!\n"));    assign_lvalue(Pike_sp-3, Pike_sp[-4].u.array->item + Pike_sp[-1].u.integer);    DO_BRANCH();    Pike_sp[-1].u.integer++;    DO_IF_DEBUG (    if (SUBTYPEOF(Pike_sp[-1]))    Pike_fatal ("Got unexpected subtype in loop variable.\n");    );    }else{    /* write_to_stderr("foreach\n", 8); */    DONT_BRANCH();
pike.git/src/interpret_functions.h:1582:    /* special case! Pike_interpreter.mark_stack may be invalid at the time we    * call return -1, so we must call the callbacks here to    * prevent false alarms! /Hubbe    */    if(d_flag>3) do_gc(NULL, 0);    if(d_flag>4) do_debug();    );    if(Pike_fp->expendible <= Pike_fp->locals + arg1)    {    pop_n_elems(Pike_sp-1 - (Pike_fp->locals + arg1)); +  DO_IF_DEBUG(Pike_fp->num_locals = arg1);    }else{    push_svalue(Pike_fp->locals + arg1);    }    DO_DUMB_RETURN;   });         OPCODE0_RETURN(F_RETURN_IF_TRUE,"return if true", I_UPDATE_SP|I_UPDATE_FP, {    if(!UNSAFE_IS_ZERO(Pike_sp-1)) DO_RETURN;    pop_stack();
pike.git/src/interpret_functions.h:1822:    low_index_current_object_no_free(Pike_sp, arg1);    Pike_sp++;    s=Pike_fp->locals+arg2;    if(TYPEOF(*s) == PIKE_T_STRING) SET_SVAL_SUBTYPE(*s, 0);    index_no_free(&tmp,Pike_sp-1,s);    free_svalue(Pike_sp-1);    move_svalue (Pike_sp - 1, &tmp);   });      OPCODE2(F_LOCAL_ARROW, "local->x", I_UPDATE_SP, { +  struct pike_frame *fp = Pike_fp;    LOCAL_VAR(struct svalue tmp);    SET_SVAL(tmp, PIKE_T_STRING, 1, string, -  Pike_fp->context->prog->strings[arg1]); +  fp->context->prog->strings[arg1]);    mark_free_svalue (Pike_sp++); -  index_no_free(Pike_sp-1,Pike_fp->locals+arg2, &tmp); +  index_no_free(Pike_sp-1,fp->locals+arg2, &tmp);    print_return_value();   });      OPCODE1(F_ARROW, "->x", 0, {    LOCAL_VAR(struct svalue tmp);    LOCAL_VAR(struct svalue tmp2);    SET_SVAL(tmp, PIKE_T_STRING, 1, string,    Pike_fp->context->prog->strings[arg1]);    index_no_free(&tmp2, Pike_sp-1, &tmp);    free_svalue(Pike_sp-1);
pike.git/src/interpret_functions.h:2443:    STACK_LEVEL_DONE (0);   });      #ifndef ENTRY_PROLOGUE_SIZE   #define ENTRY_PROLOGUE_SIZE 0   #endif /* !ENTRY_PROLOGUE_SIZE */      #define DO_RECUR(XFLAGS) do{ \    PIKE_OPCODE_T *addr; \    register struct pike_frame *new_frame; \ -  ptrdiff_t args; \ +  INT32 args = DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)); \    \    DO_IF_SECURITY(CHECK_DATA_SECURITY_OR_ERROR(Pike_fp->current_object, \    SECURITY_BIT_CALL, \    ("Function call permission denied.\n"))); \    \    FAST_CHECK_THREADS_ON_CALL(); \    check_stack(256); \    \    new_frame=alloc_pike_frame(); \    \    new_frame->refs=1; /* FIXME: Is this needed? */ \    new_frame->next=Pike_fp; \    \    JUMP_SET_TO_PC_AT_NEXT (addr); \    Pike_fp->return_addr = (PIKE_OPCODE_T *)(((INT32 *) addr) + 1); \    addr += GET_JUMP(); \    \ -  new_frame->num_locals = READ_INCR_BYTE(addr); \ -  args = READ_INCR_BYTE(addr); \ +     addr += ENTRY_PROLOGUE_SIZE; \    \ -  new_frame->num_args = new_frame->args = args; \ +  if (Pike_interpreter.trace_level > 3) { \ +  fprintf(stderr, "- Addr = 0x%+lx\n", addr); \ +  } \ +  \ +  new_frame->args = args; \    new_frame->locals=new_frame->save_sp=new_frame->expendible=Pike_sp-args; \    new_frame->save_mark_sp = new_frame->mark_sp_base = Pike_mark_sp; \ -  \ -  push_zeroes(new_frame->num_locals - args); \ -  \ -  DO_IF_DEBUG({ \ -  if(Pike_interpreter.trace_level > 3) \ -  fprintf(stderr,"- Allocating %d extra locals.\n", \ -  new_frame->num_locals - new_frame->num_args); \ -  if (Pike_fp && (new_frame->locals < Pike_fp->locals)) { \ -  fatal("New locals below old locals: %p < %p\n", \ -  new_frame->locals, Pike_fp->locals); \ -  } \ -  }); \ -  \ -  \ +  DO_IF_DEBUG(new_frame->num_args=0;new_frame->num_locals=0;); \    SET_PROG_COUNTER(addr); \    new_frame->fun=Pike_fp->fun; \    DO_IF_PROFILING( new_frame->ident=Pike_fp->ident ); \    new_frame->current_storage=Pike_fp->current_storage; \    if(Pike_fp->scope) add_ref(new_frame->scope=Pike_fp->scope); \    add_ref(new_frame->current_object = Pike_fp->current_object); \    add_ref(new_frame->current_program = Pike_fp->current_program); \    new_frame->context = Pike_fp->context; \    \    DO_IF_PROFILING({ \
pike.git/src/interpret_functions.h:2549:    */    if(((p != Pike_fp->context->prog) ||    (Pike_fp->context !=    &p->inherits[p->identifier_references[Pike_fp->context->identifier_level +    arg1].inherit_offset])) ||    (ID_FROM_INT(p, arg1+Pike_fp->context->identifier_level)->    identifier_flags & IDENTIFIER_SCOPE_USED))    {    PIKE_OPCODE_T *faddr;    ptrdiff_t num_locals; -  ptrdiff_t args; +  INT32 args = DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp));       JUMP_SET_TO_PC_AT_NEXT (faddr);    faddr += GET_JUMP(); -  num_locals = READ_INCR_BYTE(faddr); /* ignored */ -  args = READ_INCR_BYTE(faddr); +        if(low_mega_apply(APPLY_LOW,    args,    Pike_fp->current_object,    (void *)(ptrdiff_t)(arg1+    Pike_fp->context->identifier_level)))    {    Pike_fp->flags |= PIKE_FRAME_RETURN_INTERNAL;    addr = Pike_fp->pc;    }
pike.git/src/interpret_functions.h:2588:   OPCODE0_PTRJUMP(F_RECUR_AND_POP, "recur & pop", I_UPDATE_ALL, {    DO_RECUR(PIKE_FRAME_RETURN_POP);   });         /* Assume that the number of arguments is correct */   /* FIXME: adjust Pike_mark_sp */   OPCODE0_PTRJUMP(F_TAIL_RECUR, "tail recursion", I_UPDATE_ALL, {    INT32 num_locals;    PIKE_OPCODE_T *addr; -  INT32 args; +  INT32 args = DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp));       FAST_CHECK_THREADS_ON_CALL();       JUMP_SET_TO_PC_AT_NEXT (addr);    addr += GET_JUMP(); -  num_locals = READ_INCR_BYTE(addr); -  args = READ_INCR_BYTE(addr); +     addr += ENTRY_PROLOGUE_SIZE;    SET_PROG_COUNTER(addr);       if(Pike_sp-args != Pike_fp->locals)    {    DO_IF_DEBUG({    if (Pike_sp < Pike_fp->locals + args)    Pike_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));    }    -  push_zeroes(num_locals - args); -  -  DO_IF_DEBUG({ -  if(Pike_sp != Pike_fp->locals + Pike_fp->num_locals) -  Pike_fatal("Sp whacked!\n"); -  }); -  +     FETCH;    JUMP_DONE;   });      #if 0   /* This opcode needs mending if it is to work with machine code. */   OPCODE0_JUMP(F_BREAKPOINT, "breakpoint", 0, {    extern void o_breakpoint(void);    o_breakpoint();    DO_JUMP_TO(PROG_COUNTER-1);
pike.git/src/interpret_functions.h:2701:    ref_push_object_inherit(loc.o,    (loc.inherit - loc.o->prog->inherits) + arg2);    }    print_return_value();   });      OPCODE2(F_MAGIC_TYPES, "::_types", I_UPDATE_SP, {    push_magic_index(magic_types_program, arg2, arg1);   });    + OPCODE2(F_INIT_FRAME, "init_frame", 0, { +  Pike_fp->num_args = arg1; +  Pike_fp->num_locals = arg2; +  }); +  + OPCODE1(F_PROTECT_STACK, "protect_stack", 0, { +  Pike_fp->expendible = Pike_fp->locals + arg1; +  }); +  + OPCODE2(F_FILL_STACK, "fill_stack", I_UPDATE_SP, { +  INT32 tmp = (Pike_fp->locals + arg1) - Pike_sp; +  if (tmp > 0) { +  if (arg2) { +  push_undefines(tmp); +  } else { +  push_zeroes(tmp); +  } +  } +  }); +  + OPCODE1(F_MARK_AT, "mark_at", I_UPDATE_SP, { +  *(Pike_mark_sp++) = Pike_fp->locals + arg1; +  }); +    /*   #undef PROG_COUNTER   */