[sgen] We must do bridge processing with all sgen locks taken.
[mono.git] / mono / metadata / object-internals.h
index 3a455158cd5821fd152e917c532869885968c7ee..d969533904f41f5f88dbd5ad5c4d422bc7df7c2f 100644 (file)
@@ -83,7 +83,7 @@
 #endif
 
 #define MONO_CHECK_ARG(arg, expr)              G_STMT_START{             \
-     if (!(expr))                                                        \
+               if (G_UNLIKELY (!(expr)))                                                         \
        {                                                                 \
                MonoException *ex;                                        \
                char *msg = g_strdup_printf ("assertion `%s' failed",     \
@@ -95,7 +95,7 @@
        };                              }G_STMT_END
 
 #define MONO_CHECK_ARG_NULL(arg)           G_STMT_START{                 \
-     if (arg == NULL)                                                    \
+               if (G_UNLIKELY (arg == NULL))                                             \
        {                                                                 \
                MonoException *ex;                                        \
                if (arg) {} /* check if the name exists */                \
@@ -194,6 +194,27 @@ struct _MonoString {
 #define mono_array_length_fast(array) ((array)->max_length)
 #define mono_array_addr_with_size_fast(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
 
+#define mono_array_addr_fast(array,type,index) ((type*)(void*) mono_array_addr_with_size_fast (array, sizeof (type), index))
+#define mono_array_get_fast(array,type,index) ( *(type*)mono_array_addr_fast ((array), type, (index)) ) 
+#define mono_array_set_fast(array,type,index,value)    \
+       do {    \
+               type *__p = (type *) mono_array_addr_fast ((array), type, (index));     \
+               *__p = (value); \
+       } while (0)
+#define mono_array_setref_fast(array,index,value)      \
+       do {    \
+               void **__p = (void **) mono_array_addr_fast ((array), void*, (index));  \
+               mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value));     \
+               /* *__p = (value);*/    \
+       } while (0)
+#define mono_array_memcpy_refs_fast(dest,destidx,src,srcidx,count)     \
+       do {    \
+               void **__p = (void **) mono_array_addr_fast ((dest), void*, (destidx)); \
+               void **__s = mono_array_addr_fast ((src), void*, (srcidx));     \
+               mono_gc_wbarrier_arrayref_copy (__p, __s, (count));     \
+       } while (0)
+
+
 typedef struct {
        MonoObject obj;
        MonoObject *identity;
@@ -376,8 +397,6 @@ struct _MonoInternalThread {
        volatile int lock_thread_id; /* to be used as the pre-shifted thread id in thin locks. Used for appdomain_ref push/pop */
        HANDLE      handle;
        MonoArray  *cached_culture_info;
-       gpointer    unused1;
-       MonoBoolean threadpool_thread;
        gunichar2  *name;
        guint32     name_len;
        guint32     state;
@@ -390,7 +409,10 @@ struct _MonoInternalThread {
        gpointer jit_data;
        void *thread_info; /*This is MonoThreadInfo*, but to simplify dependencies, let's make it a void* here. */
        MonoAppContext *current_appcontext;
-       int stack_size;
+       MonoException *pending_exception;
+       MonoThread *root_domain_thread;
+       MonoObject *_serialized_principal;
+       int _serialized_principal_version;
        gpointer appdomain_refs;
        /* This is modified using atomic ops, so keep it a gint32 */
        gint32 interruption_requested;
@@ -398,25 +420,30 @@ struct _MonoInternalThread {
        gpointer suspended_event;
        gpointer resume_event;
        CRITICAL_SECTION *synch_cs;
+       MonoBoolean threadpool_thread;
        MonoBoolean thread_dump_requested;
-       gpointer end_stack; /* This is only used when running in the debugger. */
        MonoBoolean thread_interrupt_requested;
+       gpointer end_stack; /* This is only used when running in the debugger. */
+       int stack_size;
        guint8  apartment_state;
        gint32 critical_region_level;
-       guint32 unused0;        
+       gint32 managed_id;
+       guint32 small_id;
        MonoThreadManageCallback manage_callback;
-       MonoException *pending_exception;
-       MonoThread *root_domain_thread;
        gpointer interrupt_on_stop;
        gsize    flags;
        gpointer android_tid;
        gpointer thread_pinning_ref;
-       gint32 managed_id;
        gint32 ignore_next_signal;
+       MonoMethod *async_invoke_method;
        /* 
         * These fields are used to avoid having to increment corlib versions
-        * when a new field is added to the unmanaged MonoThread structure.
+        * when a new field is added to this structure.
+        * Please synchronize any changes with InternalThread in Thread.cs, i.e. add the
+        * same field there.
         */
+       gpointer unused1;
+       gpointer unused2;
 };
 
 struct _MonoThread {
@@ -572,12 +599,14 @@ typedef struct {
 } MonoRuntimeCallbacks;
 
 typedef gboolean (*MonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data);
+typedef gboolean (*MonoInternalExceptionFrameWalk) (MonoMethod *method, gpointer ip, size_t native_offset, gboolean managed, gpointer user_data);
 
 typedef struct {
        void (*mono_walk_stack_with_ctx) (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data);
        void (*mono_walk_stack_with_state) (MonoInternalStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions options, void *user_data);
        void (*mono_raise_exception) (MonoException *ex);
        void (*mono_raise_exception_with_ctx) (MonoException *ex, MonoContext *ctx);
+       gboolean (*mono_exception_walk_trace) (MonoException *ex, MonoInternalExceptionFrameWalk func, gpointer user_data);
        gboolean (*mono_install_handler_block_guard) (MonoThreadUnwindState *unwind_state);
 } MonoRuntimeExceptionHandlingCallbacks;
 
@@ -606,10 +635,6 @@ void
 mono_message_init          (MonoDomain *domain, MonoMethodMessage *this_obj, 
                             MonoReflectionMethod *method, MonoArray *out_args) MONO_INTERNAL;
 
-MonoObject *
-mono_remoting_invoke       (MonoObject *real_proxy, MonoMethodMessage *msg, 
-                            MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
-
 MonoObject *
 mono_message_invoke        (MonoObject *target, MonoMethodMessage *msg, 
                             MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
@@ -1220,6 +1245,21 @@ typedef struct {
        MonoArray *data;
 } MonoReflectionCustomAttr;
 
+typedef struct {
+       MonoObject object;
+       MonoString *marshal_cookie;
+       MonoString *marshal_type;
+       MonoReflectionType *marshal_type_ref;
+       MonoReflectionType *marshal_safe_array_user_defined_subtype;
+       guint32 utype;
+       guint32 array_subtype;
+       gint32 safe_array_subtype;
+       gint32 size_const;
+       gint32 IidParameterIndex;
+       gint16 size_param_index;
+} MonoReflectionMarshalAsAttribute;
+
+
 typedef struct {
        MonoObject object;
        gint32 call_conv;
@@ -1372,7 +1412,7 @@ void        mono_reflection_initialize_generic_parameter (MonoReflectionGenericP
 void        mono_reflection_create_unmanaged_type (MonoReflectionType *type) MONO_INTERNAL;
 void        mono_reflection_register_with_runtime (MonoReflectionType *type) MONO_INTERNAL;
 
-void        mono_reflection_create_custom_attr_data_args (MonoImage *image, MonoMethod *method, const guchar *data, guint32 len, MonoArray **typed_args, MonoArray **named_args, CattrNamedArg **named_arg_info) MONO_INTERNAL;
+void        mono_reflection_create_custom_attr_data_args (MonoImage *image, MonoMethod *method, const guchar *data, guint32 len, MonoArray **typed_args, MonoArray **named_args, CattrNamedArg **named_arg_info, MonoError *error) MONO_INTERNAL;
 MonoMethodSignature * mono_reflection_lookup_signature (MonoImage *image, MonoMethod *method, guint32 token) MONO_INTERNAL;
 
 MonoArray* mono_param_get_objects_internal  (MonoDomain *domain, MonoMethod *method, MonoClass *refclass) MONO_INTERNAL;
@@ -1392,7 +1432,7 @@ MonoArray  *mono_reflection_sighelper_get_signature_local (MonoReflectionSigHelp
 
 MonoArray  *mono_reflection_sighelper_get_signature_field (MonoReflectionSigHelper *sig) MONO_INTERNAL;
 
-MonoReflectionMarshal* mono_reflection_marshal_from_marshal_spec (MonoDomain *domain, MonoClass *klass, MonoMarshalSpec *spec) MONO_INTERNAL;
+MonoReflectionMarshalAsAttribute* mono_reflection_marshal_as_attribute_from_marshal_spec (MonoDomain *domain, MonoClass *klass, MonoMarshalSpec *spec) MONO_INTERNAL;
 
 gpointer
 mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context) MONO_INTERNAL;
@@ -1437,11 +1477,17 @@ mono_array_full_copy (MonoArray *src, MonoArray *dest) MONO_INTERNAL;
 gboolean
 mono_array_calc_byte_len (MonoClass *class, uintptr_t len, uintptr_t *res) MONO_INTERNAL;
 
+#ifndef DISABLE_REMOTING
+MonoObject *
+mono_remoting_invoke       (MonoObject *real_proxy, MonoMethodMessage *msg, 
+                            MonoObject **exc, MonoArray **out_args) MONO_INTERNAL;
+
 gpointer
 mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy) MONO_INTERNAL;
 
 void
 mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass) MONO_INTERNAL;
+#endif
 
 gpointer
 mono_create_ftnptr (MonoDomain *domain, gpointer addr) MONO_INTERNAL;
@@ -1559,7 +1605,7 @@ void
 mono_field_static_get_value_for_thread (MonoInternalThread *thread, MonoVTable *vt, MonoClassField *field, void *value) MONO_INTERNAL;
 
 /* exported, used by the debugger */
-void *
+MONO_API void *
 mono_vtable_get_static_field_data (MonoVTable *vt);
 
 char *
@@ -1580,6 +1626,9 @@ mono_exception_get_native_backtrace (MonoException *exc) MONO_INTERNAL;
 MonoString *
 ves_icall_Mono_Runtime_GetNativeStackTrace (MonoException *exc) MONO_INTERNAL;
 
+char *
+mono_exception_get_managed_backtrace (MonoException *exc) MONO_INTERNAL;
+
 #endif /* __MONO_OBJECT_INTERNALS_H__ */