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;
25 #define PREFETCH_DYNAMIC_HEAP(addr)
27 #define PREFETCH_DYNAMIC_HEAP(addr) PREFETCH ((addr))
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
35 #define FOLLOW_OBJECT(addr) 1
36 #define ALWAYS_ADD_TO_GLOBAL_REMSET 0
37 #define CONCURRENT_NAME(x) x
41 #define HANDLE_PTR(ptr,obj) do { \
42 void *__old = *(ptr); \
44 if (__old && FOLLOW_OBJECT (__old)) { \
45 PREFETCH_DYNAMIC_HEAP (__old); \
46 CONCURRENT_NAME (major_copy_or_mark_object) ((ptr), __old, 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); \
52 if (ALWAYS_ADD_TO_GLOBAL_REMSET && G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)))) \
53 sgen_add_to_global_remset ((ptr), __old); \
58 CONCURRENT_NAME (major_scan_object) (char *start, SgenGrayQueue *queue)
60 #include "sgen-scan-object.h"
62 HEAVY_STAT (++stat_scan_object_called_major);
65 #ifdef SCAN_FOR_CONCURRENT_MARK
66 #ifdef SGEN_PARALLEL_MARK
67 #error concurrent and parallel mark not supported yet
70 CONCURRENT_NAME (major_scan_vtype) (char *start, mword desc, SgenGrayQueue *queue)
72 /* The descriptors include info about the MonoObject header as well */
73 start -= sizeof (MonoObject);
75 #define SCAN_OBJECT_NOVTABLE
76 #include "sgen-scan-object.h"
81 #undef PREFETCH_DYNAMIC_HEAP
83 #undef ALWAYS_ADD_TO_GLOBAL_REMSET
84 #undef CONCURRENT_NAME