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