Fix the build.
[mono-project.git] / mono / metadata / sgen-cardtable.h
blobec3a19760241951c11431fc1992906954e08d92b
1 /*
2 * Copyright 2001-2003 Ximian, Inc
3 * Copyright 2003-2010 Novell, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #ifndef __MONO_SGEN_CARD_TABLE_INLINES_H__
25 #define __MONO_SGEN_CARD_TABLE_INLINES_H__
27 #define SGEN_HAVE_CARDTABLE 1
29 #ifdef SGEN_HAVE_CARDTABLE
31 void sgen_card_table_reset_region (mword start, mword end) MONO_INTERNAL;
32 void* sgen_card_table_align_pointer (void *ptr) MONO_INTERNAL;
33 void sgen_card_table_mark_range (mword address, mword size) MONO_INTERNAL;
34 void sgen_cardtable_scan_object (char *obj, mword obj_size, guint8 *cards, SgenGrayQueue *queue) MONO_INTERNAL;
36 gboolean sgen_card_table_get_card_data (guint8 *dest, mword address, mword cards) MONO_INTERNAL;
37 void sgen_scan_from_card_tables (void *start_nursery, void *end_nursery, SgenGrayQueue *queue) MONO_INTERNAL;
38 void sgen_card_tables_collect_stats (gboolean begin) MONO_INTERNAL;
39 void sgen_card_table_clear (void) MONO_INTERNAL;
40 void sgen_card_table_init (void) MONO_INTERNAL;
41 gboolean sgen_ptr_in_nursery (void *p) MONO_INTERNAL;
44 /*How many bytes a single card covers*/
45 #define CARD_BITS 9
47 /* How many bits of the address space is covered by the card table.
48 * If this value is smaller than the number of address bits, card aliasing is required.
50 #define CARD_TABLE_BITS 32
52 #define CARD_SIZE_IN_BYTES (1 << CARD_BITS)
53 #define CARD_COUNT_BITS (CARD_TABLE_BITS - CARD_BITS)
54 #define CARD_COUNT_IN_BYTES (1 << CARD_COUNT_BITS)
55 #define CARD_MASK ((1 << CARD_COUNT_BITS) - 1)
57 #if SIZEOF_VOID_P * 8 > CARD_TABLE_BITS
58 #define SGEN_HAVE_OVERLAPPING_CARDS 1
59 #endif
61 extern guint8 *sgen_cardtable MONO_INTERNAL;
64 #ifdef SGEN_HAVE_OVERLAPPING_CARDS
66 static inline guint8*
67 sgen_card_table_get_card_address (mword address)
69 return sgen_cardtable + ((address >> CARD_BITS) & CARD_MASK);
72 extern guint8 *sgen_shadow_cardtable MONO_INTERNAL;
74 static inline guint8*
75 sgen_card_table_get_shadow_card_address (mword address)
77 return sgen_shadow_cardtable + ((address >> CARD_BITS) & CARD_MASK);
80 static inline gboolean
81 sgen_card_table_card_begin_scanning (mword address)
83 return *sgen_card_table_get_shadow_card_address (address) != 0;
86 static inline void
87 sgen_card_table_prepare_card_for_scanning (guint8 *card)
91 #define sgen_card_table_get_card_scan_address sgen_card_table_get_shadow_card_address
93 #else
95 static inline guint8*
96 sgen_card_table_get_card_address (mword address)
98 return sgen_cardtable + (address >> CARD_BITS);
101 static inline gboolean
102 sgen_card_table_card_begin_scanning (mword address)
104 guint8 *card = sgen_card_table_get_card_address (address);
105 gboolean res = *card;
106 *card = 0;
107 return res;
110 static inline void
111 sgen_card_table_prepare_card_for_scanning (guint8 *card)
113 *card = 0;
116 #define sgen_card_table_get_card_scan_address sgen_card_table_get_card_address
118 #endif
120 static inline gboolean
121 sgen_card_table_address_is_marked (mword address)
123 return *sgen_card_table_get_card_address (address) != 0;
126 static inline void
127 sgen_card_table_mark_address (mword address)
129 *sgen_card_table_get_card_address (address) = 1;
133 #else /*if SGEN_HAVE_CARDTABLE */
135 void
136 sgen_card_table_mark_address (mword address)
138 g_assert_not_reached ();
141 void
142 sgen_card_table_mark_range (mword address, mword size)
144 g_assert_not_reached ();
147 #define sgen_card_table_address_is_marked(p) FALSE
148 #define sgen_scan_from_card_tables(start,end,queue)
149 #define sgen_card_table_clear()
150 #define sgen_card_table_init()
151 #define sgen_card_tables_collect_stats(begin)
153 guint8*
154 mono_gc_get_card_table (int *shift_bits, gpointer *mask)
156 return NULL;
159 #endif
163 #endif