pike.git / src / interpret_functions.h

version» Context lines:

pike.git/src/interpret_functions.h:4:   || for more information.   */      /*    * Opcode definitions for the interpreter.    */      #include "global.h"      #undef CJUMP - #undef AUTO_BIGNUM_LOOP_TEST +    #undef LOOP   #undef COMPARISON   #undef MKAPPLY   #undef DO_CALL_BUILTIN    - #undef DO_IF_BIGNUM - #ifdef AUTO_BIGNUM - #define DO_IF_BIGNUM(CODE) CODE - #else /* !AUTO_BIGNUM */ - #define DO_IF_BIGNUM(CODE) - #endif /* AUTO_BIGNUM */ -  +    #undef DO_IF_ELSE_COMPUTED_GOTO   #ifdef HAVE_COMPUTED_GOTO   #define DO_IF_ELSE_COMPUTED_GOTO(A, B) (A)   #else /* !HAVE_COMPUTED_GOTO */   #define DO_IF_ELSE_COMPUTED_GOTO(A, B) (B)   #endif /* HAVE_COMPUTED_GOTO */      #ifdef GEN_PROTOS   /* Used to generate the interpret_protos.h file. */   #define OPCODE0(A, B, F, C) OPCODE0(A, B, F) --- C
pike.git/src/interpret_functions.h:507:   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|src->type) == PIKE_T_INT -  DO_IF_BIGNUM( -  &&(!INT_TYPE_ADD_OVERFLOW(src->u.integer,dst->u.integer)))) +  && !INT_TYPE_ADD_OVERFLOW(src->u.integer,dst->u.integer) )    {    SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER);    dst->u.integer += src->u.integer;    }    else if( dst->type == src->type && dst->type == PIKE_T_STRING )    {    struct pike_string *srcs = src->u.string;    struct pike_string *dsts = dst->u.string;    if( dsts->len && srcs->len )    {
pike.git/src/interpret_functions.h:552:    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_svalue( src );    f_add(2);    *dst = *--Pike_sp;    }   });      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)))) +  && !INT_TYPE_ADD_OVERFLOW(dst->u.integer,arg2) )    {    SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER);    dst->u.integer += arg2;    }    else    {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int( arg2 );    f_add(2);    *dst = *--Pike_sp;    }   });      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)))) +  && !INT_TYPE_ADD_OVERFLOW(dst->u.integer,arg2) )    {    SET_SVAL_SUBTYPE(*dst,NUMBER_NUMBER);    dst->u.integer += arg2;    push_int( dst->u.integer );    }    else    {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int( arg2 );    f_add(2);    *dst = *--Pike_sp;    }   });      OPCODE1(F_INC_LOCAL, "++local", I_UPDATE_SP, {    struct svalue *dst = Pike_fp->locals+arg1;    if( (TYPEOF(*dst) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1) )    {    push_int(++dst->u.integer);    SET_SVAL_SUBTYPE(*dst, NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int(1);    f_add(2);    assign_svalue(dst, Pike_sp-1);    }   });      OPCODE1(F_POST_INC_LOCAL, "local++", I_UPDATE_SP, {    struct svalue *dst = Pike_fp->locals+arg1;    if( (TYPEOF(*dst) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1) )    {    push_int( dst->u.integer++ );    SET_SVAL_SUBTYPE(*dst, NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    push_svalue( dst );    push_svalue( dst );    push_int(1);    f_add(2);    stack_pop_to(dst);    }   });      OPCODE1(F_INC_LOCAL_AND_POP, "++local and pop", 0, {    struct svalue *dst = Pike_fp->locals+arg1;    if( (TYPEOF(*dst) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(dst->u.integer, 1) )    {    dst->u.integer++;    SET_SVAL_SUBTYPE(*dst, NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int(1);    f_add(2);    *dst = *--Pike_sp;    }   });      OPCODE1(F_DEC_LOCAL, "--local", I_UPDATE_SP, {    struct svalue *dst = Pike_fp->locals+arg1;    if( (TYPEOF(*dst) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_SUB_OVERFLOW(dst->u.integer, 1)) -  ) -  ) +  && !INT_TYPE_SUB_OVERFLOW(dst->u.integer, 1) )    {    push_int(--(dst->u.integer));    SET_SVAL_SUBTYPE(*dst, NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int(1);    o_subtract();    assign_svalue(dst,Pike_sp-1);    }   });      OPCODE1(F_POST_DEC_LOCAL, "local--", I_UPDATE_SP, {    push_svalue( Pike_fp->locals + arg1);       if( (TYPEOF(Pike_fp->locals[arg1]) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_SUB_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1)) -  ) -  ) +  && !INT_TYPE_SUB_OVERFLOW(Pike_fp->locals[arg1].u.integer, 1) )    {    Pike_fp->locals[arg1].u.integer--;    SET_SVAL_SUBTYPE(Pike_fp->locals[arg1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    push_svalue(Pike_fp->locals + arg1);    push_int(1);    o_subtract();    stack_pop_to(Pike_fp->locals + arg1);    }   });      OPCODE1(F_DEC_LOCAL_AND_POP, "--local and pop", 0, {    struct svalue *dst = Pike_fp->locals+arg1;    if( (TYPEOF(*dst) == PIKE_T_INT) -  DO_IF_BIGNUM( -  && (!INT_TYPE_SUB_OVERFLOW(dst->u.integer, 1)) -  ) -  ) +  && !INT_TYPE_SUB_OVERFLOW(dst->u.integer, 1) )    {    --dst->u.integer;    SET_SVAL_SUBTYPE(*dst, NUMBER_NUMBER); /* Could have UNDEFINED there before. */    } else {    *Pike_sp++ = *dst;    SET_SVAL_TYPE(*dst,PIKE_T_INT);    push_int(1);    o_subtract();    *dst = *--Pike_sp;    }
pike.git/src/interpret_functions.h:819:   OPCODE0(F_ADD_TO, "+=", I_UPDATE_SP, {    ONERROR uwp;    move_svalue (Pike_sp, Pike_sp - 1);    mark_free_svalue (Pike_sp - 1);    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4);       if( TYPEOF(Pike_sp[-1]) == PIKE_T_INT &&    TYPEOF(Pike_sp[-2]) == PIKE_T_INT )    { -  DO_IF_BIGNUM( +     if(!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer)) -  ) +     {    /* Optimization for a rather common case. Makes it 30% faster. */    INT_TYPE val = (Pike_sp[-1].u.integer += Pike_sp[-2].u.integer);    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    assign_lvalue(Pike_sp-4,Pike_sp-1);    Pike_sp-=2;    pop_2_elems();    push_int(val);    goto add_to_done;    }
pike.git/src/interpret_functions.h:886:   OPCODE0(F_ADD_TO_AND_POP, "+= and pop", I_UPDATE_SP, {    ONERROR uwp;    move_svalue (Pike_sp, Pike_sp - 1);    mark_free_svalue (Pike_sp - 1);    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4);       if( TYPEOF(Pike_sp[-1]) == PIKE_T_INT &&    TYPEOF(Pike_sp[-2]) == PIKE_T_INT )    { -  DO_IF_BIGNUM( +     if(!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer)) -  ) +     {    /* Optimization for a rather common case. Makes it 30% faster. */    Pike_sp[-1].u.integer += Pike_sp[-2].u.integer;    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    assign_lvalue(Pike_sp-4,Pike_sp-1);    Pike_sp-=2;    pop_2_elems();    goto add_to_and_pop_done;    }    }
pike.git/src/interpret_functions.h:948:    ; /* make gcc happy */   });      OPCODE1(F_GLOBAL_LVALUE, "& global", I_UPDATE_SP, {    ref_push_object(Pike_fp->current_object);    push_obj_index(arg1 + Pike_fp->context->identifier_level);   });      OPCODE0(F_INC, "++x", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_ADD_OVERFLOW(u->integer, 1) -  ) -  ) +  if(u && !INT_TYPE_ADD_OVERFLOW(u->integer, 1))    {    INT_TYPE val = ++u->integer;    pop_2_elems();    push_int(val);    } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-3, Pike_sp-1);    stack_pop_2_elems_keep_top();    }   });      OPCODE0(F_DEC, "--x", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_SUB_OVERFLOW(u->integer, 1) -  ) -  ) +  if(u && !INT_TYPE_SUB_OVERFLOW(u->integer, 1))    {    INT_TYPE val = --u->integer;    pop_2_elems();    push_int(val);    } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-3, Pike_sp-1);    stack_pop_2_elems_keep_top();    }   });      OPCODE0(F_DEC_AND_POP, "x-- and pop", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_SUB_OVERFLOW(u->integer, 1) -  ) - ) +  if(u && !INT_TYPE_SUB_OVERFLOW(u->integer, 1))    {    --u->integer;    pop_2_elems();    }else{    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3);    }   });      OPCODE0(F_INC_AND_POP, "x++ and pop", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_ADD_OVERFLOW(u->integer, 1) -  ) -  ) +  if(u && !INT_TYPE_ADD_OVERFLOW(u->integer, 1))    {    ++u->integer;    pop_2_elems();    } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-3, Pike_sp-1);    pop_n_elems(3);    }   });      OPCODE0(F_POST_INC, "x++", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_ADD_OVERFLOW(u->integer, 1) -  ) -  ) +  if(u && !INT_TYPE_ADD_OVERFLOW(u->integer, 1))    {    INT_TYPE val = u->integer++;    pop_2_elems();    push_int(val);    } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    stack_dup();    push_int(1);    f_add(2);    assign_lvalue(Pike_sp-4, Pike_sp-1);    pop_stack();    stack_pop_2_elems_keep_top();    print_return_value();    }   });      OPCODE0(F_POST_DEC, "x--", I_UPDATE_SP, {    union anything *u=get_pointer_if_this_type(Pike_sp-2, PIKE_T_INT); -  if(u -  DO_IF_BIGNUM( -  && !INT_TYPE_SUB_OVERFLOW(u->integer, 1) -  ) -  ) +  if(u && !INT_TYPE_SUB_OVERFLOW(u->integer, 1))    {    INT_TYPE val = u->integer--;    pop_2_elems();    push_int(val);    } else {    lvalue_to_svalue_no_free(Pike_sp, Pike_sp-2); Pike_sp++;    stack_dup();    push_int(1);    o_subtract();    assign_lvalue(Pike_sp-4, Pike_sp-1);
pike.git/src/interpret_functions.h:1572:    constants[arg2].sval.u.array,Pike_fp->locals + arg1);    addr = DO_IF_ELSE_COMPUTED_GOTO(addr, (PIKE_OPCODE_T *)    DO_ALIGN(PTR_TO_INT(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_ON_BRANCH();    DO_JUMP_TO(addr + *(INT32*)addr);   });       - #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 */ +     /* LOOP(OPCODE, INCREMENT, OPERATOR, IS_OPERATOR) */   #define LOOP(ID, DESC, INC, OP2, OP4) \    OPCODE0_BRANCH(ID, DESC, 0, { \    union anything *i=get_pointer_if_this_type(Pike_sp-2, T_INT); \ -  if(i && !AUTO_BIGNUM_LOOP_TEST(i->integer,INC) && \ +  if(i && !INT_TYPE_ADD_OVERFLOW(i->integer,INC) && \    TYPEOF(Pike_sp[-3]) == T_INT) \    { \    i->integer += INC; \    if(i->integer OP2 Pike_sp[-3].u.integer) \    { \    DO_BRANCH(); \    }else{ \    /* write_to_stderr("loop\n", 8); */ \    DONT_BRANCH(); \    } \
pike.git/src/interpret_functions.h:1741:    DO_RETURN;   });      OPCODE0_RETURN(F_DUMB_RETURN,"dumb return", I_UPDATE_FP, {    DO_DUMB_RETURN;   });      OPCODE0(F_NEGATE, "unary minus", 0, {    if(TYPEOF(Pike_sp[-1]) == PIKE_T_INT)    { -  DO_IF_BIGNUM( +     if(INT_TYPE_NEG_OVERFLOW(Pike_sp[-1].u.integer))    {    convert_stack_top_to_bignum();    o_negate();    }    else -  ) +     {    Pike_sp[-1].u.integer =- Pike_sp[-1].u.integer;    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    }    }    else if(TYPEOF(Pike_sp[-1]) == PIKE_T_FLOAT)    {    Pike_sp[-1].u.float_number =- Pike_sp[-1].u.float_number;    }else{    o_negate();
pike.git/src/interpret_functions.h:1816:   COMPARISON(F_LE, "<=", is_le(Pike_sp-2,Pike_sp-1));      /* Used with F_LTOSVAL*_AND_FREE - must not release interpreter lock. */   OPCODE0(F_ADD, "+", I_UPDATE_SP, {    f_add(2);   });      /* Used with F_LTOSVAL*_AND_FREE - must not release interpreter lock. */   OPCODE0(F_ADD_INTS, "int+int", I_UPDATE_SP, {    if(TYPEOF(Pike_sp[-1]) == T_INT && TYPEOF(Pike_sp[-2]) == T_INT -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, Pike_sp[-2].u.integer))    {    Pike_sp[-2].u.integer+=Pike_sp[-1].u.integer;    SET_SVAL_SUBTYPE(Pike_sp[-2], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }else{    f_add(2);    }   });   
pike.git/src/interpret_functions.h:1853:   OPCODE0_ALIAS(F_SUBTRACT, "-", I_UPDATE_SP, o_subtract);   OPCODE0_ALIAS(F_AND, "&", I_UPDATE_SP, o_and);   OPCODE0_ALIAS(F_OR, "|", I_UPDATE_SP, o_or);   OPCODE0_ALIAS(F_XOR, "^", I_UPDATE_SP, o_xor);   OPCODE0_ALIAS(F_MULTIPLY, "*", I_UPDATE_SP, o_multiply);   OPCODE0_ALIAS(F_DIVIDE, "/", I_UPDATE_SP, o_divide);   OPCODE0_ALIAS(F_MOD, "%", I_UPDATE_SP, o_mod);      OPCODE1(F_ADD_INT, "add integer", 0, {    if(TYPEOF(Pike_sp[-1]) == T_INT -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, arg1)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, arg1))    {    Pike_sp[-1].u.integer+=arg1;    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    }else{    push_int(arg1);    f_add(2);    }   });      OPCODE1(F_ADD_NEG_INT, "add -integer", 0, {    if(TYPEOF(Pike_sp[-1]) == T_INT -  DO_IF_BIGNUM( -  && (!INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, -arg1)) -  ) -  ) +  && !INT_TYPE_ADD_OVERFLOW(Pike_sp[-1].u.integer, -arg1))    {    Pike_sp[-1].u.integer-=arg1;    SET_SVAL_SUBTYPE(Pike_sp[-1], NUMBER_NUMBER); /* Could have UNDEFINED there before. */    }else{    push_int(-arg1);    f_add(2);    }   });      OPCODE0(F_PUSH_ARRAY, "@", I_UPDATE_SP, {