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 guint64 stat_scan_object_called_major;
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.
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.
36 #define HANDLE_PTR(ptr,obj) do { \
37 GCObject *__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_concurrent ((ptr), __old, queue); \
44 if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
45 ADD_TO_GLOBAL_REMSET ((full_object), (ptr), __old); \
49 /* FIXME: Unify this with optimized code in sgen-marksweep.c. */
51 #undef ADD_TO_GLOBAL_REMSET
52 #define ADD_TO_GLOBAL_REMSET(object,ptr,target) mark_mod_union_card ((object), (void**)(ptr))
55 major_scan_object_no_mark_concurrent_anywhere (GCObject *full_object, SgenDescriptor desc, SgenGrayQueue *queue)
57 char *start = (char*)full_object;
59 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
61 #ifdef HEAVY_STATISTICS
62 sgen_descriptor_count_scanned_object (desc);
64 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
65 add_scanned_object (start);
68 #define SCAN_OBJECT_PROTOCOL
69 #include "sgen-scan-object.h"
71 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
72 HEAVY_STAT (++stat_scan_object_called_major);
76 major_scan_object_no_mark_concurrent_start (GCObject *start, SgenDescriptor desc, SgenGrayQueue *queue)
78 major_scan_object_no_mark_concurrent_anywhere (start, desc, queue);
82 major_scan_object_no_mark_concurrent (GCObject *start, SgenDescriptor desc, SgenGrayQueue *queue)
84 SGEN_ASSERT (0, !sgen_ptr_in_nursery (start), "Why are we scanning nursery objects in the concurrent collector?");
85 major_scan_object_no_mark_concurrent_anywhere (start, desc, queue);
89 #define HANDLE_PTR(ptr,obj) do { \
90 void *__old = *(ptr); \
91 binary_protocol_scan_process_reference ((obj), (ptr), __old); \
93 gboolean __still_in_nursery = major_copy_or_mark_object_no_evacuation ((ptr), __old, queue); \
94 if (G_UNLIKELY (__still_in_nursery && !sgen_ptr_in_nursery ((ptr)) && !SGEN_OBJECT_IS_CEMENTED (*(ptr)))) { \
95 void *__copy = *(ptr); \
96 sgen_add_to_global_remset ((ptr), __copy); \
103 major_scan_vtype_concurrent_finish (GCObject *full_object, char *start, SgenDescriptor desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
105 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
107 #ifdef HEAVY_STATISTICS
108 /* FIXME: We're half scanning this object. How do we account for that? */
109 //add_scanned_object (start);
112 /* The descriptors include info about the object header as well */
113 start -= SGEN_CLIENT_OBJECT_HEADER_SIZE;
115 #define SCAN_OBJECT_NOVTABLE
116 #define SCAN_OBJECT_PROTOCOL
117 #include "sgen-scan-object.h"
119 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;