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. - || $Id: interpret.c,v 1.286 2003/01/05 19:54:04 grubba Exp $ + || $Id: interpret.c,v 1.287 2003/01/09 15:21:26 grubba Exp $   */      #include "global.h" - RCSID("$Id: interpret.c,v 1.286 2003/01/05 19:54:04 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.287 2003/01/09 15:21:26 grubba 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:52:   #ifdef MAP_NORESERVE   #define USE_MMAP_FOR_STACK   #endif   #endif      /*    * Define the default evaluator stack size, used for just about everything.    */   #define EVALUATOR_STACK_SIZE 100000    - #define TRACE_LEN (100 + t_flag * 10) + #define TRACE_LEN (100 + Pike_interpreter.trace_level * 10)      /* Keep some margin on the stack space checks. They're lifted when    * handle_error runs to give it some room. */   #define SVALUE_STACK_MARGIN 100 /* Tested in 7.1: 40 was enough, 30 wasn't. */   #define C_STACK_MARGIN 8000 /* Tested in 7.1: 3000 was enough, 2600 wasn't. */      #ifdef HAVE_COMPUTED_GOTO   PIKE_OPCODE_T *fcode_to_opcode = NULL;   struct op_2_f *opcode_to_fcode = NULL;   #endif /* HAVE_COMPUTED_GOTO */
pike.git/src/interpret.c:457:    index_error(0,0,0,lval,lval+1,"Indexing a basic type.\n");    return 0;    }   }      #ifdef PIKE_DEBUG      inline void pike_trace(int level,char *fmt, ...) ATTRIBUTE((format (printf, 2, 3)));   inline void pike_trace(int level,char *fmt, ...)   { -  if(t_flag > level) +  if(Pike_interpreter.trace_level > level)    {    va_list args;    va_start(args,fmt);    vsprintf(trace_buffer,fmt,args);    va_end(args);    write_to_stderr(trace_buffer,strlen(trace_buffer));    }   }      void my_describe_inherit_structure(struct program *p)
pike.git/src/interpret.c:524:       TRACE((4, "-find_external_context(%d, inherit=%ld)\n", arg2,    DO_NOT_WARN((long)(loc->o->prog ? loc->inherit - loc->o->prog->inherits : 0))));       if(!loc->o)    Pike_error("Current object is destructed\n");       while(--arg2>=0)    {   #ifdef PIKE_DEBUG -  if(t_flag>8 && loc->o->prog) +  if(Pike_interpreter.trace_level>8 && loc->o->prog)    my_describe_inherit_structure(loc->o->prog);   #endif       TRACE((4,"- i->parent_offset=%d i->parent_identifier=%d\n",    loc->inherit->parent_offset,    loc->inherit->parent_identifier));       TRACE((4,"- o->parent_identifier=%d inherit->identifier_level=%d\n",    loc->o->prog &&    (loc->o->prog->flags & PROGRAM_USES_PARENT) ?
pike.git/src/interpret.c:614: Inside #if defined(PIKE_DEBUG)
  #ifdef PIKE_DEBUG    if(loc->parent_identifier < 0 ||    loc->parent_identifier > p->num_identifier_references)    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) +  if(Pike_interpreter.trace_level>28)    my_describe_inherit_structure(p);   #endif       TRACE((5,"- Parent identifier = %d (%s), inherit # = %ld\n",    loc->parent_identifier,    ID_FROM_INT(p, loc->parent_identifier)->name->str,    DO_NOT_WARN((long)(loc->inherit - p->inherits))));      #ifdef DEBUG_MALLOC    if (loc->inherit->storage_offset == 0x55555555) {
pike.git/src/interpret.c:645:       TRACE((4,"--find_external_context: parent_id=%d (%s)\n",    loc->parent_identifier,    ID_FROM_INT(loc->o->prog,loc->parent_identifier)->name->str    ));   }      #ifdef PIKE_DEBUG   void print_return_value(void)   { -  if(t_flag>3) +  if(Pike_interpreter.trace_level>3)    {    char *s;       init_buf();    describe_svalue(Pike_sp-1,0,0);    s=simple_free_buf();    if((size_t)strlen(s) > (size_t)TRACE_LEN)    {    s[TRACE_LEN]=0;    s[TRACE_LEN-1]='.';
pike.git/src/interpret.c:815:    /* No extra setup needed! \    */ \    return ((int (*)(void))(pc))(); \    } \    } while(0)   #endif /* !CALL_MACHINE_CODE */      #define OPCODE0(O,N,F,C) \   void PIKE_CONCAT(opcode_,O)(void) { \    DEF_PROG_COUNTER; \ - DO_IF_DEBUG(if(t_flag > 3) fprintf(stderr,"- (%p,%ld): %s()\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N));\ + DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) fprintf(stderr,"- (%p,%ld): %s()\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N));\   C }      #define OPCODE1(O,N,F,C) \   void PIKE_CONCAT(opcode_,O)(INT32 arg1) {\    DEF_PROG_COUNTER; \ - DO_IF_DEBUG(if(t_flag > 3) fprintf(stderr,"- (%p,%ld): %s(%d)\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N,arg1)); \ + DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) fprintf(stderr,"- (%p,%ld): %s(%d)\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N,arg1)); \   C }         #define OPCODE2(O,N,F,C) \   void PIKE_CONCAT(opcode_,O)(INT32 arg1,INT32 arg2) { \    DEF_PROG_COUNTER; \ - DO_IF_DEBUG(if(t_flag > 3) fprintf(stderr,"- (%p,%ld): %s(%d,%d)\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N,arg1,arg2)); \ + DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) fprintf(stderr,"- (%p,%ld): %s(%d,%d)\n",PROG_COUNTER,DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)),N,arg1,arg2)); \   C }      #ifdef OPCODE_INLINE_BRANCH   #define TEST_OPCODE0(O,N,F,C) \   int PIKE_CONCAT(test_opcode_,O)(void) { \    int branch_taken = 0; \    DEF_PROG_COUNTER; \ -  DO_IF_DEBUG(if(t_flag > 3) \ +  DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) \    fprintf(stderr, "- (%p,%ld): %s()\n", PROG_COUNTER, \    DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)), \    N));\    C; \    return branch_taken; \    }      #define TEST_OPCODE1(O,N,F,C) \   int PIKE_CONCAT(test_opcode_,O)(INT32 arg1) {\    int branch_taken = 0; \    DEF_PROG_COUNTER; \ -  DO_IF_DEBUG(if(t_flag > 3) \ +  DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) \    fprintf(stderr, "- (%p,%ld): %s(%d)\n", PROG_COUNTER, \    DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)), \    N, arg1)); \    C; \    return branch_taken; \    }         #define TEST_OPCODE2(O,N,F,C) \   int PIKE_CONCAT(test_opcode_,O)(INT32 arg1, INT32 arg2) { \    int branch_taken = 0; \    DEF_PROG_COUNTER; \ -  DO_IF_DEBUG(if(t_flag > 3) \ +  DO_IF_DEBUG(if(Pike_interpreter.trace_level > 3) \    fprintf(stderr, "- (%p,%ld): %s(%d,%d)\n", PROG_COUNTER, \    DO_NOT_WARN((long)(Pike_sp-Pike_interpreter.evaluator_stack)), \    N, arg1, arg2)); \    C; \    return branch_taken; \    }      #define DO_BRANCH() (branch_taken = -1)   #define DONT_BRANCH() (branch_taken = 0)   #else /* !OPCODE_INLINE_BRANCH */
pike.git/src/interpret.c:926: Inside #if defined(__GNUC__)
  DEF_PROG_COUNTER;      #ifdef PIKE_DEBUG   /* Note: The debug code is extracted, to keep the frame size constant. */   static int eval_instruction_low(PIKE_OPCODE_T *pc);   #endif /* PIKE_DEBUG */      static int eval_instruction(PIKE_OPCODE_T *pc)   #ifdef PIKE_DEBUG   { -  if (t_flag && pc) { +  if (Pike_interpreter.trace_level && pc) {    int i;    fprintf(stderr, "Calling code at %p:\n", pc);   #ifdef PIKE_OPCODE_ALIGN    if (((INT32)pc) % PIKE_OPCODE_ALIGN) {    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",
