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 * 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 * Scans one object, using the OBJ_XXX macros. The start of the
23 * object must be given in the variable "char* start". Afterwards,
24 * "start" will point to the start of the next object, if the scanned
25 * object contained references. If not, the value of "start" should
26 * be considered undefined after executing this code.
28 * Modifiers (automatically undefined):
30 * SCAN_OBJECT_NOSCAN - if defined, don't actually scan the object,
31 * i.e. don't invoke the OBJ_XXX macros.
33 * SCAN_OBJECT_NOVTABLE - desc is provided by the includer, instead of
34 * vt. Complex arrays cannot not be scanned.
36 * SCAN_OBJECT_PROTOCOL - if defined, binary protocol the scan.
37 * Should only be used for scanning that's done for the actual
38 * collection, not for debugging scans.
42 #ifndef SCAN_OBJECT_NOVTABLE
46 vt = (GCVTable*)SGEN_LOAD_VTABLE (start);
47 //type = vt->desc & 0x7;
49 /* gcc should be smart enough to remove the bounds check, but it isn't:( */
52 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
53 binary_protocol_scan_begin (start, vt, sgen_safe_object_get_size ((MonoObject*)start));
56 #if defined(SGEN_HEAVY_BINARY_PROTOCOL) && defined(SCAN_OBJECT_PROTOCOL)
57 binary_protocol_scan_vtype_begin (start + sizeof (MonoObject), size);
61 case DESC_TYPE_RUN_LENGTH:
62 #define SCAN OBJ_RUN_LEN_FOREACH_PTR (desc, start)
63 #ifndef SCAN_OBJECT_NOSCAN
68 case DESC_TYPE_SMALL_BITMAP:
69 #define SCAN OBJ_BITMAP_FOREACH_PTR (desc, start)
70 #ifndef SCAN_OBJECT_NOSCAN
75 case DESC_TYPE_VECTOR:
76 #define SCAN OBJ_VECTOR_FOREACH_PTR (desc, start)
77 #ifndef SCAN_OBJECT_NOSCAN
82 case DESC_TYPE_LARGE_BITMAP:
83 #define SCAN OBJ_LARGE_BITMAP_FOREACH_PTR (desc, start)
84 #ifndef SCAN_OBJECT_NOSCAN
89 case DESC_TYPE_COMPLEX:
90 /* this is a complex object */
91 #define SCAN OBJ_COMPLEX_FOREACH_PTR (desc, start)
92 #ifndef SCAN_OBJECT_NOSCAN
97 #ifndef SCAN_OBJECT_NOVTABLE
98 case DESC_TYPE_COMPLEX_ARR:
99 /* this is an array of complex structs */
100 #define SCAN OBJ_COMPLEX_ARR_FOREACH_PTR (vt, start)
101 #ifndef SCAN_OBJECT_NOSCAN
107 case DESC_TYPE_COMPLEX_PTRFREE:
111 g_assert_not_reached ();
115 #undef SCAN_OBJECT_NOSCAN
116 #undef SCAN_OBJECT_NOVTABLE
117 #undef SCAN_OBJECT_PROTOCOL