5 #ifndef __MONO_OBJECT_INTERNALS_H__
6 #define __MONO_OBJECT_INTERNALS_H__
8 #include <mono/utils/mono-forward-internal.h>
9 #include <mono/metadata/object-forward.h>
10 #include <mono/metadata/handle-decl.h>
12 #include <mono/metadata/object.h>
13 #include <mono/metadata/threads.h>
14 #include <mono/metadata/reflection.h>
15 #include <mono/metadata/mempool.h>
16 #include <mono/metadata/class-internals.h>
17 #include <mono/metadata/threads-types.h>
18 #include <mono/metadata/handle.h>
19 #include <mono/metadata/abi-details.h>
20 #include "mono/utils/mono-compiler.h"
21 #include "mono/utils/mono-error.h"
22 #include "mono/utils/mono-error-internals.h"
23 #include "mono/utils/mono-machine.h"
24 #include "mono/utils/mono-stack-unwinding.h"
25 #include "mono/utils/mono-tls.h"
26 #include "mono/utils/mono-coop-mutex.h"
27 #include <mono/metadata/icalls.h>
29 /* Use this as MONO_CHECK_ARG (arg,expr,) in functions returning void */
30 #define MONO_CHECK_ARG(arg, expr, retval) do { \
31 if (G_UNLIKELY (!(expr))) \
33 if (0) { (void)(arg); } /* check if the name exists */ \
35 mono_error_set_argument_format (error, #arg, "assertion `%s' failed", #expr); \
36 mono_error_set_pending_exception (error); \
41 #define MONO_CHECK_ARG_NULL_NAMED(arg, argname, retval) do { \
42 if (G_UNLIKELY (!(arg))) \
45 mono_error_set_argument_null (error, (argname), ""); \
46 mono_error_set_pending_exception (error); \
50 /* Use this as MONO_CHECK_ARG_NULL (arg,) in functions returning void */
51 #define MONO_CHECK_ARG_NULL(arg, retval) do { \
52 if (G_UNLIKELY (!(arg))) \
54 mono_error_set_argument_null (error, #arg, ""); \
59 /* Use this as MONO_CHECK_ARG_NULL_HANDLE (arg,) in functions returning void */
60 #define MONO_CHECK_ARG_NULL_HANDLE(arg, retval) do { \
61 if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \
63 mono_error_set_argument_null (error, #arg, ""); \
68 #define MONO_CHECK_ARG_NULL_HANDLE_NAMED(arg, argname, retval) do { \
69 if (G_UNLIKELY (MONO_HANDLE_IS_NULL (arg))) \
71 mono_error_set_argument_null (error, (argname), ""); \
76 /* Use this as MONO_CHECK_NULL (arg,) in functions returning void */
77 #define MONO_CHECK_NULL(arg, retval) do { \
78 if (G_UNLIKELY (!(arg))) \
81 mono_error_set_null_reference (error); \
82 mono_error_set_pending_exception (error); \
88 mono_class_create_array (MonoClass
*element_class
, uint32_t rank
);
91 mono_array_new_specific_handle (MonoVTable
*vtable
, uintptr_t n
, MonoError
*error
);
94 mono_array_new_specific_checked (MonoVTable
*vtable
, uintptr_t n
, MonoError
*error
);
98 * These should be used instead of the original versions.
101 static inline MonoClass
*
102 mono_array_class_get_cached_function (MonoClass
*eclass
, MonoClass
**aclass
)
104 MonoClass
*a
= *aclass
;
107 a
= mono_class_create_array (eclass
, 1);
114 // eclass should be a run-time constant
115 // If you get an error using this macro, you need to manually instantiate the MonoClass *foo ## _array cache.
116 // See for example object_class_array.
117 #define mono_array_class_get_cached(eclass) (mono_array_class_get_cached_function ((eclass), &(eclass ## _array)))
119 static inline MonoArray
*
120 mono_array_new_cached_function (MonoDomain
*domain
, MonoClass
*aclass
, int size
, MonoError
*error
)
122 MonoVTable
*vtable
= mono_class_vtable_checked (domain
, aclass
, error
);
123 MonoArray
*arr
= NULL
;
125 arr
= mono_array_new_specific_checked (vtable
, size
, error
);
129 // eclass should be a run-time constant
130 // If you get an error using this macro, you need to manually instantiate the MonoClass *foo ## _array cache.
131 // See for example object_class_array.
132 #define mono_array_new_cached(domain, eclass, size, error) \
133 mono_array_new_cached_function ((domain), mono_array_class_get_cached (eclass), (size), (error))
135 static inline MonoArrayHandle
136 mono_array_new_cached_handle_function (MonoDomain
*domain
, MonoClass
*aclass
, int size
, MonoError
*error
)
138 MonoVTable
*vtable
= mono_class_vtable_checked (domain
, aclass
, error
);
139 MonoArrayHandle arr
= NULL_HANDLE_ARRAY
;
141 arr
= mono_array_new_specific_handle (vtable
, size
, error
);
145 // eclass should be a run-time constant
146 // If you get an error using this macro, you need to manually instantiate the MonoClass *foo ## _array cache.
147 // See for example object_class_array.
148 #define mono_array_new_cached_handle(domain, eclass, size, error) \
149 mono_array_new_cached_handle_function ((domain), mono_array_class_get_cached (eclass), (size), (error))
151 #ifdef MONO_BIG_ARRAYS
152 typedef uint64_t mono_array_size_t
;
153 typedef int64_t mono_array_lower_bound_t
;
154 #define MONO_ARRAY_MAX_INDEX G_MAXINT64
155 #define MONO_ARRAY_MAX_SIZE G_MAXUINT64
157 typedef uint32_t mono_array_size_t
;
158 typedef int32_t mono_array_lower_bound_t
;
159 #define MONO_ARRAY_MAX_INDEX ((int32_t) 0x7fffffff)
160 #define MONO_ARRAY_MAX_SIZE ((uint32_t) 0xffffffff)
164 mono_array_size_t length
;
165 mono_array_lower_bound_t lower_bound
;
170 /* bounds is NULL for szarrays */
171 MonoArrayBounds
*bounds
;
172 /* total number of elements of the array */
173 mono_array_size_t max_length
;
174 /* we use mono_64bitaligned_t to ensure proper alignment on platforms that need it */
175 mono_64bitaligned_t vector
[MONO_ZERO_LEN_ARRAY
];
178 #define MONO_SIZEOF_MONO_ARRAY (MONO_STRUCT_OFFSET (MonoArray, vector))
183 mono_unichar2 chars
[MONO_ZERO_LEN_ARRAY
];
186 #define MONO_SIZEOF_MONO_STRING (MONO_STRUCT_OFFSET (MonoString, chars))
188 #define mono_object_class(obj) (((MonoObject*)(obj))->vtable->klass)
189 #define mono_object_domain(obj) (((MonoObject*)(obj))->vtable->domain)
191 #define mono_string_chars_fast(s) ((mono_unichar2*)(s)->chars)
192 #define mono_string_length_fast(s) ((s)->length)
195 * mono_array_length_internal:
196 * \param array a \c MonoArray*
197 * \returns the total number of elements in the array. This works for
198 * both vectors and multidimensional arrays.
200 #define mono_array_length_internal(array) ((array)->max_length)
204 mono_array_handle_length (MonoArrayHandle arr
)
206 MONO_REQ_GC_UNSAFE_MODE
;
208 return mono_array_length_internal (MONO_HANDLE_RAW (arr
));
211 // Equivalent to mono_array_addr_with_size, except:
212 // 1. A macro instead of a function -- the types of size and index are open.
213 // 2. mono_array_addr_with_size could, but does not, do GC mode transitions.
214 #define mono_array_addr_with_size_fast(array,size,index) ( ((char*)(array)->vector) + (size) * (index) )
216 #define mono_array_addr_fast(array,type,index) ((type*)(void*) mono_array_addr_with_size_fast (array, sizeof (type), index))
217 #define mono_array_get_fast(array,type,index) ( *(type*)mono_array_addr_fast ((array), type, (index)) )
218 #define mono_array_set_fast(array,type,index,value) \
220 type *__p = (type *) mono_array_addr_fast ((array), type, (index)); \
223 #define mono_array_setref_fast(array,index,value) \
225 void **__p = (void **) mono_array_addr_fast ((array), void*, (index)); \
226 mono_gc_wbarrier_set_arrayref_internal ((array), __p, (MonoObject*)(value)); \
227 /* *__p = (value);*/ \
229 #define mono_array_memcpy_refs_fast(dest,destidx,src,srcidx,count) \
231 void **__p = (void **) mono_array_addr_fast ((dest), void*, (destidx)); \
232 void **__s = mono_array_addr_fast ((src), void*, (srcidx)); \
233 mono_gc_wbarrier_arrayref_copy_internal (__p, __s, (count)); \
236 // _internal is like _fast, but preserves the preexisting subtlety of the closed types of things:
239 // in order to mimic non-_internal but without the GC mode transitions, or at least,
240 // to avoid the runtime using the embedding API, whether or not it has GC mode transitions.
242 mono_array_addr_with_size_internal (MonoArray
*array
, int size
, uintptr_t idx
)
244 return mono_array_addr_with_size_fast (array
, size
, idx
);
247 #define mono_array_addr_internal(array,type,index) ((type*)(void*) mono_array_addr_with_size_internal (array, sizeof (type), index))
248 #define mono_array_get_internal(array,type,index) ( *(type*)mono_array_addr_internal ((array), type, (index)) )
249 #define mono_array_set_internal(array,type,index,value) \
251 type *__p = (type *) mono_array_addr_internal ((array), type, (index)); \
254 #define mono_array_setref_internal(array,index,value) \
256 void **__p = (void **) mono_array_addr_internal ((array), void*, (index)); \
257 mono_gc_wbarrier_set_arrayref_internal ((array), __p, (MonoObject*)(value)); \
258 /* *__p = (value);*/ \
260 #define mono_array_memcpy_refs_internal(dest,destidx,src,srcidx,count) \
262 void **__p = (void **) mono_array_addr_internal ((dest), void*, (destidx)); \
263 void **__s = mono_array_addr_internal ((src), void*, (srcidx)); \
264 mono_gc_wbarrier_arrayref_copy_internal (__p, __s, (count)); \
267 static inline gboolean
268 mono_handle_array_has_bounds (MonoArrayHandle arr
)
270 return MONO_HANDLE_GETVAL (arr
, bounds
) != NULL
;
274 mono_handle_array_get_bounds_dim (MonoArrayHandle arr
, gint32 dim
, MonoArrayBounds
*bounds
)
276 *bounds
= MONO_HANDLE_GETVAL (arr
, bounds
[dim
]);
281 #ifndef ENABLE_NETCORE
282 MonoObject
*identity
;
284 } MonoMarshalByRefObject
;
286 TYPED_HANDLE_DECL (MonoMarshalByRefObject
);
288 /* This is a copy of System.AppDomain */
289 struct _MonoAppDomain
{
290 MonoMarshalByRefObject mbr
;
294 /* Safely access System.AppDomain from native code */
295 TYPED_HANDLE_DECL (MonoAppDomain
);
297 /* Safely access System.AppDomainSetup from native code. (struct is in domain-internals.h) */
298 TYPED_HANDLE_DECL (MonoAppDomainSetup
);
300 typedef struct _MonoStringBuilder MonoStringBuilder
;
301 TYPED_HANDLE_DECL (MonoStringBuilder
);
303 struct _MonoStringBuilder
{
305 MonoArray
*chunkChars
;
306 MonoStringBuilder
* chunkPrevious
; // Link to the block logically before this block
307 int chunkLength
; // The index in ChunkChars that represent the end of the block
308 int chunkOffset
; // The logial offset (sum of all characters in previous blocks)
313 mono_string_builder_capacity (MonoStringBuilderHandle sbh
)
315 MonoStringBuilder
*sb
= MONO_HANDLE_RAW (sbh
);
316 return sb
->chunkOffset
+ sb
->chunkChars
->max_length
;
320 mono_string_builder_string_length (MonoStringBuilderHandle sbh
)
322 MonoStringBuilder
*sb
= MONO_HANDLE_RAW (sbh
);
323 return sb
->chunkOffset
+ sb
->chunkLength
;
334 } MonoArgumentHandle
;
337 MonoMethodSignature
*sig
;
343 struct _MonoException
{
345 MonoString
*class_name
;
348 MonoObject
*inner_ex
;
349 MonoString
*help_link
;
350 /* Stores the IPs and the generic sharing infos
351 (vtable/MRGCTX) of the frames. */
352 MonoArray
*trace_ips
;
353 MonoString
*stack_trace
;
354 MonoString
*remote_stack_trace
;
355 gint32 remote_stack_index
;
356 /* Dynamic methods referenced by the stack trace */
357 MonoObject
*dynamic_methods
;
360 MonoObject
*serialization_manager
;
361 MonoObject
*captured_traces
;
362 MonoArray
*native_trace_ips
;
363 gint32 caught_in_unmanaged
;
368 } MonoSystemException
;
370 TYPED_HANDLE_DECL (MonoSystemException
);
372 #ifndef ENABLE_NETCORE
374 MonoSystemException base
;
375 MonoString
*param_name
;
376 } MonoArgumentException
;
381 MonoObject
*async_state
;
383 MonoObject
*async_delegate
;
385 MonoObject
*object_data
;
386 MonoBoolean sync_completed
;
387 MonoBoolean completed
;
388 MonoBoolean endinvoke_called
;
389 MonoObject
*async_callback
;
390 MonoObject
*execution_context
;
391 MonoObject
*original_context
;
395 TYPED_HANDLE_DECL (MonoAsyncResult
);
398 MonoMarshalByRefObject object
;
402 TYPED_HANDLE_DECL (MonoWaitHandle
);
404 /* This is a copy of System.Runtime.Remoting.Messaging.CallType */
407 CallType_BeginInvoke
= 1,
408 CallType_EndInvoke
= 2,
412 /* System.Threading.StackCrawlMark */
414 * This type is used to identify the method where execution has entered
415 * the BCL during stack walks. The outermost public method should
416 * define it like this:
417 * StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
418 * and pass the stackMark as a byref argument down the call chain
419 * until it reaches an icall.
423 STACK_CRAWL_CALLER
= 1,
424 STACK_CRAWL_CALLERS_CALLER
= 2,
425 STACK_CRAWL_THREAD
= 3
426 } MonoStackCrawlMark
;
428 /* MonoSafeHandle is in class-internals.h. */
429 /* Safely access System.Net.Sockets.SafeSocketHandle from native code */
430 TYPED_HANDLE_DECL (MonoSafeHandle
);
432 /* This corresponds to System.Type */
433 struct _MonoReflectionType
{
438 /* Safely access System.Type from native code */
439 TYPED_HANDLE_DECL (MonoReflectionType
);
443 MonoReflectionType
*class_to_proxy
;
445 MonoObject
*unwrapped_server
;
446 gint32 target_domain_id
;
447 MonoString
*target_uri
;
448 MonoObject
*object_identity
;
450 MonoObject
*stub_data
;
453 /* Safely access System.Runtime.Remoting.Proxies.RealProxy from native code */
454 TYPED_HANDLE_DECL (MonoRealProxy
);
456 typedef struct _MonoIUnknown MonoIUnknown
;
457 typedef struct _MonoIUnknownVTable MonoIUnknownVTable
;
459 /* STDCALL on windows, CDECL everywhere else to work with XPCOM and MainWin COM */
461 #define STDCALL __stdcall
466 struct _MonoIUnknownVTable
468 int (STDCALL
*QueryInterface
)(MonoIUnknown
*pUnk
, gconstpointer riid
, gpointer
* ppv
);
469 int (STDCALL
*AddRef
)(MonoIUnknown
*pUnk
);
470 int (STDCALL
*Release
)(MonoIUnknown
*pUnk
);
475 const MonoIUnknownVTable
*vtable
;
479 MonoMarshalByRefObject object
;
480 MonoIUnknown
*iunknown
;
481 GHashTable
* itf_hash
;
482 MonoObject
*synchronization_context
;
485 TYPED_HANDLE_DECL (MonoComObject
);
488 MonoRealProxy real_proxy
;
489 MonoComObject
*com_object
;
491 } MonoComInteropProxy
;
493 TYPED_HANDLE_DECL (MonoComInteropProxy
);
498 MonoRemoteClass
*remote_class
;
499 MonoBoolean custom_type_info
;
500 } MonoTransparentProxy
;
502 /* Safely access System.Runtime.Remoting.Proxies.TransparentProxy from native code */
503 TYPED_HANDLE_DECL (MonoTransparentProxy
);
507 MonoReflectionMethod
*method
;
510 MonoArray
*arg_types
;
514 MonoAsyncResult
*async_result
;
518 TYPED_HANDLE_DECL (MonoMethodMessage
);
520 /* Keep in sync with the System.MonoAsyncCall */
523 MonoMethodMessage
*msg
;
524 MonoMethod
*cb_method
;
525 MonoDelegate
*cb_target
;
531 TYPED_HANDLE_DECL (MonoAsyncCall
);
536 MonoArray
*captured_traces
;
537 MonoBoolean debug_info
;
540 TYPED_HANDLE_DECL (MonoStackTrace
);
545 gint32 native_offset
;
546 gint64 method_address
;
548 MonoReflectionMethod
*method
;
549 MonoString
*filename
;
552 MonoString
*internal_method_name
;
555 TYPED_HANDLE_DECL (MonoStackFrame
);
558 MONO_THREAD_FLAG_DONT_MANAGE
= 1, // Don't wait for or abort this thread
559 MONO_THREAD_FLAG_NAME_SET
= 2, // Thread name set from managed code
560 MONO_THREAD_FLAG_APPDOMAIN_ABORT
= 4, // Current requested abort originates from appdomain unload
563 struct _MonoThreadInfo
;
565 typedef struct MonoThreadName
{
566 char* volatile chars
; // null check outside of lock
572 mono_gstring_append_thread_name (GString
*, MonoInternalThread
*);
576 * NETCORE: There is only one thread object,
577 * thread->internal_thread points to itself.
579 struct _MonoInternalThread
{
580 // FIXME: Mechanize keeping this in sync with managed.
582 volatile int lock_thread_id
; /* to be used as the pre-shifted thread id in thin locks. Used for appdomain_ref push/pop */
583 MonoThreadHandle
*handle
;
584 gpointer native_handle
;
586 guint32 state
; /* must be accessed while longlived->synch_cs is locked */
587 MonoException
*abort_exc
;
588 int abort_state_handle
;
589 guint64 tid
; /* This is accessed as a gsize in the code (so it can hold a 64bit pointer on systems that need it), but needs to reserve 64 bits of space on all machines as it corresponds to a field in managed code */
590 gsize debugger_thread
; // FIXME switch to bool as soon as CI testing with corlib version bump works
591 gpointer
*static_data
;
592 struct _MonoThreadInfo
*thread_info
;
593 MonoAppContext
*current_appcontext
;
594 MonoThread
*root_domain_thread
;
595 MonoObject
*_serialized_principal
;
596 int _serialized_principal_version
;
597 gpointer appdomain_refs
;
598 /* This is modified using atomic ops, so keep it a gint32 */
599 gint32 __interruption_requested
;
600 /* data that must live as long as this managed object is not finalized
601 * or as long as the underlying thread is attached, whichever is
603 MonoLongLivedThreadData
*longlived
;
604 MonoBoolean threadpool_thread
;
605 MonoBoolean thread_interrupt_requested
;
607 guint8 apartment_state
;
608 gint32 critical_region_level
;
611 MonoThreadManageCallback manage_callback
;
613 gpointer thread_pinning_ref
;
614 gsize __abort_protected_block_count
;
616 GPtrArray
*owned_mutexes
;
617 MonoOSEvent
*suspended
;
618 gint32 self_suspended
; // TRUE | FALSE
621 #ifdef ENABLE_NETCORE
622 struct _MonoInternalThread
*internal_thread
;
623 MonoObject
*start_obj
;
624 MonoException
*pending_exception
;
626 void* unused
[3]; // same size as netcore
628 /* This is used only to check that we are in sync between the representation
629 * of MonoInternalThread in native and InternalThread in managed
631 * DO NOT RENAME! DO NOT ADD FIELDS AFTER! */
635 #ifndef ENABLE_NETCORE
638 MonoInternalThread
*internal_thread
;
639 MonoObject
*start_obj
;
640 MonoException
*pending_exception
;
646 MonoObject
*additional
;
647 } MonoStreamingContext
;
652 MonoBoolean readOnly
;
653 MonoString
*AMDesignator
;
654 MonoString
*PMDesignator
;
655 MonoString
*DateSeparator
;
656 MonoString
*TimeSeparator
;
657 MonoString
*ShortDatePattern
;
658 MonoString
*LongDatePattern
;
659 MonoString
*ShortTimePattern
;
660 MonoString
*LongTimePattern
;
661 MonoString
*MonthDayPattern
;
662 MonoString
*YearMonthPattern
;
663 guint32 FirstDayOfWeek
;
664 guint32 CalendarWeekRule
;
665 MonoArray
*AbbreviatedDayNames
;
667 MonoArray
*MonthNames
;
668 MonoArray
*GenitiveMonthNames
;
669 MonoArray
*AbbreviatedMonthNames
;
670 MonoArray
*GenitiveAbbreviatedMonthNames
;
671 MonoArray
*ShortDatePatterns
;
672 MonoArray
*LongDatePatterns
;
673 MonoArray
*ShortTimePatterns
;
674 MonoArray
*LongTimePatterns
;
675 MonoArray
*MonthDayPatterns
;
676 MonoArray
*YearMonthPatterns
;
677 MonoArray
*ShortestDayNames
;
678 } MonoDateTimeFormatInfo
;
683 MonoArray
*numberGroupSizes
;
684 MonoArray
*currencyGroupSizes
;
685 MonoArray
*percentGroupSizes
;
686 MonoString
*positiveSign
;
687 MonoString
*negativeSign
;
688 MonoString
*numberDecimalSeparator
;
689 MonoString
*numberGroupSeparator
;
690 MonoString
*currencyGroupSeparator
;
691 MonoString
*currencyDecimalSeparator
;
692 MonoString
*currencySymbol
;
693 MonoString
*ansiCurrencySymbol
; /* unused */
694 MonoString
*naNSymbol
;
695 MonoString
*positiveInfinitySymbol
;
696 MonoString
*negativeInfinitySymbol
;
697 MonoString
*percentDecimalSeparator
;
698 MonoString
*percentGroupSeparator
;
699 MonoString
*percentSymbol
;
700 MonoString
*perMilleSymbol
;
701 MonoString
*nativeDigits
; /* unused */
702 gint32 dataItem
; /* unused */
703 guint32 numberDecimalDigits
;
704 gint32 currencyDecimalDigits
;
705 gint32 currencyPositivePattern
;
706 gint32 currencyNegativePattern
;
707 gint32 numberNegativePattern
;
708 gint32 percentPositivePattern
;
709 gint32 percentNegativePattern
;
710 gint32 percentDecimalDigits
;
711 } MonoNumberFormatInfo
;
716 MonoString
*icu_name
;
717 gpointer ICU_collator
;
722 MonoString
*NativeName
;
723 MonoArray
*ShortDatePatterns
;
724 MonoArray
*YearMonthPatterns
;
725 MonoArray
*LongDatePatterns
;
726 MonoString
*MonthDayPattern
;
729 MonoArray
*AbbreviatedEraNames
;
730 MonoArray
*AbbreviatedEnglishEraNames
;
732 MonoArray
*AbbreviatedDayNames
;
733 MonoArray
*SuperShortDayNames
;
734 MonoArray
*MonthNames
;
735 MonoArray
*AbbreviatedMonthNames
;
736 MonoArray
*GenitiveMonthNames
;
737 MonoArray
*GenitiveAbbreviatedMonthNames
;
740 TYPED_HANDLE_DECL (MonoCalendarData
);
744 MonoString
*AMDesignator
;
745 MonoString
*PMDesignator
;
746 MonoString
*TimeSeparator
;
747 MonoArray
*LongTimePatterns
;
748 MonoArray
*ShortTimePatterns
;
749 guint32 FirstDayOfWeek
;
750 guint32 CalendarWeekRule
;
753 TYPED_HANDLE_DECL (MonoCultureData
);
757 MonoBoolean is_read_only
;
760 gint32 datetime_index
;
762 gint32 calendar_type
;
763 MonoBoolean use_user_override
;
764 MonoNumberFormatInfo
*number_format
;
765 MonoDateTimeFormatInfo
*datetime_format
;
766 MonoObject
*textinfo
;
768 MonoString
*englishname
;
769 MonoString
*nativename
;
770 MonoString
*iso3lang
;
771 MonoString
*iso2lang
;
772 MonoString
*win3lang
;
773 MonoString
*territory
;
774 MonoArray
*native_calendar_names
;
775 MonoCompareInfo
*compareinfo
;
776 const void* text_info_data
;
779 TYPED_HANDLE_DECL (MonoCultureInfo
);
784 MonoString
*iso2name
;
785 MonoString
*iso3name
;
786 MonoString
*win3name
;
787 MonoString
*english_name
;
788 MonoString
*native_name
;
789 MonoString
*currency_symbol
;
790 MonoString
*iso_currency_symbol
;
791 MonoString
*currency_english_name
;
792 MonoString
*currency_native_name
;
795 TYPED_HANDLE_DECL (MonoRegionInfo
);
797 #endif /* !ENABLE_NETCORE */
802 } MonoInterfaceTypeAttribute
;
804 /* Safely access System.Delegate from native code */
805 TYPED_HANDLE_DECL (MonoDelegate
);
808 * Callbacks supplied by the runtime and called by the modules in metadata/
809 * This interface is easier to extend than adding a new function type +
810 * a new 'install' function for every callback.
813 gpointer (*create_ftnptr
) (MonoDomain
*domain
, gpointer addr
);
814 gpointer (*get_addr_from_ftnptr
) (gpointer descr
);
815 char* (*get_runtime_build_info
) (void);
816 const char* (*get_runtime_build_version
) (void);
817 gpointer (*get_vtable_trampoline
) (MonoVTable
*vtable
, int slot_index
);
818 gpointer (*get_imt_trampoline
) (MonoVTable
*vtable
, int imt_slot_index
);
819 gboolean (*imt_entry_inited
) (MonoVTable
*vtable
, int imt_slot_index
);
820 void (*set_cast_details
) (MonoClass
*from
, MonoClass
*to
);
821 void (*debug_log
) (int level
, MonoString
*category
, MonoString
*message
);
822 gboolean (*debug_log_is_enabled
) (void);
823 void (*init_delegate
) (MonoDelegateHandle delegate
, MonoError
*error
);
824 MonoObject
* (*runtime_invoke
) (MonoMethod
*method
, void *obj
, void **params
, MonoObject
**exc
, MonoError
*error
);
825 void* (*compile_method
) (MonoMethod
*method
, MonoError
*error
);
826 gpointer (*create_jump_trampoline
) (MonoDomain
*domain
, MonoMethod
*method
, gboolean add_sync_wrapper
, MonoError
*error
);
827 gpointer (*create_jit_trampoline
) (MonoDomain
*domain
, MonoMethod
*method
, MonoError
*error
);
828 /* used to free a dynamic method */
829 void (*free_method
) (MonoDomain
*domain
, MonoMethod
*method
);
830 gpointer (*create_remoting_trampoline
) (MonoDomain
*domain
, MonoMethod
*method
, MonoRemotingTarget target
, MonoError
*error
);
831 gpointer (*create_delegate_trampoline
) (MonoDomain
*domain
, MonoClass
*klass
);
832 gpointer (*interp_get_remoting_invoke
) (MonoMethod
*method
, gpointer imethod
, MonoError
*error
);
833 GHashTable
*(*get_weak_field_indexes
) (MonoImage
*image
);
834 void (*install_state_summarizer
) (void);
835 gboolean (*is_interpreter_enabled
) (void);
836 } MonoRuntimeCallbacks
;
838 typedef gboolean (*MonoInternalStackWalk
) (MonoStackFrameInfo
*frame
, MonoContext
*ctx
, gpointer data
);
839 typedef gboolean (*MonoInternalExceptionFrameWalk
) (MonoMethod
*method
, gpointer ip
, size_t native_offset
, gboolean managed
, gpointer user_data
);
842 void (*mono_walk_stack_with_ctx
) (MonoInternalStackWalk func
, MonoContext
*ctx
, MonoUnwindOptions options
, void *user_data
);
843 void (*mono_walk_stack_with_state
) (MonoInternalStackWalk func
, MonoThreadUnwindState
*state
, MonoUnwindOptions options
, void *user_data
);
844 void (*mono_raise_exception
) (MonoException
*ex
);
845 void (*mono_raise_exception_with_ctx
) (MonoException
*ex
, MonoContext
*ctx
);
846 gboolean (*mono_exception_walk_trace
) (MonoException
*ex
, MonoInternalExceptionFrameWalk func
, gpointer user_data
);
847 gboolean (*mono_install_handler_block_guard
) (MonoThreadUnwindState
*unwind_state
);
848 void (*mono_uninstall_current_handler_block_guard
) (void);
849 gboolean (*mono_current_thread_has_handle_block_guard
) (void);
850 gboolean (*mono_above_abort_threshold
) (void);
851 void (*mono_clear_abort_threshold
) (void);
852 void (*mono_reraise_exception
) (MonoException
*ex
);
853 void (*mono_summarize_managed_stack
) (MonoThreadSummary
*out
);
854 void (*mono_summarize_unmanaged_stack
) (MonoThreadSummary
*out
);
855 void (*mono_summarize_exception
) (MonoException
*exc
, MonoThreadSummary
*out
);
856 void (*mono_register_native_library
) (const char *module_path
, const char *module_name
);
857 void (*mono_allow_all_native_libraries
) (void);
858 } MonoRuntimeExceptionHandlingCallbacks
;
860 MONO_COLD
void mono_set_pending_exception (MonoException
*exc
);
862 /* remoting and async support */
865 mono_async_result_new (MonoDomain
*domain
, gpointer handle
,
866 MonoObject
*state
, gpointer data
, MonoObject
*object_data
, MonoError
*error
);
868 mono_wait_handle_new (MonoDomain
*domain
, gpointer handle
, MonoError
*error
);
871 mono_wait_handle_get_handle (MonoWaitHandle
*handle
);
874 mono_message_init (MonoDomain
*domain
, MonoMethodMessage
*this_obj
,
875 MonoReflectionMethod
*method
, MonoArray
*out_args
, MonoError
*error
);
878 mono_method_call_message_new (MonoMethod
*method
, gpointer
*params
, MonoMethod
*invoke
,
879 MonoDelegate
**cb
, MonoObject
**state
, MonoError
*error
);
882 mono_method_return_message_restore (MonoMethod
*method
, gpointer
*params
, MonoArray
*out_args
, MonoError
*error
);
885 mono_delegate_ctor_with_method (MonoObjectHandle this_obj
, MonoObjectHandle target
, gpointer addr
, MonoMethod
*method
, MonoError
*error
);
888 mono_delegate_ctor (MonoObjectHandle this_obj
, MonoObjectHandle target
, gpointer addr
, MonoError
*error
);
891 mono_get_delegate_invoke_checked (MonoClass
*klass
, MonoError
*error
);
894 mono_get_delegate_begin_invoke_checked (MonoClass
*klass
, MonoError
*error
);
897 mono_get_delegate_end_invoke_checked (MonoClass
*klass
, MonoError
*error
);
900 mono_runtime_free_method (MonoDomain
*domain
, MonoMethod
*method
);
903 mono_install_callbacks (MonoRuntimeCallbacks
*cbs
);
905 MonoRuntimeCallbacks
*
906 mono_get_runtime_callbacks (void);
909 mono_install_eh_callbacks (MonoRuntimeExceptionHandlingCallbacks
*cbs
);
911 MonoRuntimeExceptionHandlingCallbacks
*
912 mono_get_eh_callbacks (void);
915 mono_raise_exception_deprecated (MonoException
*ex
);
918 mono_reraise_exception_deprecated (MonoException
*ex
);
921 mono_raise_exception_with_context (MonoException
*ex
, MonoContext
*ctx
);
924 mono_type_initialization_init (void);
927 mono_type_initialization_cleanup (void);
930 mono_thread_kill (MonoInternalThread
*thread
, int signal
);
933 mono_thread_get_tls_key (void);
936 mono_thread_get_tls_offset (void);
939 mono_domain_get_tls_key (void);
942 mono_domain_get_tls_offset (void);
944 /* Reflection and Reflection.Emit support */
947 * Handling System.Type objects:
949 * Fields defined as System.Type in managed code should be defined as MonoObject*
950 * in unmanaged structures, and the monotype_cast () function should be used for
951 * casting them to MonoReflectionType* to avoid crashes/security issues when
952 * encountering instances of user defined subclasses of System.Type.
955 #define IS_MONOTYPE(obj) (!(obj) || (m_class_get_image (mono_object_class ((obj))) == mono_defaults.corlib && ((MonoReflectionType*)(obj))->type != NULL))
957 #define IS_MONOTYPE_HANDLE(obj) IS_MONOTYPE (MONO_HANDLE_RAW (obj))
959 /* This should be used for accessing members of Type[] arrays */
960 #define mono_type_array_get(arr,index) monotype_cast (mono_array_get_internal ((arr), gpointer, (index)))
963 * Cast an object to MonoReflectionType, making sure it is a System.MonoType or
966 static inline MonoReflectionType
*
967 monotype_cast (MonoObject
*obj
)
969 g_assert (IS_MONOTYPE (obj
));
971 return (MonoReflectionType
*)obj
;
975 * The following structure must match the C# implementation in our corlib.
978 struct _MonoReflectionMethod
{
982 MonoReflectionType
*reftype
;
985 /* Safely access System.Reflection.MonoMethod from native code */
986 TYPED_HANDLE_DECL (MonoReflectionMethod
);
988 struct _MonoDelegate
{
990 /* The compiled code of the target method */
992 /* The invoke code */
993 gpointer invoke_impl
;
996 gpointer delegate_trampoline
;
997 /* Extra argument passed to the target method in llvmonly mode */
1000 * If non-NULL, this points to a memory location which stores the address of
1001 * the compiled code of the method, or NULL if it is not yet compiled.
1003 guint8
**method_code
;
1004 gpointer interp_method
;
1005 /* Interp method that is executed when invoking the delegate */
1006 gpointer interp_invoke_impl
;
1007 MonoReflectionMethod
*method_info
;
1008 MonoReflectionMethod
*original_method_info
;
1010 MonoBoolean method_is_virtual
;
1013 typedef struct _MonoMulticastDelegate MonoMulticastDelegate
;
1014 struct _MonoMulticastDelegate
{
1015 MonoDelegate delegate
;
1016 MonoArray
*delegates
;
1019 /* Safely access System.MulticastDelegate from native code */
1020 TYPED_HANDLE_DECL (MonoMulticastDelegate
);
1022 struct _MonoReflectionField
{
1025 MonoClassField
*field
;
1027 MonoReflectionType
*type
;
1031 /* Safely access System.Reflection.MonoField from native code */
1032 TYPED_HANDLE_DECL (MonoReflectionField
);
1034 struct _MonoReflectionProperty
{
1037 MonoProperty
*property
;
1040 /* Safely access System.Reflection.MonoProperty from native code */
1041 TYPED_HANDLE_DECL (MonoReflectionProperty
);
1043 /*This is System.EventInfo*/
1044 struct _MonoReflectionEvent
{
1046 #ifndef ENABLE_NETCORE
1047 MonoObject
*cached_add_event
;
1051 /* Safely access System.Reflection.EventInfo from native code */
1052 TYPED_HANDLE_DECL (MonoReflectionEvent
);
1055 MonoReflectionEvent object
;
1058 } MonoReflectionMonoEvent
;
1060 /* Safely access Systme.Reflection.MonoEvent from native code */
1061 TYPED_HANDLE_DECL (MonoReflectionMonoEvent
);
1065 } MonoReflectionParameter
;
1067 /* Safely access System.Reflection.ParameterInfo from native code */
1068 TYPED_HANDLE_DECL (MonoReflectionParameter
);
1070 struct _MonoReflectionMethodBody
{
1074 /* Safely access System.Reflection.MethodBody from native code */
1075 TYPED_HANDLE_DECL (MonoReflectionMethodBody
);
1077 /* System.RuntimeAssembly */
1078 struct _MonoReflectionAssembly
{
1080 MonoAssembly
*assembly
;
1082 MonoObject
*evidence
; /* Evidence */
1086 MonoReflectionType
*utype
;
1092 MonoReflectionType
*parent
;
1093 MonoReflectionType
*ret
;
1100 MonoReflectionType
*parent
;
1101 MonoReflectionType
*declaring_type
;
1103 MonoReflectionMethod
*get
;
1104 MonoReflectionMethod
*set
;
1109 MonoReflectionType
*declaring_type
;
1110 MonoReflectionType
*reflected_type
;
1112 MonoReflectionMethod
*add_method
;
1113 MonoReflectionMethod
*remove_method
;
1114 MonoReflectionMethod
*raise_method
;
1116 MonoArray
*other_methods
;
1122 } MonoReflectionILTokenInfo
;
1131 MonoArray
*ex_handlers
;
1132 gint32 num_token_fixups
;
1133 MonoArray
*token_fixups
;
1134 } MonoReflectionILGen
;
1137 MonoArray
*handlers
;
1141 } MonoILExceptionInfo
;
1148 gint32 filter_offset
;
1149 } MonoILExceptionBlock
;
1153 MonoObject
*catch_type
;
1154 gint32 filter_offset
;
1158 gint32 handler_offset
;
1159 gint32 handler_length
;
1160 } MonoReflectionExceptionHandlingClause
;
1163 /* Safely access System.Reflection.ExceptionHandlingClause from native code */
1164 TYPED_HANDLE_DECL (MonoReflectionExceptionHandlingClause
);
1168 MonoReflectionType
*local_type
;
1169 MonoBoolean is_pinned
;
1170 guint16 local_index
;
1171 } MonoReflectionLocalVariableInfo
;
1173 /* Safely access System.Reflection.LocalVariableInfo from native code */
1174 TYPED_HANDLE_DECL (MonoReflectionLocalVariableInfo
);
1178 * Must have the same layout as MonoReflectionLocalVariableInfo, since
1179 * LocalBuilder inherits from it under net 2.0.
1183 MonoBoolean is_pinned
;
1184 guint16 local_index
;
1186 } MonoReflectionLocalBuilder
;
1194 MonoString
*mcookie
;
1195 MonoString
*marshaltype
;
1196 MonoObject
*marshaltyperef
;
1198 MonoBoolean has_size
;
1199 } MonoReflectionMarshal
;
1203 MonoObject
* methodb
;
1206 MonoReflectionMarshal
*marshal_info
;
1210 MonoObject
*def_value
;
1211 } MonoReflectionParamBuilder
;
1215 MonoMethod
*mhandle
;
1216 MonoReflectionILGen
*ilgen
;
1217 MonoArray
*parameters
;
1225 MonoBoolean init_locals
;
1226 MonoArray
*param_modreq
;
1227 MonoArray
*param_modopt
;
1228 MonoArray
*permissions
;
1229 } MonoReflectionCtorBuilder
;
1231 /* Safely access System.Reflection.Emit.ConstructorBuilder from native code */
1232 TYPED_HANDLE_DECL (MonoReflectionCtorBuilder
);
1236 MonoMethod
*mhandle
;
1238 MonoArray
*parameters
;
1244 MonoReflectionILGen
*ilgen
;
1248 MonoArray
*override_methods
;
1250 MonoString
*dllentry
;
1252 guint32 extra_flags
;
1255 MonoBoolean init_locals
;
1256 MonoGenericContainer
*generic_container
;
1257 MonoArray
*generic_params
;
1258 MonoArray
*return_modreq
;
1259 MonoArray
*return_modopt
;
1260 MonoArray
*param_modreq
;
1261 MonoArray
*param_modopt
;
1262 MonoArray
*permissions
;
1263 } MonoReflectionMethodBuilder
;
1265 /* Safely access System.Reflection.Emit.MethodBuilder from native code */
1266 TYPED_HANDLE_DECL (MonoReflectionMethodBuilder
);
1270 MonoMethod
*mhandle
;
1271 MonoReflectionType
*parent
;
1272 MonoReflectionType
*ret
;
1273 MonoArray
*parameters
;
1277 } MonoReflectionArrayMethod
;
1279 /* Safely access System.Reflection.Emit.MonoArrayMethod from native code */
1280 TYPED_HANDLE_DECL (MonoReflectionArrayMethod
);
1285 MonoString
*filename
;
1289 } MonoReflectionResource
;
1295 MonoArray
*res_data
;
1296 } MonoReflectionWin32Resource
;
1301 } MonoReflectionPermissionSet
;
1304 MonoReflectionAssembly assembly
;
1305 MonoDynamicAssembly
*dynamic_assembly
;
1306 MonoReflectionMethod
*entry_point
;
1311 MonoArray
*resources
;
1312 MonoArray
*public_key
;
1313 MonoString
*version
;
1314 MonoString
*culture
;
1318 MonoBoolean delay_sign
;
1320 MonoArray
*loaded_modules
;
1321 MonoArray
*win32_resources
;
1323 MonoArray
*permissions_minimum
;
1324 MonoArray
*permissions_optional
;
1325 MonoArray
*permissions_refused
;
1328 MonoBoolean corlib_internal
;
1329 MonoArray
*type_forwarders
;
1330 MonoArray
*pktoken
; /* as hexadecimal byte[] */
1331 } MonoReflectionAssemblyBuilder
;
1333 /* Safely access System.Reflection.Emit.AssemblyBuilder from native code */
1334 TYPED_HANDLE_DECL (MonoReflectionAssemblyBuilder
);
1341 MonoObject
*def_value
;
1343 MonoReflectionType
*typeb
;
1344 MonoArray
*rva_data
;
1346 MonoReflectionMarshal
*marshal_info
;
1347 MonoClassField
*handle
;
1350 } MonoReflectionFieldBuilder
;
1352 /* Safely access System.Reflection.Emit.FieldBuilder from native code */
1353 TYPED_HANDLE_DECL (MonoReflectionFieldBuilder
);
1360 MonoArray
*parameters
;
1362 MonoObject
*def_value
;
1363 MonoReflectionMethodBuilder
*set_method
;
1364 MonoReflectionMethodBuilder
*get_method
;
1366 MonoObject
*type_builder
;
1367 MonoArray
*returnModReq
;
1368 MonoArray
*returnModOpt
;
1369 MonoArray
*paramModReq
;
1370 MonoArray
*paramModOpt
;
1372 } MonoReflectionPropertyBuilder
;
1374 /* System.RuntimeModule */
1375 struct _MonoReflectionModule
{
1378 MonoReflectionAssembly
*assembly
;
1381 MonoString
*scopename
;
1382 MonoBoolean is_resource
;
1386 /* Safely access System.Reflection.Module from native code */
1387 TYPED_HANDLE_DECL (MonoReflectionModule
);
1390 MonoReflectionModule module
;
1391 MonoDynamicImage
*dynamic_image
;
1397 MonoReflectionAssemblyBuilder
*assemblyb
;
1398 MonoArray
*global_methods
;
1399 MonoArray
*global_fields
;
1401 MonoArray
*resources
;
1402 GHashTable
*unparented_classes
;
1403 MonoArray
*table_indexes
;
1404 } MonoReflectionModuleBuilder
;
1406 /* Safely acess System.Reflection.Emit.ModuleBuidler from native code */
1407 TYPED_HANDLE_DECL (MonoReflectionModuleBuilder
);
1410 MonoTypeBuilderNew
= 0,
1411 MonoTypeBuilderEntered
= 1,
1412 MonoTypeBuilderFinished
= 2
1413 } MonoTypeBuilderState
;
1415 struct _MonoReflectionTypeBuilder
{
1416 MonoReflectionType type
;
1420 MonoReflectionType
*nesting_type
;
1421 MonoArray
*interfaces
;
1425 MonoArray
*properties
;
1430 MonoArray
*subtypes
;
1433 MonoReflectionModuleBuilder
*module
;
1435 gint32 packing_size
;
1436 MonoGenericContainer
*generic_container
;
1437 MonoArray
*generic_params
;
1438 MonoArray
*permissions
;
1439 MonoReflectionType
*created
;
1444 MonoReflectionType type
;
1445 MonoReflectionType
*element_type
;
1447 } MonoReflectionArrayType
;
1449 /* Safely access System.Reflection.Emit.ArrayType (in DerivedTypes.cs) from native code */
1450 TYPED_HANDLE_DECL (MonoReflectionArrayType
);
1453 MonoReflectionType type
;
1454 MonoReflectionType
*element_type
;
1455 } MonoReflectionDerivedType
;
1457 /* Safely access System.Reflection.Emit.SymbolType and subclasses (in DerivedTypes.cs) from native code */
1458 TYPED_HANDLE_DECL (MonoReflectionDerivedType
);
1461 MonoReflectionType type
;
1462 MonoReflectionTypeBuilder
*tbuilder
;
1463 MonoReflectionMethodBuilder
*mbuilder
;
1466 MonoReflectionType
*base_type
;
1467 MonoArray
*iface_constraints
;
1470 } MonoReflectionGenericParam
;
1472 /* Safely access System.Reflection.Emit.GenericTypeParameterBuilder from native code */
1473 TYPED_HANDLE_DECL (MonoReflectionGenericParam
);
1476 MonoReflectionType type
;
1477 MonoReflectionTypeBuilder
*tb
;
1478 } MonoReflectionEnumBuilder
;
1480 /* Safely access System.Reflection.Emit.EnumBuilder from native code */
1481 TYPED_HANDLE_DECL (MonoReflectionEnumBuilder
);
1483 typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass
;
1484 struct _MonoReflectionGenericClass
{
1485 MonoReflectionType type
;
1486 MonoReflectionType
*generic_type
; /*Can be either a MonoType or a TypeBuilder*/
1487 MonoArray
*type_arguments
;
1490 /* Safely access System.Reflection.Emit.TypeBuilderInstantiation from native code */
1491 TYPED_HANDLE_DECL (MonoReflectionGenericClass
);
1496 MonoString
*codebase
;
1497 gint32 major
, minor
, build
, revision
;
1498 MonoObject
*cultureInfo
;
1501 MonoObject
*keypair
;
1502 MonoArray
*publicKey
;
1503 MonoArray
*keyToken
;
1504 guint32 versioncompat
;
1505 MonoObject
*version
;
1506 guint32 processor_architecture
;
1507 } MonoReflectionAssemblyName
;
1509 /* Safely access System.Reflection.AssemblyName from native code */
1510 TYPED_HANDLE_DECL (MonoReflectionAssemblyName
);
1515 MonoReflectionType
*type
;
1516 MonoReflectionTypeBuilder
*typeb
;
1518 MonoReflectionMethodBuilder
*add_method
;
1519 MonoReflectionMethodBuilder
*remove_method
;
1520 MonoReflectionMethodBuilder
*raise_method
;
1521 MonoArray
*other_methods
;
1524 } MonoReflectionEventBuilder
;
1528 MonoReflectionMethod
*ctor
;
1530 } MonoReflectionCustomAttr
;
1532 TYPED_HANDLE_DECL (MonoReflectionCustomAttr
);
1538 gint32 safe_array_subtype
;
1539 MonoReflectionType
*marshal_safe_array_user_defined_subtype
;
1540 gint32 IidParameterIndex
;
1541 guint32 array_subtype
;
1542 gint16 size_param_index
;
1544 MonoString
*marshal_type
;
1545 MonoReflectionType
*marshal_type_ref
;
1546 MonoString
*marshal_cookie
;
1547 } MonoReflectionMarshalAsAttribute
;
1551 MonoString
*marshal_cookie
;
1552 MonoString
*marshal_type
;
1553 MonoReflectionType
*marshal_type_ref
;
1554 MonoReflectionType
*marshal_safe_array_user_defined_subtype
;
1556 guint32 array_subtype
;
1557 gint32 safe_array_subtype
;
1559 gint32 IidParameterIndex
;
1560 gint16 size_param_index
;
1561 } MonoReflectionMarshalAsAttribute
;
1564 /* Safely access System.Runtime.InteropServices.MarshalAsAttribute */
1565 TYPED_HANDLE_DECL (MonoReflectionMarshalAsAttribute
);
1571 MonoBoolean best_fit_mapping
;
1572 MonoBoolean throw_on_unmappable
;
1573 MonoBoolean set_last_error
;
1574 } MonoReflectionUnmanagedFunctionPointerAttribute
;
1579 } MonoReflectionGuidAttribute
;
1583 MonoMethod
*mhandle
;
1585 MonoReflectionType
*rtype
;
1586 MonoArray
*parameters
;
1589 MonoReflectionModule
*module
;
1590 MonoBoolean skip_visibility
;
1591 MonoBoolean init_locals
;
1592 MonoReflectionILGen
*ilgen
;
1595 GSList
*referenced_by
;
1596 MonoReflectionType
*owner
;
1597 } MonoReflectionDynamicMethod
;
1599 /* Safely access System.Reflection.Emit.DynamicMethod from native code */
1600 TYPED_HANDLE_DECL (MonoReflectionDynamicMethod
);
1604 MonoReflectionModuleBuilder
*module
;
1605 MonoArray
*arguments
;
1607 MonoReflectionType
*return_type
;
1609 guint32 unmanaged_call_conv
;
1612 } MonoReflectionSigHelper
;
1614 /* Safely access System.Reflection.Emit.SignatureHelper from native code */
1615 TYPED_HANDLE_DECL (MonoReflectionSigHelper
);
1619 MonoBoolean visible
;
1620 } MonoReflectionComVisibleAttribute
;
1624 MonoReflectionType
*type
;
1625 } MonoReflectionComDefaultInterfaceAttribute
;
1628 RESOURCE_LOCATION_EMBEDDED
= 1,
1629 RESOURCE_LOCATION_ANOTHER_ASSEMBLY
= 2,
1630 RESOURCE_LOCATION_IN_MANIFEST
= 4
1635 MonoReflectionAssembly
*assembly
;
1636 MonoString
*filename
;
1638 } MonoManifestResourceInfo
;
1640 /* Safely access System.Reflection.ManifestResourceInfo from native code */
1641 TYPED_HANDLE_DECL (MonoManifestResourceInfo
);
1643 /* A boxed IntPtr */
1649 /* Keep in sync with System.GenericParameterAttributes */
1651 GENERIC_PARAMETER_ATTRIBUTE_NON_VARIANT
= 0,
1652 GENERIC_PARAMETER_ATTRIBUTE_COVARIANT
= 1,
1653 GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT
= 2,
1654 GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK
= 3,
1656 GENERIC_PARAMETER_ATTRIBUTE_NO_SPECIAL_CONSTRAINT
= 0,
1657 GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT
= 4,
1658 GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT
= 8,
1659 GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT
= 16,
1660 GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK
= 28
1661 } GenericParameterAttributes
;
1665 MonoClassField
*field
;
1669 /* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr. However
1670 * for uniformity, icall wrapping will make handles anyway. So this is the method for getting the payload.
1672 static inline MonoInternalThread
*
1673 mono_internal_thread_handle_ptr (MonoInternalThreadHandle h
)
1675 /* The SUPPRESS here prevents a Centrinel warning due to merely seeing this
1676 * function definition. Callees will still get a warning unless we
1677 * attach a suppress attribute to the declaration.
1679 return MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (h
));
1682 gboolean
mono_image_create_pefile (MonoReflectionModuleBuilder
*module
, gpointer file
, MonoError
*error
);
1683 guint32
mono_image_insert_string (MonoReflectionModuleBuilderHandle module
, MonoStringHandle str
, MonoError
*error
);
1684 guint32
mono_image_create_token (MonoDynamicImage
*assembly
, MonoObjectHandle obj
, gboolean create_methodspec
, gboolean register_token
, MonoError
*error
);
1685 void mono_dynamic_image_free (MonoDynamicImage
*image
);
1686 void mono_dynamic_image_free_image (MonoDynamicImage
*image
);
1687 void mono_dynamic_image_release_gc_roots (MonoDynamicImage
*image
);
1689 void mono_reflection_setup_internal_class (MonoReflectionTypeBuilder
*tb
);
1691 void mono_reflection_get_dynamic_overrides (MonoClass
*klass
, MonoMethod
***overrides
, int *num_overrides
, MonoError
*error
);
1693 void mono_reflection_destroy_dynamic_method (MonoReflectionDynamicMethod
*mb
);
1697 ves_icall_SymbolType_create_unmanaged_type (MonoReflectionType
*type
);
1699 void mono_reflection_register_with_runtime (MonoReflectionType
*type
);
1701 MonoMethodSignature
* mono_reflection_lookup_signature (MonoImage
*image
, MonoMethod
*method
, guint32 token
, MonoError
*error
);
1703 MonoArrayHandle
mono_param_get_objects_internal (MonoDomain
*domain
, MonoMethod
*method
, MonoClass
*refclass
, MonoError
*error
);
1706 mono_class_bind_generic_parameters (MonoClass
*klass
, int type_argc
, MonoType
**types
, gboolean is_dynamic
);
1708 mono_reflection_bind_generic_parameters (MonoReflectionTypeHandle type
, int type_argc
, MonoType
**types
, MonoError
*error
);
1710 mono_reflection_generic_class_initialize (MonoReflectionGenericClass
*type
, MonoArray
*fields
);
1713 MonoReflectionEvent
*
1714 ves_icall_TypeBuilder_get_event_info (MonoReflectionTypeBuilder
*tb
, MonoReflectionEventBuilder
*eb
);
1716 MonoReflectionMarshalAsAttributeHandle
1717 mono_reflection_marshal_as_attribute_from_marshal_spec (MonoDomain
*domain
, MonoClass
*klass
, MonoMarshalSpec
*spec
, MonoError
*error
);
1720 mono_reflection_lookup_dynamic_token (MonoImage
*image
, guint32 token
, gboolean valid_token
, MonoClass
**handle_class
, MonoGenericContext
*context
, MonoError
*error
);
1723 mono_reflection_call_is_assignable_to (MonoClass
*klass
, MonoClass
*oklass
, MonoError
*error
);
1726 mono_image_build_metadata (MonoReflectionModuleBuilder
*module
, MonoError
*error
);
1729 mono_get_constant_value_from_blob (MonoDomain
* domain
, MonoTypeEnum type
, const char *blob
, void *value
, MonoStringHandleOut string_handle
, MonoError
*error
);
1732 mono_metadata_read_constant_value (const char *blob
, MonoTypeEnum type
, void *value
, MonoError
*error
);
1735 mono_string_from_blob (const char *str
, MonoError
*error
);
1738 mono_release_type_locks (MonoInternalThread
*thread
);
1741 * mono_string_handle_length:
1742 * \param s \c MonoString
1743 * \returns the length in characters of the string
1745 #ifdef ENABLE_CHECKED_BUILD_GC
1748 mono_string_handle_length (MonoStringHandle s
);
1752 #define mono_string_handle_length(s) (MONO_HANDLE_GETVAL ((s), length))
1757 mono_string_handle_to_utf8 (MonoStringHandle s
, MonoError
*error
);
1760 mono_string_to_utf8_image (MonoImage
*image
, MonoStringHandle s
, MonoError
*error
);
1763 mono_array_clone_in_domain (MonoDomain
*domain
, MonoArrayHandle array
, MonoError
*error
);
1766 mono_array_clone_checked (MonoArray
*array
, MonoError
*error
);
1769 mono_array_full_copy (MonoArray
*src
, MonoArray
*dest
);
1772 mono_array_calc_byte_len (MonoClass
*klass
, uintptr_t len
, uintptr_t *res
);
1775 mono_array_new_checked (MonoDomain
*domain
, MonoClass
*eclass
, uintptr_t n
, MonoError
*error
);
1778 mono_array_new_full_checked (MonoDomain
*domain
, MonoClass
*array_class
, uintptr_t *lengths
, intptr_t *lower_bounds
, MonoError
*error
);
1782 ves_icall_array_new (MonoDomain
*domain
, MonoClass
*eclass
, uintptr_t n
);
1786 ves_icall_array_new_specific (MonoVTable
*vtable
, uintptr_t n
);
1788 #ifndef DISABLE_REMOTING
1790 mono_remote_class (MonoDomain
*domain
, MonoStringHandle class_name
, MonoClass
*proxy_class
, MonoError
*error
);
1793 mono_remote_class_is_interface_proxy (MonoRemoteClass
*remote_class
);
1796 mono_remoting_invoke (MonoObject
*real_proxy
, MonoMethodMessage
*msg
, MonoObject
**exc
, MonoArray
**out_args
, MonoError
*error
);
1799 mono_remote_class_vtable (MonoDomain
*domain
, MonoRemoteClass
*remote_class
, MonoRealProxyHandle real_proxy
, MonoError
*error
);
1802 mono_upgrade_remote_class (MonoDomain
*domain
, MonoObjectHandle tproxy
, MonoClass
*klass
, MonoError
*error
);
1805 mono_load_remote_field_checked (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, void **res
, MonoError
*error
);
1808 mono_load_remote_field_new_checked (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, MonoError
*error
);
1811 mono_store_remote_field_checked (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, void* val
, MonoError
*error
);
1814 mono_store_remote_field_new_checked (MonoObject
*this_obj
, MonoClass
*klass
, MonoClassField
*field
, MonoObject
*arg
, MonoError
*error
);
1820 mono_create_ftnptr (MonoDomain
*domain
, gpointer addr
);
1823 mono_get_addr_from_ftnptr (gpointer descr
);
1826 mono_nullable_init (guint8
*buf
, MonoObject
*value
, MonoClass
*klass
);
1829 mono_nullable_init_from_handle (guint8
*buf
, MonoObjectHandle value
, MonoClass
*klass
);
1832 mono_nullable_init_unboxed (guint8
*buf
, gpointer value
, MonoClass
*klass
);
1835 mono_value_box_checked (MonoDomain
*domain
, MonoClass
*klass
, void* val
, MonoError
*error
);
1838 mono_value_box_handle (MonoDomain
*domain
, MonoClass
*klass
, gpointer val
, MonoError
*error
);
1841 mono_nullable_box (gpointer buf
, MonoClass
*klass
, MonoError
*error
);
1844 mono_nullable_box_handle (gpointer buf
, MonoClass
*klass
, MonoError
*error
);
1846 // A code size optimization (source and object) equivalent to MONO_HANDLE_NEW (MonoObject, NULL);
1848 mono_new_null (void);
1850 #ifdef MONO_SMALL_CONFIG
1851 #define MONO_IMT_SIZE 9
1853 #define MONO_IMT_SIZE 19
1858 gpointer target_code
;
1861 typedef struct _MonoImtBuilderEntry
{
1863 struct _MonoImtBuilderEntry
*next
;
1864 MonoImtItemValue value
;
1866 guint8 has_target_code
: 1;
1867 } MonoImtBuilderEntry
;
1869 typedef struct _MonoIMTCheckItem MonoIMTCheckItem
;
1871 struct _MonoIMTCheckItem
{
1873 int check_target_idx
;
1874 MonoImtItemValue value
;
1876 guint8
*code_target
;
1878 guint8 compare_done
;
1880 guint8 short_branch
;
1881 guint8 has_target_code
;
1884 typedef gpointer (*MonoImtTrampolineBuilder
) (MonoVTable
*vtable
, MonoDomain
*domain
,
1885 MonoIMTCheckItem
**imt_entries
, int count
, gpointer fail_trunk
);
1888 mono_install_imt_trampoline_builder (MonoImtTrampolineBuilder func
);
1891 mono_set_always_build_imt_trampolines (gboolean value
);
1894 mono_vtable_build_imt_slot (MonoVTable
* vtable
, int imt_slot
);
1897 mono_method_get_imt_slot (MonoMethod
*method
);
1900 mono_method_add_generic_virtual_invocation (MonoDomain
*domain
, MonoVTable
*vtable
,
1901 gpointer
*vtable_slot
,
1902 MonoMethod
*method
, gpointer code
);
1905 mono_method_alloc_generic_virtual_trampoline (MonoDomain
*domain
, int size
);
1907 #define mono_method_alloc_generic_virtual_trampoline(domain, size) (g_cast (mono_method_alloc_generic_virtual_trampoline ((domain), (size))))
1910 MONO_UNHANDLED_POLICY_LEGACY
,
1911 MONO_UNHANDLED_POLICY_CURRENT
1912 } MonoRuntimeUnhandledExceptionPolicy
;
1914 MonoRuntimeUnhandledExceptionPolicy
1915 mono_runtime_unhandled_exception_policy_get (void);
1917 mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy policy
);
1920 mono_unhandled_exception_checked (MonoObjectHandle exc
, MonoError
*error
);
1923 mono_class_try_get_vtable (MonoDomain
*domain
, MonoClass
*klass
);
1926 mono_runtime_run_module_cctor (MonoImage
*image
, MonoDomain
*domain
, MonoError
*error
);
1929 mono_runtime_class_init_full (MonoVTable
*vtable
, MonoError
*error
);
1932 mono_method_clear_object (MonoDomain
*domain
, MonoMethod
*method
);
1935 mono_class_compute_bitmap (MonoClass
*klass
, gsize
*bitmap
, int size
, int offset
, int *max_set
, gboolean static_fields
);
1938 mono_object_xdomain_representation (MonoObjectHandle obj
, MonoDomain
*target_domain
, MonoError
*error
);
1941 mono_class_is_reflection_method_or_constructor (MonoClass
*klass
);
1944 mono_get_object_from_blob (MonoDomain
*domain
, MonoType
*type
, const char *blob
, MonoStringHandleOut string_handle
, MonoError
*error
);
1947 mono_class_has_ref_info (MonoClass
*klass
);
1949 MonoReflectionTypeBuilder
*
1950 mono_class_get_ref_info_raw (MonoClass
*klass
);
1953 mono_class_set_ref_info (MonoClass
*klass
, MonoObjectHandle obj
);
1956 mono_class_free_ref_info (MonoClass
*klass
);
1959 mono_object_new_pinned (MonoDomain
*domain
, MonoClass
*klass
, MonoError
*error
);
1962 mono_object_new_pinned_handle (MonoDomain
*domain
, MonoClass
*klass
, MonoError
*error
);
1965 mono_object_new_specific_checked (MonoVTable
*vtable
, MonoError
*error
);
1969 ves_icall_object_new (MonoDomain
*domain
, MonoClass
*klass
);
1973 ves_icall_object_new_specific (MonoVTable
*vtable
);
1976 mono_object_new_alloc_specific_checked (MonoVTable
*vtable
, MonoError
*error
);
1979 mono_field_get_value_internal (MonoObject
*obj
, MonoClassField
*field
, void *value
);
1982 mono_field_static_get_value_checked (MonoVTable
*vt
, MonoClassField
*field
, void *value
, MonoStringHandleOut string_handle
, MonoError
*error
);
1985 mono_field_static_get_value_for_thread (MonoInternalThread
*thread
, MonoVTable
*vt
, MonoClassField
*field
, void *value
, MonoStringHandleOut string_handle
, MonoError
*error
);
1988 mono_object_handle_get_virtual_method (MonoObjectHandle obj
, MonoMethod
*method
, MonoError
*error
);
1990 /* exported, used by the debugger */
1992 mono_vtable_get_static_field_data (MonoVTable
*vt
);
1995 mono_field_get_value_object_checked (MonoDomain
*domain
, MonoClassField
*field
, MonoObject
*obj
, MonoError
*error
);
1998 mono_static_field_get_value_handle (MonoDomain
*domain
, MonoClassField
*field
, MonoError
*error
);
2001 mono_property_set_value_handle (MonoProperty
*prop
, MonoObjectHandle obj
, void **params
, MonoError
*error
);
2004 mono_property_get_value_checked (MonoProperty
*prop
, void *obj
, void **params
, MonoError
*error
);
2007 mono_object_try_to_string (MonoObject
*obj
, MonoObject
**exc
, MonoError
*error
);
2010 mono_string_to_utf8_ignore (MonoString
*s
);
2013 mono_monitor_is_il_fastpath_wrapper (MonoMethod
*method
);
2016 mono_string_is_interned_lookup (MonoStringHandle str
, gboolean insert
, MonoError
*error
);
2019 * mono_string_intern_checked:
2020 * \param str String to intern
2021 * \param error set on error.
2022 * Interns the string passed.
2023 * \returns The interned string. On failure returns NULL and sets \p error
2025 #define mono_string_intern_checked(str, error) (mono_string_is_interned_lookup ((str), TRUE, (error)))
2028 * mono_string_is_interned_internal:
2029 * \param o String to probe
2030 * \returns Whether the string has been interned.
2032 #define mono_string_is_interned_internal(str, error) (mono_string_is_interned_lookup ((str), FALSE, (error)))
2035 mono_exception_handle_get_native_backtrace (MonoExceptionHandle exc
);
2038 mono_exception_get_managed_backtrace (MonoException
*exc
);
2041 mono_copy_value (MonoType
*type
, void *dest
, void *value
, int deref_pointer
);
2044 mono_error_raise_exception_deprecated (MonoError
*target_error
);
2047 mono_error_set_pending_exception_slow (MonoError
*error
);
2049 static inline gboolean
2050 mono_error_set_pending_exception (MonoError
*error
)
2052 return is_ok (error
) ? FALSE
: mono_error_set_pending_exception_slow (error
);
2056 mono_glist_to_array (GList
*list
, MonoClass
*eclass
, MonoError
*error
);
2059 mono_object_new_checked (MonoDomain
*domain
, MonoClass
*klass
, MonoError
*error
);
2062 mono_object_new_handle (MonoDomain
*domain
, MonoClass
*klass
, MonoError
*error
);
2064 // This function skips handling of remoting and COM.
2065 // "alloc" means "less".
2067 mono_object_new_alloc_by_vtable (MonoVTable
*vtable
, MonoError
*error
);
2070 mono_object_new_mature (MonoVTable
*vtable
, MonoError
*error
);
2073 mono_object_new_handle_mature (MonoVTable
*vtable
, MonoError
*error
);
2076 mono_object_clone_checked (MonoObject
*obj
, MonoError
*error
);
2079 mono_object_clone_handle (MonoObjectHandle obj
, MonoError
*error
);
2082 mono_object_isinst_checked (MonoObject
*obj
, MonoClass
*klass
, MonoError
*error
);
2085 mono_object_handle_isinst (MonoObjectHandle obj
, MonoClass
*klass
, MonoError
*error
);
2088 mono_object_handle_isinst_mbyref (MonoObjectHandle obj
, MonoClass
*klass
, MonoError
*error
);
2091 mono_object_handle_isinst_mbyref_raw (MonoObjectHandle obj
, MonoClass
*klass
, MonoError
*error
);
2094 mono_string_new_size_handle (MonoDomain
*domain
, gint32 len
, MonoError
*error
);
2097 mono_string_new_len_checked (MonoDomain
*domain
, const char *text
, guint length
, MonoError
*error
);
2100 mono_string_new_size_checked (MonoDomain
*domain
, gint32 len
, MonoError
*error
);
2103 mono_ldstr_checked (MonoDomain
*domain
, MonoImage
*image
, uint32_t str_index
, MonoError
*error
);
2106 mono_ldstr_handle (MonoDomain
*domain
, MonoImage
*image
, uint32_t str_index
, MonoError
*error
);
2108 MONO_PROFILER_API MonoString
*
2109 mono_string_new_checked (MonoDomain
*domain
, const char *text
, MonoError
*merror
);
2112 mono_string_new_wtf8_len_checked (MonoDomain
*domain
, const char *text
, guint length
, MonoError
*error
);
2115 mono_string_new_utf16_checked (MonoDomain
*domain
, const gunichar2
*text
, gint32 len
, MonoError
*error
);
2118 mono_string_new_utf16_handle (MonoDomain
*domain
, const gunichar2
*text
, gint32 len
, MonoError
*error
);
2121 mono_string_new_utf8_len (MonoDomain
*domain
, const char *text
, guint length
, MonoError
*error
);
2124 mono_string_from_utf16_checked (const mono_unichar2
*data
, MonoError
*error
);
2127 mono_string_from_utf32_checked (const mono_unichar4
*data
, MonoError
*error
);
2130 mono_ldstr_utf8 (MonoImage
*image
, guint32 idx
, MonoError
*error
);
2133 mono_utf16_to_utf8 (const mono_unichar2
*s
, gsize slength
, MonoError
*error
);
2136 mono_utf16_to_utf8len (const mono_unichar2
*s
, gsize slength
, gsize
*utf8_length
, MonoError
*error
);
2139 mono_runtime_object_init_checked (MonoObject
*this_obj
, MonoError
*error
);
2141 MONO_PROFILER_API MonoObject
*
2142 mono_runtime_try_invoke (MonoMethod
*method
, void *obj
, void **params
, MonoObject
**exc
, MonoError
*error
);
2144 // The exc parameter is deliberately missing and so far this has proven to reduce code duplication.
2145 // In particular, if an exception is returned from underlying otherwise succeeded call,
2146 // is set into the MonoError with mono_error_set_exception_instance.
2147 // The result is that caller need only check MonoError.
2149 mono_runtime_try_invoke_handle (MonoMethod
*method
, MonoObjectHandle obj
, void **params
, MonoError
* error
);
2152 mono_runtime_invoke_checked (MonoMethod
*method
, void *obj
, void **params
, MonoError
*error
);
2155 mono_runtime_invoke_handle (MonoMethod
*method
, MonoObjectHandle obj
, void **params
, MonoError
* error
);
2158 mono_runtime_invoke_handle_void (MonoMethod
*method
, MonoObjectHandle obj
, void **params
, MonoError
* error
);
2161 mono_runtime_try_invoke_array (MonoMethod
*method
, void *obj
, MonoArray
*params
,
2162 MonoObject
**exc
, MonoError
*error
);
2165 mono_runtime_invoke_array_checked (MonoMethod
*method
, void *obj
, MonoArray
*params
,
2169 mono_compile_method_checked (MonoMethod
*method
, MonoError
*error
);
2172 mono_runtime_delegate_try_invoke (MonoObject
*delegate
, void **params
,
2173 MonoObject
**exc
, MonoError
*error
);
2176 mono_runtime_delegate_invoke_checked (MonoObject
*delegate
, void **params
,
2180 mono_runtime_get_main_args_handle (MonoError
*error
);
2183 mono_runtime_run_main_checked (MonoMethod
*method
, int argc
, char* argv
[],
2187 mono_runtime_try_run_main (MonoMethod
*method
, int argc
, char* argv
[],
2191 mono_runtime_exec_main_checked (MonoMethod
*method
, MonoArray
*args
, MonoError
*error
);
2194 mono_runtime_try_exec_main (MonoMethod
*method
, MonoArray
*args
, MonoObject
**exc
);
2197 mono_try_assembly_resolve_handle (MonoAssemblyLoadContext
*alc
, MonoStringHandle fname
, MonoAssembly
*requesting
, gboolean refonly
, MonoError
*error
);
2200 mono_runtime_object_init_handle (MonoObjectHandle this_obj
, MonoError
*error
);
2202 /* GC write barriers support */
2204 mono_gc_wbarrier_object_copy_handle (MonoObjectHandle obj
, MonoObjectHandle src
);
2207 mono_class_get_virtual_method (MonoClass
*klass
, MonoMethod
*method
, gboolean is_proxy
, MonoError
*error
);
2210 mono_string_empty_handle (MonoDomain
*domain
);
2213 * mono_object_get_data:
2215 * Return a pointer to the beginning of data inside a MonoObject.
2217 static inline gpointer
2218 mono_object_get_data (MonoObject
*o
)
2220 return (guint8
*)o
+ MONO_ABI_SIZEOF (MonoObject
);
2223 #define mono_handle_get_data_unsafe(handle) ((gpointer)((guint8*)MONO_HANDLE_RAW (handle) + MONO_ABI_SIZEOF (MonoObject)))
2226 mono_vtype_get_field_addr (gpointer vtype
, MonoClassField
*field
);
2228 #define MONO_OBJECT_SETREF_INTERNAL(obj,fieldname,value) do { \
2229 mono_gc_wbarrier_set_field_internal ((MonoObject*)(obj), &((obj)->fieldname), (MonoObject*)value); \
2230 /*(obj)->fieldname = (value);*/ \
2233 /* This should be used if 's' can reside on the heap */
2234 #define MONO_STRUCT_SETREF_INTERNAL(s,field,value) do { \
2235 mono_gc_wbarrier_generic_store_internal (&((s)->field), (MonoObject*)(value)); \
2238 static inline gunichar2
*
2239 mono_string_chars_internal (MonoString
*s
)
2241 MONO_REQ_GC_UNSAFE_MODE
;
2246 mono_string_length_internal (MonoString
*s
)
2248 MONO_REQ_GC_UNSAFE_MODE
;
2253 mono_string_empty_internal (MonoDomain
*domain
);
2256 mono_string_to_utf8len (MonoStringHandle s
, gsize
*utf8len
, MonoError
*error
);
2259 mono_string_to_utf8_checked_internal (MonoString
*string_obj
, MonoError
*error
);
2262 mono_string_equal_internal (MonoString
*s1
, MonoString
*s2
);
2265 mono_string_hash_internal (MonoString
*s
);
2268 mono_object_hash_internal (MonoObject
* obj
);
2272 mono_value_copy_internal (void* dest
, const void* src
, MonoClass
*klass
);
2275 mono_value_copy_array_internal (MonoArray
*dest
, int dest_idx
, const void* src
, int count
);
2277 MONO_PROFILER_API MonoVTable
* mono_object_get_vtable_internal (MonoObject
*obj
);
2280 mono_object_get_domain_internal (MonoObject
*obj
);
2282 static inline gpointer
2283 mono_object_unbox_internal (MonoObject
*obj
)
2285 /* add assert for valuetypes? */
2286 g_assert (m_class_is_valuetype (mono_object_class (obj
)));
2287 return mono_object_get_data (obj
);
2292 mono_monitor_exit_internal (MonoObject
*obj
);
2294 MONO_PROFILER_API
unsigned mono_object_get_size_internal (MonoObject
*o
);
2296 MONO_PROFILER_API MonoDomain
* mono_vtable_domain_internal (MonoVTable
*vtable
);
2298 MONO_PROFILER_API MonoClass
* mono_vtable_class_internal (MonoVTable
*vtable
);
2301 mono_object_get_virtual_method_internal (MonoObject
*obj
, MonoMethod
*method
);
2304 mono_get_delegate_invoke_internal (MonoClass
*klass
);
2307 mono_get_delegate_begin_invoke_internal (MonoClass
*klass
);
2310 mono_get_delegate_end_invoke_internal (MonoClass
*klass
);
2313 mono_unhandled_exception_internal (MonoObject
*exc
);
2316 mono_print_unhandled_exception_internal (MonoObject
*exc
);
2319 mono_raise_exception_internal (MonoException
*ex
);
2322 mono_field_set_value_internal (MonoObject
*obj
, MonoClassField
*field
, void *value
);
2325 mono_field_static_set_value_internal (MonoVTable
*vt
, MonoClassField
*field
, void *value
);
2328 mono_field_get_value_internal (MonoObject
*obj
, MonoClassField
*field
, void *value
);
2330 MonoMethod
* mono_get_context_capture_method (void);
2333 mono_runtime_get_aotid_arr (void);
2335 /* GC handles support
2337 * A handle can be created to refer to a managed object and either prevent it
2338 * from being garbage collected or moved or to be able to know if it has been
2339 * collected or not (weak references).
2340 * mono_gchandle_new () is used to prevent an object from being garbage collected
2341 * until mono_gchandle_free() is called. Use a TRUE value for the pinned argument to
2342 * prevent the object from being moved (this should be avoided as much as possible
2343 * and this should be used only for shorts periods of time or performance will suffer).
2344 * To create a weakref use mono_gchandle_new_weakref (): track_resurrection should
2345 * usually be false (see the GC docs for more details).
2346 * mono_gchandle_get_target () can be used to get the object referenced by both kinds
2347 * of handle: for a weakref handle, if an object has been collected, it will return NULL.
2350 mono_gchandle_new_internal (MonoObject
*obj
, mono_bool pinned
);
2353 mono_gchandle_new_weakref_internal (MonoObject
*obj
, mono_bool track_resurrection
);
2357 mono_gchandle_get_target_internal (uint32_t gchandle
);
2359 void mono_gchandle_free_internal (uint32_t gchandle
);
2361 /* Reference queue support
2363 * A reference queue is used to get notifications of when objects are collected.
2364 * Call mono_gc_reference_queue_new to create a new queue and pass the callback that
2365 * will be invoked when registered objects are collected.
2366 * Call mono_gc_reference_queue_add to register a pair of objects and data within a queue.
2367 * The callback will be triggered once an object is both unreachable and finalized.
2370 mono_gc_reference_queue_new_internal (mono_reference_queue_callback callback
);
2373 mono_gc_reference_queue_free_internal (MonoReferenceQueue
*queue
);
2376 mono_gc_reference_queue_add_internal (MonoReferenceQueue
*queue
, MonoObject
*obj
, void *user_data
);
2378 #define mono_gc_reference_queue_add_handle(queue, obj, user_data) \
2379 (mono_gc_reference_queue_add_internal ((queue), MONO_HANDLE_RAW (MONO_HANDLE_CAST (MonoObject, obj)), (user_data)))
2381 /* GC write barriers support */
2383 mono_gc_wbarrier_set_field_internal (MonoObject
*obj
, void* field_ptr
, MonoObject
* value
);
2386 mono_gc_wbarrier_set_arrayref_internal (MonoArray
*arr
, void* slot_ptr
, MonoObject
* value
);
2389 mono_gc_wbarrier_arrayref_copy_internal (void* dest_ptr
, const void* src_ptr
, int count
);
2392 mono_gc_wbarrier_generic_store_internal (void volatile* ptr
, MonoObject
* value
);
2395 mono_gc_wbarrier_generic_store_atomic_internal (void *ptr
, MonoObject
*value
);
2399 mono_gc_wbarrier_generic_nostore_internal (void* ptr
);
2402 mono_gc_wbarrier_value_copy_internal (void* dest
, const void* src
, int count
, MonoClass
*klass
);
2405 mono_gc_wbarrier_object_copy_internal (MonoObject
* obj
, MonoObject
*src
);
2407 #endif /* __MONO_OBJECT_INTERNALS_H__ */