Skip to content

Commit

Permalink
Add more info for collections/thread suspends to the sgen binary prot…
Browse files Browse the repository at this point in the history
…ocol.
  • Loading branch information
vargaz committed Oct 15, 2012
1 parent c7e2740 commit f374d51
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
5 changes: 3 additions & 2 deletions mono/metadata/sgen-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,7 @@ collect_nursery (void)

reset_pinned_from_failed_allocation ();

binary_protocol_collection (GENERATION_NURSERY);
binary_protocol_collection (stat_minor_gcs, GENERATION_NURSERY);
check_scan_starts ();

sgen_nursery_alloc_prepare_for_minor ();
Expand Down Expand Up @@ -2622,7 +2622,7 @@ major_do_collection (const char *reason)
//count_ref_nonref_objs ();
//consistency_check ();

binary_protocol_collection (GENERATION_OLD);
binary_protocol_collection (stat_major_gcs, GENERATION_OLD);
check_scan_starts ();

sgen_gray_object_queue_init (&gray_queue);
Expand Down Expand Up @@ -3481,6 +3481,7 @@ restart_threads_until_none_in_managed_allocator (void)
if (!info->thread_is_dying && (!info->stack_start || info->in_critical_region ||
is_ip_in_managed_allocator (info->stopped_domain, info->stopped_ip))) {
binary_protocol_thread_restart ((gpointer)mono_thread_info_get_tid (info));
DEBUG (3, fprintf (gc_debug_file, "thread %p resumed.\n", (void*)info->info.native_handle));
result = sgen_resume_thread (info);
if (result) {
++restart_count;
Expand Down
5 changes: 5 additions & 0 deletions mono/metadata/sgen-os-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <glib.h>
#include "metadata/sgen-gc.h"
#include "metadata/sgen-archdep.h"
#include "metadata/sgen-protocol.h"
#include "metadata/object-internals.h"
#include "metadata/gc-internal.h"

Expand Down Expand Up @@ -97,6 +98,10 @@ sgen_suspend_thread (SgenThreadInfo *info)
if (mono_gc_get_gc_callbacks ()->thread_suspend_func)
mono_gc_get_gc_callbacks ()->thread_suspend_func (info->runtime_data, &ctx, NULL);

DEBUG (1, fprintf (gc_debug_file, "thread %p stopped at %p stack_start=%p\n", (void*)info->info.native_handle, info->stopped_ip, info->stack_start));

binary_protocol_thread_suspend ((gpointer)mono_thread_info_get_tid (info), info->stopped_ip);

return TRUE;
}

Expand Down
12 changes: 9 additions & 3 deletions mono/metadata/sgen-protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ protocol_entry (unsigned char type, gpointer data, int size)
}

void
binary_protocol_collection (int generation)
binary_protocol_collection (int index, int generation)
{
SGenProtocolCollection entry = { generation };
SGenProtocolCollection entry = { index, generation };
binary_protocol_flush_buffers (FALSE);
protocol_entry (SGEN_PROTOCOL_COLLECTION, &entry, sizeof (SGenProtocolCollection));
}
Expand Down Expand Up @@ -237,12 +237,18 @@ binary_protocol_empty (gpointer start, 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
Expand Down
13 changes: 10 additions & 3 deletions mono/metadata/sgen-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum {
SGEN_PROTOCOL_PTR_UPDATE,
SGEN_PROTOCOL_CLEANUP,
SGEN_PROTOCOL_EMPTY,
SGEN_PROTOCOL_THREAD_SUSPEND,
SGEN_PROTOCOL_THREAD_RESTART,
SGEN_PROTOCOL_THREAD_REGISTER,
SGEN_PROTOCOL_THREAD_UNREGISTER,
Expand All @@ -46,7 +47,7 @@ enum {
};

typedef struct {
int generation;
int index, generation;
} SGenProtocolCollection;

typedef struct {
Expand Down Expand Up @@ -105,6 +106,10 @@ typedef struct {
int size;
} SGenProtocolEmpty;

typedef struct {
gpointer thread, stopped_ip;
} SGenProtocolThreadSuspend;

typedef struct {
gpointer thread;
} SGenProtocolThreadRestart;
Expand Down Expand Up @@ -133,7 +138,7 @@ gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;

void binary_protocol_flush_buffers (gboolean force) MONO_INTERNAL;

void binary_protocol_collection (int generation) MONO_INTERNAL;
void binary_protocol_collection (int index, int generation) MONO_INTERNAL;
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;
Expand All @@ -145,6 +150,7 @@ void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value
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;
Expand All @@ -156,7 +162,7 @@ void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offs
#define binary_protocol_is_enabled() FALSE

#define binary_protocol_flush_buffers(force)
#define binary_protocol_collection(generation)
#define binary_protocol_collection(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)
Expand All @@ -168,6 +174,7 @@ void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offs
#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)
Expand Down
9 changes: 8 additions & 1 deletion tools/sgen/sgen-grep-binprot.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ read_entry (FILE *in, void **data)
case SGEN_PROTOCOL_PTR_UPDATE: size = sizeof (SGenProtocolPtrUpdate); break;
case SGEN_PROTOCOL_CLEANUP: size = sizeof (SGenProtocolCleanup); break;
case SGEN_PROTOCOL_EMPTY: size = sizeof (SGenProtocolEmpty); break;
case SGEN_PROTOCOL_THREAD_SUSPEND: size = sizeof (SGenProtocolThreadSuspend); break;
case SGEN_PROTOCOL_THREAD_RESTART: size = sizeof (SGenProtocolThreadRestart); break;
case SGEN_PROTOCOL_THREAD_REGISTER: size = sizeof (SGenProtocolThreadRegister); break;
case SGEN_PROTOCOL_THREAD_UNREGISTER: size = sizeof (SGenProtocolThreadUnregister); break;
Expand All @@ -51,7 +52,7 @@ print_entry (int type, void *data)
switch (type) {
case SGEN_PROTOCOL_COLLECTION: {
SGenProtocolCollection *entry = data;
printf ("collection generation %d\n", entry->generation);
printf ("collection %d generation %d\n", entry->index, entry->generation);
break;
}
case SGEN_PROTOCOL_ALLOC: {
Expand Down Expand Up @@ -110,6 +111,11 @@ print_entry (int type, void *data)
printf ("empty start %p size %d\n", entry->start, entry->size);
break;
}
case SGEN_PROTOCOL_THREAD_SUSPEND: {
SGenProtocolThreadSuspend *entry = data;
printf ("thread_suspend thread %p ip %p\n", entry->thread, entry->stopped_ip);
break;
}
case SGEN_PROTOCOL_THREAD_RESTART: {
SGenProtocolThreadRestart *entry = data;
printf ("thread_restart thread %p\n", entry->thread);
Expand Down Expand Up @@ -147,6 +153,7 @@ is_match (gpointer ptr, int type, void *data)
{
switch (type) {
case SGEN_PROTOCOL_COLLECTION:
case SGEN_PROTOCOL_THREAD_SUSPEND:
case SGEN_PROTOCOL_THREAD_RESTART:
case SGEN_PROTOCOL_THREAD_REGISTER:
case SGEN_PROTOCOL_THREAD_UNREGISTER:
Expand Down

0 comments on commit f374d51

Please sign in to comment.