} TrampolinePage;
static GHashTable *aot_modules;
-#define mono_aot_lock() mono_mutex_lock (&aot_mutex)
-#define mono_aot_unlock() mono_mutex_unlock (&aot_mutex)
+#define mono_aot_lock() mono_os_mutex_lock (&aot_mutex)
+#define mono_aot_unlock() mono_os_mutex_unlock (&aot_mutex)
static mono_mutex_t aot_mutex;
/*
#define USE_PAGE_TRAMPOLINES 0
#endif
-#define mono_aot_page_lock() mono_mutex_lock (&aot_page_mutex)
-#define mono_aot_page_unlock() mono_mutex_unlock (&aot_page_mutex)
+#define mono_aot_page_lock() mono_os_mutex_lock (&aot_page_mutex)
+#define mono_aot_page_unlock() mono_os_mutex_unlock (&aot_page_mutex)
static mono_mutex_t aot_page_mutex;
static MonoAotModule *mscorlib_aot_module;
static inline void
amodule_lock (MonoAotModule *amodule)
{
- mono_mutex_lock (&amodule->mutex);
+ mono_os_mutex_lock (&amodule->mutex);
}
static inline void
amodule_unlock (MonoAotModule *amodule)
{
- mono_mutex_unlock (&amodule->mutex);
+ mono_os_mutex_unlock (&amodule->mutex);
}
/*
g_assert_not_reached ();
break;
}
- if (target && wrapper != target)
- return FALSE;
- ref->method = wrapper;
+ if (target) {
+ /*
+ * Due to the way mini_get_shared_method () works, we could end up with
+ * multiple copies of the same wrapper.
+ */
+ if (wrapper->klass != target->klass)
+ return FALSE;
+ ref->method = target;
+ } else {
+ ref->method = wrapper;
+ }
} else {
/*
* These wrappers are associated with a signature, not with a method.
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module '%s' not found: %s\n", aot_name, err);
g_free (err);
- aot_name = g_strdup_printf ("%s/mono/aot-cache/%s/%s%s", mono_assembly_getrootdir(), ARCHITECTURE, g_path_get_basename (assembly->image->name), MONO_SOLIB_EXT);
+ aot_name = g_strdup_printf ("%s/mono/aot-cache/%s/%s%s", mono_assembly_getrootdir(), MONO_ARCHITECTURE, g_path_get_basename (assembly->image->name), MONO_SOLIB_EXT);
sofile = mono_dl_open (aot_name, MONO_DL_LAZY, &err);
if (!sofile) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module '%s' not found: %s\n", aot_name, err);
amodule->blob = blob;
amodule->shared_got = g_new0 (gpointer, info->nshared_got_entries);
- mono_mutex_init_recursive (&amodule->mutex);
+ mono_os_mutex_init_recursive (&amodule->mutex);
/* Read image table */
{
void
mono_aot_init (void)
{
- mono_mutex_init_recursive (&aot_mutex);
- mono_mutex_init_recursive (&aot_page_mutex);
+ mono_os_mutex_init_recursive (&aot_mutex);
+ mono_os_mutex_init_recursive (&aot_page_mutex);
aot_modules = g_hash_table_new (NULL, NULL);
#ifndef __native_client__
case MONO_PATCH_INFO_AOT_MODULE:
case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR:
break;
- case MONO_PATCH_INFO_LLVM_IMT_TRAMPOLINE: {
- MonoJumpInfoImtTramp *imt_tramp = mono_mempool_alloc0 (mp, sizeof (MonoJumpInfoImtTramp));
-
- imt_tramp->method = decode_resolve_method_ref (aot_module, p, &p);
- imt_tramp->vt_offset = decode_value (p, &p);
-
- ji->data.imt_tramp = imt_tramp;
- break;
- }
case MONO_PATCH_INFO_SIGNATURE:
ji->data.target = decode_signature (aot_module, p, &p);
break;
mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
{
MonoClass *klass = method->klass;
+ MonoMethod *orig_method = method;
guint32 method_index;
MonoAotModule *amodule = klass->image->aot_module;
guint8 *code;
+ gboolean cache_result = FALSE;
+
+ if (domain != mono_get_root_domain ())
+ /* Non shared AOT code can't be used in other appdomains */
+ return NULL;
if (enable_aot_cache && !amodule && domain->entry_assembly && klass->image == mono_defaults.corlib) {
/* This cannot be AOTed during startup, so do it now */
if (code)
return code;
+ cache_result = TRUE;
method_index = find_aot_method (method, &amodule);
/*
* Special case the ICollection<T> wrappers for arrays, as they cannot
method_index = mono_metadata_token_index (method->token) - 1;
}
- return load_method (domain, amodule, klass->image, method, method->token, method_index);
+ code = load_method (domain, amodule, klass->image, method, method->token, method_index);
+ if (code && cache_result) {
+ amodule_lock (amodule);
+ g_hash_table_insert (amodule->method_to_code, orig_method, code);
+ amodule_unlock (amodule);
+ }
+ return code;
}
/**