5 * Copyright 2001-2003 Ximian, Inc
6 * Copyright 2003-2010 Novell, Inc.
7 * Copyright (C) 2013 Xamarin Inc
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 * Scans one object, using the OBJ_XXX macros. The start of the
13 * object must be given in the variable "char* start". Afterwards,
14 * "start" will point to the start of the next object, if the scanned
15 * object contained references. If not, the value of "start" should
16 * be considered undefined after executing this code. The object's
17 * GC descriptor must be in the variable "mword desc".
19 * The macro `HANDLE_PTR` will be invoked for every reference encountered while scanning the
20 * object. It is called with two parameters: The pointer to the reference (not the
21 * reference itself!) as well as the pointer to the scanned object.
23 * Modifiers (automatically undefined):
25 * SCAN_OBJECT_NOSCAN - if defined, don't actually scan the object,
26 * i.e. don't invoke the OBJ_XXX macros.
28 * SCAN_OBJECT_NOVTABLE - desc is provided by the includer, instead of
29 * vt. Complex arrays cannot not be scanned.
31 * SCAN_OBJECT_PROTOCOL - if defined, binary protocol the scan.
32 * Should only be used for scanning that's done for the actual
33 * collection, not for debugging scans.
37 #ifndef SCAN_OBJECT_NOVTABLE
38 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
39 binary_protocol_scan_begin ((GCObject*)start, SGEN_LOAD_VTABLE ((GCObject*)start), sgen_safe_object_get_size ((GCObject*)start));
42 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
43 binary_protocol_scan_vtype_begin (start + SGEN_CLIENT_OBJECT_HEADER_SIZE, size);
46 switch (desc & DESC_TYPE_MASK) {
47 case DESC_TYPE_RUN_LENGTH:
48 #define SCAN OBJ_RUN_LEN_FOREACH_PTR (desc, ((GCObject*)start))
49 #ifndef SCAN_OBJECT_NOSCAN
54 case DESC_TYPE_VECTOR:
55 #define SCAN OBJ_VECTOR_FOREACH_PTR (desc, ((GCObject*)start))
56 #ifndef SCAN_OBJECT_NOSCAN
61 case DESC_TYPE_BITMAP:
62 #define SCAN OBJ_BITMAP_FOREACH_PTR (desc, ((GCObject*)start))
63 #ifndef SCAN_OBJECT_NOSCAN
68 case DESC_TYPE_COMPLEX:
69 /* this is a complex object */
70 #define SCAN OBJ_COMPLEX_FOREACH_PTR (desc, ((GCObject*)start))
71 #ifndef SCAN_OBJECT_NOSCAN
76 #ifndef SCAN_OBJECT_NOVTABLE
77 case DESC_TYPE_COMPLEX_ARR:
78 /* this is an array of complex structs */
79 #define SCAN OBJ_COMPLEX_ARR_FOREACH_PTR (desc, ((GCObject*)start))
80 #ifndef SCAN_OBJECT_NOSCAN
86 case DESC_TYPE_SMALL_PTRFREE:
87 case DESC_TYPE_COMPLEX_PTRFREE:
91 g_assert_not_reached ();
95 #undef SCAN_OBJECT_NOSCAN
96 #undef SCAN_OBJECT_NOVTABLE
97 #undef SCAN_OBJECT_PROTOCOL