Add two wrappers which are used to transition between normal and gsharedvt code.
[mono.git] / mono / metadata / marshal.h
index 9ad4a5f5a626e9e3f8448ebd0565b0b4f4577e93..be407d24b08f62543522a43cbaae9445532a2f28 100644 (file)
@@ -76,10 +76,101 @@ typedef enum {
        MARSHAL_ACTION_MANAGED_CONV_RESULT
 } MarshalAction;
 
+/*
+ * This is an extension of the MONO_WRAPPER_ enum to avoid adding more elements to that
+ * enum.
+ */
+typedef enum {
+       WRAPPER_SUBTYPE_NONE,
+       /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
+       WRAPPER_SUBTYPE_ELEMENT_ADDR,
+       WRAPPER_SUBTYPE_STRING_CTOR,
+       /* Subtypes of MONO_WRAPPER_STELEMREF */
+       WRAPPER_SUBTYPE_VIRTUAL_STELEMREF,
+       /* Subtypes of MONO_WRAPPER_UNKNOWN */
+       WRAPPER_SUBTYPE_FAST_MONITOR_ENTER,
+       WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4,
+       WRAPPER_SUBTYPE_FAST_MONITOR_EXIT,
+       WRAPPER_SUBTYPE_PTR_TO_STRUCTURE,
+       WRAPPER_SUBTYPE_STRUCTURE_TO_PTR,
+       /* Subtypes of MONO_WRAPPER_CASTCLASS */
+       WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE,
+       WRAPPER_SUBTYPE_ISINST_WITH_CACHE,
+       /* Subtypes of MONO_WRAPPER_RUNTIME_INVOKE */
+       WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC,
+       WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT,
+       WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL,
+       /* Subtypes of MONO_WRAPPER_MANAGED_TO_NATIVE */
+       WRAPPER_SUBTYPE_ICALL_WRAPPER,
+       WRAPPER_SUBTYPE_NATIVE_FUNC_AOT,
+       /* Subtypes of MONO_WRAPPER_UNKNOWN */
+       WRAPPER_SUBTYPE_SYNCHRONIZED_INNER,
+       WRAPPER_SUBTYPE_GSHAREDVT_IN,
+       WRAPPER_SUBTYPE_GSHAREDVT_OUT,
+       /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
+       WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER
+} WrapperSubtype;
+
+typedef struct {
+       MonoMethod *method;
+       MonoClass *klass;
+} NativeToManagedWrapperInfo;
+
+typedef struct {
+       MonoMethod *method;
+} StringCtorWrapperInfo;
+
+typedef struct {
+       int kind;
+} VirtualStelemrefWrapperInfo;
+
 typedef struct {
        guint32 rank, elem_size;
 } ElementAddrWrapperInfo;
 
+typedef struct {
+       MonoMethod *method;
+} RuntimeInvokeWrapperInfo;
+
+typedef struct {
+       MonoMethod *method;
+} ManagedToNativeWrapperInfo;
+
+typedef struct {
+       MonoMethod *method;
+} SynchronizedInnerWrapperInfo;
+
+typedef struct {
+       MonoMethod *method;
+} GenericArrayHelperWrapperInfo;
+
+/*
+ * This structure contains additional information to uniquely identify a given wrapper
+ * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
+ * of wrappers, i.e. ones which do not have a 1-1 association with a method/class.
+ */
+typedef struct {
+       WrapperSubtype subtype;
+       union {
+               /* RUNTIME_INVOKE_... */
+               RuntimeInvokeWrapperInfo runtime_invoke;
+               /* STRING_CTOR */
+               StringCtorWrapperInfo string_ctor;
+               /* ELEMENT_ADDR */
+               ElementAddrWrapperInfo element_addr;
+               /* VIRTUAL_STELEMREF */
+               VirtualStelemrefWrapperInfo virtual_stelemref;
+               /* MONO_WRAPPER_NATIVE_TO_MANAGED */
+               NativeToManagedWrapperInfo native_to_managed;
+               /* MONO_WRAPPER_MANAGED_TO_NATIVE */
+               ManagedToNativeWrapperInfo managed_to_native;
+               /* SYNCHRONIZED_INNER */
+               SynchronizedInnerWrapperInfo synchronized_inner;
+               /* GENERIC_ARRAY_HELPER */
+               GenericArrayHelperWrapperInfo generic_array_helper;
+       } d;
+} WrapperInfo;
+
 G_BEGIN_DECLS
 
 /*type of the function pointer of methods returned by mono_marshal_get_runtime_invoke*/
