Merge pull request #2799 from BrzVlad/fix-conc-card-clean
[mono.git] / mono / mini / aot-runtime.c
index 29caca50306f0cf68d730d41e96f7c601d00a0d0..4f633c190af2b0cac360db5e69a43ad7eda30728 100644 (file)
@@ -1324,15 +1324,9 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
 }
 
 static gboolean
-decode_method_ref (MonoAotModule *module, MethodRef *ref, guint8 *buf, guint8 **endbuf)
+decode_method_ref (MonoAotModule *module, MethodRef *ref, guint8 *buf, guint8 **endbuf, MonoError *error)
 {
-       MonoError error;
-       gboolean res = decode_method_ref_with_target (module, ref, NULL, buf, endbuf, &error);
-       if (!is_ok (&error)) {
-               g_warning ("Could not decode methodref due to %s", mono_error_get_message (&error));
-               mono_error_cleanup (&error);
-       }
-       return res;
+       return decode_method_ref_with_target (module, ref, NULL, buf, endbuf, error);
 }
 
 /*
@@ -1992,7 +1986,10 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                                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(), MONO_ARCHITECTURE, g_path_get_basename (assembly->image->name), MONO_SOLIB_EXT);
+                               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);
                                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);
@@ -2355,6 +2352,7 @@ mono_aot_cleanup (void)
 static gboolean
 decode_cached_class_info (MonoAotModule *module, MonoCachedClassInfo *info, guint8 *buf, guint8 **endbuf)
 {
+       MonoError error;
        guint32 flags;
        MethodRef ref;
        gboolean res;
@@ -2375,13 +2373,15 @@ decode_cached_class_info (MonoAotModule *module, MonoCachedClassInfo *info, guin
        info->is_generic_container = (flags >> 8) & 0x1;
 
        if (info->has_cctor) {
-               res = decode_method_ref (module, &ref, buf, &buf);
+               res = decode_method_ref (module, &ref, buf, &buf, &error);
+               mono_error_assert_ok (&error); /* FIXME don't swallow the error */
                if (!res)
                        return FALSE;
                info->cctor_token = ref.token;
        }
        if (info->has_finalize) {
-               res = decode_method_ref (module, &ref, buf, &buf);
+               res = decode_method_ref (module, &ref, buf, &buf, &error);
+               mono_error_assert_ok (&error); /* FIXME don't swallow the error */
                if (!res)
                        return FALSE;
                info->finalize_image = ref.image;
@@ -2401,6 +2401,7 @@ decode_cached_class_info (MonoAotModule *module, MonoCachedClassInfo *info, guin
 gpointer
 mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot)
 {
+       MonoError error;
        int i;
        MonoClass *klass = vtable->klass;
        MonoAotModule *amodule = (MonoAotModule *)klass->image->aot_module;
@@ -2420,10 +2421,13 @@ mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int sl
        if (!err)
                return NULL;
 
-       for (i = 0; i < slot; ++i)
-               decode_method_ref (amodule, &ref, p, &p);
+       for (i = 0; i < slot; ++i) {
+               decode_method_ref (amodule, &ref, p, &p, &error);
+               mono_error_cleanup (&error); /* FIXME don't swallow the error */
+       }
 
-       res = decode_method_ref (amodule, &ref, p, &p);
+       res = decode_method_ref (amodule, &ref, p, &p, &error);
+       mono_error_cleanup (&error); /* FIXME don't swallow the error */
        if (!res)
                return NULL;
        if (ref.no_aot_trampoline)
@@ -3055,7 +3059,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
                        mono_error_cleanup (&error); /* FIXME don't swallow the error */
                }
 
-               gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
+               gi->generic_sharing_context = alloc0_jit_info_data (domain, sizeof (MonoGenericSharingContext), async);
                if (decode_value (p, &p)) {
                        /* gsharedvt */
                        MonoGenericSharingContext *gsctx = gi->generic_sharing_context;
@@ -3446,7 +3450,8 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
                MethodRef ref;
                gboolean res;
 
-               res = decode_method_ref (aot_module, &ref, p, &p);
+               res = decode_method_ref (aot_module, &ref, p, &p, &error);
+               mono_error_assert_ok (&error); /* FIXME don't swallow the error */
                if (!res)
                        goto cleanup;