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); \
44 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
46 PARALLEL_COPY_OBJECT ((ptr), queue); \
48 SGEN_COND_LOG (9, __old != __copy, "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
49 if (G_UNLIKELY (sgen_ptr_in_nursery (__copy) && !sgen_ptr_in_nursery ((ptr)))) \
50 sgen_add_to_global_remset ((ptr), __copy); \
55 * Scan the object pointed to by @start for references to
56 * other objects between @from_start and @from_end and copy
57 * them to the gray_objects area.
60 PARALLEL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
62 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
64 #define SCAN_OBJECT_PROTOCOL
65 #include "sgen-scan-object.h"
67 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
68 HEAVY_STAT (++stat_scan_object_called_nursery);
74 * Scan the valuetype pointed to by START, described by DESC for references to
75 * other objects between @from_start and @from_end and copy them to the gray_objects area.
76 * Returns a pointer to the end of the object.
79 PARALLEL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
81 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
83 /* The descriptors include info about the MonoObject header as well */
84 start -= sizeof (MonoObject);
86 #define SCAN_OBJECT_NOVTABLE
87 #define SCAN_OBJECT_PROTOCOL
88 #include "sgen-scan-object.h"
92 /* Global remsets are handled in SERIAL_COPY_OBJECT_FROM_OBJ */
93 #define HANDLE_PTR(ptr,obj) do { \
94 void *__old = *(ptr); \
95 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
97 SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue); \
98 SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
103 SERIAL_SCAN_OBJECT (char *start, SgenGrayQueue *queue)
105 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
107 #define SCAN_OBJECT_PROTOCOL
108 #include "sgen-scan-object.h"
110 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
111 HEAVY_STAT (++stat_scan_object_called_nursery);
115 SERIAL_SCAN_VTYPE (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
117 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
119 /* The descriptors include info about the MonoObject header as well */
120 start -= sizeof (MonoObject);
122 #define SCAN_OBJECT_NOVTABLE
123 #define SCAN_OBJECT_PROTOCOL
124 #include "sgen-scan-object.h"
127 #define FILL_MINOR_COLLECTOR_SCAN_OBJECT(collector) do { \
128 (collector)->parallel_ops.scan_object = PARALLEL_SCAN_OBJECT; \
129 (collector)->parallel_ops.scan_vtype = PARALLEL_SCAN_VTYPE; \
130 (collector)->serial_ops.scan_object = SERIAL_SCAN_OBJECT; \
131 (collector)->serial_ops.scan_vtype = SERIAL_SCAN_VTYPE; \