Mon Jan 24 16:42:29 CET 2005 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Mon, 24 Jan 2005 15:31:10 +0000 (15:31 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Mon, 24 Jan 2005 15:31:10 +0000 (15:31 -0000)
* gc-internal.h, null-gc.c, profiler.c, boehm-gc.c: hook the
GC events to the profiler.

svn path=/trunk/mono/; revision=39417

mono/metadata/ChangeLog
mono/metadata/boehm-gc.c
mono/metadata/gc-internal.h
mono/metadata/null-gc.c
mono/metadata/profiler.c

index 12aff3f6919eaeeb0fb9cf7440623d2895ea88de..7fcf5240a261732b3fc00da0ff38a1d0aed8b1e7 100644 (file)
@@ -1,4 +1,9 @@
 
+Mon Jan 24 16:42:29 CET 2005 Paolo Molaro <lupus@ximian.com>
+
+       * gc-internal.h, null-gc.c, profiler.c, boehm-gc.c: hook the
+       GC events to the profiler.
+
 Mon Jan 24 15:59:54 CET 2005 Paolo Molaro <lupus@ximian.com>
 
        * gc.c: remove valgrind detection nonsense. Set GC_DONT_GC
index ba03f856b8461ba7cc53962d8e1de19e5abf5504..dcd6731ae2c402d4b12a2a07a767b52cd362bb87 100644 (file)
@@ -7,6 +7,7 @@
 #include <mono/os/gc_wrapper.h>
 #include <mono/metadata/mono-gc.h>
 #include <mono/metadata/gc-internal.h>
+#include <mono/metadata/profiler-private.h>
 
 #if HAVE_BOEHM_GC
 
@@ -54,6 +55,8 @@ mono_gc_enable (void)
 #endif
 }
 
+extern int GC_is_marked (void *p);
+
 gboolean
 mono_object_is_alive (MonoObject* o)
 {
@@ -64,5 +67,35 @@ mono_object_is_alive (MonoObject* o)
 #endif
 }
 
+#ifdef USE_INCLUDED_LIBGC
+
+static void
+on_gc_notification (GCEventType event)
+{
+       mono_profiler_gc_event ((MonoGCEvent) event, 0);
+}
+static void
+on_gc_heap_resize (size_t new_size)
+{
+       mono_profiler_gc_heap_resize (new_size);
+}
+
+void
+mono_gc_enable_events (void)
+{
+       GC_notify_event = on_gc_notification;
+       GC_on_heap_resize = on_gc_heap_resize;
+}
+
+#else
+
+void
+mono_gc_enable_events (void)
+{
+}
+
+#endif
+
 #endif /* no Boehm GC */
 
index 9074428354a10b45703439ad3e0891114f65babb..c4670acc163190ebf4c4483601b78242bb01bb4c 100644 (file)
@@ -35,6 +35,7 @@ extern void mono_gc_disable (void);
 extern gboolean mono_object_is_alive (MonoObject* obj);
 extern gboolean mono_gc_is_finalizer_thread (MonoThread *thread);
 extern gpointer mono_gc_out_of_memory (size_t size);
+extern void     mono_gc_enable_events (void);
 
 #endif /* __MONO_METADATA_GC_H__ */
 
index eba36749ace274782add9055986fdf716df51823..f5e671bc562e21e0247e3ce9b169601a7ae52bd1 100644 (file)
@@ -50,5 +50,10 @@ mono_object_is_alive (MonoObject* o)
        return TRUE;
 }
 
+void
+mono_gc_enable_events (void)
+{
+}
+
 #endif
 
index 86bd62cd80029efa0f874d2b44b318d563699d0a..f051b1f96261a52f853c5656f25a5e38e8bb69cd 100644 (file)
@@ -5,6 +5,7 @@
 #include "mono/metadata/mono-debug.h"
 #include "mono/metadata/class-internals.h"
 #include "mono/metadata/domain-internals.h"
+#include "mono/metadata/gc-internal.h"
 #include "mono/io-layer/io-layer.h"
 #include <string.h>
 #include <sys/time.h>
@@ -377,6 +378,7 @@ mono_profiler_gc_event (MonoGCEvent event, int generation)
 void
 mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback)
 {
+       mono_gc_enable_events ();
        gc_event = callback;
        gc_heap_resize = heap_resize_callback;
 }