[hybrid] Enable logging for methods not found with gsharedvt enabled
[mono.git] / mono / mini / aot-runtime.c
index c531afce043a4dc4ed03e3dd3909e7585c437a78..86c6fbb5d0dd4399fc48b8f4c7f05b03aac69d15 100644 (file)
@@ -268,15 +268,15 @@ load_image (MonoAotModule *amodule, int index, MonoError *error)
 
        assembly = mono_assembly_load (&amodule->image_names [index], amodule->assembly->basedir, &status);
        if (!assembly) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable because dependency %s is not found.\n", amodule->aot_name, amodule->image_names [index].name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable because dependency %s is not found.", amodule->aot_name, amodule->image_names [index].name);
                mono_error_set_bad_image_name (error, amodule->aot_name, "module is unusable because dependency %s is not found (error %d).\n", amodule->image_names [index].name, status);
                amodule->out_of_date = TRUE;
                return NULL;
        }
 
        if (strcmp (assembly->image->guid, amodule->image_guids [index])) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
-               mono_error_set_bad_image_name (error, amodule->aot_name, "module is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
+               mono_error_set_bad_image_name (error, amodule->aot_name, "module is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').", amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
                amodule->out_of_date = TRUE;
                return NULL;
        }
@@ -903,8 +903,7 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                }
                case MONO_WRAPPER_LDFLD:
                case MONO_WRAPPER_LDFLDA:
-               case MONO_WRAPPER_STFLD:
-               case MONO_WRAPPER_ISINST: {
+               case MONO_WRAPPER_STFLD: {
                        MonoClass *klass = decode_klass_ref (module, p, &p, error);
                        if (!klass)
                                return FALSE;
@@ -914,8 +913,6 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
                                ref->method = mono_marshal_get_ldflda_wrapper (&klass->byval_arg);
                        else if (wrapper_type == MONO_WRAPPER_STFLD)
                                ref->method = mono_marshal_get_stfld_wrapper (&klass->byval_arg);
-                       else if (wrapper_type == MONO_WRAPPER_ISINST)
-                               ref->method = mono_marshal_get_isinst (klass);
                        else {
                                mono_error_set_bad_image_name (error, module->aot_name, "Unknown AOT wrapper type %d", wrapper_type);
                                return FALSE;
@@ -1921,7 +1918,7 @@ init_amodule_got (MonoAotModule *amodule)
 static void
 load_aot_module (MonoAssembly *assembly, gpointer user_data)
 {
-       char *aot_name;
+       char *aot_name, *found_aot_name;
        MonoAotModule *amodule;
        MonoDl *sofile;
        gboolean usable = TRUE;
@@ -1956,43 +1953,70 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
 
        sofile = NULL;
 
+       found_aot_name = NULL;
+
        if (info) {
                /* Statically linked AOT module */
                aot_name = g_strdup_printf ("%s", assembly->aname.name);
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "Found statically linked AOT module '%s'.\n", aot_name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "Found statically linked AOT module '%s'.", aot_name);
                if (!(info->flags & MONO_AOT_FILE_FLAG_LLVM_ONLY)) {
                        globals = (void **)info->globals;
                        g_assert (globals);
                }
        } else {
+               char *err;
+
                if (enable_aot_cache)
                        sofile = aot_cache_load_module (assembly, &aot_name);
                if (!sofile) {
-                       char *err;
                        aot_name = g_strdup_printf ("%s%s", assembly->image->name, MONO_SOLIB_EXT);
 
                        sofile = mono_dl_open (aot_name, MONO_DL_LAZY, &err);
-
+                       if (sofile) {
+                               found_aot_name = g_strdup (aot_name);
+                       } else {
+                               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: image '%s' not found: %s", aot_name, err);
+                               g_free (err);
+                       }
+                       g_free (aot_name);
+               }
+               if (!sofile) {
+                       char *basename = g_path_get_basename (assembly->image->name);
+                       aot_name = g_strdup_printf ("%s/mono/aot-cache/%s/%s%s", mono_assembly_getrootdir(), MONO_ARCHITECTURE, basename, MONO_SOLIB_EXT);
+                       g_free (basename);
+                       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);
+                               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: image '%s' not found: %s", aot_name, err);
                                g_free (err);
+                       }
+               }
+               if (!sofile) {
+                       GList *l;
+
+                       for (l = mono_aot_paths; l; l = l->next) {
+                               char *path = l->data;
 
-                               g_free (aot_name);
                                char *basename = g_path_get_basename (assembly->image->name);
-                               aot_name = g_strdup_printf ("%s/mono/aot-cache/%s/%s%s", mono_assembly_getrootdir(), MONO_ARCHITECTURE, basename, MONO_SOLIB_EXT);
-                               g_free (basename);
+                               aot_name = g_strdup_printf ("%s/%s%s", path, basename, 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);
+                               if (sofile) {
+                                       found_aot_name = g_strdup (aot_name);
+                               } else {
+                                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: image '%s' not found: %s", aot_name, err);
                                        g_free (err);
                                }
-
+                               g_free (basename);
+                               g_free (aot_name);
+                               if (sofile)
+                                       break;
                        }
                }
                if (!sofile) {
-                       if (mono_aot_only && assembly->image->tables [MONO_TABLE_METHOD].rows)
+                       if (mono_aot_only && assembly->image->tables [MONO_TABLE_METHOD].rows) {
+                               aot_name = g_strdup_printf ("%s%s", assembly->image->name, MONO_SOLIB_EXT);
                                g_error ("Failed to load AOT module '%s' in aot-only mode.\n", aot_name);
-                       g_free (aot_name);
+                               g_free (aot_name);
+                       }
                        return;
                }
        }
@@ -2033,12 +2057,12 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
 
        if (!usable) {
                if (mono_aot_only) {
-                       g_error ("Failed to load AOT module '%s' while running in aot-only mode: %s.\n", aot_name, msg);
+                       g_error ("Failed to load AOT module '%s' while running in aot-only mode: %s.\n", found_aot_name, msg);
                } else {
-                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable: %s.\n", aot_name, msg);
+                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable: %s.", found_aot_name, msg);
                }
                g_free (msg);
-               g_free (aot_name);
+               g_free (found_aot_name);
                if (sofile)
                        mono_dl_close (sofile);
                assembly->image->aot_module = NULL;
@@ -2053,7 +2077,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        g_assert (info->generic_tramp_num == MONO_TRAMPOLINE_NUM);
 
        amodule = g_new0 (MonoAotModule, 1);
-       amodule->aot_name = aot_name;
+       amodule->aot_name = found_aot_name;
        amodule->assembly = assembly;
 
        memcpy (&amodule->info, info, sizeof (*info));
@@ -2273,12 +2297,12 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        }
 
        if (amodule->out_of_date) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: Module %s is unusable because a dependency is out-of-date.\n", assembly->image->name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: Module %s is unusable because a dependency is out-of-date.", assembly->image->name);
                if (mono_aot_only)
