Mon Jan 19 17:44:50 CET 2004 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / mini / aot.c
index 4b52694d2b40b2bd8f3972dbe396679cf5476bb8..a24419d440eff910468080f669dca3d5c3212713 100644 (file)
@@ -250,6 +250,9 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
        if (!method->token)
                return NULL;
 
+       if (mono_profiler_get_events () & MONO_PROFILE_ENTER_LEAVE)
+               return NULL;
+
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
                (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
                (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
@@ -285,11 +288,11 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
                        memcpy (code, minfo->info->code_start, minfo->info->code_size);
 
                        if (mono_aot_verbose > 1)
-                               printf ("REUSE METHOD: %s %p - %p.\n", mono_method_full_name (method, TRUE), code, (char*)code + code_len);
+                               printf ("REUSE METHOD: %s %p - %p.\n", mono_method_full_name (method, TRUE), code, (char*)code + minfo->info->code_size);
 
                        /* Do this outside the lock to avoid deadlocks */
                        LeaveCriticalSection (&aot_mutex);
-                       mono_arch_patch_code (method, domain, code, minfo->patch_info);
+                       mono_arch_patch_code (method, domain, code, minfo->patch_info, TRUE);
                        EnterCriticalSection (&aot_mutex);
 
                        /* Relocate jinfo */
@@ -412,7 +415,7 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
                gpointer *table;
                int pages;
                int i, err;
-               guint32 last_offset;
+               guint32 last_offset, buf_len;
 
                if (aot_module->opts & MONO_OPT_SHARED)
                        mp = mono_mempool_new ();
@@ -545,6 +548,11 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
                        patch_info = ji;
                }
 
+               info = (gpointer)((guint8*)info + 4);
+               buf_len = *(guint32*)info;
+               info = (gpointer)((guint8*)info + 4);
+               mono_debug_add_aot_method (domain, method, code, (guint8*)info, buf_len);
+
                if (use_loaded_code) {
                /* disable write protection */
 #ifndef PLATFORM_WIN32
@@ -562,7 +570,7 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
 
                /* Do this outside the lock to avoid deadlocks */
                LeaveCriticalSection (&aot_mutex);
-               mono_arch_patch_code (method, domain, code, patch_info);
+               mono_arch_patch_code (method, domain, code, patch_info, TRUE);
                EnterCriticalSection (&aot_mutex);
 
                if (aot_module->opts & MONO_OPT_SHARED)
@@ -1034,6 +1042,21 @@ emit_method (MonoAotCompile *acfg, MonoCompile *cfg)
        /* NULL terminated array */
        fprintf (tmpfp, "\t.long 0\n");
 
+       {
+               guint8 *buf;
+               guint32 buf_len;
+
+               mono_debug_serialize_debug_info (cfg, &buf, &buf_len);
+
+               fprintf (tmpfp, "\t.long %d\n", buf_len);
+
+               for (i = 0; i < buf_len; ++i)
+                       fprintf (tmpfp, ".byte %d\n", (unsigned int) buf [i]);
+
+               if (buf_len > 0)
+                       g_free (buf);
+       }
+
        /* fixme: save the rest of the required infos */
 
        g_free (mname);
@@ -1107,7 +1130,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts)
                //printf ("START:           %s\n", mono_method_full_name (method, TRUE));
                //mono_compile_method (method);
 
-               cfg = mini_method_compile (method, opts, mono_root_domain, 0);
+               cfg = mini_method_compile (method, opts, mono_root_domain, FALSE, 0);
                g_assert (cfg);
 
                if (cfg->disable_aot) {
@@ -1238,11 +1261,11 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts)
        system (com);
        g_free (com);*/
 
-       printf ("Compiled %d out of %d methods (%d%%)\n", ccount, mcount, (ccount*100)/mcount);
-       printf ("%d methods contain absolute addresses (%d%%)\n", abscount, (abscount*100)/mcount);
-       printf ("%d methods contain wrapper references (%d%%)\n", wrappercount, (wrappercount*100)/mcount);
-       printf ("%d methods contain lmf pointers (%d%%)\n", lmfcount, (lmfcount*100)/mcount);
-       printf ("%d methods have other problems (%d%%)\n", ocount, (ocount*100)/mcount);
+       printf ("Compiled %d out of %d methods (%d%%)\n", ccount, mcount, mcount ? (ccount*100)/mcount : 100);
+       printf ("%d methods contain absolute addresses (%d%%)\n", abscount, mcount ? (abscount*100)/mcount : 100);
+       printf ("%d methods contain wrapper references (%d%%)\n", wrappercount, mcount ? (wrappercount*100)/mcount : 100);
+       printf ("%d methods contain lmf pointers (%d%%)\n", lmfcount, mcount ? (lmfcount*100)/mcount : 100);
+       printf ("%d methods have other problems (%d%%)\n", ocount, mcount ? (ocount*100)/mcount : 100);
        unlink (tmpfname);
 
        return 0;