pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.c:1049:    cc, cc ? cc->prev : NULL)); \    if (!cc) \    Pike_fatal ("Catch context dropoff.\n"); \    if (cc->frame != Pike_fp) \    Pike_fatal ("Catch context doesn't belong to this frame.\n"); \    if (Pike_mark_sp != cc->recovery.mark_sp + Pike_interpreter.mark_stack) \    Pike_fatal ("Mark sp diff in catch context pop.\n"); \    ); \    debug_malloc_touch (cc); \    UNSETJMP (cc->recovery); \ -  frame_set_expendible(Pike_fp, cc->save_expendible); \ +     Pike_interpreter.catch_ctx = cc->prev; \    really_free_catch_context (cc); \    } while (0)   #else   #define POP_CATCH_CONTEXT do { \    struct catch_context *cc = Pike_interpreter.catch_ctx; \    DO_IF_DEBUG ( \    TRACE((3,"- Popping catch context %p ==> %p\n", \    cc, cc ? cc->prev : NULL)); \    if (!Pike_interpreter.catching_eval_jmpbuf) \    Pike_fatal ("Not in catching eval.\n"); \    if (!cc) \    Pike_fatal ("Catch context dropoff.\n"); \    if (cc->frame != Pike_fp) \    Pike_fatal ("Catch context doesn't belong to this frame.\n"); \    if (Pike_mark_sp != cc->recovery.mark_sp + Pike_interpreter.mark_stack) \    Pike_fatal ("Mark sp diff in catch context pop.\n"); \    ); \    debug_malloc_touch (cc); \    UNSETJMP (cc->recovery); \ -  frame_set_expendible(Pike_fp, cc->save_expendible); \ +     Pike_interpreter.catch_ctx = cc->prev; \    really_free_catch_context (cc); \    } while (0)   #endif      static struct catch_context *free_catch_context;   static int num_catch_ctx, num_free_catch_ctx;      PMOD_EXPORT void really_free_catch_context( struct catch_context *data )   {
pike.git/src/interpret.c:1198: Inside #if defined(PIKE_USE_MACHINE_CODE) and #if defined(OPCODE_INLINE_RETURN)
   }   #endif    {    struct catch_context *new_catch_ctx = alloc_catch_context();   #ifdef PIKE_DEBUG    new_catch_ctx->frame = Pike_fp;    init_recovery (&new_catch_ctx->recovery, 0, 0, PERR_LOCATION());   #else    init_recovery (&new_catch_ctx->recovery, 0);   #endif -  new_catch_ctx->save_expendible = frame_get_expendible(Pike_fp); +     new_catch_ctx->continue_reladdr = (INT32)get_unaligned32(addr)    /* We need to run the entry prologue... */    - ENTRY_PROLOGUE_SIZE;       new_catch_ctx->next_addr = addr;    new_catch_ctx->prev = Pike_interpreter.catch_ctx;    Pike_interpreter.catch_ctx = new_catch_ctx;    DO_IF_DEBUG({    TRACE((3,"- Pushed catch context %p\n", new_catch_ctx));    });    }    -  Pike_fp->expendible_offset = Pike_fp->num_locals; -  +     /* Need to adjust next_addr by sizeof(INT32) to skip past the jump    * address to the continue position after the catch block. */    addr = (PIKE_OPCODE_T *) ((INT32 *) addr + 1);       if (Pike_interpreter.catching_eval_jmpbuf) {    /* There's already a catching_eval_instruction around our    * eval_instruction, so we can just continue. */    debug_malloc_touch_named (Pike_interpreter.catch_ctx, "(1)");    /* Skip past the entry prologue... */    addr += ENTRY_PROLOGUE_SIZE;
