1d486ca41b7d076762b92efbba0961d5cd67ef8f
[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_FINISH,
34         SGEN_PROTOCOL_WORLD_STOPPING,
35         SGEN_PROTOCOL_WORLD_STOPPED,
36         SGEN_PROTOCOL_WORLD_RESTARTING,
37         SGEN_PROTOCOL_WORLD_RESTARTED,
38         SGEN_PROTOCOL_ALLOC,
39         SGEN_PROTOCOL_COPY,
40         SGEN_PROTOCOL_PIN_STAGE,
41         SGEN_PROTOCOL_PIN,
42         SGEN_PROTOCOL_MARK,
43         SGEN_PROTOCOL_SCAN_BEGIN,
44         SGEN_PROTOCOL_SCAN_VTYPE_BEGIN,
45         SGEN_PROTOCOL_WBARRIER,
46         SGEN_PROTOCOL_GLOBAL_REMSET,
47         SGEN_PROTOCOL_PTR_UPDATE,
48         SGEN_PROTOCOL_CLEANUP,
49         SGEN_PROTOCOL_EMPTY,
50         SGEN_PROTOCOL_THREAD_SUSPEND,
51         SGEN_PROTOCOL_THREAD_RESTART,
52         SGEN_PROTOCOL_THREAD_REGISTER,
53         SGEN_PROTOCOL_THREAD_UNREGISTER,
54         SGEN_PROTOCOL_MISSING_REMSET,
55         SGEN_PROTOCOL_ALLOC_PINNED,
56         SGEN_PROTOCOL_ALLOC_DEGRADED,
57         SGEN_PROTOCOL_CARD_SCAN,
58         SGEN_PROTOCOL_CEMENT,
59         SGEN_PROTOCOL_CEMENT_RESET,
60         SGEN_PROTOCOL_DISLINK_UPDATE,
61         SGEN_PROTOCOL_DISLINK_UPDATE_STAGED,
62         SGEN_PROTOCOL_DISLINK_PROCESS_STAGED,
63         SGEN_PROTOCOL_DOMAIN_UNLOAD_BEGIN,
64         SGEN_PROTOCOL_DOMAIN_UNLOAD_END,
65         SGEN_PROTOCOL_GRAY_ENQUEUE,
66         SGEN_PROTOCOL_GRAY_DEQUEUE,
67 };
68
69 typedef struct {
70         int generation;
71 } SGenProtocolCollectionForce;
72
73 typedef struct {
74         int index, generation;
75 } SGenProtocolCollectionBegin;
76
77 typedef struct {
78         int index, generation;
79         long long num_scanned_objects;
80         long long num_unique_scanned_objects;
81 } SGenProtocolCollectionEnd;
82
83 typedef struct {
84         long long timestamp;
85 } SGenProtocolWorldStopping;
86
87 typedef struct {
88         long long timestamp;
89         long long total_major_cards;
90         long long marked_major_cards;
91         long long total_los_cards;
92         long long marked_los_cards;
93 } SGenProtocolWorldStopped;
94
95 typedef struct {
96         int generation;
97         long long timestamp;
98         long long total_major_cards;
99         long long marked_major_cards;
100         long long total_los_cards;
101         long long marked_los_cards;
102 } SGenProtocolWorldRestarting;
103
104 typedef struct {
105         int generation;
106         long long timestamp;
107 } SGenProtocolWorldRestarted;
108
109 typedef struct {
110         gpointer obj;
111         gpointer vtable;
112         int size;
113 } SGenProtocolAlloc;
114
115 typedef struct {
116         gpointer from;
117         gpointer to;
118         gpointer vtable;
119         int size;
120 } SGenProtocolCopy;
121
122 typedef struct {
123         gpointer addr_ptr;
124         gpointer addr;
125 } SGenProtocolPinStage;
126
127 typedef struct {
128         gpointer obj;
129         gpointer vtable;
130         int size;
131 } SGenProtocolPin;
132
133 typedef struct {
134         gpointer obj;
135         gpointer vtable;
136         int size;
137 } SGenProtocolMark;
138
139 typedef struct {
140         gpointer obj;
141         gpointer vtable;
142         int size;
143 } SGenProtocolScanBegin;
144
145 typedef struct {
146         gpointer obj;
147         int size;
148 } SGenProtocolScanVTypeBegin;
149
150 typedef struct {
151         gpointer ptr;
152         gpointer value;
153         gpointer value_vtable;
154 } SGenProtocolWBarrier;
155
156 typedef struct {
157         gpointer ptr;
158         gpointer value;
159         gpointer value_vtable;
160 } SGenProtocolGlobalRemset;
161
162 typedef struct {
163         gpointer ptr;
164         gpointer old_value;
165         gpointer new_value;
166         gpointer vtable;
167         int size;
168 } SGenProtocolPtrUpdate;
169
170 typedef struct {
171         gpointer ptr;
172         gpointer vtable;
173         int size;
174 } SGenProtocolCleanup;
175
176 typedef struct {
177         gpointer start;
178         int size;
179 } SGenProtocolEmpty;
180
181 typedef struct {
182         gpointer thread, stopped_ip;
183 } SGenProtocolThreadSuspend;
184
185 typedef struct {
186         gpointer thread;
187 } SGenProtocolThreadRestart;
188
189 typedef struct {
190         gpointer thread;
191 } SGenProtocolThreadRegister;
192
193 typedef struct {
194         gpointer thread;
195 } SGenProtocolThreadUnregister;
196
197 typedef struct {
198         gpointer obj;
199         gpointer obj_vtable;
200         int offset;
201         gpointer value;
202         gpointer value_vtable;
203         int value_pinned;
204 } SGenProtocolMissingRemset;
205
206 typedef struct {
207         gpointer start;
208         int size;
209 } SGenProtocolCardScan;
210
211 typedef struct {
212         gpointer obj;
213         gpointer vtable;
214         int size;
215 } SGenProtocolCement;
216
217 typedef struct {
218         gpointer link;
219         gpointer obj;
220         int track;
221         int staged;
222 } SGenProtocolDislinkUpdate;
223
224 typedef struct {
225         gpointer link;
226         gpointer obj;
227         int track;
228         int index;
229 } SGenProtocolDislinkUpdateStaged;
230
231 typedef struct {
232         gpointer link;
233         gpointer obj;
234         int index;
235 } SGenProtocolDislinkProcessStaged;
236
237 typedef struct {
238         gpointer domain;
239 } SGenProtocolDomainUnload;
240
241 typedef struct {
242         gpointer queue;
243         gpointer cursor;
244         gpointer value;
245 } SGenProtocolGrayQueue;
246
247 /* missing: finalizers, roots, non-store wbarriers */
248
249 void binary_protocol_init (const char *filename, long long limit) MONO_INTERNAL;
250 gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;
251
252 void binary_protocol_flush_buffers (gboolean force) MONO_INTERNAL;
253
254 void binary_protocol_collection_force (int generation) MONO_INTERNAL;
255 void binary_protocol_collection_begin (int index, int generation) MONO_INTERNAL;
256 void binary_protocol_collection_end (int index, int generation, long long num_objects_scanned, long long num_unique_objects_scanned) MONO_INTERNAL;
257 void binary_protocol_concurrent_start (void) MONO_INTERNAL;
258 void binary_protocol_concurrent_update_finish (void) MONO_INTERNAL;
259 void binary_protocol_world_stopping (long long timestamp) MONO_INTERNAL;
260 void binary_protocol_world_stopped (long long timestamp, long long total_major_cards,
261                 long long marked_major_cards, long long total_los_cards, long long marked_los_cards) MONO_INTERNAL;
262 void binary_protocol_world_restarting (int generation, long long timestamp,
263                 long long total_major_cards, long long marked_major_cards, long long total_los_cards, long long marked_los_cards) MONO_INTERNAL;
264 void binary_protocol_world_restarted (int generation, long long timestamp) MONO_INTERNAL;
265
266 void binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip) MONO_INTERNAL;
267 void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
268 void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
269 void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
270 void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
271                 gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
272
273 void binary_protocol_cement (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
274 void binary_protocol_cement_reset (void) MONO_INTERNAL;
275
276 void binary_protocol_domain_unload_begin (gpointer domain) MONO_INTERNAL;
277 void binary_protocol_domain_unload_end (gpointer domain) MONO_INTERNAL;
278
279 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
280
281 #define binary_protocol_is_heavy_enabled()      binary_protocol_is_enabled ()
282
283 void binary_protocol_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
284 void binary_protocol_alloc_pinned (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
285 void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
286 void binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size) MONO_INTERNAL;
287 void binary_protocol_pin_stage (gpointer addr_ptr, gpointer addr) MONO_INTERNAL;
288 void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
289 void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
290 void binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
291 void binary_protocol_scan_vtype_begin (gpointer start, int size) MONO_INTERNAL;
292 void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
293 void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
294 void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
295 void binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
296 void binary_protocol_empty (gpointer start, int size) MONO_INTERNAL;
297 void binary_protocol_card_scan (gpointer start, int size) MONO_INTERNAL;
298 void binary_protocol_dislink_update (gpointer link, gpointer obj, int track, int staged) MONO_INTERNAL;
299 void binary_protocol_dislink_update_staged (gpointer link, gpointer obj, int track, int index) MONO_INTERNAL;
300 void binary_protocol_dislink_process_staged (gpointer link, gpointer obj, int index) MONO_INTERNAL;
301 void binary_protocol_gray_enqueue (gpointer queue, gpointer cursor, gpointer value) MONO_INTERNAL;
302 void binary_protocol_gray_dequeue (gpointer queue, gpointer cursor, gpointer value) MONO_INTERNAL;
303
304 #else
305
306 #define binary_protocol_is_heavy_enabled()      FALSE
307
308 #define binary_protocol_alloc(obj, vtable, size)
309 #define binary_protocol_alloc_pinned(obj, vtable, size)
310 #define binary_protocol_alloc_degraded(obj, vtable, size)
311 #define binary_protocol_copy(from, to, vtable, size)
312 #define binary_protocol_pin_stage(addr_ptr, addr)
313 #define binary_protocol_pin(obj, vtable, size)
314 #define binary_protocol_mark(obj, vtable, size)
315 #define binary_protocol_scan_begin(obj, vtable, size)
316 #define binary_protocol_scan_vtype_begin(obj, size)
317 #define binary_protocol_wbarrier(ptr, value, value_vtable)
318 #define binary_protocol_global_remset(ptr, value, value_vtable)
319 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
320 #define binary_protocol_cleanup(ptr, vtable, size)
321 #define binary_protocol_empty(start, size)
322 #define binary_protocol_card_scan(start, size)
323 #define binary_protocol_dislink_update(link,obj,track,staged)
324 #define binary_protocol_dislink_update_staged(link,obj,track,index)
325 #define binary_protocol_dislink_process_staged(link,obj,index)
326 #define binary_protocol_gray_enqueue(queue,cursor,value)
327 #define binary_protocol_gray_dequeue(queue,cursor,value)
328
329 #endif
330
331 #endif