domain-internals.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /**
  2. * \file
  3. * Appdomain-related internal data structures and functions.
  4. * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
  5. * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  6. */
  7. #ifndef __MONO_METADATA_DOMAIN_INTERNALS_H__
  8. #define __MONO_METADATA_DOMAIN_INTERNALS_H__
  9. #include <mono/utils/mono-forward-internal.h>
  10. #include <mono/metadata/object-forward.h>
  11. #include <mono/metadata/appdomain.h>
  12. #include <mono/metadata/mempool.h>
  13. #include <mono/metadata/lock-tracer.h>
  14. #include <mono/utils/mono-codeman.h>
  15. #include <mono/metadata/mono-hash.h>
  16. #include <mono/metadata/mono-conc-hash.h>
  17. #include <mono/utils/mono-compiler.h>
  18. #include <mono/utils/mono-internal-hash.h>
  19. #include <mono/metadata/loader-internals.h>
  20. #include <mono/metadata/mempool-internals.h>
  21. #include <mono/metadata/handle-decl.h>
  22. /* Mono appdomain support is deeply itegrated in the runtime, as a result, even
  23. * though .NET Standard does not include System.AppDomain in
  24. * System.Private.CoreLib, we still depend on having an appdomain class.
  25. * So we move it to Mono.MonoDomain
  26. *
  27. */
  28. #ifndef ENABLE_NETCORE
  29. #define MONO_APPDOMAIN_CLASS_NAME_SPACE "System"
  30. #define MONO_APPDOMAIN_CLASS_NAME "AppDomain"
  31. #define MONO_APPDOMAIN_SETUP_CLASS_NAME_SPACE "System"
  32. #define MONO_APPDOMAIN_SETUP_CLASS_NAME "AppDomainSetup"
  33. #else
  34. /* We don't care anymore about the managed appdomain representation
  35. * so we just use a sentinel System.Object in the parts of the code that still care
  36. */
  37. /*
  38. #define MONO_APPDOMAIN_CLASS_NAME_SPACE "System"
  39. #define MONO_APPDOMAIN_CLASS_NAME "Object"
  40. */
  41. #endif
  42. G_BEGIN_DECLS
  43. /*
  44. * If this is set, the memory belonging to appdomains is not freed when a domain is
  45. * unloaded, and assemblies loaded by the appdomain are not unloaded either. This
  46. * allows us to use typed gc in non-default appdomains too, leading to increased
  47. * performance.
  48. */
  49. extern gboolean mono_dont_free_domains;
  50. #ifndef ENABLE_NETCORE
  51. /* This is a copy of System.AppDomainSetup */
  52. typedef struct {
  53. MonoObject object;
  54. MonoString *application_base;
  55. MonoString *application_name;
  56. MonoString *cache_path;
  57. MonoString *configuration_file;
  58. MonoString *dynamic_base;
  59. MonoString *license_file;
  60. MonoString *private_bin_path;
  61. MonoString *private_bin_path_probe;
  62. MonoString *shadow_copy_directories;
  63. MonoString *shadow_copy_files;
  64. MonoBoolean publisher_policy;
  65. MonoBoolean path_changed;
  66. int loader_optimization;
  67. MonoBoolean disallow_binding_redirects;
  68. MonoBoolean disallow_code_downloads;
  69. MonoObject *activation_arguments; /* it is System.Object in 1.x, ActivationArguments in 2.0 */
  70. MonoObject *domain_initializer;
  71. MonoObject *application_trust; /* it is System.Object in 1.x, ApplicationTrust in 2.0 */
  72. MonoArray *domain_initializer_args;
  73. MonoBoolean disallow_appbase_probe;
  74. MonoArray *configuration_bytes;
  75. MonoArray *serialized_non_primitives;
  76. } MonoAppDomainSetup;
  77. #endif
  78. typedef struct _MonoJitInfoTable MonoJitInfoTable;
  79. typedef struct _MonoJitInfoTableChunk MonoJitInfoTableChunk;
  80. #define MONO_JIT_INFO_TABLE_CHUNK_SIZE 64
  81. struct _MonoJitInfoTableChunk
  82. {
  83. int refcount;
  84. volatile int num_elements;
  85. volatile gint8 *last_code_end;
  86. MonoJitInfo *next_tombstone;
  87. MonoJitInfo * volatile data [MONO_JIT_INFO_TABLE_CHUNK_SIZE];
  88. };
  89. struct _MonoJitInfoTable
  90. {
  91. MonoDomain *domain;
  92. int num_chunks;
  93. int num_valid;
  94. MonoJitInfoTableChunk *chunks [MONO_ZERO_LEN_ARRAY];
  95. };
  96. #define MONO_SIZEOF_JIT_INFO_TABLE (sizeof (struct _MonoJitInfoTable) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
  97. typedef GArray MonoAotModuleInfoTable;
  98. typedef struct {
  99. guint32 flags;
  100. gint32 exvar_offset;
  101. gpointer try_start;
  102. gpointer try_end;
  103. gpointer handler_start;
  104. /*
  105. * For LLVM compiled code, this is the index of the il clause
  106. * associated with this handler.
  107. */
  108. int clause_index;
  109. uint32_t try_offset;
  110. uint32_t try_len;
  111. uint32_t handler_offset;
  112. uint32_t handler_len;
  113. union {
  114. MonoClass *catch_class;
  115. gpointer filter;
  116. gpointer handler_end;
  117. } data;
  118. } MonoJitExceptionInfo;
  119. /*
  120. * Contains information about the type arguments for generic shared methods.
  121. */
  122. typedef struct {
  123. gboolean is_gsharedvt;
  124. } MonoGenericSharingContext;
  125. /* Simplified DWARF location list entry */
  126. typedef struct {
  127. /* Whenever the value is in a register */
  128. gboolean is_reg;
  129. /*
  130. * If is_reg is TRUE, the register which contains the value. Otherwise
  131. * the base register.
  132. */
  133. int reg;
  134. /*
  135. * If is_reg is FALSE, the offset of the stack location relative to 'reg'.
  136. * Otherwise, 0.
  137. */
  138. int offset;
  139. /*
  140. * Offsets of the PC interval where the value is in this location.
  141. */
  142. int from, to;
  143. } MonoDwarfLocListEntry;
  144. typedef struct
  145. {
  146. MonoGenericSharingContext *generic_sharing_context;
  147. int nlocs;
  148. MonoDwarfLocListEntry *locations;
  149. gint32 this_offset;
  150. guint8 this_reg;
  151. gboolean has_this:1;
  152. gboolean this_in_reg:1;
  153. } MonoGenericJitInfo;
  154. /*
  155. A try block hole is used to represent a non-contiguous part of
  156. of a segment of native code protected by a given .try block.
  157. Usually, a try block is defined as a contiguous segment of code.
  158. But in some cases it's needed to have some parts of it to not be protected.
  159. For example, given "try {} finally {}", the code in the .try block to call
  160. the finally part looks like:
  161. try {
  162. ...
  163. call finally_block
  164. adjust stack
  165. jump outside try block
  166. ...
  167. } finally {
  168. ...
  169. }
  170. The instructions between the call and the jump should not be under the try block since they happen
  171. after the finally block executes, which means if an async exceptions happens at that point we would
  172. execute the finally clause twice. So, to avoid this, we introduce a hole in the try block to signal
  173. that those instructions are not protected.
  174. */
  175. typedef struct
  176. {
  177. guint32 offset;
  178. guint16 clause;
  179. guint16 length;
  180. } MonoTryBlockHoleJitInfo;
  181. typedef struct
  182. {
  183. guint16 num_holes;
  184. MonoTryBlockHoleJitInfo holes [MONO_ZERO_LEN_ARRAY];
  185. } MonoTryBlockHoleTableJitInfo;
  186. typedef struct
  187. {
  188. guint32 stack_size;
  189. guint32 epilog_size;
  190. } MonoArchEHJitInfo;
  191. typedef struct {
  192. /* Relative to code_start */
  193. int thunks_offset;
  194. int thunks_size;
  195. } MonoThunkJitInfo;
  196. typedef struct {
  197. guint8 *unw_info;
  198. int unw_info_len;
  199. } MonoUnwindJitInfo;
  200. typedef enum {
  201. JIT_INFO_NONE = 0,
  202. JIT_INFO_HAS_GENERIC_JIT_INFO = (1 << 0),
  203. JIT_INFO_HAS_TRY_BLOCK_HOLES = (1 << 1),
  204. JIT_INFO_HAS_ARCH_EH_INFO = (1 << 2),
  205. JIT_INFO_HAS_THUNK_INFO = (1 << 3),
  206. /*
  207. * If this is set, the unwind info is stored in the structure, instead of being pointed to by the
  208. * 'unwind_info' field.
  209. */
  210. JIT_INFO_HAS_UNWIND_INFO = (1 << 4)
  211. } MonoJitInfoFlags;
  212. G_ENUM_FUNCTIONS (MonoJitInfoFlags)
  213. struct _MonoJitInfo {
  214. /* NOTE: These first two elements (method and
  215. next_jit_code_hash) must be in the same order and at the
  216. same offset as in RuntimeMethod, because of the jit_code_hash
  217. internal hash table in MonoDomain. */
  218. union {
  219. MonoMethod *method;
  220. MonoImage *image;
  221. MonoAotModule *aot_info;
  222. MonoTrampInfo *tramp_info;
  223. } d;
  224. union {
  225. MonoJitInfo *next_jit_code_hash;
  226. MonoJitInfo *next_tombstone;
  227. } n;
  228. gpointer code_start;
  229. guint32 unwind_info;
  230. int code_size;
  231. guint32 num_clauses:15;
  232. /* Whenever the code is domain neutral or 'shared' */
  233. gboolean domain_neutral:1;
  234. gboolean has_generic_jit_info:1;
  235. gboolean has_try_block_holes:1;
  236. gboolean has_arch_eh_info:1;
  237. gboolean has_thunk_info:1;
  238. gboolean has_unwind_info:1;
  239. gboolean from_aot:1;
  240. gboolean from_llvm:1;
  241. gboolean dbg_attrs_inited:1;
  242. gboolean dbg_hidden:1;
  243. /* Whenever this jit info was loaded in async context */
  244. gboolean async:1;
  245. gboolean dbg_step_through:1;
  246. gboolean dbg_non_user_code:1;
  247. /*
  248. * Whenever this jit info refers to a trampoline.
  249. * d.tramp_info contains additional data in this case.
  250. */
  251. gboolean is_trampoline:1;
  252. /* Whenever this jit info refers to an interpreter method */
  253. gboolean is_interp:1;
  254. gboolean dbg_ignore : 1;
  255. /* FIXME: Embed this after the structure later*/
  256. gpointer gc_info; /* Currently only used by SGen */
  257. gpointer seq_points;
  258. MonoJitExceptionInfo clauses [MONO_ZERO_LEN_ARRAY];
  259. /* There is an optional MonoGenericJitInfo after the clauses */
  260. /* There is an optional MonoTryBlockHoleTableJitInfo after MonoGenericJitInfo clauses*/
  261. /* There is an optional MonoArchEHJitInfo after MonoTryBlockHoleTableJitInfo */
  262. /* There is an optional MonoThunkJitInfo after MonoArchEHJitInfo */
  263. };
  264. #define MONO_SIZEOF_JIT_INFO (offsetof (struct _MonoJitInfo, clauses))
  265. typedef struct {
  266. gpointer *static_data; /* Used to free the static data without going through the MonoAppContext object itself. */
  267. MonoGCHandle gc_handle;
  268. } ContextStaticData;
  269. struct _MonoAppContext {
  270. MonoObject obj;
  271. gint32 domain_id;
  272. gint32 context_id;
  273. gpointer *static_data;
  274. ContextStaticData *data;
  275. };
  276. /* Lock-free allocator */
  277. typedef struct {
  278. guint8 *mem;
  279. gpointer prev;
  280. int size, pos;
  281. } LockFreeMempoolChunk;
  282. typedef struct {
  283. LockFreeMempoolChunk *current, *chunks;
  284. } LockFreeMempool;
  285. /*
  286. * We have two unloading states because the domain
  287. * must remain fully functional while AppDomain::DomainUnload is
  288. * processed.
  289. * After that unloading began and all domain facilities are teared down
  290. * such as execution of new threadpool jobs.
  291. */
  292. typedef enum {
  293. MONO_APPDOMAIN_CREATED,
  294. MONO_APPDOMAIN_UNLOADING_START,
  295. MONO_APPDOMAIN_UNLOADING,
  296. MONO_APPDOMAIN_UNLOADED
  297. } MonoAppDomainState;
  298. typedef struct _MonoThunkFreeList {
  299. guint32 size;
  300. int length; /* only valid for the wait list */
  301. struct _MonoThunkFreeList *next;
  302. } MonoThunkFreeList;
  303. typedef struct _MonoJitCodeHash MonoJitCodeHash;
  304. struct _MonoDomain {
  305. /*
  306. * This lock must never be taken before the loader lock,
  307. * i.e. if both are taken by the same thread, the loader lock
  308. * must taken first.
  309. */
  310. MonoCoopMutex lock;
  311. /*
  312. * keep all the managed objects close to each other for the precise GC
  313. * For the Boehm GC we additionally keep close also other GC-tracked pointers.
  314. */
  315. #ifndef ENABLE_NETCORE
  316. #define MONO_DOMAIN_FIRST_OBJECT setup
  317. MonoAppDomainSetup *setup;
  318. #else
  319. #define MONO_DOMAIN_FIRST_OBJECT domain
  320. #endif
  321. MonoAppDomain *domain;
  322. MonoAppContext *default_context;
  323. MonoException *out_of_memory_ex;
  324. MonoException *null_reference_ex;
  325. MonoException *stack_overflow_ex;
  326. /* typeof (void) */
  327. MonoObject *typeof_void;
  328. /* Ephemeron Tombstone*/
  329. MonoObject *ephemeron_tombstone;
  330. /* new MonoType [0] */
  331. MonoArray *empty_types;
  332. MonoString *empty_string;
  333. /*
  334. * The fields between FIRST_GC_TRACKED and LAST_GC_TRACKED are roots, but
  335. * not object references.
  336. */
  337. #define MONO_DOMAIN_FIRST_GC_TRACKED env
  338. MonoGHashTable *env;
  339. MonoGHashTable *ldstr_table;
  340. #define MONO_DOMAIN_LAST_GC_TRACKED ldstr_table
  341. guint32 state;
  342. /* Needed by Thread:GetDomainID() */
  343. gint32 domain_id;
  344. gint32 shadow_serial;
  345. /*
  346. * For framework Mono, this is every assembly loaded in this
  347. * domain. For netcore, this is every assembly loaded in every ALC in
  348. * this domain. In netcore, the thread that adds an assembly to its
  349. * MonoAssemblyLoadContext:loaded_assemblies should also add it to this
  350. * list.
  351. */
  352. GSList *domain_assemblies;
  353. MonoAssembly *entry_assembly;
  354. char *friendly_name;
  355. /* maps remote class key -> MonoRemoteClass */
  356. GHashTable *proxy_vtable_hash;
  357. /* Protected by 'jit_code_hash_lock' */
  358. MonoInternalHashTable jit_code_hash;
  359. mono_mutex_t jit_code_hash_lock;
  360. int num_jit_info_table_duplicates;
  361. MonoJitInfoTable *
  362. volatile jit_info_table;
  363. /*
  364. * Contains information about AOT loaded code.
  365. * Only used in the root domain.
  366. */
  367. MonoJitInfoTable *
  368. volatile aot_modules;
  369. GSList *jit_info_free_queue;
  370. /* Used when loading assemblies */
  371. gchar **search_path;
  372. gchar *private_bin_path;
  373. LockFreeMempool *lock_free_mp;
  374. /* Used by remoting proxies */
  375. MonoMethod *create_proxy_for_type_method;
  376. MonoMethod *private_invoke_method;
  377. /* Used to store offsets of thread and context static fields */
  378. GHashTable *special_static_fields;
  379. /*
  380. * This must be a GHashTable, since these objects can't be finalized
  381. * if the hashtable contains a GC visible reference to them.
  382. */
  383. GHashTable *finalizable_objects_hash; // TODO: this needs to be moved for unloadability with non-sgen gc
  384. /* Protects the three hashes above */
  385. mono_mutex_t finalizable_objects_hash_lock;
  386. /* Used when accessing 'domain_assemblies' */
  387. MonoCoopMutex assemblies_lock;
  388. GHashTable *generic_virtual_cases;
  389. /* Information maintained by the JIT engine */
  390. gpointer runtime_info;
  391. /* Information maintained by mono-debug.c */
  392. gpointer debug_info;
  393. /* Contains the compiled runtime invoke wrapper used by finalizers */
  394. gpointer finalize_runtime_invoke;
  395. /* Contains the compiled runtime invoke wrapper used by async resylt creation to capture thread context*/
  396. gpointer capture_context_runtime_invoke;
  397. /* Contains the compiled method used by async resylt creation to capture thread context*/
  398. gpointer capture_context_method;
  399. /* Assembly bindings, the per-domain part */
  400. GSList *assembly_bindings;
  401. gboolean assembly_bindings_parsed;
  402. /* Used by socket-io.c */
  403. /* These are domain specific, since the assembly can be unloaded */
  404. MonoImage *socket_assembly;
  405. MonoClass *sockaddr_class;
  406. MonoClassField *sockaddr_data_field;
  407. MonoClassField *sockaddr_data_length_field;
  408. /* Cache function pointers for architectures */
  409. /* that require wrappers */
  410. GHashTable *ftnptrs_hash; // TODO: need to move?
  411. /* Maps MonoMethod* to weak links to DynamicMethod objects */
  412. GHashTable *method_to_dyn_method;
  413. /* <ThrowUnobservedTaskExceptions /> support */
  414. gboolean throw_unobserved_task_exceptions;
  415. guint32 execution_context_field_offset;
  416. #ifdef ENABLE_NETCORE
  417. GSList *alcs;
  418. MonoAssemblyLoadContext *default_alc;
  419. MonoCoopMutex alcs_lock; /* Used when accessing 'alcs' */
  420. #endif
  421. #ifndef ENABLE_NETCORE
  422. // Holds domain code memory
  423. MonoMemoryManager *memory_manager;
  424. #endif
  425. };
  426. typedef struct {
  427. guint16 major, minor, build, revision;
  428. } AssemblyVersionSet;
  429. /* MonoRuntimeInfo: Contains information about versions supported by this runtime */
  430. typedef struct {
  431. char runtime_version [12];
  432. char framework_version [4];
  433. AssemblyVersionSet version_sets [5];
  434. } MonoRuntimeInfo;
  435. static inline void
  436. mono_domain_assemblies_lock (MonoDomain *domain)
  437. {
  438. mono_locks_coop_acquire (&domain->assemblies_lock, DomainAssembliesLock);
  439. }
  440. static inline void
  441. mono_domain_assemblies_unlock (MonoDomain *domain)
  442. {
  443. mono_locks_coop_release (&domain->assemblies_lock, DomainAssembliesLock);
  444. }
  445. #define mono_domain_jit_code_hash_lock(domain) mono_locks_os_acquire(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
  446. #define mono_domain_jit_code_hash_unlock(domain) mono_locks_os_release(&(domain)->jit_code_hash_lock, DomainJitCodeHashLock)
  447. typedef MonoDomain* (*MonoLoadFunc) (const char *filename, const char *runtime_version);
  448. void mono_domain_lock (MonoDomain *domain);
  449. void mono_domain_unlock (MonoDomain *domain);
  450. void
  451. mono_install_runtime_load (MonoLoadFunc func);
  452. MonoDomain*
  453. mono_runtime_load (const char *filename, const char *runtime_version);
  454. typedef void (*MonoCreateDomainFunc) (MonoDomain *domain);
  455. void
  456. mono_install_create_domain_hook (MonoCreateDomainFunc func);
  457. typedef void (*MonoFreeDomainFunc) (MonoDomain *domain);
  458. void
  459. mono_install_free_domain_hook (MonoFreeDomainFunc func);
  460. void
  461. mono_runtime_quit_internal (void);
  462. void
  463. mono_cleanup (void);
  464. void
  465. mono_close_exe_image (void);
  466. int
  467. mono_jit_info_size (MonoJitInfoFlags flags, int num_clauses, int num_holes);
  468. void
  469. mono_jit_info_init (MonoJitInfo *ji, MonoMethod *method, guint8 *code, int code_size,
  470. MonoJitInfoFlags flags, int num_clauses, int num_holes);
  471. MonoJitInfoTable *
  472. mono_jit_info_table_new (MonoDomain *domain);
  473. void
  474. mono_jit_info_table_free (MonoJitInfoTable *table);
  475. void
  476. mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
  477. void
  478. mono_jit_info_table_remove (MonoDomain *domain, MonoJitInfo *ji);
  479. void
  480. mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end);
  481. MonoGenericJitInfo*
  482. mono_jit_info_get_generic_jit_info (MonoJitInfo *ji);
  483. MonoGenericSharingContext*
  484. mono_jit_info_get_generic_sharing_context (MonoJitInfo *ji);
  485. void
  486. mono_jit_info_set_generic_sharing_context (MonoJitInfo *ji, MonoGenericSharingContext *gsctx);
  487. char *
  488. mono_make_shadow_copy (const char *filename, MonoError *error);
  489. gboolean
  490. mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name);
  491. // TODO: remove these on netcore, we should always be explicit about allocating from ALCs
  492. //#ifndef ENABLE_NETCORE
  493. gpointer
  494. mono_domain_alloc (MonoDomain *domain, guint size);
  495. #define mono_domain_alloc(domain, size) (g_cast (mono_domain_alloc ((domain), (size))))
  496. gpointer
  497. mono_domain_alloc0 (MonoDomain *domain, guint size);
  498. #define mono_domain_alloc0(domain, size) (g_cast (mono_domain_alloc0 ((domain), (size))))
  499. //#endif
  500. gpointer
  501. mono_domain_alloc0_lock_free (MonoDomain *domain, guint size);
  502. #define mono_domain_alloc0_lock_free(domain, size) (g_cast (mono_domain_alloc0_lock_free ((domain), (size))))
  503. void
  504. mono_domain_unset (void);
  505. void
  506. mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exception);
  507. #ifndef ENABLE_NETCORE
  508. gboolean
  509. mono_domain_set_config_checked (MonoDomain *domain, const char *base_dir, const char *config_file_name, MonoError *error);
  510. #endif
  511. MonoTryBlockHoleTableJitInfo*
  512. mono_jit_info_get_try_block_hole_table_info (MonoJitInfo *ji);
  513. MonoArchEHJitInfo*
  514. mono_jit_info_get_arch_eh_info (MonoJitInfo *ji);
  515. MonoThunkJitInfo*
  516. mono_jit_info_get_thunk_info (MonoJitInfo *ji);
  517. MonoUnwindJitInfo*
  518. mono_jit_info_get_unwind_info (MonoJitInfo *ji);
  519. /*
  520. * Installs a new function which is used to return a MonoJitInfo for a method inside
  521. * an AOT module.
  522. */
  523. typedef MonoJitInfo *(*MonoJitInfoFindInAot) (MonoDomain *domain, MonoImage *image, gpointer addr);
  524. void mono_install_jit_info_find_in_aot (MonoJitInfoFindInAot func);
  525. void
  526. mono_jit_code_hash_init (MonoInternalHashTable *jit_code_hash);
  527. MonoAssembly *
  528. mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus *status);
  529. const MonoRuntimeInfo*
  530. mono_get_runtime_info (void);
  531. void
  532. mono_runtime_set_no_exec (gboolean val);
  533. gboolean
  534. mono_runtime_get_no_exec (void);
  535. void
  536. mono_domain_parse_assembly_bindings (MonoDomain *domain, int amajor, int aminor, gchar *domain_config_file_name);
  537. UNITY_MONO_API gboolean
  538. mono_assembly_name_parse (const char *name, MonoAssemblyName *aname);
  539. MonoAssembly *
  540. mono_domain_assembly_open_internal (MonoDomain *domain, MonoAssemblyLoadContext *alc, const char *name);
  541. MonoImage *mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc,
  542. const char *filename,
  543. MonoImageOpenStatus *status,
  544. gboolean refonly,
  545. const char *culture);
  546. MonoAssembly *
  547. mono_try_assembly_resolve (MonoAssemblyLoadContext *alc, const char *fname, MonoAssembly *requesting, gboolean refonly, MonoError *error);
  548. MonoAssembly *
  549. mono_domain_assembly_postload_search (MonoAssemblyLoadContext *alc, MonoAssembly *requesting, MonoAssemblyName *aname, gboolean refonly, gboolean postload, gpointer user_data, MonoError *error);
  550. #ifndef ENABLE_NETCORE
  551. void mono_domain_set_options_from_config (MonoDomain *domain);
  552. #endif
  553. int mono_framework_version (void);
  554. void mono_assembly_cleanup_domain_bindings (guint32 domain_id);
  555. MonoJitInfo* mono_jit_info_table_find_internal (MonoDomain *domain, gpointer addr, gboolean try_aot, gboolean allow_trampolines);
  556. void
  557. mono_jit_info_table_foreach_internal (MonoDomain *domain, MonoJitInfoFunc func, gpointer user_data);
  558. void mono_enable_debug_domain_unload (gboolean enable);
  559. void
  560. mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoThreadAttachCB attach_cb, MonoError *error);
  561. void
  562. mono_context_init_checked (MonoDomain *domain, MonoError *error);
  563. gboolean
  564. mono_assembly_has_reference_assembly_attribute (MonoAssembly *assembly, MonoError *error);
  565. GPtrArray*
  566. mono_domain_get_assemblies (MonoDomain *domain, gboolean refonly);
  567. void
  568. mono_runtime_register_appctx_properties (int nprops, const char **keys, const char **values);
  569. void
  570. mono_runtime_install_appctx_properties (void);
  571. gboolean
  572. mono_domain_set_fast (MonoDomain *domain, gboolean force);
  573. MonoAssemblyLoadContext *
  574. mono_domain_default_alc (MonoDomain *domain);
  575. #ifdef ENABLE_NETCORE
  576. static inline void
  577. mono_domain_alcs_lock (MonoDomain *domain)
  578. {
  579. mono_coop_mutex_lock (&domain->alcs_lock);
  580. }
  581. static inline void
  582. mono_domain_alcs_unlock (MonoDomain *domain)
  583. {
  584. mono_coop_mutex_unlock (&domain->alcs_lock);
  585. }
  586. #endif
  587. static inline
  588. MonoAssemblyLoadContext *
  589. mono_domain_ambient_alc (MonoDomain *domain)
  590. {
  591. /*
  592. * FIXME: All the callers of mono_domain_ambient_alc should get an ALC
  593. * passed to them from their callers.
  594. */
  595. return mono_domain_default_alc (domain);
  596. }
  597. static inline MonoMemoryManager *
  598. mono_domain_memory_manager (MonoDomain *domain)
  599. {
  600. #ifdef ENABLE_NETCORE
  601. return (MonoMemoryManager *)mono_domain_default_alc (domain)->memory_manager;
  602. #else
  603. return domain->memory_manager;
  604. #endif
  605. }
  606. static inline MonoMemoryManager *
  607. mono_domain_ambient_memory_manager (MonoDomain *domain)
  608. {
  609. // FIXME: All callers of mono_domain_ambient_memory_manager should get a MemoryManager from their callers or context
  610. return mono_domain_memory_manager (domain);
  611. }
  612. G_END_DECLS
  613. #endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */