Merge pull request #600 from tr8dr/master
[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 #include "sgen-gc.h"
24
25 #ifdef SGEN_BINARY_PROTOCOL
26
27 enum {
28         SGEN_PROTOCOL_COLLECTION_FORCE,
29         SGEN_PROTOCOL_COLLECTION_BEGIN,
30         SGEN_PROTOCOL_COLLECTION_END,
31         SGEN_PROTOCOL_ALLOC,
32         SGEN_PROTOCOL_COPY,
33         SGEN_PROTOCOL_PIN,
34         SGEN_PROTOCOL_MARK,
35         SGEN_PROTOCOL_SCAN_BEGIN,
36         SGEN_PROTOCOL_SCAN_VTYPE_BEGIN,
37         SGEN_PROTOCOL_WBARRIER,
38         SGEN_PROTOCOL_GLOBAL_REMSET,
39         SGEN_PROTOCOL_PTR_UPDATE,
40         SGEN_PROTOCOL_CLEANUP,
41         SGEN_PROTOCOL_EMPTY,
42         SGEN_PROTOCOL_THREAD_SUSPEND,
43         SGEN_PROTOCOL_THREAD_RESTART,
44         SGEN_PROTOCOL_THREAD_REGISTER,
45         SGEN_PROTOCOL_THREAD_UNREGISTER,
46         SGEN_PROTOCOL_MISSING_REMSET,
47         SGEN_PROTOCOL_ALLOC_PINNED,
48         SGEN_PROTOCOL_ALLOC_DEGRADED,
49         SGEN_PROTOCOL_CARD_SCAN,
50         SGEN_PROTOCOL_CEMENT,
51         SGEN_PROTOCOL_CEMENT_RESET,
52         SGEN_PROTOCOL_DISLINK_UPDATE,
53         SGEN_PROTOCOL_DISLINK_UPDATE_STAGED,
54         SGEN_PROTOCOL_DISLINK_PROCESS_STAGED,
55         SGEN_PROTOCOL_DOMAIN_UNLOAD_BEGIN,
56         SGEN_PROTOCOL_DOMAIN_UNLOAD_END
57 };
58
59 typedef struct {
60         int generation;
61 } SGenProtocolCollectionForce;
62
63 typedef struct {
64         int index, generation;
65 } SGenProtocolCollection;
66
67 typedef struct {
68         gpointer obj;
69         gpointer vtable;
70         int size;
71 } SGenProtocolAlloc;
72
73 typedef struct {
74         gpointer from;
75         gpointer to;
76         gpointer vtable;
77         int size;
78 } SGenProtocolCopy;
79
80 typedef struct {
81         gpointer obj;
82         gpointer vtable;
83         int size;
84 } SGenProtocolPin;
85
86 typedef struct {
87         gpointer obj;
88         gpointer vtable;
89         int size;
90 } SGenProtocolMark;
91
92 typedef struct {
93         gpointer obj;
94         gpointer vtable;
95         int size;
96 } SGenProtocolScanBegin;
97
98 typedef struct {
99         gpointer obj;
100         int size;
101 } SGenProtocolScanVTypeBegin;
102
103 typedef struct {
104         gpointer ptr;
105         gpointer value;
106         gpointer value_vtable;
107 } SGenProtocolWBarrier;
108
109 typedef struct {
110         gpointer ptr;
111         gpointer value;
112         gpointer value_vtable;
113 } SGenProtocolGlobalRemset;
114
115 typedef struct {
116         gpointer ptr;
117         gpointer old_value;
118         gpointer new_value;
119         gpointer vtable;
120         int size;
121 } SGenProtocolPtrUpdate;
122
123 typedef struct {
124         gpointer ptr;
125         gpointer vtable;
126         int size;
127 } SGenProtocolCleanup;
128
129 typedef struct {
130         gpointer start;
131         int size;
132 } SGenProtocolEmpty;
133
134 typedef struct {
135         gpointer thread, stopped_ip;
136 } SGenProtocolThreadSuspend;
137
138 typedef struct {
139         gpointer thread;
140 } SGenProtocolThreadRestart;
141
142 typedef struct {
143         gpointer thread;
144 } SGenProtocolThreadRegister;
145
146 typedef struct {
147         gpointer thread;
148 } SGenProtocolThreadUnregister;
149
150 typedef struct {
151         gpointer obj;
152         gpointer obj_vtable;
153         int offset;
154         gpointer value;
155         gpointer value_vtable;
156         int value_pinned;
157 } SGenProtocolMissingRemset;
158
159 typedef struct {
160         gpointer start;
161         int size;
162 } SGenProtocolCardScan;
163
164 typedef struct {
165         gpointer obj;
166         gpointer vtable;
167         int size;
168 } SGenProtocolCement;
169
170 typedef struct {
171         gpointer link;
172         gpointer obj;
173         int track;
174         int staged;
175 } SGenProtocolDislinkUpdate;
176
177 typedef struct {
178         gpointer link;
179         gpointer obj;
180         int track;
181         int index;
182 } SGenProtocolDislinkUpdateStaged;
183
184 typedef struct {
185         gpointer link;
186         gpointer obj;
187         int index;
188 } SGenProtocolDislinkProcessStaged;
189
190 typedef struct {
191         gpointer domain;
192 } SGenProtocolDomainUnload;
193
194 /* missing: finalizers, dislinks, roots, non-store wbarriers */
195
196 void binary_protocol_init (const char *filename) MONO_INTERNAL;
197 gboolean binary_protocol_is_enabled (void) MONO_INTERNAL;
198
199 void binary_protocol_flush_buffers (gboolean force) MONO_INTERNAL;
200
201 void binary_protocol_collection_force (int generation) MONO_INTERNAL;
202 void binary_protocol_collection_begin (int index, int generation) MONO_INTERNAL;
203 void binary_protocol_collection_end (int index, int generation) MONO_INTERNAL;
204 void binary_protocol_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
205 void binary_protocol_alloc_pinned (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
206 void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
207 void binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size) MONO_INTERNAL;
208 void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
209 void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
210 void binary_protocol_scan_begin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
211 void binary_protocol_scan_vtype_begin (gpointer start, int size) MONO_INTERNAL;
212 void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
213 void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
214 void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
215 void binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
216 void binary_protocol_empty (gpointer start, int size) MONO_INTERNAL;
217 void binary_protocol_thread_suspend (gpointer thread, gpointer stopped_ip) MONO_INTERNAL;
218 void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
219 void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
220 void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
221 void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
222                 gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
223 void binary_protocol_card_scan (gpointer start, int size) MONO_INTERNAL;
224 void binary_protocol_cement (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
225 void binary_protocol_cement_reset (void) MONO_INTERNAL;
226 void binary_protocol_dislink_update (gpointer link, gpointer obj, int track, int staged) MONO_INTERNAL;
227 void binary_protocol_dislink_update_staged (gpointer link, gpointer obj, int track, int index) MONO_INTERNAL;
228 void binary_protocol_dislink_process_staged (gpointer link, gpointer obj, int index) MONO_INTERNAL;
229 void binary_protocol_domain_unload_begin (gpointer domain) MONO_INTERNAL;
230 void binary_protocol_domain_unload_end (gpointer domain) MONO_INTERNAL;
231
232 #else
233
234 #define binary_protocol_is_enabled()    FALSE
235
236 #define binary_protocol_flush_buffers(force)
237 #define binary_protocol_collection_force(generation)
238 #define binary_protocol_collection_begin(index, generation)
239 #define binary_protocol_collection_end(index, generation)
240 #define binary_protocol_alloc(obj, vtable, size)
241 #define binary_protocol_alloc_pinned(obj, vtable, size)
242 #define binary_protocol_alloc_degraded(obj, vtable, size)
243 #define binary_protocol_copy(from, to, vtable, size)
244 #define binary_protocol_pin(obj, vtable, size)
245 #define binary_protocol_mark(obj, vtable, size)
246 #define binary_protocol_scan_begin(obj, vtable, size)
247 #define binary_protocol_scan_vtype_begin(obj, size)
248 #define binary_protocol_wbarrier(ptr, value, value_vtable)
249 #define binary_protocol_global_remset(ptr, value, value_vtable)
250 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
251 #define binary_protocol_cleanup(ptr, vtable, size)
252 #define binary_protocol_empty(start, size)
253 #define binary_protocol_thread_suspend(thread, ip)
254 #define binary_protocol_thread_restart(thread)
255 #define binary_protocol_thread_register(thread)
256 #define binary_protocol_thread_unregister(thread)
257 #define binary_protocol_missing_remset(obj, obj_vtable, offset, value, value_vtable, value_pinned)
258 #define binary_protocol_card_scan(start, size)
259 #define binary_protocol_cement(ptr, vtable, size)
260 #define binary_protocol_cement_reset()
261 #define binary_protocol_dislink_update(link,obj,track,staged)
262 #define binary_protocol_dislink_update_staged(link,obj,track,index)
263 #define binary_protocol_dislink_process_staged(link,obj,index)
264 #define binary_protocol_domain_unload_begin(domain)
265 #define binary_protocol_domain_unload_end(domain)
266
267 #endif