pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:23:   #include "lex.h"   #include "builtin_functions.h"   #include "signal_handler.h"   #include "gc.h"   #include "threads.h"   #include "callback.h"   #include "fd_control.h"   #include "bignum.h"   #include "pike_types.h"   #include "pikecode.h" + #include "pike_compiler.h"      #include <fcntl.h>   #include <errno.h>   #include <ctype.h>      #ifdef HAVE_MMAP      #ifdef HAVE_SYS_MMAN_H   #include <sys/mman.h>   #endif
pike.git/src/interpret.c:549: Inside #if defined(PIKE_DEBUG)
   }   }      #define TRACE(X) pike_trace X   #else   #define TRACE(X)   #endif      static struct inherit dummy_inherit   #ifdef PIKE_DEBUG -  = {-4711, -4711, -4711, -4711, (size_t) -4711, -4711, NULL, NULL, NULL} + = {-4711, -4711, -4711, -4711, (size_t) -4711, -4711, NULL, NULL, NULL, NULL}   #endif   ;      /* Find the lexical scope @[depth] levels out.    *    * @[loc]:    * Input:    * struct object *o // object to start from.    * struct inherit *inherit // inherit in o->prog.    * (int parent_identifier) // identifier in o to start from.
pike.git/src/interpret.c:2003:   }      static struct pike_frame_chunk {    struct pike_frame_chunk *next;   } *pike_frame_chunks;   static int num_pike_frame_chunks;   static int num_pike_frames;      PMOD_EXPORT void really_free_pike_frame( struct pike_frame *X )   { -  free_object(X->current_object); +  do_free_object(X->current_object);    if(X->current_program)    free_program(X->current_program);    if(X->scope)    free_pike_scope(X->scope);    DO_IF_DEBUG(    if(X->flags & PIKE_FRAME_MALLOCED_LOCALS)    Pike_fatal("Pike frame is not supposed to have malloced locals here!\n"));    if (X->flags & PIKE_FRAME_SAVE_LOCALS) {    free(X->save_locals_bitmask);    X->flags &= ~PIKE_FRAME_SAVE_LOCALS;
pike.git/src/interpret.c:2038:   struct pike_frame *alloc_pike_frame(void)   {    struct pike_frame *res;    if( free_pike_frame )    {    res = free_pike_frame;    PIKE_MEMPOOL_ALLOC(&free_pike_frame, res, sizeof(struct pike_frame));    PIKE_MEM_RW_RANGE(&res->next, sizeof(void*));    free_pike_frame = res->next;    PIKE_MEM_WO_RANGE(&res->next, sizeof(void*)); +  memset(res, 0, sizeof(struct pike_frame));    gc_init_marker(res);    res->refs=0;    add_ref(res); /* For DMALLOC... */    res->flags=0;    res->next=0;    res->scope=0;    res->pc = NULL;       return res;    }
pike.git/src/interpret.c:2180:    if( (p = o->prog) )    {    struct svalue *save_sp = Pike_sp - args;    struct reference *ref = p->identifier_references + fun;    struct inherit *context = p->inherits + ref->inherit_offset;    struct identifier *function = context->prog->identifiers + ref->identifier_offset;    struct svalue *constant = NULL;    struct pike_frame *new_frame = NULL;       int type = (function->identifier_flags & (IDENTIFIER_TYPE_MASK|IDENTIFIER_ALIAS)); -  if( o->prog != pike_trampoline_program && function->func.offset != -1 ) +  if( o->prog != pike_trampoline_program && +  !( + #ifdef USE_VALGRIND +  type & IDENTIFIER_PIKE_FUNCTION && + #endif +  function->func.offset == -1 ))    {    switch( type )    {    case IDENTIFIER_CONSTANT:    constant = &context->prog->constants[function->func.const_info.offset].sval;    if( TYPEOF(*constant) != PIKE_T_PROGRAM )    break;    /* FALLTHRU */    case IDENTIFIER_C_FUNCTION:    case IDENTIFIER_PIKE_FUNCTION:
pike.git/src/interpret.c:2944:   int apply_low_safe_and_stupid(struct object *o, INT32 offset)   {    JMP_BUF tmp;    struct pike_frame *new_frame=alloc_pike_frame();    int ret;    volatile int use_dummy_reference = 1;    struct program *prog = o->prog;    int p_flags = prog->flags;    LOW_JMP_BUF *saved_jmpbuf;    int fun = -1; +  int save_compiler_pass = Pike_compiler->compiler_pass;       /* Search for a function that belongs to the current program,    * since this is needed for opcodes that use INHERIT_FROM_*    * (eg F_EXTERN) to work.    */    for (fun = prog->num_identifier_references; fun--;) {    if (!prog->identifier_references[fun].inherit_offset) {    use_dummy_reference = 0;    break;    }    }    -  + #ifdef PIKE_DEBUG +  if (Pike_compiler->new_program != prog) { +  Pike_fatal("Invalid use of apply_low_save_and_stupid().\n"); +  } + #endif /* PIKE_DEBUG */ +  +  /* NB: add_to_*() are only valid in the first pass! */ +  Pike_compiler->compiler_pass = COMPILER_PASS_FIRST;    if (use_dummy_reference) {    /* No suitable function was found, so add one. */    struct identifier dummy;    struct reference dummy_ref = {    0, 0, ID_HIDDEN,    PIKE_T_UNKNOWN, { 0, },    }; -  /* FIXME: Assert that o->prog == Pike_compiler->new_program */ +     copy_shared_string(dummy.name, empty_pike_string);    copy_pike_type(dummy.type, function_type_string);    dummy.filename_strno = -1;    dummy.linenumber = 0;    dummy.run_time_type = PIKE_T_FUNCTION;    dummy.identifier_flags = IDENTIFIER_PIKE_FUNCTION|IDENTIFIER_HAS_BODY;    dummy.func.offset = offset;    dummy.opt_flags = 0;    dummy_ref.identifier_offset = prog->num_identifiers;    add_to_identifiers(dummy);
pike.git/src/interpret.c:3023: Inside #if defined(PIKE_DEBUG)
   if (tmp != -1)    Pike_fatal ("Unexpected return value from eval_instruction: %d\n", tmp);    if(Pike_sp<Pike_interpreter.evaluator_stack)    Pike_fatal("Stack error (simple).\n");   #endif    ret=0;    }    UNSETJMP(tmp);       Pike_interpreter.catching_eval_jmpbuf = saved_jmpbuf; +  Pike_compiler->compiler_pass = save_compiler_pass;       if (use_dummy_reference) {    /* Pop the dummy identifier. */    free_type(function_type_string);    free_string(empty_pike_string);    prog->num_identifier_references--;    prog->num_identifiers--;    }       assert (new_frame == Pike_fp);
pike.git/src/interpret.c:3239:    int id = find_identifier(fun, o->prog);    if (id >= 0)    apply_low(o, id, args);    else    Pike_error ("Cannot call unknown function \"%s\".\n", fun);   }         PMOD_EXPORT void apply_svalue(struct svalue *s, INT32 args)   { -  if(TYPEOF(*s) == T_INT) +  if(IS_UNDEFINED(s))    { -  +  /* FIXME: Why? cf LysLysKOM 22891031. */    pop_n_elems(args); -  push_int(0); +  push_undefined();    }else{    ptrdiff_t expected_stack=Pike_sp-args+1 - Pike_interpreter.evaluator_stack;       strict_apply_svalue(s,args);    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))    {