pike.git/src/interpret.c:1275: Inside #if defined(PIKE_USE_MACHINE_CODE)
      DO_IF_DEBUG ({    TRACE((3,"- Caught exception. catch context: %p\n", cc));    if (!cc) Pike_fatal ("Catch context dropoff.\n");    if (cc->frame != Pike_fp)    Pike_fatal ("Catch context doesn't belong to this frame.\n");    });       debug_malloc_touch_named (cc, "(3)");    UNSETJMP (cc->recovery); -  frame_set_expendible(Pike_fp, cc->save_expendible); +     move_svalue (Pike_sp++, &throw_value);    mark_free_svalue (&throw_value);    low_destruct_objects_to_destruct();       if (cc->continue_reladdr < 0)    FAST_CHECK_THREADS_ON_BRANCH();    addr = cc->next_addr + cc->continue_reladdr;       DO_IF_DEBUG({    TRACE((3,"- Popping catch context %p ==> %p\n",
pike.git/src/interpret.c:1330: Inside #if defined(OPCODE_INLINE_CATCH)
   }   #endif    {    struct catch_context *new_catch_ctx = alloc_catch_context();   #ifdef PIKE_DEBUG    new_catch_ctx->frame = Pike_fp;    init_recovery (&new_catch_ctx->recovery, 0, 0, PERR_LOCATION());   #else    init_recovery (&new_catch_ctx->recovery, 0);   #endif -  new_catch_ctx->save_expendible = frame_get_expendible(Pike_fp); +        /* Note: no prologue. */    new_catch_ctx->continue_reladdr = (INT32)get_unaligned32(addr);       new_catch_ctx->next_addr = addr;    new_catch_ctx->prev = Pike_interpreter.catch_ctx;    Pike_interpreter.catch_ctx = new_catch_ctx;    DO_IF_DEBUG({    TRACE((3,"- Pushed catch context %p\n", new_catch_ctx));    });    }    -  Pike_fp->expendible_offset = Pike_fp->num_locals; -  +     /* Need to adjust next_addr by sizeof(INT32) to skip past the jump    * address to the continue position after the catch block. */    return (PIKE_OPCODE_T *) ((INT32 *) addr + 1) + ENTRY_PROLOGUE_SIZE;   }      /* Helper function for F_CATCH machine code. Called when an exception    is caught. Pops the catch context and returns the continue jump    destination. */   PIKE_OPCODE_T *handle_caught_exception(void)   {
pike.git/src/interpret.c:1368:       DO_IF_DEBUG ({    TRACE((3,"- Caught exception. catch context: %p\n", cc));    if (!cc) Pike_fatal ("Catch context dropoff.\n");    if (cc->frame != Pike_fp)    Pike_fatal ("Catch context doesn't belong to this frame.\n");    });       debug_malloc_touch_named (cc, "(3)");    UNSETJMP (cc->recovery); -  frame_set_expendible(Pike_fp, cc->save_expendible); +     move_svalue (Pike_sp++, &throw_value);    mark_free_svalue (&throw_value);    low_destruct_objects_to_destruct();       if (cc->continue_reladdr < 0)    FAST_CHECK_THREADS_ON_BRANCH();    addr = cc->next_addr + cc->continue_reladdr;       DO_IF_DEBUG({    TRACE((3,"- Popping catch context %p ==> %p\n",
pike.git/src/interpret.c:2029:    if (X->flags & PIKE_FRAME_SAVE_LOCALS) {    free(X->save_locals_bitmask);    X->flags &= ~PIKE_FRAME_SAVE_LOCALS;    }    DO_IF_DMALLOC(    X->current_program=0;    X->context=0;    X->scope=0;    X->current_object=0;    X->flags=0; -  X->expendible_offset=0; +     X->locals=0;    );    X->next = free_pike_frame;    PIKE_MEMPOOL_FREE(&free_pike_frame, X, sizeof(struct pike_frame));    free_pike_frame = X;   }      struct pike_frame *alloc_pike_frame(void)   {    struct pike_frame *res;
pike.git/src/interpret.c:2081:    res = res->next;    }    res->next = NULL;    num_pike_frames+=FRAMES_PER_CHUNK;    }    return alloc_pike_frame();   }      void LOW_POP_PIKE_FRAME_slow_path(struct pike_frame *frame)   { -  ptrdiff_t exp_offset = frame->expendible_offset; +     debug_malloc_touch(frame); -  if (exp_offset || (frame->flags & PIKE_FRAME_SAVE_LOCALS)) { +  +  if (frame->flags & PIKE_FRAME_SAVE_LOCALS) { +  int num_new_locals = 0; +  int num_locals = frame->num_locals; +  int i; +  +  /* find the highest set bit */ +  for (i = num_locals - 1; i >= 0; i--) { +  unsigned INT16 bitmask = frame->save_locals_bitmask[i / 16]; +  +  if (bitmask & (1 << (i % 16))) { +  num_new_locals = i + 1; +  break; +  } +  } +  +  if (num_new_locals) +  { +  struct svalue *s = xcalloc(sizeof(struct svalue), num_new_locals);    struct svalue *locals = frame->locals; -  struct svalue *s; -  INT16 num_new_locals = 0; -  unsigned int num_bitmask_entries = 0; -  if(frame->flags & PIKE_FRAME_SAVE_LOCALS) { -  ptrdiff_t offset; -  for (offset = 0; -  offset < (ptrdiff_t)((frame->num_locals >> 4) + 1); -  offset++) { -  if (*(frame->save_locals_bitmask + offset)) -  num_bitmask_entries = offset + 1; +  unsigned INT16 bitmask = 0; +  +  for (i = 0; i < num_new_locals; i++) { +  unsigned INT16 bitmask = frame->save_locals_bitmask[i / 16]; +  +  if (bitmask & (1 << (i % 16))) { +  assign_svalue_no_free(s + i, locals + i);    } -  } else { +    #ifdef PIKE_DEBUG -  if( (locals + frame->num_locals > Pike_sp) || -  (Pike_sp < locals + exp_offset) || -  (exp_offset < 0) || (exp_offset > frame->num_locals)) -  Pike_fatal("Stack failure in POP_PIKE_FRAME " -  "%p+%d=%p %p %hd!n", -  locals, frame->num_locals, -  locals + frame->num_locals, -  Pike_sp, exp_offset); +  else +  mark_free_svalue(s + i);   #endif    }    -  num_new_locals = MAXIMUM(exp_offset, num_bitmask_entries << 4); -  -  s=(struct svalue *)xalloc(sizeof(struct svalue)* -  num_new_locals); -  memset(s, 0, sizeof(struct svalue) * num_new_locals); -  -  { -  int idx; -  unsigned INT16 bitmask=0; -  -  for (idx = 0; idx < num_new_locals; idx++) { -  if (!(idx % 16)) { -  ptrdiff_t offset = (ptrdiff_t)(idx >> 4); -  if (offset < num_bitmask_entries) { -  bitmask = *(frame->save_locals_bitmask + offset); +  frame->locals = s; +  frame->flags |= PIKE_FRAME_MALLOCED_LOCALS;    } else { -  bitmask = 0; +  frame->locals = NULL;    } -  } -  if (bitmask & (1 << (idx % 16)) || idx < exp_offset) { -  assign_svalue_no_free(s + (ptrdiff_t)idx, -  locals + (ptrdiff_t)idx); -  } -  } -  } -  if(frame->flags & PIKE_FRAME_SAVE_LOCALS) { +     frame->flags &= ~PIKE_FRAME_SAVE_LOCALS; -  +     free(frame->save_locals_bitmask); -  } +     frame->num_locals = num_new_locals; -  frame->locals=s; -  frame->flags|=PIKE_FRAME_MALLOCED_LOCALS; +     } else { -  frame->locals=0; +  frame->locals = NULL;    } -  +     frame->next=0;   }      void count_memory_in_pike_frames(size_t *num, size_t *size )   {    *num = num_pike_frames;    *size = num_pike_frame_chunks * (FRAME_CHUNK_SIZE*8);   }   #undef FRAMES_PER_CHUNK   #undef FRAME_CHUNK_SIZE
pike.git/src/interpret.c:2243:    new_frame->children_base);   #endif    new_frame->next = Pike_fp;    add_ref(new_frame->current_object = o);    add_ref(new_frame->current_program = p);    new_frame->context = context;    new_frame->fun = (unsigned INT16)fun;    new_frame->locals = save_sp;    new_frame->args = args;    new_frame->save_sp_offset = 0; -  new_frame->expendible_offset = 0; +       #ifdef PIKE_DEBUG    if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_FREE)    Pike_fatal("Pike code called within gc.\n");   #endif       Pike_fp = new_frame;    debug_malloc_touch(Pike_fp);   #ifdef PROFILING    function->num_calls++;
pike.git/src/interpret.c:3006:    fun = prog->num_identifier_references;    add_to_identifier_references(dummy_ref);    }       /* FIXME: Is this up-to-date with mega_apply? */    new_frame->next = Pike_fp;    add_ref(new_frame->current_object = o);    add_ref(new_frame->current_program = prog);    new_frame->context = prog->inherits;    new_frame->locals = Pike_sp; -  new_frame->expendible_offset=0; +     new_frame->args = 0;    new_frame->num_args=0;    new_frame->num_locals=0;    new_frame->fun = fun;    new_frame->pc = 0;    new_frame->current_storage=o->storage;      #ifdef PIKE_DEBUG    if (Pike_fp && (new_frame->locals < Pike_fp->locals)) {    Pike_fatal("New locals below old locals: %p < %p\n",