Permalink
Browse files

Add a debug function to sgen to do consistency checks of object point…

…ers.
  • Loading branch information...
vargaz committed Oct 14, 2012
1 parent 63a5e6a commit f6a5608f00d8051bb3a13437b69ed3e1ea55381c
Showing with 27 additions and 0 deletions.
  1. +25 −0 mono/metadata/sgen-debug.c
  2. +1 −0 mono/metadata/sgen-gc.h
  3. +1 −0 mono/metadata/sgen-gray.c
View
@@ -375,4 +375,29 @@ sgen_check_whole_heap (void)
g_assert (!broken_heap);
}
+
+static gboolean
+ptr_in_heap (char *object)
+{
+ if (sgen_ptr_in_nursery (object))
+ return TRUE;
+
+ if (sgen_los_is_valid_object (object))
+ return TRUE;
+
+ if (major_collector.is_valid_object (object))
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * sgen_check_objref:
+ * Do consistency checks on the object reference OBJ. Assert on failure.
+ */
+void
+sgen_check_objref (char *obj)
+{
+ g_assert (ptr_in_heap (obj));
+}
+
#endif /*HAVE_SGEN_GC*/
View
@@ -983,6 +983,7 @@ void sgen_check_consistency (void);
void sgen_check_major_refs (void);
void sgen_check_whole_heap (void);
void sgen_check_whole_heap_stw (void) MONO_INTERNAL;
+void sgen_check_objref (char *obj);
/* Write barrier support */
@@ -69,6 +69,7 @@ void
sgen_gray_object_enqueue (SgenGrayQueue *queue, char *obj)
{
DEBUG (9, g_assert (obj));
+ //sgen_check_objref (obj);
if (G_UNLIKELY (!queue->first || queue->first->end == SGEN_GRAY_QUEUE_SECTION_SIZE))
sgen_gray_object_alloc_queue_section (queue);
DEBUG (9, g_assert (queue->first && queue->first->end < SGEN_GRAY_QUEUE_SECTION_SIZE));

0 comments on commit f6a5608

Please sign in to comment.