2 * sgen-minor-scan-object.h: Object scanning in the nursery collectors.
4 * Copyright 2001-2003 Ximian, Inc
5 * Copyright 2003-2010 Novell, Inc.
6 * Copyright (C) 2012 Xamarin Inc
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License 2.0 as published by the Free Software Foundation;
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License 2.0 along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 extern long long stat_scan_object_called_nursery;
24 #if defined(SGEN_SIMPLE_NURSERY)
25 #define SERIAL_SCAN_OBJECT simple_nursery_serial_scan_object
26 #define SERIAL_SCAN_VTYPE simple_nursery_serial_scan_vtype
27 #define PARALLEL_SCAN_OBJECT simple_nursery_parallel_scan_object
28 #define PARALLEL_SCAN_VTYPE simple_nursery_parallel_scan_vtype
30 #elif defined (SGEN_SPLIT_NURSERY)
31 #define SERIAL_SCAN_OBJECT split_nursery_serial_scan_object
32 #define SERIAL_SCAN_VTYPE split_nursery_serial_scan_vtype
33 #define PARALLEL_SCAN_OBJECT split_nursery_parallel_scan_object
34 #define PARALLEL_SCAN_VTYPE split_nursery_parallel_scan_vtype
37 #error "Please define GC_CONF_NAME"
41 #define HANDLE_PTR(ptr,obj) do { \
42 void *__old = *(ptr); \
45 PARALLEL_COPY_OBJECT ((ptr), queue); \
47 SGEN_COND_LOG (9, __old != __copy, "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
48 if (G_UNLIKELY (sgen_ptr_in_nursery (__copy) && !sgen_ptr_in_nursery ((ptr)))) \
49 sgen_add_to_global_remset ((ptr)); \
54 * Scan the object pointed to by @start for references to
55 * other objects between @from_start and @from_end and copy
56 * them to the gray_objects area.
59 PARALLEL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
61 #include "sgen-scan-object.h"
63 HEAVY_STAT (++stat_scan_object_called_nursery);
69 * Scan the valuetype pointed to by START, described by DESC for references to
70 * other objects between @from_start and @from_end and copy them to the gray_objects area.
71 * Returns a pointer to the end of the object.
74 PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue)
76 /* The descriptors include info about the MonoObject header as well */
77 start -= sizeof (MonoObject);
79 #define SCAN_OBJECT_NOVTABLE
80 #include "sgen-scan-object.h"
84 /* Global remsets are handled in SERIAL_COPY_OBJECT_FROM_OBJ */
85 #define HANDLE_PTR(ptr,obj) do { \
86 void *__old = *(ptr); \
88 SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue); \
89 SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
94 SERIAL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
96 #include "sgen-scan-object.h"
98 HEAVY_STAT (++stat_scan_object_called_nursery);
102 SERIAL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue)
104 /* The descriptors include info about the MonoObject header as well */
105 start -= sizeof (MonoObject);
107 #define SCAN_OBJECT_NOVTABLE
108 #include "sgen-scan-object.h"
111 #define FILL_MINOR_COLLECTOR_SCAN_OBJECT(collector) do { \
112 (collector)->parallel_ops.scan_object = PARALLEL_SCAN_OBJECT; \
113 (collector)->parallel_ops.scan_vtype = PARALLEL_SCAN_VTYPE; \
114 (collector)->serial_ops.scan_object = SERIAL_SCAN_OBJECT; \
115 (collector)->serial_ops.scan_vtype = SERIAL_SCAN_VTYPE; \