[dtrace] Probe for pinning of objects.
[mono.git] / mono / metadata / sgen-marksweep.c
index bdf4de076d85baea8e5b3780ac9afcef0b59b1ef..72cd5c5b4a3732615761733183e2e4c8c6620a8f 100644 (file)
@@ -101,7 +101,7 @@ struct _MSBlockInfo {
 };
 
 #ifdef FIXED_HEAP
-static int ms_heap_num_blocks = MS_DEFAULT_HEAP_NUM_BLOCKS;
+static mword ms_heap_num_blocks = MS_DEFAULT_HEAP_NUM_BLOCKS;
 
 static char *ms_heap_start;
 static char *ms_heap_end;
@@ -304,14 +304,14 @@ major_alloc_heap (mword nursery_size, mword nursery_align, int the_nursery_bits)
        char *nursery_start;
        mword major_heap_size = ms_heap_num_blocks * MS_BLOCK_SIZE;
        mword alloc_size = nursery_size + major_heap_size;
-       int i;
+       mword i;
 
        g_assert (ms_heap_num_blocks > 0);
        g_assert (nursery_size % MS_BLOCK_SIZE == 0);
        if (nursery_align)
                g_assert (nursery_align % MS_BLOCK_SIZE == 0);
 
-       nursery_start = sgen_alloc_os_memory_aligned (alloc_size, nursery_align ? nursery_align : MS_BLOCK_SIZE, TRUE, "heap");
+       nursery_start = sgen_alloc_os_memory_aligned (alloc_size, nursery_align ? nursery_align : MS_BLOCK_SIZE, TRUE, TRUE, "heap");
        ms_heap_start = nursery_start + nursery_size;
        ms_heap_end = ms_heap_start + major_heap_size;
 
@@ -336,9 +336,9 @@ major_alloc_heap (mword nursery_size, mword nursery_align, int the_nursery_bits)
 {
        char *start;
        if (nursery_align)
-               start = sgen_alloc_os_memory_aligned (nursery_size, nursery_align, TRUE, "nursery");
+               start = sgen_alloc_os_memory_aligned (nursery_size, nursery_align, TRUE, TRUE, "nursery");
        else
-               start = sgen_alloc_os_memory (nursery_size, TRUE, "nursery");
+               start = sgen_alloc_os_memory (nursery_size, TRUE, TRUE, "nursery");
 
        return start;
 }
@@ -389,7 +389,7 @@ ms_get_empty_block (void)
 
  retry:
        if (!empty_blocks) {
-               p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * MS_BLOCK_ALLOC_NUM, MS_BLOCK_SIZE, TRUE, "major heap section");
+               p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * MS_BLOCK_ALLOC_NUM, MS_BLOCK_SIZE, TRUE, TRUE, "major heap section");
 
                for (i = 0; i < MS_BLOCK_ALLOC_NUM; ++i) {
                        block = p;
@@ -1370,6 +1370,9 @@ major_copy_or_mark_object (void **ptr, SgenGrayQueue *queue)
                        if (SGEN_OBJECT_IS_PINNED (obj))
                                return;
                        binary_protocol_pin (obj, (gpointer)SGEN_LOAD_VTABLE (obj), sgen_safe_object_get_size ((MonoObject*)obj));
+                       if (MONO_GC_OBJ_PINNED_ENABLED ()) {
+                               MONO_GC_OBJ_PINNED (obj, sgen_safe_object_get_size (obj), NULL, GENERATION_OLD);
+                       }
                        SGEN_PIN_OBJECT (obj);
                        /* FIXME: only enqueue if object has references */
                        GRAY_OBJECT_ENQUEUE (queue, obj);
@@ -1456,7 +1459,14 @@ ms_sweep (void)
                        } else {
                                /* an unmarked object */
                                if (MS_OBJ_ALLOCED (obj, block)) {
+                                       /*
+                                        * FIXME: Merge consecutive
+                                        * slots for lower reporting
+                                        * overhead.  Maybe memset
+                                        * will also benefit?
+                                        */
                                        binary_protocol_empty (obj, block->obj_size);
+                                       MONO_GC_MAJOR_SWEEPED (obj, block->obj_size);
                                        memset (obj, 0, block->obj_size);
                                }
                                *(void**)obj = block->free_list;
@@ -1697,7 +1707,7 @@ major_have_computer_minor_collection_allowance (void)
 
        while (num_empty_blocks > section_reserve) {
                void *next = *(void**)empty_blocks;
-               sgen_free_os_memory (empty_blocks, MS_BLOCK_SIZE);
+               sgen_free_os_memory (empty_blocks, MS_BLOCK_SIZE, TRUE);
                empty_blocks = next;
                /*
                 * Needs not be atomic because this is running