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 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 extern guint64 stat_scan_object_called_nursery
;
13 #undef SERIAL_SCAN_OBJECT
14 #undef SERIAL_SCAN_VTYPE
15 #undef SERIAL_SCAN_PTR_FIELD
16 #undef SERIAL_DRAIN_GRAY_STACK
18 #if defined(SGEN_SIMPLE_NURSERY)
20 #ifdef SGEN_CONCURRENT_MAJOR
21 #define SERIAL_SCAN_OBJECT simple_nursery_serial_with_concurrent_major_scan_object
22 #define SERIAL_SCAN_VTYPE simple_nursery_serial_with_concurrent_major_scan_vtype
23 #define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_with_concurrent_major_scan_ptr_field
24 #define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_with_concurrent_major_drain_gray_stack
26 #define SERIAL_SCAN_OBJECT simple_nursery_serial_scan_object
27 #define SERIAL_SCAN_VTYPE simple_nursery_serial_scan_vtype
28 #define SERIAL_SCAN_PTR_FIELD simple_nursery_serial_scan_ptr_field
29 #define SERIAL_DRAIN_GRAY_STACK simple_nursery_serial_drain_gray_stack
32 #elif defined (SGEN_SPLIT_NURSERY)
34 #ifdef SGEN_CONCURRENT_MAJOR
35 #define SERIAL_SCAN_OBJECT split_nursery_serial_with_concurrent_major_scan_object
36 #define SERIAL_SCAN_VTYPE split_nursery_serial_with_concurrent_major_scan_vtype
37 #define SERIAL_SCAN_PTR_FIELD split_nursery_serial_with_concurrent_major_scan_ptr_field
38 #define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_with_concurrent_major_drain_gray_stack
40 #define SERIAL_SCAN_OBJECT split_nursery_serial_scan_object
41 #define SERIAL_SCAN_VTYPE split_nursery_serial_scan_vtype
42 #define SERIAL_SCAN_PTR_FIELD split_nursery_serial_scan_ptr_field
43 #define SERIAL_DRAIN_GRAY_STACK split_nursery_serial_drain_gray_stack
47 #error "No nursery configuration specified"
51 /* Global remsets are handled in SERIAL_COPY_OBJECT_FROM_OBJ */
52 #define HANDLE_PTR(ptr,obj) do { \
53 void *__old = *(ptr); \
54 SGEN_OBJECT_LAYOUT_STATISTICS_MARK_BITMAP ((obj), (ptr)); \
55 binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
57 SERIAL_COPY_OBJECT_FROM_OBJ ((ptr), queue); \
58 SGEN_COND_LOG (9, __old != *(ptr), "Overwrote field at %p with %p (was: %p)", (ptr), *(ptr), __old); \
63 SERIAL_SCAN_OBJECT (GCObject
*full_object
, SgenDescriptor desc
, SgenGrayQueue
*queue
)
65 char *start
= (char*)full_object
;
67 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP
;
69 #ifdef HEAVY_STATISTICS
70 sgen_descriptor_count_scanned_object (desc
);
73 SGEN_ASSERT (9, sgen_get_current_collection_generation () == GENERATION_NURSERY
, "Must not use minor scan during major collection.");
75 #define SCAN_OBJECT_PROTOCOL
76 #include "sgen-scan-object.h"
78 SGEN_OBJECT_LAYOUT_STATISTICS_COMMIT_BITMAP
;
79 HEAVY_STAT (++stat_scan_object_called_nursery
);
83 SERIAL_SCAN_VTYPE (GCObject
*full_object
, char *start
, SgenDescriptor desc
, SgenGrayQueue
*queue
BINARY_PROTOCOL_ARG (size_t size
))
85 SGEN_OBJECT_LAYOUT_STATISTICS_DECLARE_BITMAP
;
87 SGEN_ASSERT (9, sgen_get_current_collection_generation () == GENERATION_NURSERY
, "Must not use minor scan during major collection.");
89 /* The descriptors include info about the MonoObject header as well */
90 start
-= SGEN_CLIENT_OBJECT_HEADER_SIZE
;
92 #define SCAN_OBJECT_NOVTABLE
93 #define SCAN_OBJECT_PROTOCOL
94 #include "sgen-scan-object.h"
98 SERIAL_SCAN_PTR_FIELD (GCObject
*full_object
, GCObject
**ptr
, SgenGrayQueue
*queue
)
100 HANDLE_PTR (ptr
, NULL
);
104 SERIAL_DRAIN_GRAY_STACK (SgenGrayQueue
*queue
)
110 GRAY_OBJECT_DEQUEUE_SERIAL (queue
, &obj
, &desc
);
114 SERIAL_SCAN_OBJECT (obj
, desc
, queue
);
118 #define FILL_MINOR_COLLECTOR_SCAN_OBJECT(ops) do { \
119 (ops)->scan_object = SERIAL_SCAN_OBJECT; \
120 (ops)->scan_vtype = SERIAL_SCAN_VTYPE; \
121 (ops)->scan_ptr_field = SERIAL_SCAN_PTR_FIELD; \
122 (ops)->drain_gray_stack = SERIAL_DRAIN_GRAY_STACK; \