/*
* The binary protocol enables logging a lot of the GC ativity in a way that is not very
- * intrusive and produce a compact file that can be searched using a custom tool.
- *
+ * intrusive and produces a compact file that can be searched using a custom tool. This
+ * option enables very fine-grained binary protocol events, which will make the GC a tiny
+ * bit less efficient even if no binary protocol file is generated.
*/
-//#define SGEN_BINARY_PROTOCOL
+//#define SGEN_HEAVY_BINARY_PROTOCOL
/*
* This enables checks whenever objects are enqueued in gray queues.
*/
//#define SGEN_OBJECT_LAYOUT_STATISTICS
-#ifndef SGEN_BINARY_PROTOCOL
+#ifndef SGEN_HEAVY_BINARY_PROTOCOL
#ifndef HEAVY_STATISTICS
#define MANAGED_ALLOCATION
#ifndef XDOMAIN_CHECKS_IN_WBARRIER
return;
}
-#ifdef SGEN_BINARY_PROTOCOL
- {
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
+ if (binary_protocol_is_heavy_enabled ()) {
int i;
for (i = 0; i < count; ++i) {
gpointer dest = (gpointer*)dest_ptr + i;
}
}
-#ifdef SGEN_BINARY_PROTOCOL
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
#undef HANDLE_PTR
#define HANDLE_PTR(ptr,obj) do { \
gpointer o = *(gpointer*)(ptr); \
return;
}
-#ifdef SGEN_BINARY_PROTOCOL
- {
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
+ if (binary_protocol_is_heavy_enabled ()) {
size_t element_size = mono_class_value_size (klass, NULL);
int i;
for (i = 0; i < count; ++i) {
return;
}
-#ifdef SGEN_BINARY_PROTOCOL
- scan_object_for_binary_protocol_copy_wbarrier (obj, (char*)src, (mword) src->vtable->gc_descr);
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
+ if (binary_protocol_is_heavy_enabled ())
+ scan_object_for_binary_protocol_copy_wbarrier (obj, (char*)src, (mword) src->vtable->gc_descr);
#endif
remset.wbarrier_object_copy (obj, src);
fprintf (heap_dump_file, "<sgen-dump>\n");
do_pin_stats = TRUE;
}
-#ifdef SGEN_BINARY_PROTOCOL
} else if (g_str_has_prefix (opt, "binary-protocol=")) {
char *filename = strchr (opt, '=') + 1;
binary_protocol_init (filename);
-#endif
} else {
sgen_env_var_error (MONO_GC_DEBUG_NAME, "Ignoring.", "Unknown option `%s`.", opt);
fprintf (stderr, " print-allowance\n");
fprintf (stderr, " print-pinning\n");
fprintf (stderr, " heap-dump=<filename>\n");
-#ifdef SGEN_BINARY_PROTOCOL
fprintf (stderr, " binary-protocol=<filename>\n");
-#endif
fprintf (stderr, "\n");
usage_printed = TRUE;
GENERATION_MAX
};
-#ifdef SGEN_BINARY_PROTOCOL
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
#define BINARY_PROTOCOL_ARG(x) ,x
#else
#define BINARY_PROTOCOL_ARG(x)
MONO_GC_OBJ_CEMENTED ((mword)obj, sgen_safe_object_get_size ((MonoObject*)obj),
vt->klass->name_space, vt->klass->name);
}
-#ifdef SGEN_BINARY_PROTOCOL
binary_protocol_cement (obj, (gpointer)SGEN_LOAD_VTABLE (obj),
sgen_safe_object_get_size ((MonoObject*)obj));
-#endif
}
return FALSE;
#include "utils/mono-mmap.h"
#include "utils/mono-threads.h"
-#ifdef SGEN_BINARY_PROTOCOL
-
/* If not null, dump binary protocol to this file */
static FILE *binary_protocol_file = NULL;
protocol_entry (SGEN_PROTOCOL_COLLECTION_END, &entry, sizeof (SGenProtocolCollection));
}
+void
+binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip)
+{
+ SGenProtocolThreadSuspend entry = { thread, stopped_ip };
+ protocol_entry (SGEN_PROTOCOL_THREAD_SUSPEND, &entry, sizeof (SGenProtocolThreadSuspend));
+}
+
+void
+binary_protocol_thread_restart (gpointer thread)
+{
+ SGenProtocolThreadRestart entry = { thread };
+ protocol_entry (SGEN_PROTOCOL_THREAD_RESTART, &entry, sizeof (SGenProtocolThreadRestart));
+}
+
+void
+binary_protocol_thread_register (gpointer thread)
+{
+ SGenProtocolThreadRegister entry = { thread };
+ protocol_entry (SGEN_PROTOCOL_THREAD_REGISTER, &entry, sizeof (SGenProtocolThreadRegister));
+
+}
+
+void
+binary_protocol_thread_unregister (gpointer thread)
+{
+ SGenProtocolThreadUnregister entry = { thread };
+ protocol_entry (SGEN_PROTOCOL_THREAD_UNREGISTER, &entry, sizeof (SGenProtocolThreadUnregister));
+
+}
+
+void
+binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset, gpointer value, gpointer value_vtable, int value_pinned)
+{
+ SGenProtocolMissingRemset entry = { obj, obj_vtable, offset, value, value_vtable, value_pinned };
+ protocol_entry (SGEN_PROTOCOL_MISSING_REMSET, &entry, sizeof (SGenProtocolMissingRemset));
+
+}
+
+void
+binary_protocol_cement (gpointer obj, gpointer vtable, int size)
+{
+ SGenProtocolCement entry = { obj, vtable, size };
+ protocol_entry (SGEN_PROTOCOL_CEMENT, &entry, sizeof (SGenProtocolCement));
+}
+
+void
+binary_protocol_cement_reset (void)
+{
+ protocol_entry (SGEN_PROTOCOL_CEMENT_RESET, NULL, 0);
+}
+
+void
+binary_protocol_domain_unload_begin (gpointer domain)
+{
+ SGenProtocolDomainUnload entry = { domain };
+ protocol_entry (SGEN_PROTOCOL_DOMAIN_UNLOAD_BEGIN, &entry, sizeof (SGenProtocolDomainUnload));
+}
+
+void
+binary_protocol_domain_unload_end (gpointer domain)
+{
+ SGenProtocolDomainUnload entry = { domain };
+ protocol_entry (SGEN_PROTOCOL_DOMAIN_UNLOAD_END, &entry, sizeof (SGenProtocolDomainUnload));
+}
+
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
void
binary_protocol_alloc (gpointer obj, gpointer vtable, int size)
{
protocol_entry (SGEN_PROTOCOL_EMPTY, &entry, sizeof (SGenProtocolEmpty));
}
-void
-binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip)
-{
- SGenProtocolThreadSuspend entry = { thread, stopped_ip };
- protocol_entry (SGEN_PROTOCOL_THREAD_SUSPEND, &entry, sizeof (SGenProtocolThreadSuspend));
-}
-
-void
-binary_protocol_thread_restart (gpointer thread)
-{
- SGenProtocolThreadRestart entry = { thread };
- protocol_entry (SGEN_PROTOCOL_THREAD_RESTART, &entry, sizeof (SGenProtocolThreadRestart));
-}
-
-void
-binary_protocol_thread_register (gpointer thread)
-{
- SGenProtocolThreadRegister entry = { thread };
- protocol_entry (SGEN_PROTOCOL_THREAD_REGISTER, &entry, sizeof (SGenProtocolThreadRegister));
-
-}
-
-void
-binary_protocol_thread_unregister (gpointer thread)
-{
- SGenProtocolThreadUnregister entry = { thread };
- protocol_entry (SGEN_PROTOCOL_THREAD_UNREGISTER, &entry, sizeof (SGenProtocolThreadUnregister));
-
-}
-
-void
-binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset, gpointer value, gpointer value_vtable, int value_pinned)
-{
- SGenProtocolMissingRemset entry = { obj, obj_vtable, offset, value, value_vtable, value_pinned };
- protocol_entry (SGEN_PROTOCOL_MISSING_REMSET, &entry, sizeof (SGenProtocolMissingRemset));
-
-}
-
void
binary_protocol_card_scan (gpointer start, int size)
{
protocol_entry (SGEN_PROTOCOL_CARD_SCAN, &entry, sizeof (SGenProtocolCardScan));
}
-void
-binary_protocol_cement (gpointer obj, gpointer vtable, int size)
-{
- SGenProtocolCement entry = { obj, vtable, size };
- protocol_entry (SGEN_PROTOCOL_CEMENT, &entry, sizeof (SGenProtocolCement));
-}
-
-void
-binary_protocol_cement_reset (void)
-{
- protocol_entry (SGEN_PROTOCOL_CEMENT_RESET, NULL, 0);
-}
-
void
binary_protocol_dislink_update (gpointer link, gpointer obj, int track, int staged)
{
SGenProtocolDislinkProcessStaged entry = { link, obj, index };
protocol_entry (SGEN_PROTOCOL_DISLINK_PROCESS_STAGED, &entry, sizeof (SGenProtocolDislinkProcessStaged));
}
-
-void
-binary_protocol_domain_unload_begin (gpointer domain)
-{
- SGenProtocolDomainUnload entry = { domain };
- protocol_entry (SGEN_PROTOCOL_DOMAIN_UNLOAD_BEGIN, &entry, sizeof (SGenProtocolDomainUnload));
-}
-
-void
-binary_protocol_domain_unload_end (gpointer domain)
-{
- SGenProtocolDomainUnload entry = { domain };
- protocol_entry (SGEN_PROTOCOL_DOMAIN_UNLOAD_END, &entry, sizeof (SGenProtocolDomainUnload));
-}
-
#endif
#endif /* HAVE_SGEN_GC */
#include "sgen-gc.h"
-#ifdef SGEN_BINARY_PROTOCOL
-
enum {
SGEN_PROTOCOL_COLLECTION_FORCE,
SGEN_PROTOCOL_COLLECTION_BEGIN,
gpointer domain;
} SGenProtocolDomainUnload;
-/* missing: finalizers, dislinks, roots, non-store wbarriers */
+/* missing: finalizers, roots, non-store wbarriers */
void binary_protocol_init (const char *filename) MONO_INTERNAL;
gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;
void binary_protocol_collection_force (int generation) MONO_INTERNAL;
void binary_protocol_collection_begin (int index, int generation) MONO_INTERNAL;
void binary_protocol_collection_end (int index, int generation) MONO_INTERNAL;
+
+void binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip) MONO_INTERNAL;
+void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
+void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
+void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
+void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
+ gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
+
+void binary_protocol_cement (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
+void binary_protocol_cement_reset (void) MONO_INTERNAL;
+
+void binary_protocol_domain_unload_begin (gpointer domain) MONO_INTERNAL;
+void binary_protocol_domain_unload_end (gpointer domain) MONO_INTERNAL;
+
+#ifdef SGEN_HEAVY_BINARY_PROTOCOL
+
+#define binary_protocol_is_heavy_enabled() binary_protocol_is_enabled ()
+
void binary_protocol_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_alloc_pinned (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
void binary_protocol_empty (gpointer start, int size) MONO_INTERNAL;
-void binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip) MONO_INTERNAL;
-void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
-void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
-void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
-void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
- gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
void binary_protocol_card_scan (gpointer start, int size) MONO_INTERNAL;
-void binary_protocol_cement (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
-void binary_protocol_cement_reset (void) MONO_INTERNAL;
void binary_protocol_dislink_update (gpointer link, gpointer obj, int track, int staged) MONO_INTERNAL;
void binary_protocol_dislink_update_staged (gpointer link, gpointer obj, int track, int index) MONO_INTERNAL;
void binary_protocol_dislink_process_staged (gpointer link, gpointer obj, int index) MONO_INTERNAL;
-void binary_protocol_domain_unload_begin (gpointer domain) MONO_INTERNAL;
-void binary_protocol_domain_unload_end (gpointer domain) MONO_INTERNAL;
#else
-#define binary_protocol_is_enabled() FALSE
+#define binary_protocol_is_heavy_enabled() FALSE
-#define binary_protocol_flush_buffers(force)
-#define binary_protocol_collection_force(generation)
-#define binary_protocol_collection_begin(index, generation)
-#define binary_protocol_collection_end(index, generation)
#define binary_protocol_alloc(obj, vtable, size)
#define binary_protocol_alloc_pinned(obj, vtable, size)
#define binary_protocol_alloc_degraded(obj, vtable, size)
#define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
#define binary_protocol_cleanup(ptr, vtable, size)
#define binary_protocol_empty(start, size)
-#define binary_protocol_thread_suspend(thread, ip)
-#define binary_protocol_thread_restart(thread)
-#define binary_protocol_thread_register(thread)
-#define binary_protocol_thread_unregister(thread)
-#define binary_protocol_missing_remset(obj, obj_vtable, offset, value, value_vtable, value_pinned)
#define binary_protocol_card_scan(start, size)
-#define binary_protocol_cement(ptr, vtable, size)
-#define binary_protocol_cement_reset()
#define binary_protocol_dislink_update(link,obj,track,staged)
#define binary_protocol_dislink_update_staged(link,obj,track,index)
#define binary_protocol_dislink_process_staged(link,obj,index)
-#define binary_protocol_domain_unload_begin(domain)
-#define binary_protocol_domain_unload_end(domain)
#endif
/* gcc should be smart enough to remove the bounds check, but it isn't:( */
desc = vt->desc;
-#if defined(SGEN_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
+#if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
binary_protocol_scan_begin (start, vt, sgen_safe_object_get_size ((MonoObject*)start));
#endif
#else
-#if defined(SGEN_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
+#if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
binary_protocol_scan_vtype_begin (start + sizeof (MonoObject), size);
#endif
#endif