[jit] Change MonoGenericParam.gshared_constraint to be a full MonoType so it can...
[mono.git] / mono / metadata / sgen-marksweep-scan-object-concurrent.h
1 /*
2  * sgen-major-scan-object.h: Object scanning in the major collectors.
3  *
4  * Copyright 2001-2003 Ximian, Inc
5  * Copyright 2003-2010 Novell, Inc.
6  * Copyright (C) 2012 Xamarin Inc
7  *
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;
11  *
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.
16  *
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.
20  */
21
22 extern guint64 stat_scan_object_called_major;
23
24 /*
25  * FIXME: We use the same scanning function in the concurrent collector whether we scan
26  * during the starting/finishing collection pause (with the world stopped) or from the
27  * concurrent worker thread.
28  *
29  * As long as the world is stopped, we should just follow pointers into the nursery and
30  * evict if possible.  In that case we also don't need the ALWAYS_ADD_TO_GLOBAL_REMSET case,
31  * which only seems to make sense for when the world is stopped, in which case we only need
32  * it because we don't follow into the nursery.
33  */
34
35 #undef HANDLE_PTR
36 #define HANDLE_PTR(ptr,obj)     do {                                    \
37                 void *__old = *(ptr);                                   \
38                 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
39                 binary_protocol_scan_process_reference ((obj), (ptr), __old); \
40                 if (__old && !sgen_ptr_in_nursery (__old)) {            \
41                         PREFETCH_READ (__old);                  \
42                         major_copy_or_mark_object_with_evacuation_concurrent ((ptr), __old, queue); \
43                 } else {                                                \
44                         if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
45                                 sgen_add_to_global_remset ((ptr), __old); \
46                 }                                                       \
47         } while (0)
48
49 /* FIXME: Unify this with optimized code in sgen-marksweep.c. */
50
51 static void
52 major_scan_object_no_mark_concurrent (char *start, mword desc, SgenGrayQueue *queue)
53 {
54         SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
55
56 #ifdef HEAVY_STATISTICS
57         sgen_descriptor_count_scanned_object (desc);
58 #endif
59 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
60         add_scanned_object (start);
61 #endif
62
63 #define SCAN_OBJECT_PROTOCOL
64 #include "sgen-scan-object.h"
65
66         SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
67         HEAVY_STAT (++stat_scan_object_called_major);
68 }
69
70 static void
71 major_scan_vtype_concurrent (char *start, mword desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
72 {
73         SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
74
75 #ifdef HEAVY_STATISTICS
76         /* FIXME: We're half scanning this object.  How do we account for that? */
77         //add_scanned_object (start);
78 #endif
79
80         /* The descriptors include info about the MonoObject header as well */
81         start -= sizeof (MonoObject);
82
83 #define SCAN_OBJECT_NOVTABLE
84 #define SCAN_OBJECT_PROTOCOL
85 #include "sgen-scan-object.h"
86
87         SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
88 }