[sgen] Enqueue objects with their descriptors.
[mono-project.git] / mono / metadata / sgen-major-scan-object.h
blob668a9cd6411910ec27346e3bed0eaca794622bb9
1 /*
2 * sgen-major-scan-object.h: Object scanning in the major 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_major;
24 #ifdef FIXED_HEAP
25 #define PREFETCH_DYNAMIC_HEAP(addr)
26 #else
27 #define PREFETCH_DYNAMIC_HEAP(addr) PREFETCH ((addr))
28 #endif
30 #ifdef SCAN_FOR_CONCURRENT_MARK
31 #define FOLLOW_OBJECT(addr) (!sgen_ptr_in_nursery ((addr)))
32 #define ALWAYS_ADD_TO_GLOBAL_REMSET 1
33 #define CONCURRENT_NAME(x) x ## _concurrent
34 #else
35 #define FOLLOW_OBJECT(addr) 1
36 #define ALWAYS_ADD_TO_GLOBAL_REMSET 0
37 #define CONCURRENT_NAME(x) x
38 #endif
40 #undef HANDLE_PTR
41 #define HANDLE_PTR(ptr,obj) do { \
42 void *__old = *(ptr); \
43 void *__copy; \
44 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
45 if (__old && FOLLOW_OBJECT (__old)) { \
46 PREFETCH_DYNAMIC_HEAP (__old); \
47 CONCURRENT_NAME (major_copy_or_mark_object) ((ptr), __old, queue); \
48 __copy = *(ptr); \
49 SGEN_COND_LOG (9, __old != __copy, "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
50 if (G_UNLIKELY (sgen_ptr_in_nursery (__copy) && !sgen_ptr_in_nursery ((ptr)))) \
51 sgen_add_to_global_remset ((ptr), __copy); \
52 } else { \
53 if (ALWAYS_ADD_TO_GLOBAL_REMSET && G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
54 sgen_add_to_global_remset ((ptr), __old); \
55 } \
56 } while (0)
58 static void
59 CONCURRENT_NAME (major_scan_object) (char *start, mword desc, SgenGrayQueue *queue)
61 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
63 #define SCAN_OBJECT_PROTOCOL
64 #include "sgen-scan-object.h"
66 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
67 HEAVY_STAT (++stat_scan_object_called_major);
70 #ifdef SCAN_FOR_CONCURRENT_MARK
71 #ifdef SGEN_PARALLEL_MARK
72 #error concurrent and parallel mark not supported yet
73 #else
74 static void
75 CONCURRENT_NAME (major_scan_vtype) (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
77 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
79 /* The descriptors include info about the MonoObject header as well */
80 start -= sizeof (MonoObject);
82 #define SCAN_OBJECT_NOVTABLE
83 #define SCAN_OBJECT_PROTOCOL
84 #include "sgen-scan-object.h"
86 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
88 #endif
89 #endif
91 #undef PREFETCH_DYNAMIC_HEAP
92 #undef FOLLOW_OBJECT
93 #undef ALWAYS_ADD_TO_GLOBAL_REMSET
94 #undef CONCURRENT_NAME