* blob where the data was stored.
*/
static guint32
-add_to_blob (MonoAotCompile *acfg, guint8 *data, guint32 data_len)
+add_to_blob (MonoAotCompile *acfg, const guint8 *data, guint32 data_len)
{
if (acfg->blob.alloc_size == 0)
stream_init (&acfg->blob);
case MONO_WRAPPER_ALLOC: {
AllocatorWrapperInfo *info = mono_marshal_get_wrapper_info (method);
+ /* The GC name is saved once in MonoAotFileInfo */
g_assert (info->alloc_type != -1);
encode_value (info->alloc_type, p, &p);
break;
{
char symbol [128];
int i;
+ int gc_name_offset;
+ const char *gc_name;
+
+ /*
+ * The managed allocators are GC specific, so can't use an AOT image created by one GC
+ * in another.
+ */
+ gc_name = mono_gc_get_gc_name ();
+ gc_name_offset = add_to_blob (acfg, (guint8*)gc_name, strlen (gc_name) + 1);
sprintf (symbol, "mono_aot_file_info");
emit_section_change (acfg, ".data", 0);
emit_label (acfg, symbol);
emit_global (acfg, symbol, FALSE);
- /* The data emitted here must match MonoAotFileInfo in aot-runtime.c. */
+ /* The data emitted here must match MonoAotFileInfo. */
emit_int32 (acfg, acfg->plt_got_offset_base);
emit_int32 (acfg, (int)(acfg->got_offset * sizeof (gpointer)));
emit_int32 (acfg, acfg->plt_offset);
emit_int32 (acfg, acfg->nmethods);
emit_int32 (acfg, acfg->flags);
emit_int32 (acfg, acfg->opts);
+ emit_int32 (acfg, gc_name_offset);
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
emit_int32 (acfg, acfg->num_trampolines [i]);
MonoAotFileInfo *file_info = NULL;
int i;
gpointer *got_addr;
+ guint8 *blob;
if (mono_compile_aot)
return;
usable = FALSE;
}
+ find_symbol (sofile, globals, "blob", (gpointer*)&blob);
+
+ if (((MonoAotFileInfo*)file_info)->gc_name_index != -1) {
+ char *gc_name = (char*)&blob [((MonoAotFileInfo*)file_info)->gc_name_index];
+ const char *current_gc_name = mono_gc_get_gc_name ();
+
+ if (strcmp (current_gc_name, gc_name) != 0) {
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is compiled against GC %s, while the current runtime uses GC %s.\n", aot_name, gc_name, current_gc_name);
+ usable = FALSE;
+ }
+ }
+
if (!usable) {
if (mono_aot_only) {
fprintf (stderr, "Failed to load AOT module '%s' while running in aot-only mode.\n", aot_name);
exit (1);
+ } else {
+ mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable.\n", aot_name);
}
g_free (aot_name);
if (sofile)
amodule->globals = globals;
amodule->sofile = sofile;
amodule->method_to_code = g_hash_table_new (mono_aligned_addr_hash, NULL);
+ amodule->blob = blob;
/* Read image table */
{
find_symbol (sofile, globals, "methods_end", (gpointer*)&amodule->code_end);
find_symbol (sofile, globals, "method_info_offsets", (gpointer*)&amodule->method_info_offsets);
find_symbol (sofile, globals, "ex_info_offsets", (gpointer*)&amodule->ex_info_offsets);
- find_symbol (sofile, globals, "blob", (gpointer*)&amodule->blob);
find_symbol (sofile, globals, "class_info_offsets", (gpointer*)&amodule->class_info_offsets);
find_symbol (sofile, globals, "class_name_table", (gpointer *)&amodule->class_name_table);
find_symbol (sofile, globals, "extra_method_table", (gpointer *)&amodule->extra_method_table);
{
int i;
MonoClass *klass = vtable->klass;
- MonoAotModule *aot_module = klass->image->aot_module;
+ MonoAotModule *amodule = klass->image->aot_module;
guint8 *info, *p;
MonoCachedClassInfo class_info;
gboolean err;
MonoImage *image;
gboolean no_aot_trampoline;
- if (MONO_CLASS_IS_INTERFACE (klass) || klass->rank || !aot_module)
+ if (MONO_CLASS_IS_INTERFACE (klass) || klass->rank || !amodule)
return NULL;
- info = &aot_module->blob [mono_aot_get_offset (aot_module->class_info_offsets, mono_metadata_token_index (klass->type_token) - 1)];
+ info = &amodule->blob [mono_aot_get_offset (amodule->class_info_offsets, mono_metadata_token_index (klass->type_token) - 1)];
p = info;
- err = decode_cached_class_info (aot_module, &class_info, p, &p);
+ err = decode_cached_class_info (amodule, &class_info, p, &p);
if (!err)
return NULL;
for (i = 0; i < slot; ++i)
- decode_method_ref (aot_module, &token, NULL, NULL, p, &p);
+ decode_method_ref (amodule, &token, NULL, NULL, p, &p);
- image = decode_method_ref (aot_module, &token, NULL, &no_aot_trampoline, p, &p);
+ image = decode_method_ref (amodule, &token, NULL, &no_aot_trampoline, p, &p);
if (!image)
return NULL;
if (no_aot_trampoline)
gboolean
mono_aot_get_cached_class_info (MonoClass *klass, MonoCachedClassInfo *res)
{
- MonoAotModule *aot_module = klass->image->aot_module;
+ MonoAotModule *amodule = klass->image->aot_module;
guint8 *p;
gboolean err;
- if (klass->rank || !aot_module)
+ if (klass->rank || !amodule)
return FALSE;
- p = (guint8*)&aot_module->blob [mono_aot_get_offset (aot_module->class_info_offsets, mono_metadata_token_index (klass->type_token) - 1)];
+ p = (guint8*)&amodule->blob [mono_aot_get_offset (amodule->class_info_offsets, mono_metadata_token_index (klass->type_token) - 1)];
- err = decode_cached_class_info (aot_module, res, p, &p);
+ err = decode_cached_class_info (amodule, res, p, &p);
if (!err)
return FALSE;
gboolean
mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const char *name, MonoClass **klass)
{
- MonoAotModule *aot_module = image->aot_module;
+ MonoAotModule *amodule = image->aot_module;
guint16 *table, *entry;
guint16 table_size;
guint32 hash;
guint32 cols [MONO_TYPEDEF_SIZE];
GHashTable *nspace_table;
- if (!aot_module || !aot_module->class_name_table)
+ if (!amodule || !amodule->class_name_table)
return FALSE;
mono_aot_lock ();
*klass = NULL;
/* First look in the cache */
- if (!aot_module->name_cache)
- aot_module->name_cache = g_hash_table_new (g_str_hash, g_str_equal);
- nspace_table = g_hash_table_lookup (aot_module->name_cache, name_space);
+ if (!amodule->name_cache)
+ amodule->name_cache = g_hash_table_new (g_str_hash, g_str_equal);
+ nspace_table = g_hash_table_lookup (amodule->name_cache, name_space);
if (nspace_table) {
*klass = g_hash_table_lookup (nspace_table, name);
if (*klass) {
}
}
- table_size = aot_module->class_name_table [0];
- table = aot_module->class_name_table + 1;
+ table_size = amodule->class_name_table [0];
+ table = amodule->class_name_table + 1;
if (name_space [0] == '\0')
full_name = g_strdup_printf ("%s", name);
/* Add to cache */
if (*klass) {
mono_aot_lock ();
- nspace_table = g_hash_table_lookup (aot_module->name_cache, name_space);
+ nspace_table = g_hash_table_lookup (amodule->name_cache, name_space);
if (!nspace_table) {
nspace_table = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (aot_module->name_cache, (char*)name_space2, nspace_table);
+ g_hash_table_insert (amodule->name_cache, (char*)name_space2, nspace_table);
}
g_hash_table_insert (nspace_table, (char*)name2, *klass);
mono_aot_unlock ();