pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:1:   /*\   ||| 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.   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.262 2002/06/25 14:26:40 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.263 2002/08/15 14:49:21 marcus Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "pike_error.h"   #include "language.h"   #include "stralloc.h"   #include "constants.h"
pike.git/src/interpret.c:111:   void push_sp_mark(void)   {    if(Pike_mark_sp == Pike_interpreter.mark_stack + Pike_stack_size)    Pike_error("No more mark stack!\n");    *Pike_mark_sp++=Pike_sp;   }   ptrdiff_t pop_sp_mark(void)   {   #ifdef PIKE_DEBUG    if(Pike_mark_sp < Pike_interpreter.mark_stack) -  fatal("Mark stack underflow!\n"); +  Pike_fatal("Mark stack underflow!\n");   #endif    return Pike_sp - *--Pike_mark_sp;   }         #ifdef PIKE_DEBUG   static void gc_check_stack_callback(struct callback *foo, void *bar, void *gazonk)   {    struct pike_frame *f;    debug_gc_xmark_svalues(Pike_interpreter.evaluator_stack,
pike.git/src/interpret.c:524:    PARENT_INFO(loc->o)->parent_identifier : -1,    loc->inherit->identifier_level));       switch(loc->inherit->parent_offset)    {    default:    {    struct external_variable_context tmp=*loc;   #ifdef PIKE_DEBUG    if(!loc->inherit->inherit_level) -  fatal("Gahhh! inherit level zero in wrong place!\n"); +  Pike_fatal("Gahhh! inherit level zero in wrong place!\n");   #endif    while(tmp.inherit->inherit_level >= loc->inherit->inherit_level)    {    TRACE((5,"- inherit-- (%d >= %d)\n",tmp.inherit->inherit_level, loc->inherit->inherit_level));    tmp.inherit--;    }       find_external_context(&tmp,    loc->inherit->parent_offset);    loc->o=tmp.o;
pike.git/src/interpret.c:572:    if(!loc->o)    Pike_error("Parent was lost during cloning.\n");       if(!(p=loc->o->prog))    Pike_error("Attempting to access variable in destructed object\n");      #ifdef DEBUG_MALLOC    if (loc->o->refs == 0x55555555) {    fprintf(stderr, "The object %p has been zapped!\n", loc->o);    describe(p); -  fatal("Object zapping detected.\n"); +  Pike_fatal("Object zapping detected.\n");    }    if (p->refs == 0x55555555) {    fprintf(stderr, "The program %p has been zapped!\n", p);    describe(p);    fprintf(stderr, "Which taken from the object %p\n", loc->o);    describe(loc->o); -  fatal("Looks like the program %p has been zapped!\n", p); +  Pike_fatal("Looks like the program %p has been zapped!\n", p);    }   #endif /* DEBUG_MALLOC */      #ifdef PIKE_DEBUG    if(loc->parent_identifier < 0 ||    loc->parent_identifier > p->num_identifier_references) -  fatal("Identifier out of range, loc->parent_identifer=%d!\n", +  Pike_fatal("Identifier out of range, loc->parent_identifer=%d!\n",    loc->parent_identifier);   #endif       loc->inherit=INHERIT_FROM_INT(p, loc->parent_identifier);      #ifdef PIKE_DEBUG    if(t_flag>28)    my_describe_inherit_structure(p);   #endif   
pike.git/src/interpret.c:610:    DO_NOT_WARN((long)(loc->inherit - p->inherits))));      #ifdef DEBUG_MALLOC    if (loc->inherit->storage_offset == 0x55555555) {    fprintf(stderr, "The inherit %p has been zapped!\n", loc->inherit);    debug_malloc_dump_references(loc->inherit,0,2,0);    fprintf(stderr, "It was extracted from the program %p %d\n", p, loc->parent_identifier);    describe(p);    fprintf(stderr, "Which was in turn taken from the object %p\n", loc->o);    describe(loc->o); -  fatal("Looks like the program %p has been zapped!\n", p); +  Pike_fatal("Looks like the program %p has been zapped!\n", p);    }   #endif /* DEBUG_MALLOC */    }       TRACE((4,"--find_external_context: parent_id=%d (%s)\n",    loc->parent_identifier,    ID_FROM_INT(loc->o->prog,loc->parent_identifier)->name->str    ));   }   
pike.git/src/interpret.c:760:    }while(e!=backlogp);   }      #endif   static int o_catch(PIKE_OPCODE_T *pc);         #ifdef PIKE_DEBUG   #define EVAL_INSTR_RET_CHECK(x) \    if (x == -2) \ -  fatal("Return value -2 from eval_instruction is not handled here.\n"\ +  Pike_fatal("Return value -2 from eval_instruction is not handled here.\n"\    "Probable cause: F_ESCAPE_CATCH outside catch block.\n")   #else   #define EVAL_INSTR_RET_CHECK(x)   #endif         #ifdef PIKE_USE_MACHINE_CODE      /* Labels to jump to to cause eval_instruction to return */   /* FIXME: Replace these with assembler lables */
pike.git/src/interpret.c:849: Inside #if defined(__GNUC__)
  {    do_inter_return_label = && inter_return_label;    do_escape_catch_label = && inter_escape_catch_label;      #ifdef PIKE_DEBUG    if (t_flag) {    int i;    fprintf(stderr, "Calling code at 0x%p:\n", pc);   #ifdef PIKE_OPCODE_ALIGN    if (((INT32)pc) % PIKE_OPCODE_ALIGN) { -  fatal("Odd offset!\n"); +  Pike_fatal("Odd offset!\n");    }   #endif /* PIKE_OPCODE_ALIGN */    for (i=0; i < 16; i+=4) {    fprintf(stderr,    " 0x%08x 0x%08x 0x%08x 0x%08x\n",    ((int *)pc)[i],    ((int *)pc)[i+1],    ((int *)pc)[i+2],    ((int *)pc)[i+3]);    }
pike.git/src/interpret.c:1037:   #define EXIT_BLOCK(X) do { \    free_object(X->current_object); \    if(X->context.prog) free_program(X->context.prog); \    if(X->context.parent) free_object(X->context.parent); \    if(X->scope) free_pike_scope(X->scope); \    DO_IF_SECURITY( if(X->current_creds) { \    free_object(X->current_creds); \    }) \    DO_IF_DEBUG( \    if(X->flags & PIKE_FRAME_MALLOCED_LOCALS) \ -  fatal("Pike frame is not supposed to have malloced locals here!\n")); \ +  Pike_fatal("Pike frame is not supposed to have malloced locals here!\n")); \    \    DO_IF_DMALLOC( \    X->context.prog=0; \    X->context.parent=0; \    X->context.name=0; \    X->scope=0; \    X->current_object=0; \    X->flags=0; \    X->expendible=0; \    X->locals=0; \
pike.git/src/interpret.c:1083:    struct svalue *save_sp=Pike_sp-args;      #if defined(PIKE_DEBUG) && defined(_REENTRANT)    if(d_flag)    {    THREAD_T self = th_self();       CHECK_INTERPRETER_LOCK();       if( Pike_interpreter.thread_id && !th_equal( OBJ2THREAD(Pike_interpreter.thread_id)->id, self) ) -  fatal("Current thread is wrong.\n"); +  Pike_fatal("Current thread is wrong.\n");       if(thread_for_id(th_self()) != Pike_interpreter.thread_id) -  fatal("thread_for_id() (or Pike_interpreter.thread_id) failed in mega_apply! " +  Pike_fatal("thread_for_id() (or Pike_interpreter.thread_id) failed in mega_apply! "    "%p != %p\n", thread_for_id(self), Pike_interpreter.thread_id);    }   #endif       switch(type)    {    case APPLY_STACK:    if(!args)    PIKE_ERROR("`()", "Too few arguments (apply stack).\n", Pike_sp, 0);    args--;
pike.git/src/interpret.c:1145: Inside #if defined(PIKE_DEBUG)
   do_trace_call(args);    }   #endif    (*(s->u.efun->function))(args);      #ifdef PIKE_DEBUG    s->u.efun->runs++;    if(Pike_sp != expected_stack + !s->u.efun->may_return_void)    {    if(Pike_sp < expected_stack) -  fatal("Function popped too many arguments: %s\n", +  Pike_fatal("Function popped too many arguments: %s\n",    s->u.efun->name->str);    if(Pike_sp>expected_stack+1) -  fatal("Function left droppings on stack: %s\n", +  Pike_fatal("Function left droppings on stack: %s\n",    s->u.efun->name->str);    if(Pike_sp == expected_stack && !s->u.efun->may_return_void) -  fatal("Non-void function returned without return value on stack: %s %d\n", +  Pike_fatal("Non-void function returned without return value on stack: %s %d\n",    s->u.efun->name->str,s->u.efun->may_return_void);    if(Pike_sp==expected_stack+1 && s->u.efun->may_return_void) -  fatal("Void function returned with a value on the stack: %s %d\n", +  Pike_fatal("Void function returned with a value on the stack: %s %d\n",    s->u.efun->name->str, s->u.efun->may_return_void);    }   #endif       break;    }else{    type=APPLY_SVALUE;    o=s->u.object;    if(o->prog == pike_trampoline_program)    {
