コード例 #1
0
ファイル: boehm_gc.c プロジェクト: phs75/gap
void InitBags(UInt              initial_size,
              Bag *             stack_bottom,
              UInt              stack_align)
{
    UInt i; /* loop variable                   */

    /* install the marking functions                                       */
    for (i = 0; i < NUM_TYPES; i++) {
        TabMarkTypeBags[i] = -1;
    }
#ifndef DISABLE_GC
#ifdef HPCGAP
    if (!getenv("GC_MARKERS")) {
        /* The Boehm GC does not have an API to set the number of
         * markers for the parallel mark and sweep implementation,
         * so we use the documented environment variable GC_MARKERS
         * instead. However, we do not override it if it's already
         * set.
         */
        static char marker_env_str[32];
        unsigned    num_markers = 2;
        if (!SyNumGCThreads)
            SyNumGCThreads = SyNumProcessors;
        if (SyNumGCThreads) {
            if (SyNumGCThreads <= MAX_GC_THREADS)
                num_markers = (unsigned)SyNumProcessors;
            else
                num_markers = MAX_GC_THREADS;
        }
        sprintf(marker_env_str, "GC_MARKERS=%u", num_markers);
        putenv(marker_env_str);
    }
#endif
    GC_set_all_interior_pointers(0);
    GC_init();
    GC_set_free_space_divisor(1);
    TLAllocatorInit();
    GC_register_displacement(0);
    GC_register_displacement(sizeof(BagHeader));
    initial_size *= 1024;
    if (GC_get_heap_size() < initial_size)
        GC_expand_hp(initial_size - GC_get_heap_size());
    if (SyStorKill)
        GC_set_max_heap_size(SyStorKill * 1024);
#ifdef HPCGAP
    AddGCRoots();
    CreateMainRegion();
#else
    void * p = ActiveGAPState();
    GC_add_roots(p, (char *)p + sizeof(GAPState));
#endif
    for (i = 0; i <= MAX_GC_PREFIX_DESC; i++) {
        BuildPrefixGCDescriptor(i);
        /* This is necessary to initialize some internal structures
         * in the garbage collector: */
        GC_generic_malloc(sizeof(BagHeader) + i * sizeof(Bag), GCMKind[i]);
    }
#endif /* DISABLE_GC */
}
コード例 #2
0
ファイル: dbg_mlc.c プロジェクト: dariaphoebe/bdwgc
GC_INNER void GC_start_debugging(void)
{
# ifndef SHORT_DBG_HDRS
    GC_check_heap = GC_check_heap_proc;
    GC_print_all_smashed = GC_print_all_smashed_proc;
# else
    GC_check_heap = GC_do_nothing;
    GC_print_all_smashed = GC_do_nothing;
# endif
  GC_print_heap_obj = GC_debug_print_heap_obj_proc;
  GC_debugging_started = TRUE;
  GC_register_displacement((word)sizeof(oh));
}
コード例 #3
0
ファイル: main.c プロジェクト: tioui/EiffelStudio
rt_public void eif_rtinit(int argc, EIF_NATIVE_CHAR **argv, EIF_NATIVE_CHAR **envp)
{
	char *eif_timeout;

		/* Retrieve root argument if any and update `argc' accordingly. */
	eif_retrieve_root(&argc, argv);

#ifdef EIF_WINDOWS
	set_windows_exception_filter();

#if defined(_MSC_VER) && _MSC_VER >= 1400 /* version 14.0+ (MSVC 8.0+)  */
		/* Ensures consistent behavior across all our platforms where we
		 * get 2-digit exponent up to 99 and then 3-digit exponent for 100 and
		 * above. */
   (void) _set_output_format(_TWO_DIGIT_EXPONENT);
#endif

#endif

#ifdef BOEHM_GC
	GC_register_displacement (OVERHEAD);
#endif

	ieee_init();
	starting_working_directory = (char *) eif_malloc (PATH_MAX + 1);
		/* Initialize directory to an empty string by default. */
	starting_working_directory [0] = '\0';

	ufill();							/* Get urgent memory chunks */

#if defined(DEBUG) && (EIF_OS != EIF_OS_VXWORKS) && !defined(EIF_WINDOWS)
	/* The following install signal handlers for signals USR1 and USR2. Both
	 * raise an immediate scanning of memory and dumping of the free list usage
	 * and other statistics. The difference is that USR1 also performrs a full
	 * GC cycle before runnning the diagnosis. If memck() is programmed to
	 * panic when inconsistencies are detected, this may raise a system failure
	 * due to race condition. There is nothing the user can do about it, except
	 * pray--RAM.
	 */

	esignal(SIGUSR1, mem_diagnose);
	esignal(SIGUSR2, mem_diagnose);
#endif

	/* Check if the user wants to override the default timeout value
	 * for interprocess communications (IPC). This new value is specified in
	 * the ISE_TIMEOUT environment variable
	 */
	eif_timeout = getenv("ISE_TIMEOUT");
	if ((eif_timeout != NULL) && (strlen(eif_timeout) > 0)) {		/* Environment variable set */
		TIMEOUT = (unsigned) atoi(eif_timeout);
	} else {
		TIMEOUT = 30;
	}

	eoption = egc_foption;

#ifdef WORKBENCH
	xinitint();							/* Interpreter initialization */
	esystem = egc_fsystem;
	eif_par_table = egc_partab;
	eif_par_table_size = egc_partab_size;
	eorg_table = egc_forg_table;
	pattern = egc_fpattern;

	debug_initialize(); /* Initialize debug information (breakpoints ...) */

	/* In workbench mode, we have a slight problem: when we link ewb in
	 * workbench mode, since ewb is a child from ised, the run-time will
	 * assume, wrongly, that the executable is started in debug mode. Therefore,
	 * we need a special run-time, with no debugging hooks involved.
	 */
#ifndef NOHOOK
	winit();					/* Did we start under ewb control? */
#endif

	/* Initialize dynamically computed variables (i.e. system dependent)
	 * Then we may call update. Eventually, when debugging the
	 * application, the values loaded from the update file will be overridden
	 * by the workbench (via winit).
	 */

	egc_einit();							/* Various static initializations */
	fcount = scount;

	{
		char temp = 0;
		int i;

		for (i=1;i<argc;i++) {
			if (0 == rt_nstrcmp (argv[i], rt_nmakestr("-ignore_updt"))) {
				temp = (char) 1;	
				break;
			}
		}
		update(temp, argv[0]);					
	}									/* Read melted information
										 * Note: the `update' function takes
										 * care of the initialization of the 
										 * temporary descriptor structures
										 */

	create_desc();						/* Create descriptor (call) tables */
	
#else

	/*
	 * Initialize the finalized system with the static data structures.
	 */
	esystem = egc_fsystem;
	eif_par_table = egc_partab;
	eif_par_table_size = egc_partab_size;
	eif_gen_conf_init (eif_par_table_size);
	nbref = egc_fnbref;
	esize = egc_fsize;

#endif

#if !defined CUSTOM || defined NEED_UMAIN_H
	umain(argc, argv, envp);			/* User's initializations */
#endif
#if !defined CUSTOM || defined NEED_ARGV_H
	rt_arg_init(argc, argv);				/* Save copy for class ARGUMENTS */
#endif
	eif_environ = envp;				/* Save pointer to environment variable storage */
	once_init();
#if defined(EIF_THREADS) && defined(WORKBENCH)
	notify_root_thread();
#endif
	initprf();						/* Initialize profiler. */
	init_emnger();					/* Initialize ISE_EXCEPTION_MANAGER */
	init_scp_manager();				/* Initialize ISE_SCOOP_MANAGER */

		/* Initialize our root class. */
	eif_init_root();
}
コード例 #4
0
ファイル: dbg_mlc.c プロジェクト: dariaphoebe/bdwgc
GC_API void GC_CALL GC_debug_register_displacement(size_t offset)
{
    GC_register_displacement(offset);
    GC_register_displacement((word)sizeof(oh) + offset);
}