pike.git/src/interpret.c:1041:   #define PIKE_DEBUG   #define NDEBUG   #undef DO_IF_DEBUG   #define DO_IF_DEBUG(X) X   #undef print_return_value      #undef eval_instruction      static inline int eval_instruction(unsigned char *pc)   { -  if(d_flag || t_flag>2) +  if(d_flag || Pike_interpreter.trace_level>2)    return eval_instruction_with_debug(pc);    else    return eval_instruction_without_debug(pc);   }         #else   #include "interpreter.h"   #endif   
pike.git/src/interpret.c:1253:    Pike_error("Attempt to call a mapping\n");    default:    Pike_error("Call to non-function value type:%s.\n",    get_name_of_type(s->type));       case T_FUNCTION:    if(s->subtype == FUNCTION_BUILTIN)    {   #ifdef PIKE_DEBUG    struct svalue *expected_stack = Pike_sp-args; -  if(t_flag>1) +  if(Pike_interpreter.trace_level>1)    {    init_buf();    describe_svalue(s,0,0);    do_trace_call(args);    }   #endif    check_threads_etc();    (*(s->u.efun->function))(args);      #ifdef PIKE_DEBUG
pike.git/src/interpret.c:1300:    o=scope->current_object;    goto apply_low_with_scope;    }    fun=s->subtype;    goto apply_low;    }    break;       case T_ARRAY:   #ifdef PIKE_DEBUG -  if(t_flag>1) +  if(Pike_interpreter.trace_level>1)    {    init_buf();    describe_svalue(s,0,0);    do_trace_call(args);    }   #endif    apply_array(s->u.array,args);    break;       case T_PROGRAM:   #ifdef PIKE_DEBUG -  if(t_flag>1) +  if(Pike_interpreter.trace_level>1)    {    init_buf();    describe_svalue(s,0,0);    do_trace_call(args);    }   #endif    push_object(clone_object(s->u.program,args));    break;       case T_OBJECT:
pike.git/src/interpret.c:1383:    if(type != APPLY_SVALUE_STRICT)    push_int(0);    }else{    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(t_flag>1) trace_return_value(); +  if(Pike_interpreter.trace_level>1) trace_return_value();    }    return 0;   }            #define low_return_profiling()      #ifdef PROFILING   #ifdef HAVE_GETHRTIME
pike.git/src/interpret.c:1439:    push_int(0);    }else{    if(save_sp+1 < Pike_sp)    {    assign_svalue(save_sp,Pike_sp-1);    pop_n_elems(Pike_sp-save_sp-1);       /* consider using a flag for immediate destruct instead... */    destruct_objects_to_destruct();    } -  if(t_flag>1) trace_return_value(); +  if(Pike_interpreter.trace_level>1) trace_return_value();    }   }      void low_return_pop(void)   {    basic_low_return();       if(save_sp < Pike_sp)    {    pop_n_elems(Pike_sp-save_sp);
pike.git/src/interpret.c:1611:    */      /*! @endclass    */      PMOD_EXPORT void call_handle_error(void)   {    dmalloc_touch_svalue(&throw_value);    if (Pike_interpreter.svalue_stack_margin) {    ONERROR tmp; -  int old_t_flag = t_flag; -  t_flag = 0; +  int old_t_flag = Pike_interpreter.trace_level; +  Pike_interpreter.trace_level = 0;    Pike_interpreter.svalue_stack_margin = 0;    Pike_interpreter.c_stack_margin = 0;    SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!");    *(Pike_sp++) = throw_value;    throw_value.type=T_INT;    APPLY_MASTER("handle_error", 1);    pop_stack();    UNSET_ONERROR(tmp);    Pike_interpreter.svalue_stack_margin = SVALUE_STACK_MARGIN;    Pike_interpreter.c_stack_margin = C_STACK_MARGIN; -  t_flag = old_t_flag; +  Pike_interpreter.trace_level = old_t_flag;    }    else {    free_svalue(&throw_value);    throw_value.type=T_INT;    }   }      PMOD_EXPORT int apply_low_safe_and_stupid(struct object *o, INT32 offset)   {    JMP_BUF tmp;