=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/gc/alloc.c,v retrieving revision 1.6 retrieving revision 1.10 diff -u -p -r1.6 -r1.10 --- OpenXM_contrib2/asir2000/gc/alloc.c 2002/07/24 08:00:06 1.6 +++ OpenXM_contrib2/asir2000/gc/alloc.c 2009/03/10 16:40:45 1.10 @@ -72,6 +72,13 @@ int GC_full_freq = 19; /* Every 20th collection is GC_bool GC_need_full_gc = FALSE; /* Need full GC do to heap growth. */ +#ifdef THREADS + GC_bool GC_world_stopped = FALSE; +# define IF_THREADS(x) x +#else +# define IF_THREADS(x) +#endif + word GC_used_heap_size_after_full = 0; char * GC_copyright[] = @@ -93,6 +100,7 @@ extern signed_word GC_mem_found; /* Number of reclaim GC_bool GC_dont_expand = 0; word GC_free_space_divisor = 3; +word GC_free_space_numerator = 1; extern GC_bool GC_collection_in_progress(); /* Collection is in progress, or was abandoned. */ @@ -159,9 +167,9 @@ static word min_words_allocd() /* use a bit more of large empty heap */ + total_root_size); if (TRUE_INCREMENTAL) { - return scan_size / (2 * GC_free_space_divisor); + return scan_size * GC_free_space_numerator / (2 * GC_free_space_divisor); } else { - return scan_size / GC_free_space_divisor; + return scan_size * GC_free_space_numerator / GC_free_space_divisor; } } @@ -249,7 +257,6 @@ void GC_maybe_gc() if (GC_should_collect()) { if (!GC_incremental) { - GC_notify_full_gc(); GC_gcollect_inner(); n_partial_gcs = 0; return; @@ -301,6 +308,7 @@ void GC_maybe_gc() /* * Stop the world garbage collection. Assumes lock held, signals disabled. * If stop_func is not GC_never_stop_func, then abort if stop_func returns TRUE. + * Return TRUE if we successfully completed the collection. */ GC_bool GC_try_to_collect_inner(stop_func) GC_stop_func stop_func; @@ -308,6 +316,7 @@ GC_stop_func stop_func; # ifdef CONDPRINT CLOCK_TYPE start_time, current_time; # endif + if (GC_dont_gc) return FALSE; if (GC_incremental && GC_collection_in_progress()) { # ifdef CONDPRINT if (GC_print_stats) { @@ -321,6 +330,7 @@ GC_stop_func stop_func; GC_collect_a_little_inner(1); } } + if (stop_func == GC_never_stop_func) GC_notify_full_gc(); # ifdef CONDPRINT if (GC_print_stats) { if (GC_print_stats) GET_TIME(start_time); @@ -396,6 +406,7 @@ int n; { register int i; + if (GC_dont_gc) return; if (GC_incremental && GC_collection_in_progress()) { for (i = GC_deficit; i < GC_RATE*n; i++) { if (GC_mark_some((ptr_t)0)) { @@ -463,7 +474,12 @@ GC_stop_func stop_func; # if defined(CONDPRINT) && !defined(PRINTTIMES) if (GC_print_stats) GET_TIME(start_time); # endif +# if defined(REGISTER_LIBRARIES_EARLY) + GC_cond_register_dynamic_libraries(); +# endif + GC_timerstart(); STOP_WORLD(); + IF_THREADS(GC_world_stopped = TRUE); # ifdef CONDPRINT if (GC_print_stats) { GC_printf1("--> Marking for collection %lu ", @@ -494,7 +510,9 @@ GC_stop_func stop_func; } # endif GC_deficit = i; /* Give the mutator a chance. */ + IF_THREADS(GC_world_stopped = FALSE); START_WORLD(); + GC_timerstop(); return(FALSE); } if (GC_mark_some((ptr_t)(&dummy))) break; @@ -527,7 +545,9 @@ GC_stop_func stop_func; (*GC_check_heap)(); } + IF_THREADS(GC_world_stopped = FALSE); START_WORLD(); + GC_timerstop(); # ifdef PRINTTIMES GET_TIME(current_time); GC_printf1("World-stopped marking took %lu msecs\n", @@ -608,6 +628,7 @@ void GC_finish_collection() GET_TIME(start_time); finalize_time = start_time; # endif + GC_timerstart(); # ifdef GATHERSTATS GC_mem_found = 0; @@ -617,6 +638,7 @@ void GC_finish_collection() GC_print_address_map(); } # endif + COND_DUMP; if (GC_find_leak) { /* Mark all objects on the free list. All objects should be */ /* marked when we're done. */ @@ -724,6 +746,7 @@ void GC_finish_collection() MS_TIME_DIFF(finalize_time,start_time), MS_TIME_DIFF(done_time,finalize_time)); # endif + GC_timerstop(); } /* Externally callable routine to invoke full, stop-world collection */ @@ -758,8 +781,8 @@ void GC_finish_collection() void GC_gcollect GC_PROTO(()) { - GC_notify_full_gc(); (void)GC_try_to_collect(GC_never_stop_func); + if (GC_have_errors) GC_print_all_errors(); } word GC_n_heap_sects = 0; /* Number of sections currently in heap. */ @@ -926,6 +949,9 @@ word n; GC_prev_heap_addr = GC_last_heap_addr; GC_last_heap_addr = (ptr_t)space; GC_add_to_heap(space, bytes); +#if defined(VISUAL) + SendHeapSize(); +#endif return(TRUE); } @@ -961,7 +987,6 @@ GC_bool ignore_off_page; { if (!GC_incremental && !GC_dont_gc && (GC_dont_expand && GC_words_allocd > 0 || GC_should_collect())) { - GC_notify_full_gc(); GC_gcollect_inner(); } else { word blocks_to_get = GC_heapsize/(HBLKSIZE*GC_free_space_divisor) @@ -986,7 +1011,6 @@ GC_bool ignore_off_page; && !GC_expand_hp_inner(needed_blocks)) { if (GC_fail_count++ < GC_max_retries) { WARN("Out of Memory! Trying to continue ...\n", 0); - GC_notify_full_gc(); GC_gcollect_inner(); } else { # if !defined(AMIGA) || !defined(GC_AMIGA_FASTALLOC) @@ -1021,10 +1045,25 @@ int kind; if (sz == 0) return(0); +#if defined(VISUAL) + { +#include + extern int recv_intr; + if ( recv_intr ) { + if ( recv_intr == 1 ) { + recv_intr = 0; + int_handler(); + } else { + recv_intr = 0; + ox_usr1_handler(0); + } + } + } +#endif while (*flh == 0) { ENTER_GC(); /* Do our share of marking work */ - if(TRUE_INCREMENTAL && !GC_dont_gc) GC_collect_a_little_inner(1); + if(TRUE_INCREMENTAL) GC_collect_a_little_inner(1); /* Sweep blocks for objects of this size */ GC_continue_reclaim(sz, kind); EXIT_GC(); @@ -1046,6 +1085,8 @@ int kind; EXIT_GC(); } } + /* Successful allocation; reset failure count. */ + GC_fail_count = 0; return(*flh); }