Fix roslyn install with AOT disabled.
[mono-project.git] / mono / sgen / sgen-scan-object.h
blobb5cbedaa92ec50bb9d0b1237e353a244ad4a6303
1 /*
2 * sgen-scan-object.h: Generic object scan.
4 * Copyright 2001-2003 Ximian, Inc
5 * Copyright 2003-2010 Novell, Inc.
6 * Copyright (C) 2013 Xamarin Inc
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 * Scans one object, using the OBJ_XXX macros. The start of the
12 * object must be given in the variable "char* start". Afterwards,
13 * "start" will point to the start of the next object, if the scanned
14 * object contained references. If not, the value of "start" should
15 * be considered undefined after executing this code. The object's
16 * GC descriptor must be in the variable "mword desc".
18 * The macro `HANDLE_PTR` will be invoked for every reference encountered while scanning the
19 * object. It is called with two parameters: The pointer to the reference (not the
20 * reference itself!) as well as the pointer to the scanned object.
22 * Modifiers (automatically undefined):
24 * SCAN_OBJECT_NOSCAN - if defined, don't actually scan the object,
25 * i.e. don't invoke the OBJ_XXX macros.
27 * SCAN_OBJECT_NOVTABLE - desc is provided by the includer, instead of
28 * vt. Complex arrays cannot not be scanned.
30 * SCAN_OBJECT_PROTOCOL - if defined, binary protocol the scan.
31 * Should only be used for scanning that's done for the actual
32 * collection, not for debugging scans.
36 #ifndef SCAN_OBJECT_NOVTABLE
37 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
38 binary_protocol_scan_begin ((GCObject*)start, SGEN_LOAD_VTABLE ((GCObject*)start), sgen_safe_object_get_size ((GCObject*)start));
39 #endif
40 #else
41 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
42 binary_protocol_scan_vtype_begin (start + SGEN_CLIENT_OBJECT_HEADER_SIZE, size);
43 #endif
44 #endif
45 switch (desc & DESC_TYPE_MASK) {
46 case DESC_TYPE_RUN_LENGTH:
47 #define SCAN OBJ_RUN_LEN_FOREACH_PTR (desc, ((GCObject*)start))
48 #ifndef SCAN_OBJECT_NOSCAN
49 SCAN;
50 #endif
51 #undef SCAN
52 break;
53 case DESC_TYPE_VECTOR:
54 #define SCAN OBJ_VECTOR_FOREACH_PTR (desc, ((GCObject*)start))
55 #ifndef SCAN_OBJECT_NOSCAN
56 SCAN;
57 #endif
58 #undef SCAN
59 break;
60 case DESC_TYPE_BITMAP:
61 #define SCAN OBJ_BITMAP_FOREACH_PTR (desc, ((GCObject*)start))
62 #ifndef SCAN_OBJECT_NOSCAN
63 SCAN;
64 #endif
65 #undef SCAN
66 break;
67 case DESC_TYPE_COMPLEX:
68 /* this is a complex object */
69 #define SCAN OBJ_COMPLEX_FOREACH_PTR (desc, ((GCObject*)start))
70 #ifndef SCAN_OBJECT_NOSCAN
71 SCAN;
72 #endif
73 #undef SCAN
74 break;
75 #ifndef SCAN_OBJECT_NOVTABLE
76 case DESC_TYPE_COMPLEX_ARR:
77 /* this is an array of complex structs */
78 #define SCAN OBJ_COMPLEX_ARR_FOREACH_PTR (desc, ((GCObject*)start))
79 #ifndef SCAN_OBJECT_NOSCAN
80 SCAN;
81 #endif
82 #undef SCAN
83 break;
84 #endif
85 case DESC_TYPE_SMALL_PTRFREE:
86 case DESC_TYPE_COMPLEX_PTRFREE:
87 /*Nothing to do*/
88 break;
89 default:
90 g_assert_not_reached ();
94 #undef SCAN_OBJECT_NOSCAN
95 #undef SCAN_OBJECT_NOVTABLE
96 #undef SCAN_OBJECT_PROTOCOL