pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.243 2001/08/16 04:38:50 mast Exp $"); + RCSID("$Id: interpret.c,v 1.244 2001/08/19 03:30:10 hubbe 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:1051:   }while(0)      BLOCK_ALLOC(pike_frame,128)      int low_mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)   {    struct object *o;    struct pike_frame *scope=0;    ptrdiff_t fun;    struct svalue *save_sp=Pike_sp-args; -  int tailrecurse=-1; +     -  +    #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");       if(thread_for_id(th_self()) != Pike_interpreter.thread_id)    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: -  apply_stack: +     if(!args)    PIKE_ERROR("`()", "Too few arguments (apply stack).\n", Pike_sp, 0);    args--; -  if(Pike_sp-save_sp-args > (args<<2) + 32) -  { -  /* The test above assures these two areas -  * are not overlapping -  */ -  assign_svalues(save_sp, Pike_sp-args-1, args+1, BIT_MIXED); -  pop_n_elems(Pike_sp-save_sp-args-1); -  } +     arg1=(void *)(Pike_sp-args-1);       case APPLY_SVALUE:    case APPLY_SVALUE_STRICT:    apply_svalue:    {    struct svalue *s=(struct svalue *)arg1;    switch(s->type)    {    case T_INT:
pike.git/src/interpret.c:1236:       if(fun<0)    {    pop_n_elems(Pike_sp-save_sp);    push_int(0);    return 0;    }       check_stack(256);    check_mark_stack(256); -  check_c_stack(8192); +     -  +    #ifdef PIKE_DEBUG    if(d_flag>2) do_debug();   #endif       p=o->prog;    if(!p)    PIKE_ERROR("destructed object->function",    "Cannot call functions in destructed objects.\n", Pike_sp, args);      #ifdef PIKE_SECURITY
pike.git/src/interpret.c:1324: Inside #if defined(PIKE_DEBUG)
   DO_NOT_WARN((long)new_frame->context.storage_offset),    new_frame->context.name ? new_frame->context.name->str : "NULL");    if(t_flag>19)    {    describe(new_frame->context.prog);    }    }   #endif       -  new_frame->locals = Pike_sp - args; -  new_frame->expendible = new_frame->locals; +  new_frame->expendible =new_frame->locals = Pike_sp - args;    new_frame->args = args;    new_frame->current_storage = o->storage+new_frame->context.storage_offset;    new_frame->pc = 0;    new_frame->scope=scope;    new_frame->save_sp=save_sp;       add_ref(new_frame->current_object);    add_ref(new_frame->context.prog);    if(new_frame->context.parent) add_ref(new_frame->context.parent);    if(new_frame->scope) add_ref(new_frame->scope);
pike.git/src/interpret.c:1366:    generic_error(NULL, Pike_sp, args,    "Calling undefined function.\n");    }      #ifdef PROFILING   #ifdef HAVE_GETHRTIME    new_frame->self_time_base=function->total_time;   #endif   #endif    -  tailrecurse=-1; +     switch(function->identifier_flags & (IDENTIFIER_FUNCTION | IDENTIFIER_CONSTANT))    {    case IDENTIFIER_C_FUNCTION:    debug_malloc_touch(Pike_fp);    Pike_fp->num_args=args;    new_frame->num_locals=args;    check_threads_etc();    (*function->func.c_fun)(args);    break;   
pike.git/src/interpret.c:1414:    {    /* Create an extra svalue for tail recursion style call */    Pike_sp++;    MEMMOVE(Pike_sp-args,Pike_sp-args-1,sizeof(struct svalue)*args);    Pike_sp[-args-1].type=T_INT;    }else{    free_svalue(Pike_sp-args-1);    Pike_sp[-args-1].type=T_INT;    }    low_object_index_no_free(Pike_sp-args-1,o,fun); -  tailrecurse=args+1; -  break; +  +  /* No profiling code for calling variables - Hubbe */ +  POP_PIKE_FRAME(); +  +  if(Pike_sp-save_sp-args > (args<<2) + 32) +  { +  /* The test above assures these two areas +  * are not overlapping +  */ +  assign_svalues(save_sp, Pike_sp-args, args, BIT_MIXED); +  pop_n_elems(Pike_sp-save_sp-args);    } -  +  arg1=(void *)(Pike_sp-args-1); +  goto apply_svalue; +  }       case IDENTIFIER_PIKE_FUNCTION:    {    int num_args;    int num_locals;    PIKE_OPCODE_T *pc;      #ifdef PIKE_DEBUG    if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_FREE)    fatal("Pike code called within gc.\n");
pike.git/src/interpret.c:1503:   #endif      #if 0   #ifdef PIKE_DEBUG    if(Pike_fp!=new_frame)    fatal("Frame stack out of whack!\n");   #endif   #endif       POP_PIKE_FRAME(); -  -  if(tailrecurse>=0) -  { -  args=tailrecurse; -  goto apply_stack; +     }    } -  } +        if(save_sp+1 < Pike_sp)    {    assign_svalue(save_sp,Pike_sp-1);    pop_n_elems(Pike_sp-save_sp-1);       low_destruct_objects_to_destruct(); /* consider using a flag for immediate destruct instead... */    }       if(save_sp+1 > Pike_sp)
pike.git/src/interpret.c:1661:    fp->mark_sp_base,    sizeof(struct svalue **)*(Pike_mark_sp - fp->mark_sp_base));    fp->mark_sp_base-=freespace;    Pike_mark_sp-=freespace;    }   }         void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)   { +  check_c_stack(8192);    if(low_mega_apply(type, args, arg1, arg2))    {    eval_instruction(Pike_fp->pc   #ifdef ENTRY_PROLOGUE_SIZE    - ENTRY_PROLOGUE_SIZE   #endif /* ENTRY_PROLOGUE_SIZE */    );    low_return();    }   }