[sgen] Binary protocol entry for user-forced GCs.
authorMark Probst <mark.probst@gmail.com>
Tue, 2 Apr 2013 17:11:36 +0000 (10:11 -0700)
committerMark Probst <mark.probst@gmail.com>
Tue, 2 Apr 2013 17:39:30 +0000 (10:39 -0700)
mono/metadata/sgen-gc.c
mono/metadata/sgen-protocol.c
mono/metadata/sgen-protocol.h
tools/sgen/sgen-grep-binprot.c

index acb5f552567e4179ccc3b957cd95bb3f11704e31..ee8c445940a8a6a7118d1eada03c2ffd63453152 100644 (file)
@@ -3387,6 +3387,8 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
        const char *overflow_reason = NULL;
 
        MONO_GC_REQUESTED (generation_to_collect, requested_size, wait_to_finish ? 1 : 0);
+       if (wait_to_finish)
+               binary_protocol_collection_force (generation_to_collect);
 
        g_assert (generation_to_collect == GENERATION_NURSERY || generation_to_collect == GENERATION_OLD);
 
index bd686ee92fc2574b607af449682cba9bc480822a..ad32d8d032532e5a5515321300d1a9f65c9c98d9 100644 (file)
@@ -150,6 +150,14 @@ protocol_entry (unsigned char type, gpointer data, int size)
        } while (InterlockedCompareExchange (&binary_protocol_use_count, old_count - 1, old_count) != old_count);
 }
 
+void
+binary_protocol_collection_force (int generation)
+{
+       SGenProtocolCollectionForce entry = { generation };
+       binary_protocol_flush_buffers (FALSE);
+       protocol_entry (SGEN_PROTOCOL_COLLECTION_FORCE, &entry, sizeof (SGenProtocolCollectionForce));
+}
+
 void
 binary_protocol_collection_begin (int index, int generation)
 {
index 9005a6229178386e9a78e59ff6b29071d8272f4c..7b9dff67965e2b53183f9a6d20cfd18dad3aafef 100644 (file)
@@ -25,6 +25,7 @@
 #ifdef SGEN_BINARY_PROTOCOL
 
 enum {
+       SGEN_PROTOCOL_COLLECTION_FORCE,
        SGEN_PROTOCOL_COLLECTION_BEGIN,
        SGEN_PROTOCOL_COLLECTION_END,
        SGEN_PROTOCOL_ALLOC,
@@ -51,6 +52,10 @@ enum {
        SGEN_PROTOCOL_DISLINK_UPDATE
 };
 
+typedef struct {
+       int generation;
+} SGenProtocolCollectionForce;
+
 typedef struct {
        int index, generation;
 } SGenProtocolCollection;
@@ -171,6 +176,7 @@ gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;
 
 void binary_protocol_flush_buffers (gboolean force) 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_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
@@ -202,6 +208,7 @@ void binary_protocol_dislink_update (gpointer link, gpointer obj, int track) MON
 #define binary_protocol_is_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)
index 9a3cbe8928680af2a41802881304d9a89f36b783..9978815b73a20b43dcc83e723788c8c1cd22d091 100644 (file)
@@ -19,6 +19,7 @@ read_entry (FILE *in, void **data)
        if (fread (&type, 1, 1, in) != 1)
                return SGEN_PROTOCOL_EOF;
        switch (type) {
+       case SGEN_PROTOCOL_COLLECTION_FORCE: size = sizeof (SGenProtocolCollectionForce); break;
        case SGEN_PROTOCOL_COLLECTION_BEGIN: size = sizeof (SGenProtocolCollection); break;
        case SGEN_PROTOCOL_COLLECTION_END: size = sizeof (SGenProtocolCollection); break;
        case SGEN_PROTOCOL_ALLOC: size = sizeof (SGenProtocolAlloc); break;
@@ -61,6 +62,11 @@ static void
 print_entry (int type, void *data)
 {
        switch (type) {
+       case SGEN_PROTOCOL_COLLECTION_FORCE: {
+               SGenProtocolCollectionForce *entry = data;
+               printf ("collection force generation %d\n", entry->generation);
+               break;
+       }
        case SGEN_PROTOCOL_COLLECTION_BEGIN: {
                SGenProtocolCollection *entry = data;
                printf ("collection begin %d generation %d\n", entry->index, entry->generation);
@@ -201,6 +207,7 @@ static gboolean
 is_match (gpointer ptr, int type, void *data)
 {
        switch (type) {
+       case SGEN_PROTOCOL_COLLECTION_FORCE:
        case SGEN_PROTOCOL_COLLECTION_BEGIN:
        case SGEN_PROTOCOL_COLLECTION_END:
        case SGEN_PROTOCOL_THREAD_SUSPEND: