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 (mono_sgen_ptr_in_nursery (__copy) && !mono_sgen_ptr_in_nursery ((ptr)))) \
36 mono_sgen_add_to_global_remset ((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, SgenGrayQueue *queue)
63 /* The descriptors include info about the MonoObject header as well */
64 start -= sizeof (MonoObject);
66 #define SCAN_OBJECT_NOVTABLE
67 #include "sgen-scan-object.h"
71 #define HANDLE_PTR(ptr,obj) do { \
72 void *__old = *(ptr); \
75 nopar_copy_object ((ptr), queue); \
77 DEBUG (9, if (__old != __copy) fprintf (gc_debug_file, "Overwrote field at %p with %p (was: %p)\n", (ptr), *(ptr), __old)); \
78 if (G_UNLIKELY (mono_sgen_ptr_in_nursery (__copy) && !mono_sgen_ptr_in_nursery ((ptr)))) \
79 mono_sgen_add_to_global_remset ((ptr)); \
84 nopar_minor_scan_object (char *start, SgenGrayQueue *queue)
86 #include "sgen-scan-object.h"
88 HEAVY_STAT (++stat_scan_object_called_nursery);
92 nopar_minor_scan_vtype (char *start, mword desc, SgenGrayQueue *queue)
94 /* The descriptors include info about the MonoObject header as well */
95 start -= sizeof (MonoObject);
97 #define SCAN_OBJECT_NOVTABLE
98 #include "sgen-scan-object.h"
102 #define PREFETCH_DYNAMIC_HEAP(addr)
104 #define PREFETCH_DYNAMIC_HEAP(addr) PREFETCH ((addr))
108 #define HANDLE_PTR(ptr,obj) do { \
109 void *__old = *(ptr); \
112 PREFETCH_DYNAMIC_HEAP (__old); \
113 major_copy_or_mark_object ((ptr), queue); \
115 DEBUG (9, if (__old != __copy) mono_sgen_debug_printf (9, "Overwrote field at %p with %p (was: %p)\n", (ptr), *(ptr), __old)); \
116 if (G_UNLIKELY (mono_sgen_ptr_in_nursery (__copy) && !mono_sgen_ptr_in_nursery ((ptr)))) \
117 mono_sgen_add_to_global_remset ((ptr)); \
122 major_scan_object (char *start, SgenGrayQueue *queue)
124 #include "sgen-scan-object.h"
126 HEAVY_STAT (++stat_scan_object_called_major);
129 #define FILL_COLLECTOR_SCAN_OBJECT(collector) do { \
130 (collector)->major_scan_object = major_scan_object; \
131 (collector)->minor_scan_object = minor_scan_object; \
132 (collector)->nopar_minor_scan_object = nopar_minor_scan_object; \
133 (collector)->minor_scan_vtype = minor_scan_vtype; \
134 (collector)->nopar_minor_scan_vtype = nopar_minor_scan_vtype; \