2010-01-22 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / aot-runtime.c
index 3d74dd0a839be0adbfcf5f72e056120dd9ff8995..af8894e170c20fcad0dc0839688690423a23186f 100644 (file)
@@ -623,6 +623,19 @@ decode_method_ref (MonoAotModule *module, guint32 *token, MonoMethod **method, g
                        *method = mono_marshal_get_runtime_invoke (m, FALSE);
                        break;
                }
+               case MONO_WRAPPER_MANAGED_TO_MANAGED: {
+                       int subtype = decode_value (p, &p);
+
+                       if (subtype == MONO_AOT_WRAPPER_ELEMENT_ADDR) {
+                               int rank = decode_value (p, &p);
+                               int elem_size = decode_value (p, &p);
+
+                               *method = mono_marshal_get_array_address (rank, elem_size);
+                       } else {
+                               g_assert_not_reached ();
+                       }
+                       break;
+               }
                default:
                        g_assert_not_reached ();
                }
@@ -895,7 +908,7 @@ find_symbol (MonoDl *module, gpointer *globals, const char *name, gpointer *valu
                table_size = table [0];
                table ++;
 
-               hash = mono_aot_str_hash (name) % table_size;
+               hash = mono_metadata_str_hash (name) % table_size;
 
                entry = &table [hash * 2];
 
@@ -1435,7 +1448,7 @@ mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const ch
                        full_name = g_strdup_printf ("%s.%s", name_space, name);
                }
        }
-       hash = mono_aot_str_hash (full_name) % table_size;
+       hash = mono_metadata_str_hash (full_name) % table_size;
        if (full_name != full_name_buf)
                g_free (full_name);
 
@@ -2507,10 +2520,15 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
                if (mono_jit_stats.methods_aot >= mono_last_aot_method)
                                return NULL;
                else if (mono_jit_stats.methods_aot == mono_last_aot_method - 1) {
-                       if (method)
-                               printf ("LAST AOT METHOD: %s%s%s.%s.\n", method->klass->name_space, method->klass->name_space [0] ? "." : "", method->klass->name, method->name);
-                       else
+                       if (!method)
+                               method = mono_get_method (image, token, NULL);
+                       if (method) {
+                               char *name = mono_method_full_name (method, TRUE);
+                               printf ("LAST AOT METHOD: %s.\n", name);
+                               g_free (name);
+                       } else {
                                printf ("LAST AOT METHOD: %p %d\n", code, method_index);
+                       }
                }
        }
 
@@ -2841,8 +2859,11 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
 
                        code = mono_aot_get_method (domain, m);
                        if (code) {
-                               if (mono_method_needs_static_rgctx_invoke (m, FALSE))
-                                       code = mono_create_static_rgctx_trampoline (m, code);
+                               if (mono_method_needs_static_rgctx_invoke (m, FALSE)) {
+                                       code = mono_create_static_rgctx_trampoline (m, mono_create_ftnptr (domain, code));
+                                       /* The call above returns an ftnptr */
+                                       code = mono_get_addr_from_ftnptr (code);
+                               }
 
                                return code;
                        }
@@ -3048,6 +3069,11 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code
         */
        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) {
                /* These should already have a function descriptor */
+#ifdef PPC_USES_FUNCTION_DESCRIPTOR
+               /* Our function descriptors have a 0 environment, gcc created ones don't */
+               if (ji.type != MONO_PATCH_INFO_INTERNAL_METHOD && ji.type != MONO_PATCH_INFO_JIT_ICALL_ADDR && ji.type != MONO_PATCH_INFO_ICALL_ADDR)
+                       g_assert (((gpointer*)target) [2] == 0);
+#endif
                /* Empty */
        } else if (!no_ftnptr) {
 #ifdef PPC_USES_FUNCTION_DESCRIPTOR
@@ -3510,7 +3536,8 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
        symbol = g_strdup_printf ("rgctx_fetch_trampoline_%u", slot);
        code = load_function (mono_defaults.corlib->aot_module, symbol);
        g_free (symbol);
-       return code;
+       /* The caller expects an ftnptr */
+       return mono_create_ftnptr (mono_domain_get (), code);
 }
 
 gpointer