pike.git / src / program.c

version» Context lines:

pike.git/src/program.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: program.c,v 1.680 2008/05/01 20:42:20 mast Exp $ + || $Id: program.c,v 1.681 2008/05/02 04:15:14 mast Exp $   */      #include "global.h"   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "lex.h"
pike.git/src/program.c:53:    ptrdiff_t modulo_orig);      #undef EXIT_BLOCK   #define EXIT_BLOCK(P) exit_program_struct( (P) )      #undef COUNT_OTHER   #define COUNT_OTHER() do{ \    struct program *p; \    for(p=first_program;p;p=p->next) \    { \ -  size+=p->total_size; \ +  size+=p->total_size - sizeof (struct program); \    } \   }while(0)      BLOCK_ALLOC_FILL_PAGES(program, 4)         /* #define COMPILER_DEBUG */   /* #define PROGRAM_BUILD_DEBUG */      #ifdef COMPILER_DEBUG
pike.git/src/program.c:3726:    */   PMOD_EXPORT void set_exit_callback(void (*exit)(struct object *))   {    add_compat_event_handler();    ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_EXIT]=exit;    Pike_compiler->new_program->flags |= PROGRAM_LIVE_OBJ;   }      /*    * This callback is used by the gc to traverse all references to -  * objects. It should call some gc_recurse_* function exactly once for -  * each reference that the pike internals doesn't know about. +  * things in memory. It should call some gc_recurse_* function exactly +  * once for each reference that the pike internals doesn't know about.    *    * If a reference is shared between objects, it should be traversed    * once for every instance sharing it.    *    * The callback might be called more than once for the same instance    * during a gc pass. The gc assumes that the references are enumerated    * in the same order in that case.    *    * The callback is called after any mapped variables on the object    * have been recursed (and possibly freed).    * -  +  * If there are unmapped pointers to allocated memory then you should +  * add something like this to the recurse callback so that +  * Pike.count_memory remains accurate: +  * +  * if (Pike_in_gc == GC_PASS_COUNT_MEMORY) +  * gc_counted_bytes += <size of the allocated memory block(s)> +  * +  * If the allocated memory is shared between objects then it gets more +  * complicated and you should insert calls to the gc check callback +  * too. See e.g. multiset.c or mapping.c for how to handle that +  * correctly. +  *    * This function is obsolete; see pike_set_prog_event_callback for    * details.    */   PMOD_EXPORT void set_gc_recurse_callback(void (*m)(struct object *))   {    add_compat_event_handler();    ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_GC_RECURSE]=m;   }      /* -  * This callback is used by the gc to count all references to objects. -  * It should call gc_check, gc_check_(weak_)svalues or +  * This callback is used by the gc to count all references to things +  * in memory. It should call gc_check, gc_check_(weak_)svalues or    * gc_check_(weak_)short_svalue exactly once for each reference that -  * the pike internals doesn't know about. +  * the pike internals don't know about.    *    * If a reference is shared between objects, it should be counted once    * for all shared instances. The return value from gc_check is useful    * to ensure this; it's zero when called the first time for its -  * argument. +  * argument (it is perfectly fine to use gc_check on things that the +  * pike core doesn't know about, but they must have an INT32 refcount +  * first).    *    * This function is obsolete; see pike_set_prog_event_callback for    * details.    */   PMOD_EXPORT void set_gc_check_callback(void (*m)(struct object *))   {    add_compat_event_handler();    ((oldhandlertype *)Pike_compiler->new_program->program)[PROG_EVENT_GC_CHECK]=m;   }   
pike.git/src/program.c:9142:    if (compilation_environment) {    free_object(compilation_environment);    compilation_environment = 0;    }    if (compilation_env_program) {    free_program(compilation_env_program);    compilation_env_program = 0;    }   }    + static void gc_check_program(struct program *p); +    void gc_mark_program_as_referenced(struct program *p)   {    debug_malloc_touch(p);       if (p->flags & PROGRAM_AVOID_CHECK) {    /* Program is in an inconsistent state.    * don't look closer at it.    */    debug_malloc_touch(p);   
pike.git/src/program.c:9170:    }    }       return;    }       if(gc_mark(p))    GC_ENTER (p, T_PROGRAM) {    int e;    +  if (Pike_in_gc == GC_PASS_COUNT_MEMORY) { +  gc_counted_bytes += p->total_size; +  gc_check_program (p); +  } +     if (p == gc_mark_program_pos)    gc_mark_program_pos = p->next;    if (p == gc_internal_program)    gc_internal_program = p->next;    else {    DOUBLEUNLINK(first_program, p);    DOUBLELINK(first_program, p); /* Linked in first. */    }       if(p->parent)