[xbuild] Throw ArgumentNullException if target name is null
[mono.git] / libgc / finalize.c
index e103228c2af135f5a4ae596f7163d849ad105b8f..893f825976f65e9f0493a8178d86524c2b2dabbc 100644 (file)
@@ -807,24 +807,21 @@ void (* GC_finalizer_notifier)() = (void (*) GC_PROTO((void)))0;
 
 static GC_word last_finalizer_notification = 0;
 
-#ifdef KEEP_BACK_PTRS
-void GC_generate_random_backtrace_no_gc(void);
-#endif
-
 void GC_notify_or_invoke_finalizers GC_PROTO((void))
 {
     /* This is a convenient place to generate backtraces if appropriate, */
     /* since that code is not callable with the allocation lock.        */
-#   ifdef KEEP_BACK_PTRS
-      if (GC_backtraces > 0) {
-       static word last_back_trace_gc_no = 3;  /* Skip early ones. */
-       long i;
+#   if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH)
+      static word last_back_trace_gc_no = 1;   /* Skip first one. */
 
-       LOCK();
-       if (GC_gc_no > last_back_trace_gc_no) {
+      if (GC_gc_no > last_back_trace_gc_no) {
+       word i;
+
+#      ifdef KEEP_BACK_PTRS
+         LOCK();
          /* Stops when GC_gc_no wraps; that's OK.      */
-           last_back_trace_gc_no = (word)(-1);  /* disable others. */
-           for (i = 0; i < GC_backtraces; ++i) {
+         last_back_trace_gc_no = (word)(-1);  /* disable others. */
+         for (i = 0; i < GC_backtraces; ++i) {
              /* FIXME: This tolerates concurrent heap mutation,        */
              /* which may cause occasional mysterious results.         */
              /* We need to release the GC lock, since GC_print_callers */
@@ -832,10 +829,14 @@ void GC_notify_or_invoke_finalizers GC_PROTO((void))
              UNLOCK();
              GC_generate_random_backtrace_no_gc();
              LOCK();
-           }
-           last_back_trace_gc_no = GC_gc_no;
-       }
-       UNLOCK();
+         }
+         last_back_trace_gc_no = GC_gc_no;
+         UNLOCK();
+#      endif
+#       ifdef MAKE_BACK_GRAPH
+         if (GC_print_back_height)
+            GC_print_back_graph_stats();
+#      endif
       }
 #   endif
     if (GC_finalize_now == 0) return;