pike.git/src/interpret.c:1218:    fun=LFUN_CALL;    type=APPLY_SVALUE;    goto call_lfun;    }    break;    }       call_lfun:   #ifdef PIKE_DEBUG    if(fun < 0 || fun >= NUM_LFUNS) -  fatal("Apply lfun on illegal value!\n"); +  Pike_fatal("Apply lfun on illegal value!\n");   #endif    if(!o->prog)    PIKE_ERROR("destructed object", "Apply on destructed object.\n", Pike_sp, args);    fun = FIND_LFUN(o->prog, fun);    goto apply_low;          case APPLY_LOW:    o = (struct object *)arg1;    if(o->prog == pike_trampoline_program)
pike.git/src/interpret.c:1291:    function->self_time+=(INT32)( self_time /1000); \   }while(0)   #endif   #endif         #define basic_low_return() \    struct svalue *save_sp=Pike_fp->save_sp; \    DO_IF_DEBUG( \    if(Pike_mark_sp < Pike_fp->save_mark_sp) \ -  fatal("Popped below save_mark_sp!\n"); \ +  Pike_fatal("Popped below save_mark_sp!\n"); \    if(Pike_sp<Pike_interpreter.evaluator_stack) \ -  fatal("Stack error (also simple).\n"); \ +  Pike_fatal("Stack error (also simple).\n"); \    ) \    \    Pike_mark_sp=Pike_fp->save_mark_sp; \    \    POP_PIKE_FRAME()         void low_return(void)   {    basic_low_return();
pike.git/src/interpret.c:1349:    current=Pike_interpreter.frame_pointer;    prev=current->next;   #ifdef PIKE_DEBUG    {    JMP_BUF *rec;       if((rec=Pike_interpreter.recoveries))    {    while(rec->frame_pointer == current) rec=rec->previous;    if(rec->frame_pointer == current->next) -  fatal("You can't touch this!\n"); +  Pike_fatal("You can't touch this!\n");    }    }   #endif       Pike_interpreter.frame_pointer=prev;       target=prev->save_sp;    smsp=prev->save_mark_sp;    current->flags=prev->flags;    POP_PIKE_FRAME();
pike.git/src/interpret.c:1440:    }else{    struct svalue **save_mark_sp=Pike_mark_sp;    int x;    Pike_fp->expendible=Pike_fp->locals + Pike_fp->num_locals;       Pike_fp->flags&=~PIKE_FRAME_RETURN_INTERNAL;       x=eval_instruction(pc);   #ifdef PIKE_DEBUG    if(Pike_mark_sp < save_mark_sp) -  fatal("mark Pike_sp underflow in catch.\n"); +  Pike_fatal("mark Pike_sp underflow in catch.\n");   #endif    Pike_mark_sp=save_mark_sp;    Pike_fp->expendible=expendible;    Pike_fp->flags=flags;    if(x>=0) mega_apply(APPLY_STACK, x, 0,0); /* Should never happen */    UNSETJMP(tmp);    return x == -2 ? 2 : 1;    }   }   
pike.git/src/interpret.c:1520:    ret=1;    }else{    int tmp;    new_frame->mark_sp_base=new_frame->save_mark_sp=Pike_mark_sp;    tmp=eval_instruction(o->prog->program + offset);    EVAL_INSTR_RET_CHECK(tmp);    Pike_mark_sp=new_frame->save_mark_sp;      #ifdef PIKE_DEBUG    if(Pike_sp<Pike_interpreter.evaluator_stack) -  fatal("Stack error (simple).\n"); +  Pike_fatal("Stack error (simple).\n");   #endif    ret=0;    }    UNSETJMP(tmp);       POP_PIKE_FRAME();       return ret;   }   
pike.git/src/interpret.c:1572:   }      PMOD_EXPORT void safe_apply_low(struct object *o,int fun,int args)   {    safe_apply_low2(o, fun, args, 1);   }      PMOD_EXPORT void safe_apply(struct object *o, char *fun ,INT32 args)   {   #ifdef PIKE_DEBUG -  if(!o->prog) fatal("Apply safe on destructed object.\n"); +  if(!o->prog) Pike_fatal("Apply safe on destructed object.\n");   #endif    safe_apply_low2(o, find_identifier(fun, o->prog), args, 1);   }      /* Returns nonzero if the function was called in some handler. */   PMOD_EXPORT int low_unsafe_apply_handler(const char *fun,    struct object *handler,    struct object *compat,    INT32 args)   {
pike.git/src/interpret.c:1683:    }       UNSETJMP(recovery);    return ret;   }      PMOD_EXPORT void apply_lfun(struct object *o, int fun, int args)   {   #ifdef PIKE_DEBUG    if(fun < 0 || fun >= NUM_LFUNS) -  fatal("Apply lfun on illegal value!\n"); +  Pike_fatal("Apply lfun on illegal value!\n");   #endif    if(!o->prog)    PIKE_ERROR("destructed object", "Apply on destructed object.\n", Pike_sp, args);       apply_low(o, (int)FIND_LFUN(o->prog,fun), args);   }      PMOD_EXPORT void apply_shared(struct object *o,    struct pike_string *fun,    int args)
pike.git/src/interpret.c:1724:    if(Pike_sp > (expected_stack + Pike_interpreter.evaluator_stack))    {    pop_n_elems(Pike_sp-(expected_stack + Pike_interpreter.evaluator_stack));    }    else if(Pike_sp < (expected_stack + Pike_interpreter.evaluator_stack))    {    push_int(0);    }   #ifdef PIKE_DEBUG    if(Pike_sp < (expected_stack + Pike_interpreter.evaluator_stack)) -  fatal("Stack underflow!\n"); +  Pike_fatal("Stack underflow!\n");   #endif    }   }      #ifdef PIKE_DEBUG   void slow_check_stack(void)   {    struct svalue *s,**m;    struct pike_frame *f;       debug_check_stack();       if(Pike_sp > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) -  fatal("Svalue stack overflow. " +  Pike_fatal("Svalue stack overflow. "    "(%ld entries on stack, stack_size is %ld entries)\n",    PTRDIFF_T_TO_LONG(Pike_sp - Pike_interpreter.evaluator_stack),    PTRDIFF_T_TO_LONG(Pike_stack_size));       if(Pike_mark_sp > &(Pike_interpreter.mark_stack[Pike_stack_size])) -  fatal("Mark stack overflow.\n"); +  Pike_fatal("Mark stack overflow.\n");       if(Pike_mark_sp < Pike_interpreter.mark_stack) -  fatal("Mark stack underflow.\n"); +  Pike_fatal("Mark stack underflow.\n");       for(s=Pike_interpreter.evaluator_stack;s<Pike_sp;s++) check_svalue(s);       s=Pike_interpreter.evaluator_stack;    for(m=Pike_interpreter.mark_stack;m<Pike_mark_sp;m++)    {    if(*m < s) -  fatal("Mark stack failure.\n"); +  Pike_fatal("Mark stack failure.\n");       s=*m;    }       if(s > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) -  fatal("Mark stack exceeds svalue stack\n"); +  Pike_fatal("Mark stack exceeds svalue stack\n");       for(f=Pike_fp;f;f=f->next)    {    if(f->locals)    {    if(f->locals < Pike_interpreter.evaluator_stack ||    f->locals > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) -  fatal("Local variable pointer points to Finspång.\n"); +  Pike_fatal("Local variable pointer points to Finspång.\n");       if(f->args < 0 || f->args > Pike_stack_size) -  fatal("FEL FEL FEL! HELP!! (corrupted pike_frame)\n"); +  Pike_fatal("FEL FEL FEL! HELP!! (corrupted pike_frame)\n");    }    }   }      static const char *safe_idname_from_int(struct program *prog, int func)   {    /* ID_FROM_INT with a thick layer of checks. */    struct reference *ref;    struct inherit *inher;    struct identifier *id;