@@ -206,7 +297,7 @@ MonoMethodSignature*
 mono_marshal_get_string_ctor_signature (MonoMethod *method) MONO_INTERNAL;
 
 MonoMethod *
-mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoObject **this_loc) MONO_INTERNAL;
+mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, uint32_t this_loc) MONO_INTERNAL;
 
 gpointer
 mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type) MONO_INTERNAL;
@@ -220,6 +311,9 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
 MonoMethod *
 mono_marshal_get_native_func_wrapper (MonoImage *image, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func) MONO_INTERNAL;
 
+MonoMethod*
+mono_marshal_get_native_func_wrapper_aot (MonoClass *klass) MONO_INTERNAL;
+
 MonoMethod *
 mono_marshal_get_struct_to_ptr (MonoClass *klass) MONO_INTERNAL;
 
@@ -244,9 +338,18 @@ mono_marshal_get_stfld_remote_wrapper (MonoClass *klass) MONO_INTERNAL;
 MonoMethod *
 mono_marshal_get_synchronized_wrapper (MonoMethod *method) MONO_INTERNAL;
 
+MonoMethod *
+mono_marshal_get_synchronized_inner_wrapper (MonoMethod *method) MONO_INTERNAL;
+
 MonoMethod *
 mono_marshal_get_unbox_wrapper (MonoMethod *method) MONO_INTERNAL;
 
+MonoMethod *
+mono_marshal_get_castclass_with_cache (void) MONO_INTERNAL;
+
+MonoMethod *
+mono_marshal_get_isinst_with_cache (void) MONO_INTERNAL;
+
 MonoMethod *
 mono_marshal_get_isinst (MonoClass *klass) MONO_INTERNAL;
 
@@ -259,6 +362,9 @@ mono_marshal_get_proxy_cancast (MonoClass *klass) MONO_INTERNAL;
 MonoMethod *
 mono_marshal_get_stelemref (void) MONO_INTERNAL;
 
+MonoMethod*
+mono_marshal_get_virtual_stelemref (MonoClass *array_class) MONO_INTERNAL;
+
 MonoMethod*
 mono_marshal_get_array_address (int rank, int elem_size) MONO_INTERNAL;
 
@@ -269,6 +375,12 @@ mono_marshal_get_generic_array_helper (MonoClass *class, MonoClass *iface,
 MonoMethod *
 mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method) MONO_INTERNAL;
 
+MonoMethod*
+mono_marshal_get_gsharedvt_in_wrapper (void) MONO_INTERNAL;
+
+MonoMethod*
+mono_marshal_get_gsharedvt_out_wrapper (void) MONO_INTERNAL;
+
 void
 mono_marshal_free_dynamic_wrappers (MonoMethod *method) MONO_INTERNAL;
 
@@ -471,10 +583,10 @@ mono_signature_no_pinvoke (MonoMethod *method) MONO_INTERNAL;
 /* Called from cominterop.c */
 
 void
-mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, gboolean aot, gboolean check_exceptions) MONO_INTERNAL;
+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) MONO_INTERNAL;
 
 void
-mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoObject** this_loc) MONO_INTERNAL;
+mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle) MONO_INTERNAL;
 
 GHashTable*
 mono_marshal_get_cache (GHashTable **var, GHashFunc hash_func, GCompareFunc equal_func) MONO_INTERNAL;
@@ -489,6 +601,9 @@ mono_mb_create_and_cache (GHashTable *cache, gpointer key,
 void
 mono_marshal_emit_thread_interrupt_checkpoint (MonoMethodBuilder *mb) MONO_INTERNAL;
 
+void
+mono_marshal_use_aot_wrappers (gboolean use) MONO_INTERNAL;
+
 G_END_DECLS
 
 #endif /* __MONO_MARSHAL_H__ */