[gc] Fix gc bitmap for array of pointers. They don't contain references
[mono.git] / mono / metadata / sgen-protocol.h
1 /*
2  * sgen-protocol.h: Binary protocol of internal activity, to aid
3  * debugging.
4  *
5  * Copyright 2001-2003 Ximian, Inc
6  * Copyright 2003-2010 Novell, Inc.
7  * Copyright (C) 2012 Xamarin Inc
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License 2.0 as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License 2.0 along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #ifndef __MONO_SGENPROTOCOL_H__
24 #define __MONO_SGENPROTOCOL_H__
25
26 #include "sgen-gc.h"
27
28 enum {
29         SGEN_PROTOCOL_COLLECTION_FORCE,
30         SGEN_PROTOCOL_COLLECTION_BEGIN,
31         SGEN_PROTOCOL_COLLECTION_END,
32         SGEN_PROTOCOL_CONCURRENT_START,
33         SGEN_PROTOCOL_CONCURRENT_UPDATE,
34         SGEN_PROTOCOL_CONCURRENT_FINISH,
35         SGEN_PROTOCOL_WORLD_STOPPING,
36         SGEN_PROTOCOL_WORLD_STOPPED,
37         SGEN_PROTOCOL_WORLD_RESTARTING,
38         SGEN_PROTOCOL_WORLD_RESTARTED,
39         SGEN_PROTOCOL_ALLOC,
40         SGEN_PROTOCOL_COPY,
41         SGEN_PROTOCOL_PIN_STAGE,
42         SGEN_PROTOCOL_PIN,
43         SGEN_PROTOCOL_MARK,
44         SGEN_PROTOCOL_SCAN_BEGIN,
45         SGEN_PROTOCOL_SCAN_VTYPE_BEGIN,
46         SGEN_PROTOCOL_SCAN_PROCESS_REFERENCE,
47         SGEN_PROTOCOL_WBARRIER,
48         SGEN_PROTOCOL_GLOBAL_REMSET,
49         SGEN_PROTOCOL_PTR_UPDATE,
50         SGEN_PROTOCOL_CLEANUP,
51         SGEN_PROTOCOL_EMPTY,
52         SGEN_PROTOCOL_THREAD_SUSPEND,
53         SGEN_PROTOCOL_THREAD_RESTART,
54         SGEN_PROTOCOL_THREAD_REGISTER,
55         SGEN_PROTOCOL_THREAD_UNREGISTER,
56         SGEN_PROTOCOL_MISSING_REMSET,
57         SGEN_PROTOCOL_ALLOC_PINNED,
58         SGEN_PROTOCOL_ALLOC_DEGRADED,
59         SGEN_PROTOCOL_CARD_SCAN,
60         SGEN_PROTOCOL_CEMENT,
61         SGEN_PROTOCOL_CEMENT_RESET,
62         SGEN_PROTOCOL_DISLINK_UPDATE,
63         SGEN_PROTOCOL_DISLINK_UPDATE_STAGED,
64         SGEN_PROTOCOL_DISLINK_PROCESS_STAGED,
65         SGEN_PROTOCOL_DOMAIN_UNLOAD_BEGIN,
66         SGEN_PROTOCOL_DOMAIN_UNLOAD_END,
67         SGEN_PROTOCOL_GRAY_ENQUEUE,
68         SGEN_PROTOCOL_GRAY_DEQUEUE,
69 };
70
71 typedef struct {
72         int generation;
73 } SGenProtocolCollectionForce;
74
75 typedef struct {
76         int index, generation;
77 } SGenProtocolCollectionBegin;
78
79 typedef struct {
80         int index, generation;
81         long long num_scanned_objects;
82         long long num_unique_scanned_objects;
83 } SGenProtocolCollectionEnd;
84
85 typedef struct {
86         long long timestamp;
87 } SGenProtocolWorldStopping;
88
89 typedef struct {
90         long long timestamp;
91         long long total_major_cards;
92         long long marked_major_cards;
93         long long total_los_cards;
94         long long marked_los_cards;
95 } SGenProtocolWorldStopped;
96
97 typedef struct {
98         int generation;
99         long long timestamp;
100         long long total_major_cards;
101         long long marked_major_cards;
102         long long total_los_cards;
103         long long marked_los_cards;
104 } SGenProtocolWorldRestarting;
105
106 typedef struct {
107         int generation;
108         long long timestamp;
109 } SGenProtocolWorldRestarted;
110
111 typedef struct {
112         gpointer obj;
113         gpointer vtable;
114         int size;
115 } SGenProtocolAlloc;
116
117 typedef struct {
118         gpointer from;
119         gpointer to;
120         gpointer vtable;
121         int size;
122 } SGenProtocolCopy;
123
124 typedef struct {
125         gpointer addr_ptr;
126         gpointer addr;
127 } SGenProtocolPinStage;
128
129 typedef struct {
130         gpointer obj;
131         gpointer vtable;
132         int size;
133 } SGenProtocolPin;
134
135 typedef struct {
136         gpointer obj;
137         gpointer vtable;
138         int size;
139 } SGenProtocolMark;
140
141 typedef struct {
142         gpointer obj;
143         gpointer vtable;
144         int size;
145 } SGenProtocolScanBegin;
146
147 typedef struct {
148         gpointer obj;
149         int size;
150 } SGenProtocolScanVTypeBegin;
151
152 typedef struct {
153         gpointer obj;
154         gpointer ptr;
155         gpointer value;
156 } SGenProtocolScanProcessReference;
157
158 typedef struct {
159         gpointer ptr;
160         gpointer value;
161         gpointer value_vtable;
162 } SGenProtocolWBarrier;
163
164 typedef struct {
165         gpointer ptr;
166         gpointer value;
167         gpointer value_vtable;
168 } SGenProtocolGlobalRemset;
169
170 typedef struct {
171         gpointer ptr;
172         gpointer old_value;
173         gpointer new_value;
174         gpointer vtable;
175         int size;
176 } SGenProtocolPtrUpdate;
177
178 typedef struct {
179         gpointer ptr;
180         gpointer vtable;
181         int size;
182 } SGenProtocolCleanup;
183
184 typedef struct {
185         gpointer start;
186         int size;
187 } SGenProtocolEmpty;
188
189 typedef struct {
190         gpointer thread, stopped_ip;
191 } SGenProtocolThreadSuspend;
192
193 typedef struct {
194         gpointer thread;
195 } SGenProtocolThreadRestart;
196
197 typedef struct {
198         gpointer thread;
199 } SGenProtocolThreadRegister;
200
201 typedef struct {
202         gpointer thread;
203 } SGenProtocolThreadUnregister;
204
205 typedef struct {
206         gpointer obj;
207         gpointer obj_vtable;
208         int offset;
209         gpointer value;
210         gpointer value_vtable;
211         int value_pinned;
212 } SGenProtocolMissingRemset;
213
214 typedef struct {
215         gpointer start;
216         int size;
217 } SGenProtocolCardScan;
218
219 typedef struct {
220         gpointer obj;
221         gpointer vtable;
222         int size;
223 } SGenProtocolCement;
224
225 typedef struct {
226         gpointer link;
227         gpointer obj;
228         int track;
229         int staged;
230 } SGenProtocolDislinkUpdate;
231
232 typedef struct {
233         gpointer link;
234         gpointer obj;
235         int track;
236         int index;
237 } SGenProtocolDislinkUpdateStaged;
238
239 typedef struct {
240         gpointer link;
241         gpointer obj;
242         int index;
243 } SGenProtocolDislinkProcessStaged;
244
245 typedef struct {
246         gpointer domain;
247 } SGenProtocolDomainUnload;
248
249 typedef struct {
250         gpointer queue;
251         gpointer cursor;
252         gpointer value;
253 } SGenProtocolGrayQueue;
254
255 /* missing: finalizers, roots, non-store wbarriers */
256
257 void binary_protocol_init (const char *filename, long long limit) MONO_INTERNAL;
258 gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;
259
260 void binary_protocol_flush_buffers (gboolean force) MONO_INTERNAL;
261
262 void binary_protocol_collection_force (int generation) MONO_INTERNAL;
263 void binary_protocol_collection_begin (int index, int generation) MONO_INTERNAL;
264 void binary_protocol_collection_end (int index, int generation, long long num_objects_scanned, long long num_unique_objects_scanned) MONO_INTERNAL;
265 void binary_protocol_concurrent_start (void) MONO_INTERNAL;
266 void binary_protocol_concurrent_update (void) MONO_INTERNAL;
267 void binary_protocol_concurrent_finish (void) MONO_INTERNAL;
268 void binary_protocol_world_stopping (long long timestamp) MONO_INTERNAL;
269 void binary_protocol_world_stopped (long long timestamp, long long total_major_cards,
270                 long long marked_major_cards, long long total_los_cards, long long marked_los_cards) MONO_INTERNAL;
271 void binary_protocol_world_restarting (int generation, long long timestamp,
272                 long long total_major_cards, long long marked_major_cards, long long total_los_cards, long long marked_los_cards) MONO_INTERNAL;
273 void binary_protocol_world_restarted (int generation, long long timestamp) MONO_INTERNAL;
274
275 void binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip) MONO_INTERNAL;
276 void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
277 void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
278 void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
279 void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
280                 gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
281
282 void binary_protocol_cement (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
283 void binary_protocol_cement_reset (void) MONO_INTERNAL;
284
285 void binary_protocol_domain_unload_begin (gpointer domain) MONO_INTERNAL;
286 void binary_protocol_domain_unload_end (gpointer domain) MONO_INTERNAL;
287
288 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
289
290 #define binary_protocol_is_heavy_enabled()      binary_protocol_is_enabled ()
291
292 void binary_protocol_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
293 void binary_protocol_alloc_pinned (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
294 void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
295 void binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size) MONO_INTERNAL;
296 void binary_protocol_pin_stage (gpointer addr_ptr, gpointer addr) MONO_INTERNAL;
297 void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
298 void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
299 void binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
300 void binary_protocol_scan_vtype_begin (gpointer start, int size) MONO_INTERNAL;
301 void binary_protocol_scan_process_reference (gpointer obj, gpointer ptr, gpointer value) MONO_INTERNAL;
302 void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
303 void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
304 void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
305 void binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
306 void binary_protocol_empty (gpointer start, int size) MONO_INTERNAL;
307 void binary_protocol_card_scan (gpointer start, int size) MONO_INTERNAL;
308 void binary_protocol_dislink_update (gpointer link, gpointer obj, int track, int staged) MONO_INTERNAL;
309 void binary_protocol_dislink_update_staged (gpointer link, gpointer obj, int track, int index) MONO_INTERNAL;
310 void binary_protocol_dislink_process_staged (gpointer link, gpointer obj, int index) MONO_INTERNAL;
311 void binary_protocol_gray_enqueue (gpointer queue, gpointer cursor, gpointer value) MONO_INTERNAL;
312 void binary_protocol_gray_dequeue (gpointer queue, gpointer cursor, gpointer value) MONO_INTERNAL;
313
314 #else
315
316 #define binary_protocol_is_heavy_enabled()      FALSE
317
318 #define binary_protocol_alloc(obj, vtable, size)
319 #define binary_protocol_alloc_pinned(obj, vtable, size)
320 #define binary_protocol_alloc_degraded(obj, vtable, size)
321 #define binary_protocol_copy(from, to, vtable, size)
322 #define binary_protocol_pin_stage(addr_ptr, addr)
323 #define binary_protocol_pin(obj, vtable, size)
324 #define binary_protocol_mark(obj, vtable, size)
325 #define binary_protocol_scan_begin(obj, vtable, size)
326 #define binary_protocol_scan_vtype_begin(obj, size)
327 #define binary_protocol_scan_process_reference(obj, ptr, value)
328 #define binary_protocol_wbarrier(ptr, value, value_vtable)
329 #define binary_protocol_global_remset(ptr, value, value_vtable)
330 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
331 #define binary_protocol_cleanup(ptr, vtable, size)
332 #define binary_protocol_empty(start, size)
333 #define binary_protocol_card_scan(start, size)
334 #define binary_protocol_dislink_update(link,obj,track,staged)
335 #define binary_protocol_dislink_update_staged(link,obj,track,index)
336 #define binary_protocol_dislink_process_staged(link,obj,index)
337 #define binary_protocol_gray_enqueue(queue,cursor,value)
338 #define binary_protocol_gray_dequeue(queue,cursor,value)
339
340 #endif
341
342 #endif