Merge pull request #2582 from ludovic-henry/fix-threadpool-starvation
[mono-project.git] / mono / sgen / sgen-minor-scan-object.h
blobb1895985dc34e340f32093abfb423f967711f44a
1 /*
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 guint64 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
28 #elif defined (SGEN_SPLIT_NURSERY)
29 #define SERIAL_SCAN_OBJECT split_nursery_serial_scan_object
30 #define SERIAL_SCAN_VTYPE split_nursery_serial_scan_vtype
32 #else
33 #error "Please define GC_CONF_NAME"
34 #endif
36 #undef HANDLE_PTR
37 /* Global remsets are handled in SERIAL_COPY_OBJECT_FROM_OBJ */
38 #define HANDLE_PTR(ptr,obj) do { \
39 void *__old = *(ptr); \
40 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
41 binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
42 if (__old) { \
43 SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue); \
44 SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
45 } \
46 } while (0)
48 static void
49 SERIAL_SCAN_OBJECT (GCObject *full_object, SgenDescriptor desc, SgenGrayQueue *queue)
51 char *start = (char*)full_object;
53 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
55 #ifdef HEAVY_STATISTICS
56 sgen_descriptor_count_scanned_object (desc);
57 #endif
59 SGEN_ASSERT (9, sgen_get_current_collection_generation () == GENERATION_NURSERY, "Must not use minor scan during major collection.");
61 #define SCAN_OBJECT_PROTOCOL
62 #include "sgen-scan-object.h"
64 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP;
65 HEAVY_STAT (++stat_scan_object_called_nursery);
68 static void
69 SERIAL_SCAN_VTYPE (GCObject *full_object, char *start, SgenDescriptor desc, SgenGrayQueue *queue BINARY_PROTOCOL_ARG (size_t size))
71 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP;
73 SGEN_ASSERT (9, sgen_get_current_collection_generation () == GENERATION_NURSERY, "Must not use minor scan during major collection.");
75 /* The descriptors include info about the MonoObject header as well */
76 start -= SGEN_CLIENT_OBJECT_HEADER_SIZE;
78 #define SCAN_OBJECT_NOVTABLE
79 #define SCAN_OBJECT_PROTOCOL
80 #include "sgen-scan-object.h"
83 #define FILL_MINOR_COLLECTOR_SCAN_OBJECT(collector) do { \
84 (collector)->serial_ops.scan_object = SERIAL_SCAN_OBJECT; \
85 (collector)->serial_ops.scan_vtype = SERIAL_SCAN_VTYPE; \
86 } while (0)