[sgen] New protocol entry for processing of individual reference.
authorMark Probst <mark.probst@gmail.com>
Sat, 4 Oct 2014 22:53:27 +0000 (15:53 -0700)
committerMark Probst <mark.probst@gmail.com>
Wed, 26 Nov 2014 18:38:44 +0000 (10:38 -0800)
mono/metadata/sgen-major-scan-object.h
mono/metadata/sgen-marksweep-drain-gray-stack.h
mono/metadata/sgen-minor-scan-object.h
mono/metadata/sgen-protocol.c
mono/metadata/sgen-protocol.h
tools/sgen/sgen-grep-binprot.c

index df872a51484647adfebf5cd3f6ca2afee30c6fbf..968283105548f4402389e6304a8028801f62e3eb 100644 (file)
@@ -52,6 +52,7 @@ extern long long stat_scan_object_called_major;
 #define HANDLE_PTR(ptr,obj)    do {                                    \
                void *__old = *(ptr);                                   \
                SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
+               binary_protocol_scan_process_reference ((obj), (ptr), __old); \
                if (__old && FOLLOW_OBJECT (__old)) {                   \
                        void *__copy;                                   \
                        PREFETCH_DYNAMIC_HEAP (__old);                  \
index 6f4535c88572e79df5e090c2dab1b5d27c819e92..e63b913acb428631a1dd17a471d2834995123aac 100644 (file)
@@ -266,6 +266,7 @@ DRAIN_GRAY_STACK_FUNCTION_NAME (ScanCopyContext ctx)
 #undef HANDLE_PTR
 #define HANDLE_PTR(ptr,obj)    do {                                    \
                        void *__old = *(ptr);                           \
+                       binary_protocol_scan_process_reference ((obj), (ptr), __old); \
                        if (__old) {                                    \
                                gboolean __still_in_nursery = COPY_OR_MARK_FUNCTION_NAME ((ptr), __old, queue); \
                                if (G_UNLIKELY (__still_in_nursery && !sgen_ptr_in_nursery ((ptr)) && !SGEN_OBJECT_IS_CEMENTED (*(ptr)))) { \
index cce3d5c8576e948a5a35eaf47ce145e25b851baf..5b4338872ba0f7e7c988e8f7fa0899fa329a3742 100644 (file)
@@ -38,6 +38,7 @@ extern long long stat_scan_object_called_nursery;
 #define HANDLE_PTR(ptr,obj)    do {    \
                void *__old = *(ptr);   \
                SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
+               binary_protocol_scan_process_reference ((obj), (ptr), __old); \
                if (__old) {    \
                        SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue);     \
                        SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
index a7e6aaa597d0fcb5735b971ae365493afdacbe30..f827beb8a866edde4a6b526b0b522e5712f33f37 100644 (file)
@@ -515,6 +515,13 @@ binary_protocol_scan_vtype_begin (gpointer obj, int size)
        protocol_entry (SGEN_PROTOCOL_SCAN_VTYPE_BEGIN, &entry, sizeof (SGenProtocolScanVTypeBegin));
 }
 
+void
+binary_protocol_scan_process_reference (gpointer obj, gpointer ptr, gpointer value)
+{
+       SGenProtocolScanProcessReference entry = { obj, ptr, value };
+       protocol_entry (SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE, &entry, sizeof (SGenProtocolScanProcessReference));
+}
+
 void
 binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable)
 {
index 1d486ca41b7d076762b92efbba0961d5cd67ef8f..d485ff6366d7bae26c1db6a30c54cc76f927fd26 100644 (file)
@@ -42,6 +42,7 @@ enum {
        SGEN_PROTOCOL_MARK,
        SGEN_PROTOCOL_SCAN_BEGIN,
        SGEN_PROTOCOL_SCAN_VTYPE_BEGIN,
+       SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE,
        SGEN_PROTOCOL_WBARRIER,
        SGEN_PROTOCOL_GLOBAL_REMSET,
        SGEN_PROTOCOL_PTR_UPDATE,
@@ -147,6 +148,12 @@ typedef struct {
        int size;
 } SGenProtocolScanVTypeBegin;
 
+typedef struct {
+       gpointer obj;
+       gpointer ptr;
+       gpointer value;
+} SGenProtocolScanProcessReference;
+
 typedef struct {
        gpointer ptr;
        gpointer value;
@@ -289,6 +296,7 @@ void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL
 void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
 void binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
 void binary_protocol_scan_vtype_begin (gpointer start, int size) MONO_INTERNAL;
+void binary_protocol_scan_process_reference (gpointer obj, gpointer ptr, gpointer value) MONO_INTERNAL;
 void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
 void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
 void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
@@ -314,6 +322,7 @@ void binary_protocol_gray_dequeue (gpointer queue, gpointer cursor, gpointer val
 #define binary_protocol_mark(obj, vtable, size)
 #define binary_protocol_scan_begin(obj, vtable, size)
 #define binary_protocol_scan_vtype_begin(obj, size)
+#define binary_protocol_scan_process_reference(obj, ptr, value)
 #define binary_protocol_wbarrier(ptr, value, value_vtable)
 #define binary_protocol_global_remset(ptr, value, value_vtable)
 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
index 917f40395eb7ff306b3a7cc7e6b6c0128b0cdef8..6ae484b7cf4e9be77d4b1a96a6fa1ce986cb623f 100644 (file)
@@ -40,6 +40,7 @@ read_entry (FILE *in, void **data)
        case SGEN_PROTOCOL_MARK: size = sizeof (SGenProtocolMark); break;
        case SGEN_PROTOCOL_SCAN_BEGIN: size = sizeof (SGenProtocolScanBegin); break;
        case SGEN_PROTOCOL_SCAN_VTYPE_BEGIN: size = sizeof (SGenProtocolScanVTypeBegin); break;
+       case SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE: size = sizeof (SGenProtocolScanProcessReference); break;
        case SGEN_PROTOCOL_WBARRIER: size = sizeof (SGenProtocolWBarrier); break;
        case SGEN_PROTOCOL_GLOBAL_REMSET: size = sizeof (SGenProtocolGlobalRemset); break;
        case SGEN_PROTOCOL_PTR_UPDATE: size = sizeof (SGenProtocolPtrUpdate); break;
@@ -203,6 +204,11 @@ print_entry (int type, void *data)
                printf ("scan_vtype_begin obj %p size %d\n", entry->obj, entry->size);
                break;
        }
+       case SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE: {
+               SGenProtocolScanProcessReference *entry = data;
+               printf ("scan_process_reference obj %p ptr %p value %p\n", entry->obj, entry->ptr, entry->value);
+               break;
+       }
        case SGEN_PROTOCOL_WBARRIER: {
                SGenProtocolWBarrier *entry = data;
                printf ("wbarrier ptr %p value %p value_vtable %p\n", entry->ptr, entry->value, entry->value_vtable);
@@ -357,6 +363,10 @@ is_match (gpointer ptr, int type, void *data)
                SGenProtocolScanVTypeBegin *entry = data;
                return matches_interval (ptr, entry->obj, entry->size);
        }
+       case SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE: {
+               SGenProtocolScanProcessReference *entry = data;
+               return ptr == entry->obj || ptr == entry->ptr || ptr == entry->value;
+       }
        case SGEN_PROTOCOL_WBARRIER: {
                SGenProtocolWBarrier *entry = data;
                return ptr == entry->ptr || ptr == entry->value;