Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / sgen / sgen-layout-stats.c
1 /**
2  * \file
3  * Copyright Xamarin Inc (http://www.xamarin.com)
4  *
5  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
6  */
7
8 #include "config.h"
9 #ifdef HAVE_SGEN_GC
10
11 #include "sgen/sgen-gc.h"
12 #include "sgen/sgen-layout-stats.h"
13 #include <mono/utils/mono-compiler.h>
14
15 #ifdef SGEN_OBJECT_LAYOUT_STATISTICS
16
17 #define NUM_HISTOGRAM_ENTRIES   (1 << SGEN_OBJECT_LAYOUT_BITMAP_BITS)
18
19 static unsigned long histogram [NUM_HISTOGRAM_ENTRIES];
20 static unsigned long count_bitmap_overflow;
21 static unsigned long count_ref_array;
22 static unsigned long count_vtype_array;
23
24 void
25 sgen_object_layout_scanned_bitmap (unsigned int bitmap)
26 {
27         g_assert (!(bitmap >> SGEN_OBJECT_LAYOUT_BITMAP_BITS));
28         ++histogram [bitmap];
29 }
30
31 void
32 sgen_object_layout_scanned_bitmap_overflow (void)
33 {
34         ++count_bitmap_overflow;
35 }
36
37 void
38 sgen_object_layout_scanned_ref_array (void)
39 {
40         ++count_ref_array;
41 }
42
43 void
44 sgen_object_layout_scanned_vtype_array (void)
45 {
46         ++count_vtype_array;
47 }
48
49 void
50 sgen_object_layout_dump (FILE *out)
51 {
52         int i;
53
54         for (i = 0; i < NUM_HISTOGRAM_ENTRIES; ++i) {
55                 if (!histogram [i])
56                         continue;
57                 fprintf (out, "%d %lu\n", i, histogram [i]);
58         }
59         fprintf (out, "bitmap-overflow %lu\n", count_bitmap_overflow);
60         fprintf (out, "ref-array %lu\n", count_ref_array);
61         fprintf (out, "vtype-array %lu\n", count_vtype_array);
62 }
63 #else
64
65 MONO_EMPTY_SOURCE_FILE (sgen_layout_stats);
66 #endif /* SGEN_OBJECT_LAYOUT_STATISTICS */
67 #endif