[sgen] Make binary protocol thread-safe for real.
[mono.git] / mono / metadata / sgen-protocol.h
1 /*
2  * Copyright 2001-2003 Ximian, Inc
3  * Copyright 2003-2010 Novell, Inc.
4  * 
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:
12  * 
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  * 
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.
23  */
24
25 #ifdef SGEN_BINARY_PROTOCOL
26
27 enum {
28         SGEN_PROTOCOL_COLLECTION,
29         SGEN_PROTOCOL_ALLOC,
30         SGEN_PROTOCOL_COPY,
31         SGEN_PROTOCOL_PIN,
32         SGEN_PROTOCOL_MARK,
33         SGEN_PROTOCOL_WBARRIER,
34         SGEN_PROTOCOL_GLOBAL_REMSET,
35         SGEN_PROTOCOL_PTR_UPDATE,
36         SGEN_PROTOCOL_CLEANUP,
37         SGEN_PROTOCOL_EMPTY,
38         SGEN_PROTOCOL_THREAD_RESTART,
39         SGEN_PROTOCOL_THREAD_REGISTER,
40         SGEN_PROTOCOL_THREAD_UNREGISTER,
41         SGEN_PROTOCOL_MISSING_REMSET,
42         SGEN_PROTOCOL_ALLOC_PINNED,
43         SGEN_PROTOCOL_ALLOC_DEGRADED
44 };
45
46 typedef struct {
47         int generation;
48 } SGenProtocolCollection;
49
50 typedef struct {
51         gpointer obj;
52         gpointer vtable;
53         int size;
54 } SGenProtocolAlloc;
55
56 typedef struct {
57         gpointer from;
58         gpointer to;
59         gpointer vtable;
60         int size;
61 } SGenProtocolCopy;
62
63 typedef struct {
64         gpointer obj;
65         gpointer vtable;
66         int size;
67 } SGenProtocolPin;
68
69 typedef struct {
70         gpointer obj;
71         gpointer vtable;
72         int size;
73 } SGenProtocolMark;
74
75 typedef struct {
76         gpointer ptr;
77         gpointer value;
78         gpointer value_vtable;
79 } SGenProtocolWBarrier;
80
81 typedef struct {
82         gpointer ptr;
83         gpointer value;
84         gpointer value_vtable;
85 } SGenProtocolGlobalRemset;
86
87 typedef struct {
88         gpointer ptr;
89         gpointer old_value;
90         gpointer new_value;
91         gpointer vtable;
92         int size;
93 } SGenProtocolPtrUpdate;
94
95 typedef struct {
96         gpointer ptr;
97         gpointer vtable;
98         int size;
99 } SGenProtocolCleanup;
100
101 typedef struct {
102         gpointer start;
103         int size;
104 } SGenProtocolEmpty;
105
106 typedef struct {
107         gpointer thread;
108 } SGenProtocolThreadRestart;
109
110 typedef struct {
111         gpointer thread;
112 } SGenProtocolThreadRegister;
113
114 typedef struct {
115         gpointer thread;
116 } SGenProtocolThreadUnregister;
117
118 typedef struct {
119         gpointer obj;
120         gpointer obj_vtable;
121         int offset;
122         gpointer value;
123         gpointer value_vtable;
124         int value_pinned;
125 } SGenProtocolMissingRemset;
126
127 /* missing: finalizers, dislinks, roots, non-store wbarriers */
128
129 void binary_protocol_collection (int generation) MONO_INTERNAL;
130 void binary_protocol_alloc (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
131 void binary_protocol_alloc_pinned (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
132 void binary_protocol_alloc_degraded (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
133 void binary_protocol_copy (gpointer from, gpointer to, gpointer vtable, int size) MONO_INTERNAL;
134 void binary_protocol_pin (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
135 void binary_protocol_mark (gpointer obj, gpointer vtable, int size) MONO_INTERNAL;
136 void binary_protocol_wbarrier (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
137 void binary_protocol_global_remset (gpointer ptr, gpointer value, gpointer value_vtable) MONO_INTERNAL;
138 void binary_protocol_ptr_update (gpointer ptr, gpointer old_value, gpointer new_value, gpointer vtable, int size) MONO_INTERNAL;
139 void binary_protocol_cleanup (gpointer ptr, gpointer vtable, int size) MONO_INTERNAL;
140 void binary_protocol_empty (gpointer start, int size) MONO_INTERNAL;
141 void binary_protocol_thread_restart (gpointer thread) MONO_INTERNAL;
142 void binary_protocol_thread_register (gpointer thread) MONO_INTERNAL;
143 void binary_protocol_thread_unregister (gpointer thread) MONO_INTERNAL;
144 void binary_protocol_missing_remset (gpointer obj, gpointer obj_vtable, int offset,
145                 gpointer value, gpointer value_vtable, int value_pinned) MONO_INTERNAL;
146
147 #else
148
149 #define binary_protocol_flush_buffers(force)
150 #define binary_protocol_collection(generation)
151 #define binary_protocol_alloc(obj, vtable, size)
152 #define binary_protocol_alloc_pinned(obj, vtable, size)
153 #define binary_protocol_alloc_degraded(obj, vtable, size)
154 #define binary_protocol_copy(from, to, vtable, size)
155 #define binary_protocol_pin(obj, vtable, size)
156 #define binary_protocol_mark(obj, vtable, size)
157 #define binary_protocol_wbarrier(ptr, value, value_vtable)
158 #define binary_protocol_global_remset(ptr, value, value_vtable)
159 #define binary_protocol_ptr_update(ptr, old_value, new_value, vtable, size)
160 #define binary_protocol_cleanup(ptr, vtable, size)
161 #define binary_protocol_empty(start, size)
162 #define binary_protocol_thread_restart(thread)
163 #define binary_protocol_thread_register(thread)
164 #define binary_protocol_thread_unregister(thread)
165 #define binary_protocol_missing_remset(obj, obj_vtable, offset, value, value_vtable, value_pinned)
166
167 #endif