Merge pull request #1954 from kumpera/fix_aot_compilation
[mono.git] / mono / mini / aot-runtime.c
index fa5d6ca73253584c8145c7a0d787dcbce9209ce5..868b4fa6fbb9b77ac259fa5449a9d1f01301e181 100644 (file)
@@ -2469,7 +2469,7 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain,
        guint8 *fde, *cie, *code_start, *code_end;
        int version, fde_count;
        gint32 *table;
-       int i, j, pos, left, right, code_len;
+       int i, pos, left, right, code_len;
        MonoJitExceptionInfo *ei;
        guint32 fde_len, ei_len, nested_len, nindex;
        gpointer *type_info;
@@ -2555,16 +2555,8 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain,
                gint32 cindex1 = read32 (type_info [i]);
                GSList *l;
 
-               for (l = nesting [cindex1]; l; l = l->next) {
-                       gint32 nesting_cindex = GPOINTER_TO_INT (l->data);
-
-                       for (j = 0; j < ei_len; ++j) {
-                               gint32 cindex2 = read32 (type_info [j]);
-
-                               if (cindex2 == nesting_cindex)
-                                       nested_len ++;
-                       }
-               }
+               for (l = nesting [cindex1]; l; l = l->next)
+                       nested_len ++;
        }
 
        /*
@@ -2615,19 +2607,16 @@ decode_llvm_mono_eh_frame (MonoAotModule *amodule, MonoDomain *domain,
 
                for (l = nesting [cindex1]; l; l = l->next) {
                        gint32 nesting_cindex = GPOINTER_TO_INT (l->data);
+                       MonoJitExceptionInfo *nesting_ei;
+                       MonoJitExceptionInfo *nesting_clause = &clauses [nesting_cindex];
 
-                       for (j = 0; j < ei_len; ++j) {
-                               gint32 cindex2 = read32 (type_info [j]);
+                       nesting_ei = &jinfo->clauses [nindex];
+                       nindex ++;
 
-                               if (cindex2 == nesting_cindex) {
-                                       memcpy (&jinfo->clauses [nindex], &jinfo->clauses [j], sizeof (MonoJitExceptionInfo));
-                                       jinfo->clauses [nindex].try_start = jinfo->clauses [i].try_start;
-                                       jinfo->clauses [nindex].try_end = jinfo->clauses [i].try_end;
-                                       jinfo->clauses [nindex].handler_start = jinfo->clauses [i].handler_start;
-                                       jinfo->clauses [nindex].exvar_offset = jinfo->clauses [i].exvar_offset;
-                                       nindex ++;
-                               }
-                       }
+                       memcpy (nesting_ei, &jinfo->clauses [i], sizeof (MonoJitExceptionInfo));
+                       nesting_ei->flags = nesting_clause->flags;
+                       nesting_ei->data.catch_class = nesting_clause->data.catch_class;
+                       nesting_ei->clause_index = nesting_cindex;
                }
        }
        g_assert (nindex == ei_len + nested_len);
@@ -3280,7 +3269,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
        case MONO_PATCH_INFO_CLASS:
        case MONO_PATCH_INFO_IID:
        case MONO_PATCH_INFO_ADJUSTED_IID:
-       case MONO_PATCH_INFO_CLASS_INIT:
                /* Shared */
                ji->data.klass = decode_klass_ref (aot_module, p, &p);
                if (!ji->data.klass)
@@ -3720,7 +3708,7 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
 }
 
 static guint32
-find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method)
+find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method, guint32 hash_full)
 {
        guint32 table_size, entry_size, hash;
        guint32 *table, *entry;
@@ -3731,11 +3719,10 @@ find_aot_method_in_amodule (MonoAotModule *amodule, MonoMethod *method)
                return 0xffffff;
 
        table_size = amodule->extra_method_table [0];
+       hash = hash_full % table_size;
        table = amodule->extra_method_table + 1;
        entry_size = 3;
 
-       hash = mono_aot_method_hash (method) % table_size;
-
        entry = &table [hash * entry_size];
 
        if (entry [0] == 0)
@@ -3816,10 +3803,11 @@ find_aot_method (MonoMethod *method, MonoAotModule **out_amodule)
        guint32 index;
        GPtrArray *modules;
        int i;
+       guint32 hash = mono_aot_method_hash (method);
 
        /* Try the method's module first */
        *out_amodule = method->klass->image->aot_module;
-       index = find_aot_method_in_amodule (method->klass->image->aot_module, method);
+       index = find_aot_method_in_amodule (method->klass->image->aot_module, method, hash);
        if (index != 0xffffff)
                return index;
 
@@ -3841,7 +3829,7 @@ find_aot_method (MonoMethod *method, MonoAotModule **out_amodule)
                MonoAotModule *amodule = g_ptr_array_index (modules, i);
 
                if (amodule != method->klass->image->aot_module)
-                       index = find_aot_method_in_amodule (amodule, method);
+                       index = find_aot_method_in_amodule (amodule, method, hash);
                if (index != 0xffffff) {
                        *out_amodule = amodule;
                        break;
@@ -4302,7 +4290,7 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
         * patches, so have to translate between the two.
         * FIXME: Clean this up, but how ?
         */
-       if (ji.type == MONO_PATCH_INFO_ABS || ji.type == MONO_PATCH_INFO_INTERNAL_METHOD || ji.type == MONO_PATCH_INFO_CLASS_INIT || ji.type == MONO_PATCH_INFO_ICALL_ADDR || ji.type == MONO_PATCH_INFO_JIT_ICALL_ADDR || ji.type == MONO_PATCH_INFO_RGCTX_FETCH) {
+       if (ji.type == MONO_PATCH_INFO_ABS || ji.type == MONO_PATCH_INFO_INTERNAL_METHOD || ji.type == MONO_PATCH_INFO_ICALL_ADDR || ji.type == MONO_PATCH_INFO_JIT_ICALL_ADDR || ji.type == MONO_PATCH_INFO_RGCTX_FETCH) {
                /* These should already have a function descriptor */
 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
                /* Our function descriptors have a 0 environment, gcc created ones don't */
@@ -4570,9 +4558,6 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
                                } else if (!strcmp (ji->data.name, "specific_trampoline_monitor_exit")) {
                                        target = mono_create_specific_trampoline (NULL, MONO_TRAMPOLINE_MONITOR_EXIT, mono_get_root_domain (), NULL);
                                        target = mono_create_ftnptr_malloc (target);
-                               } else if (!strcmp (ji->data.name, "specific_trampoline_generic_class_init")) {
-                                       target = mono_create_specific_trampoline (NULL, MONO_TRAMPOLINE_GENERIC_CLASS_INIT, mono_get_root_domain (), NULL);
-                                       target = mono_create_ftnptr_malloc (target);
                                } else if (!strcmp (ji->data.name, "mono_thread_get_and_clear_pending_exception")) {
                                        target = mono_thread_get_and_clear_pending_exception;
                                } else if (!strcmp (ji->data.name, "debugger_agent_single_step_from_context")) {