-                       g_error ("Failed to load AOT module '%s' while running in aot-only mode because a dependency cannot be found or it is out of date.\n", aot_name);
+                       g_error ("Failed to load AOT module '%s' while running in aot-only mode because a dependency cannot be found or it is out of date.\n", found_aot_name);
+       } else {
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: image '%s' found.", found_aot_name);
        }
-       else
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loaded AOT Module for %s.\n", assembly->image->name);
 }
 
 /*
@@ -3591,7 +3615,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
        case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
        case MONO_PATCH_INFO_GC_NURSERY_START:
        case MONO_PATCH_INFO_GC_NURSERY_BITS:
-       case MONO_PATCH_INFO_JIT_TLS_ID:
                break;
        case MONO_PATCH_INFO_CASTCLASS_CACHE:
                ji->data.index = decode_value (p, &p);
@@ -3629,9 +3652,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
        case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
                ji->data.target = decode_signature (aot_module, p, &p);
                break;
-       case MONO_PATCH_INFO_TLS_OFFSET:
-               ji->data.target = GINT_TO_POINTER (decode_value (p, &p));
-               break;
        case MONO_PATCH_INFO_GSHAREDVT_CALL: {
                MonoJumpInfoGSharedVtCall *info = (MonoJumpInfoGSharedVtCall *)mono_mempool_alloc0 (mp, sizeof (MonoJumpInfoGSharedVtCall));
                info->sig = decode_signature (aot_module, p, &p);
@@ -3702,8 +3722,10 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
                break;
        }
        case MONO_PATCH_INFO_GC_SAFE_POINT_FLAG:
-       case MONO_PATCH_INFO_GET_TLS_TRAMP:
+       case MONO_PATCH_INFO_JIT_THREAD_ATTACH:
                break;
+       case MONO_PATCH_INFO_GET_TLS_TRAMP:
+       case MONO_PATCH_INFO_SET_TLS_TRAMP:
        case MONO_PATCH_INFO_AOT_JIT_INFO:
                ji->data.index = decode_value (p, &p);
                break;
@@ -4532,7 +4554,7 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                }
 
                if (method_index == 0xffffff) {
-                       if (mono_aot_only && mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
+                       if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
                                char *full_name;
 
                                full_name = mono_method_full_name (method, TRUE);