Skip to content
Browse files

[sgen] Binary protocol for disappearing link updates.

  • Loading branch information...
1 parent c5f97d9 commit 77b16536ee869cfd1f29ccb7a4221ed459ee7766 @schani schani committed
View
8 mono/metadata/sgen-fin-weak-hash.c
@@ -29,6 +29,7 @@
#include "metadata/sgen-gc.h"
#include "metadata/sgen-gray.h"
+#include "metadata/sgen-protocol.h"
#include "utils/dtrace.h"
#define ptr_in_nursery sgen_ptr_in_nursery
@@ -466,6 +467,7 @@ sgen_null_link_in_range (int generation, gboolean before_finalization, ScanCopyC
if (!major_collector.is_object_live (object)) {
if (sgen_gc_is_object_ready_for_finalization (object)) {
*link = NULL;
+ binary_protocol_dislink_update (link, NULL, 0);
SGEN_LOG (5, "Dislink nullified at %p to GCed object %p", link, object);
SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);
continue;
@@ -487,12 +489,14 @@ sgen_null_link_in_range (int generation, gboolean before_finalization, ScanCopyC
g_assert (copy);
*link = HIDE_POINTER (copy, track);
add_or_remove_disappearing_link ((MonoObject*)copy, link, GENERATION_OLD);
+ binary_protocol_dislink_update (link, copy, track);
SGEN_LOG (5, "Upgraded dislink at %p to major because object %p moved to %p", link, object, copy);
continue;
} else {
*link = HIDE_POINTER (copy, track);
+ binary_protocol_dislink_update (link, copy, track);
SGEN_LOG (5, "Updated dislink at %p to %p", link, DISLINK_OBJECT (link));
}
}
@@ -515,6 +519,7 @@ sgen_null_links_for_domain (MonoDomain *domain, int generation)
if (*link) {
*link = NULL;
+ binary_protocol_dislink_update (link, NULL, 0);
free = FALSE;
/*
* This can happen if finalizers are not ran, i.e. Environment.Exit ()
@@ -547,6 +552,7 @@ sgen_null_links_with_predicate (int generation, WeakLinkAlivePredicateFunc predi
if (!is_alive) {
*link = NULL;
+ binary_protocol_dislink_update (link, NULL, 0);
SGEN_LOG (5, "Dislink nullified by predicate at %p to GCed object %p", link, object);
SGEN_HASH_TABLE_FOREACH_REMOVE (TRUE);
continue;
@@ -623,6 +629,8 @@ sgen_register_disappearing_link (MonoObject *obj, void **link, gboolean track, g
else
*link = NULL;
+ binary_protocol_dislink_update (link, obj, track);
+
#if 1
if (in_gc) {
process_dislink_stage_entry (obj, link);
View
8 mono/metadata/sgen-protocol.c
@@ -300,6 +300,14 @@ binary_protocol_cement_reset (void)
{
protocol_entry (SGEN_PROTOCOL_CEMENT_RESET, NULL, 0);
}
+
+void
+binary_protocol_dislink_update (gpointer link, gpointer obj, int track)
+{
+ SGenProtocolDislinkUpdate entry = { link, obj, track };
+ protocol_entry (SGEN_PROTOCOL_DISLINK_UPDATE, &entry, sizeof (SGenProtocolDislinkUpdate));
+}
+
#endif
#endif /* HAVE_SGEN_GC */
View
11 mono/metadata/sgen-protocol.h
@@ -45,7 +45,8 @@ enum {
SGEN_PROTOCOL_ALLOC_DEGRADED,
SGEN_PROTOCOL_CARD_SCAN,
SGEN_PROTOCOL_CEMENT,
- SGEN_PROTOCOL_CEMENT_RESET
+ SGEN_PROTOCOL_CEMENT_RESET,
+ SGEN_PROTOCOL_DISLINK_UPDATE
};
typedef struct {
@@ -144,6 +145,12 @@ typedef struct {
int size;
} SGenProtocolCement;
+typedef struct {
+ gpointer link;
+ gpointer obj;
+ int track;
+} SGenProtocolDislinkUpdate;
+
/* missing: finalizers, dislinks, roots, non-store wbarriers */
void binary_protocol_init (const char *filename) MONO_INTERNAL;
@@ -173,6 +180,7 @@ void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offs
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) MONO_INTERNAL;
#else
@@ -200,5 +208,6 @@ void binary_protocol_cement_reset (void) MONO_INTERNAL;
#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)
#endif
View
13 tools/sgen/sgen-grep-binprot.c
@@ -40,6 +40,7 @@ read_entry (FILE *in, void **data)
case SGEN_PROTOCOL_CARD_SCAN: size = sizeof (SGenProtocolCardScan); break;
case SGEN_PROTOCOL_CEMENT: size = sizeof (SGenProtocolCement); break;
case SGEN_PROTOCOL_CEMENT_RESET: size = 0; break;
+ case SGEN_PROTOCOL_DISLINK_UPDATE: size = sizeof (SGenProtocolDislinkUpdate); break;
default: assert (0);
}
@@ -163,6 +164,14 @@ print_entry (int type, void *data)
case SGEN_PROTOCOL_CEMENT_RESET: {
printf ("cement_reset\n");
break;
+ case SGEN_PROTOCOL_DISLINK_UPDATE: {
+ SGenProtocolDislinkUpdate *entry = data;
+ printf ("dislink_update link %p obj %p", entry->link, entry->obj);
+ if (entry->obj)
+ printf (" track %d\n", entry->track);
+ else
+ printf ("\n");
+ break;
}
default:
assert (0);
@@ -239,6 +248,10 @@ is_match (gpointer ptr, int type, void *data)
SGenProtocolCement *entry = data;
return matches_interval (ptr, entry->obj, entry->size);
}
+ case SGEN_PROTOCOL_DISLINK_UPDATE: {
+ SGenProtocolDislinkUpdate *entry = data;
+ return ptr == entry->obj || ptr == entry->link;
+ }
default:
assert (0);
}

0 comments on commit 77b1653

Please sign in to comment.
Something went wrong with that request. Please try again.