2010-04-27 Mark Probst <mark.probst@gmail.com>
authorMark Probst <mark.probst@gmail.com>
Tue, 27 Apr 2010 18:48:23 +0000 (18:48 -0000)
committerMark Probst <mark.probst@gmail.com>
Tue, 27 Apr 2010 18:48:23 +0000 (18:48 -0000)
        * sgen-gc.c, sgen-marksweep.c, sgen-major-copying.c: Support
        heap-dump for mark&sweep.

2010-04-27  Mark Probst  <mark.probst@gmail.com>

        * scripts/mono-heapviz: If the major sections are too small, use a
        larger width.

svn path=/trunk/mono/; revision=156249

ChangeLog
mono/metadata/ChangeLog
mono/metadata/sgen-gc.c
mono/metadata/sgen-major-copying.c
mono/metadata/sgen-marksweep.c
scripts/mono-heapviz

index 3a67f77bea343a01b229ba5c313f250f84731459..8c31b0a7a3f3a21ad5b5b9254037e75fc0b8e3e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-27  Mark Probst  <mark.probst@gmail.com>
+
+       * scripts/mono-heapviz: If the major sections are too small, use a
+       larger width.
+
 2010-04-27  Zoltan Varga  <vargaz@gmail.com>
 
        * configure.in: Switch to eglib by default.
index bf3ed2cc530e2f3c9ff3ac2378eab7e028bb2111..e1f734fa5229630f197ed3cb6b35003786a07bc3 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-27  Mark Probst  <mark.probst@gmail.com>
+
+       * sgen-gc.c, sgen-marksweep.c, sgen-major-copying.c: Support
+       heap-dump for mark&sweep.
+
 2010-04-27  Zoltan Varga  <vargaz@gmail.com>
 
        * loader.c (mono_method_get_header): Move the is_inflated case before the
index 3477cfbf77ccc1a78ded63886d4411b952555cab..71b1fc9a85cdcc793c11da5b11818625c371dcb2 100644 (file)
@@ -313,6 +313,7 @@ static long time_major_fragment_creation = 0;
 static long pinned_chunk_bytes_alloced = 0;
 static long large_internal_bytes_alloced = 0;
 
+/* Keep in sync with internal_mem_names in dump_heap()! */
 enum {
        INTERNAL_MEM_PIN_QUEUE,
        INTERNAL_MEM_FRAGMENT,
@@ -1015,6 +1016,7 @@ static void check_consistency (void);
 static void check_section_scan_starts (GCMemSection *section);
 static void check_scan_starts (void);
 static void check_for_xdomain_refs (void);
+static void dump_occupied (char *start, char *end, char *section_start);
 static void dump_section (GCMemSection *section, const char *type);
 static void dump_heap (const char *type, int num, const char *reason);
 static void commit_stats (int generation);
@@ -1453,8 +1455,8 @@ mono_gc_get_bitmap_for_descr (void *descr, int *numbits)
                }       \
        } while (0)
 
-//#include "sgen-major-copying.c"
-#include "sgen-marksweep.c"
+#include "sgen-major-copying.c"
+//#include "sgen-marksweep.c"
 
 static gboolean
 is_xdomain_ref_allowed (gpointer *ptr, char *obj, MonoDomain *domain)
@@ -3025,7 +3027,8 @@ dump_heap (const char *type, int num, const char *reason)
        static char const *internal_mem_names [] = { "pin-queue", "fragment", "section", "scan-starts",
                                                     "fin-table", "finalize-entry", "dislink-table",
                                                     "dislink", "roots-table", "root-record", "statistics",
-                                                    "remset", "gray-queue", "store-remset" };
+                                                    "remset", "gray-queue", "store-remset", "marksweep-tables",
+                                                    "marksweep-block-info" };
 
        ObjectList *list;
        LOSObject *bigobj;
@@ -3051,7 +3054,7 @@ dump_heap (const char *type, int num, const char *reason)
 
        dump_section (nursery_section, "nursery");
 
-       major_dump_non_pinned_sections ();
+       major_dump_heap ();
 
        fprintf (heap_dump_file, "<los>\n");
        for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
index fd817e155ff05ae82cbf1ead876f3c2081fb58ff..e8082fc80eda750d57638260d5d7797be6db7df2 100644 (file)
@@ -792,11 +792,12 @@ major_check_scan_starts (void)
 }
 
 static void
-major_dump_non_pinned_sections (void)
+major_dump_heap (void)
 {
        GCMemSection *section;
        for (section = section_list; section; section = section->block.next)
                dump_section (section, "old");
+       /* FIXME: dump pinned sections, too */
 }
 
 static gint64
index ec6b0b9f1de4a7f505ff5970b0934be4bc5ce348..77b09f2e033f3bf92a4dd3012b0ffee34e2d1e82 100644 (file)
@@ -431,9 +431,31 @@ major_iterate_objects (gboolean non_pinned, gboolean pinned, IterateObjectCallba
 #define major_check_scan_starts()
 
 static void
-major_dump_non_pinned_sections (void)
+major_dump_heap (void)
 {
-       g_assert_not_reached ();
+       MSBlockInfo *block;
+
+       for (block = all_blocks; block; block = block->next) {
+               int count = MS_BLOCK_FREE / block->obj_size;
+               int i;
+               int start = -1;
+
+               fprintf (heap_dump_file, "<section type=\"%s\" size=\"%zu\">\n", "old", (size_t)MS_BLOCK_FREE);
+
+               for (i = 0; i <= count; ++i) {
+                       if ((i < count) && MS_OBJ_ALLOCED (MS_BLOCK_OBJ (block, i), block)) {
+                               if (start < 0)
+                                       start = i;
+                       } else {
+                               if (start >= 0) {
+                                       dump_occupied (MS_BLOCK_OBJ (block, start), MS_BLOCK_OBJ (block, i), block->block);
+                                       start = -1;
+                               }
+                       }
+               }
+
+               fprintf (heap_dump_file, "</section>\n");
+       }
 }
 
 #define MS_MARK_INDEX_IN_BLOCK_AND_ENQUEUE_CHECKED(obj,block,index) do { \
index cb8a034f977d72894dea262fab819c2be873928a..0daa98351a81b9d4af677b939aabf629380637d5 100755 (executable)
@@ -92,8 +92,11 @@ class SmallSectionHandler (SectionHandler):
         assert kind == 'old'
         if self.width <= 0:
             self.width = (size + chunk_size - 1) / chunk_size
-        else:
-            assert self.width == (size + chunk_size - 1) / chunk_size
+            if self.width < 128:
+                self.width = 512
+                self.current_section_size = size
+            else:
+                self.current_section_size = self.width * chunk_size
         self.size += size
 
     def add_object (self, klass, offset, size):
@@ -103,14 +106,14 @@ class SmallSectionHandler (SectionHandler):
         SectionHandler.add_occupied (self, self.offset + offset, size)
 
     def end_section (self):
-        self.offset += self.width * chunk_size
+        self.offset += self.current_section_size
 
     def header (self):
         return 'old sections'
 
 class LargeSectionHandler (SectionHandler):
     def __init__ (self):
-        SectionHandler.__init__ (self, 500)
+        SectionHandler.__init__ (self, 512)
 
     def start_section (self, kind, size):
         self.kind = kind