X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fprofiler%2Fmono-profiler-aot.c;h=4cf48bbd1b2491a54e3155c2c793b1934d5bb441;hb=69f207ee9e4f440e66e98bf5f685807f6527c39d;hp=72c603ca3688a9e1d4d954c34420903a518657e1;hpb=93703b4ef8bdcf1d6cf336e14f534454221730c5;p=mono.git diff --git a/mono/profiler/mono-profiler-aot.c b/mono/profiler/mono-profiler-aot.c index 72c603ca368..4cf48bbd1b2 100644 --- a/mono/profiler/mono-profiler-aot.c +++ b/mono/profiler/mono-profiler-aot.c @@ -1,3 +1,18 @@ +/* + * mono-profiler-aot.c: Ahead of Time Compiler Profiler for Mono. + * + * + * Copyright 2008-2009 Novell, Inc (http://www.novell.com) + * + * This profiler collects profiling information usable by the Mono AOT compiler + * to generate better code. It saves the information into files under ~/.mono. + * The AOT compiler can load these files during compilation. + * Currently, only the order in which methods were compiled is saved, + * allowing more efficient function ordering in the AOT files. + * Licensed under the MIT license. See LICENSE file in the project root for full license information. + */ + +#include #include #include #include @@ -6,15 +21,12 @@ #include #include #include +#include #include -/* - * This profiler collects profiling information usable by the Mono AOT compiler - * to generate better code. It saves the information into files under ~/.mono. - * The AOT compiler can load these files during compilation. - * Currently, only the order in which methods were compiled is saved, - * allowing more efficient function ordering in the AOT files. - */ +#ifdef HOST_WIN32 +#include +#endif struct _MonoProfiler { GHashTable *images; @@ -36,11 +48,14 @@ foreach_method (gpointer data, gpointer user_data) { ForeachData *udata = (ForeachData*)user_data; MonoMethod *method = (MonoMethod*)data; + char *name; if (!mono_method_get_token (method) || mono_class_get_image (mono_method_get_class (method)) != udata->image) return; - fprintf (udata->outfile, "%d\n", mono_method_get_token (method)); + name = mono_method_full_name (method, TRUE); + fprintf (udata->outfile, "%s\n", name); + g_free (name); } static void @@ -57,7 +72,7 @@ output_image (gpointer key, gpointer value, gpointer user_data) tmp = g_strdup_printf ("%s/.mono/aot-profile-data", g_get_home_dir ()); if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) { -#ifdef PLATFORM_WIN32 +#ifdef HOST_WIN32 err = mkdir (tmp); #else err = mkdir (tmp, 0777); @@ -70,7 +85,7 @@ output_image (gpointer key, gpointer value, gpointer user_data) i = 0; while (TRUE) { - outfile_name = g_strdup_printf ("%s/%s-%s-%d", tmp, mono_image_get_name (image), mono_image_get_guid (image), i); + outfile_name = g_strdup_printf ("%s/%s-%d", tmp, mono_image_get_name (image), i); if (!g_file_test (outfile_name, G_FILE_TEST_IS_REGULAR)) break; @@ -83,7 +98,7 @@ output_image (gpointer key, gpointer value, gpointer user_data) outfile = fopen (outfile_name, "w+"); g_assert (outfile); - fprintf (outfile, "#VER:%d\n", 1); + fprintf (outfile, "#VER:%d\n", 2); data.prof = prof; data.outfile = outfile; @@ -110,7 +125,7 @@ prof_jit_leave (MonoProfiler *prof, MonoMethod *method, int result) MonoImage *image = mono_class_get_image (mono_method_get_class (method)); PerImageData *data; - data = g_hash_table_lookup (prof->images, image); + data = (PerImageData *)g_hash_table_lookup (prof->images, image); if (!data) { data = g_new0 (PerImageData, 1); g_hash_table_insert (prof->images, image, data); @@ -119,6 +134,9 @@ prof_jit_leave (MonoProfiler *prof, MonoMethod *method, int result) data->methods = g_list_append (data->methods, method); } +void +mono_profiler_startup (const char *desc); + /* the entry point */ void mono_profiler_startup (const char *desc)