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.97 1998/11/09 07:23:15 hubbe Exp $"); + RCSID("$Id: interpret.c,v 1.98 1998/11/13 01:28:43 hubbe Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "error.h"   #include "language.h"   #include "stralloc.h"   #include "constants.h"
pike.git/src/interpret.c:1781:   }         void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)   {    struct object *o;    int fun, tailrecurse=-1;    struct svalue *save_sp=sp-args;   #ifdef PROFILING   #ifdef HAVE_GETHRTIME +  static long long accounted_time =0; +  long long children_base = accounted_time;    long long start_time = gethrtime(); -  +  unsigned INT32 self_time_base;   #endif   #endif       switch(type)    {    case APPLY_STACK:    apply_stack:    if(!args)    PIKE_ERROR("`()", "Too few arguments.\n", sp, 0);    args--;
pike.git/src/interpret.c:1976:    my_strcat(function->name->str);    do_trace_call(args);    }       fp = &new_frame;       if(function->func.offset == -1)    PIKE_ERROR(function->name->str, "Calling undefined function.\n", sp, args);       tailrecurse=-1; +  + #ifdef PROFILING + #ifdef HAVE_GETHRTIME +  self_time_base=function->total_time; + #endif + #endif +     switch(function->identifier_flags & (IDENTIFIER_FUNCTION | IDENTIFIER_CONSTANT))    {    case IDENTIFIER_C_FUNCTION:    fp->num_args=args;    new_frame.num_locals=args;    check_threads_etc();    (*function->func.c_fun)(args);    break;       case IDENTIFIER_CONSTANT:
pike.git/src/interpret.c:2077: Inside #if defined(DEBUG)
  #ifdef DEBUG    if(sp<evaluator_stack)    fatal("Stack error (also simple).\n");   #endif    break;    }       }   #ifdef PROFILING   #ifdef HAVE_GETHRTIME -  function->total_time+=(INT32)((gethrtime()-start_time)/1000); +  { +  long long time_passed, time_in_children, self_time; +  time_in_children= accounted_time - children_base; +  time_passed = gethrtime() - start_time; +  self_time=time_passed - time_in_children; +  accounted_time+=self_time; + #ifdef DEBUG +  if(self_time < 0) +  fatal("Self time is negative\n self_time=%ld\n time_passed=%ld\n time_in_children=%ld\n children_base=%ld\n accounted_time=%ld!\n", +  (long)(self_time/1000), +  (long)(time_passed/1000), +  (long)(time_in_children/1000), +  (long)(children_base/1000), +  (long)(accounted_time/1000) +  );   #endif -  +  function->total_time=self_time_base + (INT32)(time_passed /1000); +  function->self_time+=(INT32)( self_time /1000); +  }   #endif -  + #endif      #if 0    if(sp - new_frame.locals > 1)    {    pop_n_elems(sp - new_frame.locals -1);    }else if(sp - new_frame.locals < 1){   #ifdef DEBUG    if(sp - new_frame.locals<0) fatal("Frame underflow.\n");   #endif    sp->u.integer = 0;