OSDN Git Service

* win32_threads.c (GC_push_all_stacks): Tolerate bad sp.
[pf3gnuchains/gcc-fork.git] / boehm-gc / alloc.c
index 1664e4a..8a413b2 100644 (file)
@@ -78,7 +78,7 @@ char * GC_copyright[] =
 {"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ",
 "Copyright (c) 1991-1995 by Xerox Corporation.  All rights reserved. ",
 "Copyright (c) 1996-1998 by Silicon Graphics.  All rights reserved. ",
-"Copyright (c) 1999-2000 by Hewlett-Packard Company.  All rights reserved. ",
+"Copyright (c) 1999-2001 by Hewlett-Packard Company.  All rights reserved. ",
 "THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY",
 " EXPRESSED OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.",
 "See source code for details." };
@@ -97,13 +97,17 @@ word GC_free_space_divisor = 3;
 extern GC_bool GC_collection_in_progress();
                /* Collection is in progress, or was abandoned. */
 
+extern GC_bool GC_print_back_height;
+
 int GC_never_stop_func GC_PROTO((void)) { return(0); }
 
+unsigned long GC_time_limit = TIME_LIMIT;
+
 CLOCK_TYPE GC_start_time;      /* Time at which we stopped world.      */
                                /* used only in GC_timeout_stop_func.   */
 
 int GC_n_attempts = 0;         /* Number of attempts at finishing      */
-                               /* collection within TIME_LIMIT         */
+                               /* collection within GC_time_limit.     */
 
 #if defined(SMALL_CONFIG) || defined(NO_CLOCK)
 #   define GC_timeout_stop_func GC_never_stop_func
@@ -118,7 +122,7 @@ int GC_n_attempts = 0;              /* Number of attempts at finishing      */
 #ifndef NO_CLOCK
     GET_TIME(current_time);
     time_diff = MS_TIME_DIFF(current_time,GC_start_time);
-    if (time_diff >= TIME_LIMIT) {
+    if (time_diff >= GC_time_limit) {
 #      ifdef CONDPRINT
          if (GC_print_stats) {
            GC_printf0("Abandoning stopped marking after ");
@@ -277,9 +281,10 @@ void GC_maybe_gc()
         /* If we run out of time, this turns into      */
         /* incremental marking.                        */
 #      ifndef NO_CLOCK
-          GET_TIME(GC_start_time);
+          if (GC_time_limit != GC_TIME_UNLIMITED) { GET_TIME(GC_start_time); }
 #      endif
-        if (GC_stopped_mark(GC_timeout_stop_func)) {
+        if (GC_stopped_mark(GC_time_limit == GC_TIME_UNLIMITED? 
+                           GC_never_stop_func : GC_timeout_stop_func)) {
 #           ifdef SAVE_CALL_CHAIN
                 GC_save_callers(GC_last_stack);
 #           endif
@@ -391,7 +396,8 @@ int n;
 #              ifdef PARALLEL_MARK
                    GC_wait_for_reclaim();
 #              endif
-               if (GC_n_attempts < MAX_PRIOR_ATTEMPTS) {
+               if (GC_n_attempts < MAX_PRIOR_ATTEMPTS
+                   && GC_time_limit != GC_TIME_UNLIMITED) {
                  GET_TIME(GC_start_time);
                  if (!GC_stopped_mark(GC_timeout_stop_func)) {
                    GC_n_attempts++;
@@ -436,7 +442,7 @@ GC_stop_func stop_func;
 {
     register int i;
     int dummy;
-#   ifdef PRINTTIMES
+#   if defined(PRINTTIMES) || defined(CONDPRINT)
        CLOCK_TYPE start_time, current_time;
 #   endif
        
@@ -444,6 +450,9 @@ GC_stop_func stop_func;
 #   ifdef PRINTTIMES
        GET_TIME(start_time);
 #   endif
+#   if defined(CONDPRINT) && !defined(PRINTTIMES)
+       if (GC_print_stats) GET_TIME(start_time);
+#   endif
 #   ifdef CONDPRINT
       if (GC_print_stats) {
        GC_printf1("--> Marking for collection %lu ",
@@ -453,6 +462,11 @@ GC_stop_func stop_func;
                   (unsigned long) WORDS_TO_BYTES(GC_words_wasted));
       }
 #   endif
+#   ifdef MAKE_BACK_GRAPH
+      if (GC_print_back_height) {
+        GC_build_back_graph();
+      }
+#   endif
 
     /* Mark from all roots.  */
         /* Minimize junk left in my registers and on the stack */
@@ -506,6 +520,14 @@ GC_stop_func stop_func;
        GET_TIME(current_time);
        GC_printf1("World-stopped marking took %lu msecs\n",
                   MS_TIME_DIFF(current_time,start_time));
+#   else
+#     ifdef CONDPRINT
+       if (GC_print_stats) {
+         GET_TIME(current_time);
+         GC_printf1("World-stopped marking took %lu msecs\n",
+                    MS_TIME_DIFF(current_time,start_time));
+       }
+#     endif
 #   endif
     START_WORLD();
     return(TRUE);
@@ -612,6 +634,17 @@ void GC_finish_collection()
       GET_TIME(finalize_time);
 #   endif
 
+    if (GC_print_back_height) {
+#     ifdef MAKE_BACK_GRAPH
+       GC_traverse_back_graph();
+#     else
+#      ifndef SMALL_CONFIG
+         GC_err_printf0("Back height not available: "
+                        "Rebuild collector with -DMAKE_BACK_GRAPH\n");
+#      endif
+#     endif
+    }
+
     /* Clear free list mark bits, in case they got accidentally marked   */
     /* (or GC_find_leak is set and they were intentionally marked).     */
     /* Also subtract memory remaining from GC_mem_found count.           */