[sgen] Evacuate from emptier blocks to fuller ones
[mono.git] / mono / sgen / sgen-layout-stats.h
1 /*
2  * Copyright Xamarin Inc (http://www.xamarin.com)
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef __MONO_SGEN_LAYOUT_STATS_H__
24 #define __MONO_SGEN_LAYOUT_STATS_H__
25
26 #ifdef SGEN_OBJECT_LAYOUT_STATISTICS
27
28 #define SGEN_OBJECT_LAYOUT_BITMAP_BITS  16
29
30 void sgen_object_layout_scanned_bitmap (unsigned int bitmap);
31 void sgen_object_layout_scanned_bitmap_overflow (void);
32 void sgen_object_layout_scanned_ref_array (void);
33 void sgen_object_layout_scanned_vtype_array (void);
34
35 void sgen_object_layout_dump (FILE *out);
36
37 #define SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP    unsigned int __object_layout_bitmap = 0
38 #define SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP(o,p)  do {            \
39                 int __index = ((void**)(p)) - ((void**)(((char*)(o)) + SGEN_CLIENT_OBJECT_HEADER_SIZE)); \
40                 if (__index >= SGEN_OBJECT_LAYOUT_BITMAP_BITS)          \
41                         __object_layout_bitmap = (unsigned int)-1;      \
42                 else if (__object_layout_bitmap != (unsigned int)-1)    \
43                         __object_layout_bitmap |= (1 << __index);       \
44         } while (0)
45 #define SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP do {                \
46                 if (__object_layout_bitmap == (unsigned int)-1)         \
47                         sgen_object_layout_scanned_bitmap_overflow ();  \
48                 else                                                    \
49                         sgen_object_layout_scanned_bitmap (__object_layout_bitmap); \
50         } while (0)
51
52 #else
53
54 #define sgen_object_layout_scanned_bitmap(bitmap)
55 #define sgen_object_layout_scanned_bitmap_overflow()
56 #define sgen_object_layout_scanned_ref_array()
57 #define sgen_object_layout_scanned_vtype_array()
58
59 #define sgen_object_layout_dump(out)
60
61 #define SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP
62 #define SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP(o,p)
63 #define SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP
64
65 #endif
66
67 #endif