[sgen] Move DTrace support to Mono-specific code.
[mono.git] / mono / metadata / sgen-client.h
1 /*
2  * sgen-client.h: SGen client interface.
3  *
4  * Copyright (C) 2014 Xamarin Inc
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License 2.0 as published by the Free Software Foundation;
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License 2.0 along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <metadata/sgen-pointer-queue.h>
21
22 void sgen_client_init (void);
23
24 /*
25  * Returns the vtable used for dummy objects to fill the nursery for ease and speed of
26  * walking.  Must be a valid vtable that is not used by any actual objects.  Must be
27  * idempotent.
28  */
29 GCVTable* sgen_client_get_array_fill_vtable (void);
30
31 /*
32  * Fill the given range with a dummy object.  Its vtable must be the one returned by
33  * `sgen_client_get_array_fill_vtable()`.  If the range is too short to be filled with an
34  * object, null it.  Return `TRUE` if the range was filled with an object, `FALSE` if it was
35  * nulled.
36  */
37 gboolean sgen_client_array_fill_range (char *start, size_t size);
38
39 /*
40  * This is called if the nursery clearing policy at `clear-at-gc`, which is usually only
41  * used for debugging.  If `size` is large enough for the memory to have been filled with a
42  * dummy, object, zero its header.  Note that there might not actually be a header there.
43  */
44 void sgen_client_zero_array_fill_header (void *p, size_t size);
45
46 gboolean sgen_client_object_is_array_fill (GCObject *o);
47
48 gboolean sgen_client_object_has_critical_finalizer (GCObject *obj);
49
50 /*
51  * Called after an object is enqueued for finalization.  This is a very low-level callback.
52  * It should almost certainly be a NOP.
53  *
54  * FIXME: Can we merge this with `sgen_client_object_has_critical_finalizer()`?
55  */
56 void sgen_client_object_queued_for_finalization (GCObject *obj);
57
58 gboolean sgen_client_mark_ephemerons (ScanCopyContext ctx);
59
60 /*
61  * Clear ephemeron pairs with unreachable keys.
62  * We pass the copy func so we can figure out if an array was promoted or not.
63  */
64 void sgen_client_clear_unreachable_ephemerons (ScanCopyContext ctx);
65
66 /*
67  * This is called for objects that are larger than one card.  If it's possible to scan only
68  * parts of the object based on which cards are marked, do so and return TRUE.  Otherwise,
69  * return FALSE.
70  */
71 gboolean sgen_client_cardtable_scan_object (char *obj, mword block_obj_size, guint8 *cards, gboolean mod_union, ScanCopyContext ctx);
72
73 void sgen_client_nursery_objects_pinned (void **definitely_pinned, int count);
74
75 void sgen_client_collecting_minor (SgenPointerQueue *fin_ready_queue, SgenPointerQueue *critical_fin_queue);
76 void sgen_client_collecting_major_1 (void);
77 void sgen_client_pinned_los_object (char *obj);
78 void sgen_client_collecting_major_2 (void);
79 void sgen_client_collecting_major_3 (SgenPointerQueue *fin_ready_queue, SgenPointerQueue *critical_fin_queue);
80
81 /*
82  * If the client has registered any internal memory types, this must return a string
83  * describing the given type.  Only used for debugging.
84  */
85 const char* sgen_client_description_for_internal_mem_type (int type);
86
87 /* FIXME: Use `sgen_client_vtable_get_name()` instead of this. */
88 const char* sgen_client_object_safe_name (GCObject *obj);
89
90 const char* sgen_client_vtable_get_namespace (GCVTable *vtable);
91 const char* sgen_client_vtable_get_name (GCVTable *vtable);
92
93 void sgen_client_pre_collection_checks (void);
94
95 gboolean sgen_client_handle_gc_debug (const char *opt);
96 void sgen_client_print_gc_debug_usage (void);
97
98 #define TYPE_INT int
99 #define TYPE_LONGLONG long long
100 #define TYPE_SIZE size_t
101 #define TYPE_POINTER gpointer
102 #define TYPE_BOOL gboolean
103
104 #define BEGIN_PROTOCOL_ENTRY0(method) \
105         void sgen_client_ ## method (void);
106 #define BEGIN_PROTOCOL_ENTRY_HEAVY0(method) \
107         void sgen_client_ ## method (void);
108 #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \
109         void sgen_client_ ## method (t1 f1);
110 #define BEGIN_PROTOCOL_ENTRY_HEAVY1(method,t1,f1) \
111         void sgen_client_ ## method (t1 f1);
112 #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \
113         void sgen_client_ ## method (t1 f1, t2 f2);
114 #define BEGIN_PROTOCOL_ENTRY_HEAVY2(method,t1,f1,t2,f2) \
115         void sgen_client_ ## method (t1 f1, t2 f2);
116 #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \
117         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3);
118 #define BEGIN_PROTOCOL_ENTRY_HEAVY3(method,t1,f1,t2,f2,t3,f3) \
119         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3);
120 #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
121         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4);
122 #define BEGIN_PROTOCOL_ENTRY_HEAVY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \
123         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4);
124 #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
125         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
126 #define BEGIN_PROTOCOL_ENTRY_HEAVY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \
127         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5);
128 #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
129         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
130 #define BEGIN_PROTOCOL_ENTRY_HEAVY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \
131         void sgen_client_ ## method (t1 f1, t2 f2, t3 f3, t4 f4, t5 f5, t6 f6);
132
133 #define FLUSH()
134
135 #define DEFAULT_PRINT()
136 #define CUSTOM_PRINT(_)
137
138 #define IS_ALWAYS_MATCH(_)
139 #define MATCH_INDEX(_)
140 #define IS_VTABLE_MATCH(_)
141
142 #define END_PROTOCOL_ENTRY
143 #define END_PROTOCOL_ENTRY_HEAVY
144
145 #include "sgen-protocol-def.h"
146
147 #undef TYPE_INT
148 #undef TYPE_LONGLONG
149 #undef TYPE_SIZE
150 #undef TYPE_POINTER
151 #undef TYPE_BOOL