2 * Copyright 2001-2003 Ximian, Inc
3 * Copyright 2003-2010 Novell, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Scans one object, using the OBJ_XXX macros. The start of the
26 * object must be given in the variable "char* start". Afterwards,
27 * "start" will point to the start of the next object.
29 * Modifiers (automatically undefined):
31 * SCAN_OBJECT_NOSCAN - if defined, don't actually scan the object,
32 * i.e. don't invoke the OBJ_XXX macros.
34 * SCAN_OBJECT_ACTION - is invoked after an object has been scanned.
35 * The object's start is "start", its length in bytes (including
36 * padding at the end) is "skip_size". "desc" is the object's GC
37 * descriptor. The action can use the macro
38 * "SCAN" to scan the object.
41 #ifndef SCAN_OBJECT_ACTION
42 #define SCAN_OBJECT_ACTION
50 vt
= (GCVTable
*)LOAD_VTABLE (start
);
51 //type = vt->desc & 0x7;
53 /* gcc should be smart enough to remove the bounds check, but it isn't:( */
56 case DESC_TYPE_STRING
:
57 STRING_SIZE (skip_size
, start
);
63 case DESC_TYPE_RUN_LENGTH
:
64 OBJ_RUN_LEN_SIZE (skip_size
, desc
, start
);
66 #define SCAN OBJ_RUN_LEN_FOREACH_PTR (desc, start)
67 #ifndef SCAN_OBJECT_NOSCAN
75 case DESC_TYPE_VECTOR
:
76 skip_size
= safe_object_get_size ((MonoObject
*)start
);
77 skip_size
+= (ALLOC_ALIGN
- 1);
78 skip_size
&= ~(ALLOC_ALIGN
- 1);
79 #define SCAN OBJ_VECTOR_FOREACH_PTR (vt, start)
80 #ifndef SCAN_OBJECT_NOSCAN
87 case DESC_TYPE_SMALL_BITMAP
:
88 OBJ_BITMAP_SIZE (skip_size
, desc
, start
);
90 #define SCAN OBJ_BITMAP_FOREACH_PTR (desc, start)
91 #ifndef SCAN_OBJECT_NOSCAN
98 case DESC_TYPE_LARGE_BITMAP
:
99 skip_size
= safe_object_get_size ((MonoObject
*)start
);
100 skip_size
+= (ALLOC_ALIGN
- 1);
101 skip_size
&= ~(ALLOC_ALIGN
- 1);
102 #define SCAN OBJ_LARGE_BITMAP_FOREACH_PTR (vt,start)
103 #ifndef SCAN_OBJECT_NOSCAN
110 case DESC_TYPE_COMPLEX
:
111 /* this is a complex object */
112 skip_size
= safe_object_get_size ((MonoObject
*)start
);
113 skip_size
+= (ALLOC_ALIGN
- 1);
114 skip_size
&= ~(ALLOC_ALIGN
- 1);
115 #define SCAN OBJ_COMPLEX_FOREACH_PTR (vt, start)
116 #ifndef SCAN_OBJECT_NOSCAN
123 case DESC_TYPE_COMPLEX_ARR
:
124 /* this is an array of complex structs */
125 skip_size
= safe_object_get_size ((MonoObject
*)start
);
126 skip_size
+= (ALLOC_ALIGN
- 1);
127 skip_size
&= ~(ALLOC_ALIGN
- 1);
128 #define SCAN OBJ_COMPLEX_ARR_FOREACH_PTR (vt, start)
129 #ifndef SCAN_OBJECT_NOSCAN
137 g_assert_not_reached ();
141 #undef SCAN_OBJECT_NOSCAN
142 #undef SCAN_OBJECT_ACTION