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 extern long long stat_scan_object_called_nursery;
25 extern long long stat_scan_object_called_major;
28 #define HANDLE_PTR(ptr,obj) do { \
29 void *__old = *(ptr); \
32 copy_object ((ptr), queue); \
34 DEBUG (9, if (__old != __copy) fprintf (gc_debug_file, "Overwrote field at %p with %p (was: %p)\n", (ptr), *(ptr), __old)); \
35 if (G_UNLIKELY (ptr_in_nursery (__copy) && !ptr_in_nursery ((ptr)))) \
36 mono_sgen_add_to_global_remset (queue->allocator, (ptr)); \
41 * Scan the object pointed to by @start for references to
42 * other objects between @from_start and @from_end and copy
43 * them to the gray_objects area.
46 minor_scan_object (char *start, SgenGrayQueue *queue)
48 #include "sgen-scan-object.h"
50 HEAVY_STAT (++stat_scan_object_called_nursery);
56 * Scan the valuetype pointed to by START, described by DESC for references to
57 * other objects between @from_start and @from_end and copy them to the gray_objects area.
58 * Returns a pointer to the end of the object.
61 minor_scan_vtype (char *start, mword desc, char* from_start, char* from_end, SgenGrayQueue *queue)
65 /* The descriptors include info about the MonoObject header as well */
66 start -= sizeof (MonoObject);
69 case DESC_TYPE_RUN_LENGTH:
70 OBJ_RUN_LEN_FOREACH_PTR (desc,start);
71 OBJ_RUN_LEN_SIZE (skip_size, desc, start);
73 return start + skip_size;
74 case DESC_TYPE_SMALL_BITMAP:
75 OBJ_BITMAP_FOREACH_PTR (desc,start);
76 OBJ_BITMAP_SIZE (skip_size, desc, start);
77 return start + skip_size;
78 case DESC_TYPE_LARGE_BITMAP:
79 case DESC_TYPE_COMPLEX:
81 g_assert_not_reached ();
84 // The other descriptors can't happen with vtypes
85 g_assert_not_reached ();
92 #define PREFETCH_DYNAMIC_HEAP(addr)
94 #define PREFETCH_DYNAMIC_HEAP(addr) PREFETCH ((addr))
98 #define HANDLE_PTR(ptr,obj) do { \
99 void *__old = *(ptr); \
102 PREFETCH_DYNAMIC_HEAP (__old); \
103 major_copy_or_mark_object ((ptr), queue); \
105 DEBUG (9, if (__old != __copy) mono_sgen_debug_printf (9, "Overwrote field at %p with %p (was: %p)\n", (ptr), *(ptr), __old)); \
106 if (G_UNLIKELY (ptr_in_nursery (__copy) && !ptr_in_nursery ((ptr)))) \
107 mono_sgen_add_to_global_remset (queue->allocator, (ptr)); \
112 major_scan_object (char *start, SgenGrayQueue *queue)
114 #include "sgen-scan-object.h"
116 HEAVY_STAT (++stat_scan_object_called_major);
119 #define FILL_COLLECTOR_SCAN_OBJECT(collector) do { \
120 (collector)->major_scan_object = major_scan_object; \
121 (collector)->minor_scan_object = minor_scan_object; \
122 (collector)->minor_scan_vtype = minor_scan_vtype; \