Merge pull request #2485 from ludovic-henry/monoerror-mono_marshal_alloc
[mono.git] / mono / metadata / marshal.h
1
2 /*
3  * marshal.h: Routines for marshaling complex types in P/Invoke methods.
4  * 
5  * Author:
6  *   Paolo Molaro (lupus@ximian.com)
7  *
8  * (C) 2002 Ximian, Inc.  http://www.ximian.com
9  *
10  */
11
12 #ifndef __MONO_MARSHAL_H__
13 #define __MONO_MARSHAL_H__
14
15 #include <mono/metadata/class.h>
16 #include <mono/metadata/object-internals.h>
17 #include <mono/metadata/class-internals.h>
18 #include <mono/metadata/opcodes.h>
19 #include <mono/metadata/reflection.h>
20 #include <mono/metadata/method-builder.h>
21 #include <mono/metadata/remoting.h>
22 #include <mono/utils/mono-error.h>
23
24 #define mono_marshal_find_bitfield_offset(type, elem, byte_offset, bitmask) \
25         do { \
26                 type tmp; \
27                 memset (&tmp, 0, sizeof (tmp)); \
28                 tmp.elem = 1; \
29                 mono_marshal_find_nonzero_bit_offset ((guint8*)&tmp, sizeof (tmp), (byte_offset), (bitmask)); \
30         } while (0)
31
32 /*
33  * This structure holds the state kept by the emit_ marshalling functions.
34  * This is exported so it can be used by cominterop.c.
35  */
36 typedef struct {
37         MonoMethodBuilder *mb;
38         MonoMethodSignature *sig;
39         MonoMethodPInvoke *piinfo;
40         int *orig_conv_args; /* Locals containing the original values of byref args */
41         int retobj_var;
42         MonoClass *retobj_class;
43         MonoMethodSignature *csig; /* Might need to be changed due to MarshalAs directives */
44         MonoImage *image; /* The image to use for looking up custom marshallers */
45 } EmitMarshalContext;
46
47 typedef enum {
48         /*
49          * This is invoked to convert arguments from the current types to
50          * the underlying types expected by the platform routine.  If required,
51          * the methods create a temporary variable with the proper type, and return
52          * the location for it (either the passed argument, or the newly allocated
53          * local slot).
54          */
55         MARSHAL_ACTION_CONV_IN,
56
57         /*
58          * This operation is called to push the actual value that was optionally
59          * converted on the first stage
60          */
61         MARSHAL_ACTION_PUSH,
62
63         /*
64          * Convert byref arguments back or free resources allocated during the
65          * CONV_IN stage
66          */
67         MARSHAL_ACTION_CONV_OUT,
68
69         /*
70          * The result from the unmanaged call is at the top of the stack when
71          * this action is invoked.    The result should be stored in the
72          * third local variable slot. 
73          */
74         MARSHAL_ACTION_CONV_RESULT,
75
76         MARSHAL_ACTION_MANAGED_CONV_IN,
77         MARSHAL_ACTION_MANAGED_CONV_OUT,
78         MARSHAL_ACTION_MANAGED_CONV_RESULT
79 } MarshalAction;
80
81 /*
82  * This is an extension of the MONO_WRAPPER_ enum to avoid adding more elements to that
83  * enum.
84  */
85 typedef enum {
86         WRAPPER_SUBTYPE_NONE,
87         /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
88         WRAPPER_SUBTYPE_ELEMENT_ADDR,
89         WRAPPER_SUBTYPE_STRING_CTOR,
90         /* Subtypes of MONO_WRAPPER_STELEMREF */
91         WRAPPER_SUBTYPE_VIRTUAL_STELEMREF,
92         /* Subtypes of MONO_WRAPPER_UNKNOWN */
93         WRAPPER_SUBTYPE_FAST_MONITOR_ENTER,
94         WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4,
95         WRAPPER_SUBTYPE_FAST_MONITOR_EXIT,
96         WRAPPER_SUBTYPE_PTR_TO_STRUCTURE,
97         WRAPPER_SUBTYPE_STRUCTURE_TO_PTR,
98         /* Subtypes of MONO_WRAPPER_CASTCLASS */
99         WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE,
100         WRAPPER_SUBTYPE_ISINST_WITH_CACHE,
101         /* Subtypes of MONO_WRAPPER_RUNTIME_INVOKE */
102         WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL,
103         WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC,
104         WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT,
105         WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL,
106         /* Subtypes of MONO_WRAPPER_MANAGED_TO_NATIVE */
107         WRAPPER_SUBTYPE_ICALL_WRAPPER,
108         WRAPPER_SUBTYPE_NATIVE_FUNC_AOT,
109         WRAPPER_SUBTYPE_PINVOKE,
110         /* Subtypes of MONO_WRAPPER_UNKNOWN */
111         WRAPPER_SUBTYPE_SYNCHRONIZED_INNER,
112         WRAPPER_SUBTYPE_GSHAREDVT_IN,
113         WRAPPER_SUBTYPE_GSHAREDVT_OUT,
114         WRAPPER_SUBTYPE_ARRAY_ACCESSOR,
115         /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
116         WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER,
117         /* Subtypes of MONO_WRAPPER_DELEGATE_INVOKE */
118         WRAPPER_SUBTYPE_DELEGATE_INVOKE_VIRTUAL,
119         WRAPPER_SUBTYPE_DELEGATE_INVOKE_BOUND,
120         /* Subtypes of MONO_WRAPPER_UNKNOWN */
121         WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG,
122         WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG,
123 } WrapperSubtype;
124
125 typedef struct {
126         MonoMethod *method;
127         MonoClass *klass;
128 } NativeToManagedWrapperInfo;
129
130 typedef struct {
131         MonoMethod *method;
132 } StringCtorWrapperInfo;
133
134 typedef struct {
135         int kind;
136 } VirtualStelemrefWrapperInfo;
137
138 typedef struct {
139         guint32 rank, elem_size;
140 } ElementAddrWrapperInfo;
141
142 typedef struct {
143         MonoMethod *method;
144         /* For WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL */
145         MonoMethodSignature *sig;
146 } RuntimeInvokeWrapperInfo;
147
148 typedef struct {
149         MonoMethod *method;
150 } ManagedToNativeWrapperInfo;
151
152 typedef struct {
153         MonoMethod *method;
154 } SynchronizedWrapperInfo;
155
156 typedef struct {
157         MonoMethod *method;
158 } SynchronizedInnerWrapperInfo;
159
160 typedef struct {
161         MonoMethod *method;
162 } GenericArrayHelperWrapperInfo;
163
164 typedef struct {
165         gpointer func;
166 } ICallWrapperInfo;
167
168 typedef struct {
169         MonoMethod *method;
170 } ArrayAccessorWrapperInfo;
171
172 typedef struct {
173         MonoClass *klass;
174 } ProxyWrapperInfo;
175
176 typedef struct {
177         const char *gc_name;
178         int alloc_type;
179 } AllocatorWrapperInfo;
180
181 typedef struct {
182         MonoMethod *method;
183 } UnboxWrapperInfo;
184
185 typedef struct {
186         MonoMethod *method;
187 } RemotingWrapperInfo;
188
189 typedef struct {
190         MonoMethodSignature *sig;
191 } GsharedvtWrapperInfo;
192
193 /*
194  * This structure contains additional information to uniquely identify a given wrapper
195  * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
196  * of wrappers, i.e. ones which do not have a 1-1 association with a method/class.
197  */
198 typedef struct {
199         WrapperSubtype subtype;
200         union {
201                 /* RUNTIME_INVOKE_... */
202                 RuntimeInvokeWrapperInfo runtime_invoke;
203                 /* STRING_CTOR */
204                 StringCtorWrapperInfo string_ctor;
205                 /* ELEMENT_ADDR */
206                 ElementAddrWrapperInfo element_addr;
207                 /* VIRTUAL_STELEMREF */
208                 VirtualStelemrefWrapperInfo virtual_stelemref;
209                 /* MONO_WRAPPER_NATIVE_TO_MANAGED */
210                 NativeToManagedWrapperInfo native_to_managed;
211                 /* MONO_WRAPPER_MANAGED_TO_NATIVE */
212                 ManagedToNativeWrapperInfo managed_to_native;
213                 /* SYNCHRONIZED */
214                 SynchronizedWrapperInfo synchronized;
215                 /* SYNCHRONIZED_INNER */
216                 SynchronizedInnerWrapperInfo synchronized_inner;
217                 /* GENERIC_ARRAY_HELPER */
218                 GenericArrayHelperWrapperInfo generic_array_helper;
219                 /* ICALL_WRAPPER */
220                 ICallWrapperInfo icall;
221                 /* ARRAY_ACCESSOR */
222                 ArrayAccessorWrapperInfo array_accessor;
223                 /* PROXY_ISINST etc. */
224                 ProxyWrapperInfo proxy;
225                 /* ALLOC */
226                 AllocatorWrapperInfo alloc;
227                 /* UNBOX */
228                 UnboxWrapperInfo unbox;
229                 /* MONO_WRAPPER_REMOTING_INVOKE/MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK/MONO_WRAPPER_XDOMAIN_INVOKE */
230                 RemotingWrapperInfo remoting;
231                 /* GSHAREDVT_IN_SIG/GSHAREDVT_OUT_SIG */
232                 GsharedvtWrapperInfo gsharedvt;
233         } d;
234 } WrapperInfo;
235
236 G_BEGIN_DECLS
237
238 /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/
239 typedef MonoObject *(*RuntimeInvokeFunction) (MonoObject *this_obj, void **params, MonoObject **exc, void* compiled_method);
240
241 typedef void (*RuntimeInvokeDynamicFunction) (void *args, MonoObject **exc, void* compiled_method);
242
243 /* marshaling helper functions */
244
245 void
246 mono_marshal_init (void);
247
248 void
249 mono_marshal_init_tls (void);
250
251 void
252 mono_marshal_cleanup (void);
253
254 gint32
255 mono_class_native_size (MonoClass *klass, guint32 *align);
256
257 MonoMarshalType *
258 mono_marshal_load_type_info (MonoClass* klass);
259
260 gint32
261 mono_marshal_type_size (MonoType *type, MonoMarshalSpec *mspec, guint32 *align,
262                         gboolean as_field, gboolean unicode);
263
264 int            
265 mono_type_native_stack_size (MonoType *type, guint32 *alignment);
266
267 gpointer
268 mono_array_to_savearray (MonoArray *array);
269
270 gpointer
271 mono_array_to_lparray (MonoArray *array);
272
273 void
274 mono_free_lparray (MonoArray *array, gpointer* nativeArray);
275
276 void
277 mono_string_utf8_to_builder (MonoStringBuilder *sb, char *text);
278
279 void
280 mono_string_utf16_to_builder (MonoStringBuilder *sb, gunichar2 *text);
281
282 gchar*
283 mono_string_builder_to_utf8 (MonoStringBuilder *sb);
284
285 gunichar2*
286 mono_string_builder_to_utf16 (MonoStringBuilder *sb);
287
288 gpointer
289 mono_string_to_ansibstr (MonoString *string_obj);
290
291 gpointer
292 mono_string_to_bstr (MonoString *string_obj);
293
294 void
295 mono_string_to_byvalstr (gpointer dst, MonoString *src, int size);
296
297 void
298 mono_string_to_byvalwstr (gpointer dst, MonoString *src, int size);
299
300 gpointer
301 mono_delegate_to_ftnptr (MonoDelegate *delegate);
302
303 MonoDelegate*
304 mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
305
306 void mono_delegate_free_ftnptr (MonoDelegate *delegate);
307
308 void
309 mono_marshal_set_last_error (void);
310
311 gpointer
312 mono_marshal_asany (MonoObject *obj, MonoMarshalNative string_encoding, int param_attrs);
313
314 void
315 mono_marshal_free_asany (MonoObject *o, gpointer ptr, MonoMarshalNative string_encoding, int param_attrs);
316
317 guint
318 mono_type_to_ldind (MonoType *type);
319
320 guint
321 mono_type_to_stind (MonoType *type);
322
323 /* functions to create various architecture independent helper functions */
324
325 MonoMethod *
326 mono_marshal_method_from_wrapper (MonoMethod *wrapper);
327
328 WrapperInfo*
329 mono_wrapper_info_create (MonoMethodBuilder *mb, WrapperSubtype subtype);
330
331 void
332 mono_marshal_set_wrapper_info (MonoMethod *method, WrapperInfo *info);
333
334 WrapperInfo*
335 mono_marshal_get_wrapper_info (MonoMethod *wrapper);
336
337 MonoMethod *
338 mono_marshal_get_delegate_begin_invoke (MonoMethod *method);
339
340 MonoMethod *
341 mono_marshal_get_delegate_end_invoke (MonoMethod *method);
342
343 MonoMethod *
344 mono_marshal_get_delegate_invoke (MonoMethod *method, MonoDelegate *del);
345
346 MonoMethod *
347 mono_marshal_get_delegate_invoke_internal (MonoMethod *method, gboolean callvirt, gboolean static_method_with_first_arg_bound, MonoMethod *target_method);
348
349 MonoMethod *
350 mono_marshal_get_runtime_invoke (MonoMethod *method, gboolean is_virtual);
351
352 MonoMethod*
353 mono_marshal_get_runtime_invoke_dynamic (void);
354
355 MonoMethod *
356 mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature *sig);
357
358 MonoMethodSignature*
359 mono_marshal_get_string_ctor_signature (MonoMethod *method);
360
361 MonoMethod *
362 mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t this_loc);
363
364 gpointer
365 mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type);
366
367 MonoMethod *
368 mono_marshal_get_icall_wrapper (MonoMethodSignature *sig, const char *name, gconstpointer func, gboolean check_exceptions);
369
370 MonoMethod *
371 mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, gboolean aot);
372
373 MonoMethod *
374 mono_marshal_get_native_func_wrapper (MonoImage *image, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func);
375
376 MonoMethod*
377 mono_marshal_get_native_func_wrapper_aot (MonoClass *klass);
378
379 MonoMethod *
380 mono_marshal_get_struct_to_ptr (MonoClass *klass);
381
382 MonoMethod *
383 mono_marshal_get_ptr_to_struct (MonoClass *klass);
384
385 MonoMethod *
386 mono_marshal_get_synchronized_wrapper (MonoMethod *method);
387
388 MonoMethod *
389 mono_marshal_get_synchronized_inner_wrapper (MonoMethod *method);
390
391 MonoMethod *
392 mono_marshal_get_unbox_wrapper (MonoMethod *method);
393
394 MonoMethod *
395 mono_marshal_get_castclass_with_cache (void);
396
397 MonoMethod *
398 mono_marshal_get_isinst_with_cache (void);
399
400 MonoMethod *
401 mono_marshal_get_isinst (MonoClass *klass);
402
403 MonoMethod *
404 mono_marshal_get_castclass (MonoClass *klass);
405
406 MonoMethod *
407 mono_marshal_get_stelemref (void);
408
409 MonoMethod*
410 mono_marshal_get_virtual_stelemref (MonoClass *array_class);
411
412 MonoMethod**
413 mono_marshal_get_virtual_stelemref_wrappers (int *nwrappers);
414
415 MonoMethod*
416 mono_marshal_get_array_address (int rank, int elem_size);
417
418 MonoMethod *
419 mono_marshal_get_array_accessor_wrapper (MonoMethod *method);
420
421 MonoMethod *
422 mono_marshal_get_generic_array_helper (MonoClass *klass, MonoClass *iface,
423                                        gchar *name, MonoMethod *method);
424
425 MonoMethod *
426 mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method);
427
428 MonoMethod*
429 mono_marshal_get_gsharedvt_in_wrapper (void);
430
431 MonoMethod*
432 mono_marshal_get_gsharedvt_out_wrapper (void);
433
434 void
435 mono_marshal_free_dynamic_wrappers (MonoMethod *method);
436
437 void
438 mono_marshal_lock_internal (void);
439
440 void
441 mono_marshal_unlock_internal (void);
442
443 /* marshaling internal calls */
444
445 void * 
446 mono_marshal_alloc (gulong size, MonoError *error);
447
448 void 
449 mono_marshal_free (gpointer ptr);
450
451 void
452 mono_marshal_free_array (gpointer *ptr, int size);
453
454 gboolean 
455 mono_marshal_free_ccw (MonoObject* obj);
456
457 void
458 cominterop_release_all_rcws (void); 
459
460 void
461 ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged (MonoArray *src, gint32 start_index,
462                                                                     gpointer dest, gint32 length);
463
464 void
465 ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged (gpointer src, gint32 start_index,
466                                                                       MonoArray *dest, gint32 length);
467
468 MonoString *
469 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi (char *ptr);
470
471 MonoString *
472 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len (char *ptr, gint32 len);
473
474 MonoString *
475 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni (guint16 *ptr);
476
477 MonoString *
478 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len (guint16 *ptr, gint32 len);
479
480 MonoString *
481 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr);
482
483 guint32
484 ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal (MonoReflectionMethod *m);
485
486 guint32 
487 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error (void);
488
489 guint32 
490 ves_icall_System_Runtime_InteropServices_Marshal_SizeOf (MonoReflectionType *rtype);
491
492 void
493 ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr (MonoObject *obj, gpointer dst, MonoBoolean delete_old);
494
495 void
496 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (gpointer src, MonoObject *dst);
497
498 MonoObject *
499 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type (gpointer src, MonoReflectionType *type);
500
501 int
502 ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionType *type, MonoString *field_name);
503
504 gpointer
505 ves_icall_System_Runtime_InteropServices_Marshal_StringToBSTR (MonoString *string);
506
507 gpointer
508 ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (MonoString *string);
509
510 gpointer
511 ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni (MonoString *string);
512
513 void
514 ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure (gpointer src, MonoReflectionType *type);
515
516 void*
517 ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem (int size);
518
519 void
520 ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem (void *ptr);
521
522 gpointer 
523 ves_icall_System_Runtime_InteropServices_Marshal_ReAllocCoTaskMem (gpointer ptr, int size);
524
525 void*
526 ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal (gpointer size);
527
528 gpointer 
529 ves_icall_System_Runtime_InteropServices_Marshal_ReAllocHGlobal (gpointer ptr, gpointer size);
530
531 void
532 ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal (void *ptr);
533
534 void
535 ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR (void *ptr);
536
537 void*
538 ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement (MonoArray *arrayobj, int index);
539
540 MonoDelegate*
541 ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionType *type);
542
543 int
544 ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal (gpointer pUnk);
545
546 int
547 ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (gpointer pUnk, gpointer riid, gpointer* ppv);
548
549 int
550 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (gpointer pUnk);
551
552 void*
553 ves_icall_System_Runtime_InteropServices_Marshal_GetIUnknownForObjectInternal (MonoObject* object);
554
555 MonoObject*
556 ves_icall_System_Runtime_InteropServices_Marshal_GetObjectForCCW (void* pUnk);
557
558 void*
559 ves_icall_System_Runtime_InteropServices_Marshal_GetIDispatchForObjectInternal (MonoObject* object);
560
561 void*
562 ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (MonoObject* object, MonoReflectionType* type);
563
564 MonoBoolean
565 ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (MonoObject* object);
566
567 gint32
568 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (MonoObject* object);
569
570 MonoObject *
571 ves_icall_System_ComObject_CreateRCW (MonoReflectionType *type);
572
573 void
574 ves_icall_System_ComObject_ReleaseInterfaces(MonoComObject* obj);
575
576 gpointer
577 ves_icall_System_ComObject_GetInterfaceInternal (MonoComObject* obj, MonoReflectionType* type, MonoBoolean throw_exception);
578
579 void
580 ves_icall_Mono_Interop_ComInteropProxy_AddProxy (gpointer pUnk, MonoComInteropProxy* proxy);
581
582 MonoComInteropProxy*
583 ves_icall_Mono_Interop_ComInteropProxy_FindProxy (gpointer pUnk);
584
585 MONO_API void
586 mono_win32_compat_CopyMemory (gpointer dest, gconstpointer source, gsize length);
587
588 MONO_API void
589 mono_win32_compat_FillMemory (gpointer dest, gsize length, guchar fill);
590
591 MONO_API void
592 mono_win32_compat_MoveMemory (gpointer dest, gconstpointer source, gsize length);
593
594 MONO_API void
595 mono_win32_compat_ZeroMemory (gpointer dest, gsize length);
596
597 void
598 mono_marshal_find_nonzero_bit_offset (guint8 *buf, int len, int *byte_offset, guint8 *bitmask) MONO_LLVM_INTERNAL;
599
600 MonoMethodSignature*
601 mono_signature_no_pinvoke (MonoMethod *method);
602
603 /* Called from cominterop.c/remoting.c */
604
605 void
606 mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions, gboolean func_param);
607
608 void
609 mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle);
610
611 GHashTable*
612 mono_marshal_get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func);
613
614 MonoMethod*
615 mono_marshal_find_in_cache (GHashTable *cache, gpointer key);
616
617 MonoMethod*
618 mono_mb_create_and_cache (GHashTable *cache, gpointer key,
619                                                   MonoMethodBuilder *mb, MonoMethodSignature *sig,
620                                                   int max_stack);
621 void
622 mono_marshal_emit_thread_interrupt_checkpoint (MonoMethodBuilder *mb);
623
624 void
625 mono_marshal_emit_thread_force_interrupt_checkpoint (MonoMethodBuilder *mb);
626
627 void
628 mono_marshal_use_aot_wrappers (gboolean use);
629
630 MonoObject *
631 mono_marshal_xdomain_copy_value (MonoObject *val);
632
633 int
634 mono_mb_emit_save_args (MonoMethodBuilder *mb, MonoMethodSignature *sig, gboolean save_this);
635
636 void
637 mono_mb_emit_restore_result (MonoMethodBuilder *mb, MonoType *return_type);
638
639 MonoMethod*
640 mono_mb_create (MonoMethodBuilder *mb, MonoMethodSignature *sig,
641                                 int max_stack, WrapperInfo *info);
642
643 MonoMethod*
644 mono_mb_create_and_cache_full (GHashTable *cache, gpointer key,
645                                                            MonoMethodBuilder *mb, MonoMethodSignature *sig,
646                                                            int max_stack, WrapperInfo *info, gboolean *out_found);
647
648 G_END_DECLS
649
650 #endif /* __MONO_MARSHAL_H__ */
651
652