Branch: Tag:

2004-09-30

2004-09-30 13:20:00 by Martin Stjernholm <mast@lysator.liu.se>

Rewrote svalue assignments with move_svalue to play ball with dmalloc
and valgrind. This also avoids a valgrind warning about depending on
uninitialized values in F_ASSIGN.

Rev: src/interpret_functions.h:1.172

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: interpret_functions.h,v 1.171 2004/09/23 11:45:22 grubba Exp $ + || $Id: interpret_functions.h,v 1.172 2004/09/30 13:20:00 mast Exp $   */      /*
208:    LOCAL_VAR(struct svalue tmp); \    index_no_free(&tmp,Pike_sp-2,Pike_sp-1); \    pop_2_elems(); \ -  *Pike_sp=tmp; \ +  move_svalue (Pike_sp, &tmp); \    Pike_sp++; \ -  dmalloc_touch_svalue(Pike_sp-1); \ +     print_return_value(); \    }while(0)   
332:    index_no_free(&tmp, Pike_sp-1, &tmp2);    }    free_svalue(Pike_sp-1); -  Pike_sp[-1] = tmp; +  move_svalue (Pike_sp - 1, &tmp);    print_return_value();   });   
506:    Pike_sp[-1].u.array->flags |= ARRAY_LVALUE;    Pike_sp[-1].u.array->type_field |= BIT_UNFINISHED | BIT_MIXED;    /* FIXME: Shouldn't a ref be added here? */ -  Pike_sp[0] = Pike_sp[-1]; +  move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type = T_ARRAY_LVALUE; -  dmalloc_touch_svalue(Pike_sp); +     Pike_sp++;   });   
653:    dmalloc_touch_svalue(Pike_sp-3);    dmalloc_touch_svalue(Pike_sp-2);    dmalloc_touch_svalue(Pike_sp-1); -  Pike_sp[0] = Pike_sp[-1]; +  move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type = PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2, Pike_sp-4);
676:   });      OPCODE0(F_LTOSVAL3, "ltosval3", I_UPDATE_SP, { -  Pike_sp[0] = Pike_sp[-1]; -  Pike_sp[-1] = Pike_sp[-2]; +  move_svalue (Pike_sp, Pike_sp - 1); +  move_svalue (Pike_sp - 1, Pike_sp - 2);    Pike_sp[-2].type = PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-3, Pike_sp-5);
700:   });      OPCODE0(F_ADD_TO, "+=", I_UPDATE_SP, { -  Pike_sp[0]=Pike_sp[-1]; +  move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type=PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4);
758:   });      OPCODE0(F_ADD_TO_AND_POP, "+= and pop", I_UPDATE_SP, { -  Pike_sp[0]=Pike_sp[-1]; +  move_svalue (Pike_sp, Pike_sp - 1);    Pike_sp[-1].type=PIKE_T_INT;    Pike_sp++;    lvalue_to_svalue_no_free(Pike_sp-2,Pike_sp-4);
951:    assign_lvalue(Pike_sp-3,Pike_sp-1);    free_svalue(Pike_sp-3);    free_svalue(Pike_sp-2); -  Pike_sp[-3]=Pike_sp[-1]; -  dmalloc_touch_svalue(Pike_sp-1); -  dmalloc_touch_svalue(Pike_sp-2); +  move_svalue (Pike_sp - 3, Pike_sp - 1);    Pike_sp-=2;   });   
961:    apply_svalue(&((Pike_fp->context.prog->constants + arg1)->sval),    DO_NOT_WARN((INT32)(Pike_sp - *--Pike_mark_sp)));    free_svalue(Pike_fp->locals+arg2); -  Pike_fp->locals[arg2]=Pike_sp[-1]; -  dmalloc_touch_svalue(Pike_sp-1); +  move_svalue (Pike_fp->locals + arg2, Pike_sp - 1);    Pike_sp--;   });   
979:      OPCODE1(F_ASSIGN_LOCAL_AND_POP, "assign local and pop", I_UPDATE_SP, {    free_svalue(Pike_fp->locals + arg1); -  Pike_fp->locals[arg1] = Pike_sp[-1]; -  dmalloc_touch_svalue(Pike_sp-1); +  move_svalue (Pike_fp->locals + arg1, Pike_sp - 1);    Pike_sp--;   });   
1289:    LOCAL_VAR(struct svalue tmp2);    JUMP_SET_TO_PC_AT_NEXT (addr);    index_no_free(&tmp2, Pike_sp-2, Pike_sp-1); -  Pike_sp++[0] = tmp2; +  move_svalue (Pike_sp++, &tmp2);       tmp=switch_lookup(Pike_fp->context.prog->    constants[arg1].sval.u.array,Pike_sp-1);
1622:    if(Pike_sp[-1].type != PIKE_T_ARRAY)    Pike_error("Bad return type from o->_values() in @\n");    free_svalue(Pike_sp-2); -  Pike_sp[-2]=Pike_sp[-1]; -  dmalloc_touch_svalue(Pike_sp-1); +  move_svalue (Pike_sp - 2, Pike_sp - 1);    Pike_sp--;    break;   
1649:    if(s->type == PIKE_T_STRING) s->subtype=0;    index_no_free(&tmp,Pike_sp-1,s);    free_svalue(Pike_sp-1); -  Pike_sp[-1]=tmp; +  move_svalue (Pike_sp - 1, &tmp);   });      OPCODE2(F_GLOBAL_LOCAL_INDEX, "global[local]", I_UPDATE_SP, {
1663:    if(s->type == PIKE_T_STRING) s->subtype=0;    index_no_free(&tmp,Pike_sp-1,s);    free_svalue(Pike_sp-1); -  Pike_sp[-1]=tmp; +  move_svalue (Pike_sp - 1, &tmp);   });      OPCODE2(F_LOCAL_ARROW, "local->x", I_UPDATE_SP, {
1685:    tmp.subtype=1;    index_no_free(&tmp2, Pike_sp-1, &tmp);    free_svalue(Pike_sp-1); -  Pike_sp[-1]=tmp2; +  move_svalue (Pike_sp - 1, &tmp2);    print_return_value();   });   
1697:    tmp.subtype=0;    index_no_free(&tmp2, Pike_sp-1, &tmp);    free_svalue(Pike_sp-1); -  Pike_sp[-1]=tmp2; +  move_svalue (Pike_sp - 1, &tmp2);    print_return_value();   });   
1806:    LOCAL_VAR(struct svalue tmp);    copy_svalues_recursively_no_free(&tmp,Pike_sp-1,1,0);    free_svalue(Pike_sp-1); -  Pike_sp[-1]=tmp; +  move_svalue (Pike_sp - 1, &tmp);    print_return_value();   });   
1816:    if(tmp.type != PIKE_T_STRING)    {    pop_2_elems(); -  *Pike_sp = tmp; +  move_svalue (Pike_sp, &tmp);    Pike_sp++;    }else{    LOCAL_VAR(struct object *o); -  +  LOCAL_VAR(struct string_assignment_storage *s);    o=low_clone(string_assignment_program); -  ((struct string_assignment_storage *)o->storage)->lval[0]=Pike_sp[-2]; -  ((struct string_assignment_storage *)o->storage)->lval[1]=Pike_sp[-1]; -  ((struct string_assignment_storage *)o->storage)->s=tmp.u.string; +  s = (struct string_assignment_storage *)o->storage; +  move_svalue (s->lval, Pike_sp - 2); +  move_svalue (s->lval + 1, Pike_sp - 1); +  s->s=tmp.u.string;    Pike_sp-=2;    push_object(o);    }
1987:       index_no_free(&tmp2, s, &tmp);    free_svalue(s); -  *s=tmp2; +  move_svalue (s, &tmp2);    print_return_value();       if(low_mega_apply(APPLY_STACK, args, 0, 0))
2045:       index_no_free(&tmp2, s, &tmp);    free_svalue(s); -  *s=tmp2; +  move_svalue (s, &tmp2);    print_return_value();       if(low_mega_apply(APPLY_STACK, args, 0, 0))
2103:       index_no_free(&tmp2, s, &tmp);    free_svalue(s); -  *s=tmp2; +  move_svalue (s, &tmp2);    print_return_value();       if(low_mega_apply(APPLY_STACK, args, 0, 0))