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