X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Faot-compiler.c;h=6e91638d881fe1f3f3f97a4cf2c9d97e12c9555b;hb=82bcac8efac8c2556cf748b062592a4fdc2ecc3e;hp=e290f83f98b7b5f370fe5ed937e102ca5f4a0489;hpb=a650d4d72cf11da18ab71687f10298fad01fa33f;p=mono.git diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index e290f83f98b..6e91638d881 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -55,7 +55,8 @@ #include #include #include -#include +#include +#include #include "aot-compiler.h" #include "seq-points.h" @@ -94,6 +95,40 @@ #define ALIGN_PTR_TO(ptr,align) (gpointer)((((gssize)(ptr)) + (align - 1)) & (~(align - 1))) #define ROUND_DOWN(VALUE,SIZE) ((VALUE) & ~((SIZE) - 1)) +typedef struct { + char *name; + MonoImage *image; +} ImageProfileData; + +typedef struct ClassProfileData ClassProfileData; + +typedef struct { + int argc; + ClassProfileData **argv; + MonoGenericInst *inst; +} GInstProfileData; + +struct ClassProfileData { + ImageProfileData *image; + char *ns, *name; + GInstProfileData *inst; + MonoClass *klass; +}; + +typedef struct { + ClassProfileData *klass; + int id; + char *name; + int param_count; + char *signature; + GInstProfileData *inst; + MonoMethod *method; +} MethodProfileData; + +typedef struct { + GHashTable *images, *classes, *ginsts, *methods; +} ProfileData; + /* predefined values for static readonly fields without needed to run the .cctor */ typedef struct _ReadOnlyValue ReadOnlyValue; struct _ReadOnlyValue { @@ -114,6 +149,7 @@ typedef struct MonoAotOptions { char *outfile; char *llvm_outfile; char *data_outfile; + GList *profile_files; gboolean save_temps; gboolean write_symbols; gboolean metadata_only; @@ -146,6 +182,7 @@ typedef struct MonoAotOptions { int nrgctx_fetch_trampolines; gboolean print_skipped_methods; gboolean stats; + gboolean verbose; char *tool_prefix; char *ld_flags; char *mtriple; @@ -154,6 +191,7 @@ typedef struct MonoAotOptions { char *instances_logfile_path; char *logfile; gboolean dump_json; + gboolean profile_only; } MonoAotOptions; typedef enum { @@ -274,6 +312,8 @@ typedef struct MonoAotCompile { int objc_selector_index, objc_selector_index_2; GPtrArray *objc_selectors; GHashTable *objc_selector_to_index; + GList *profile_data; + GHashTable *profile_methods; FILE *logfile; FILE *instances_logfile; FILE *data_outfile; @@ -343,6 +383,9 @@ get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cac static void add_gsharedvt_wrappers (MonoAotCompile *acfg, MonoMethodSignature *sig, gboolean gsharedvt_in, gboolean gsharedvt_out); +static void +add_profile_instances (MonoAotCompile *acfg, ProfileData *data); + static void aot_printf (MonoAotCompile *acfg, const gchar *format, ...) { @@ -4066,30 +4109,33 @@ add_wrappers (MonoAotCompile *acfg) /* begin-invoke */ method = mono_get_delegate_begin_invoke (klass); - create_gsharedvt_inst (acfg, method, &ctx); + if (method) { + create_gsharedvt_inst (acfg, method, &ctx); - inst = mono_class_inflate_generic_method_checked (method, &ctx, &error); - g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */ + inst = mono_class_inflate_generic_method_checked (method, &ctx, &error); + g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */ - m = mono_marshal_get_delegate_begin_invoke (inst); - g_assert (m->is_inflated); + m = mono_marshal_get_delegate_begin_invoke (inst); + g_assert (m->is_inflated); - gshared = mini_get_shared_method_full (m, FALSE, TRUE); - add_extra_method (acfg, gshared); + gshared = mini_get_shared_method_full (m, FALSE, TRUE); + add_extra_method (acfg, gshared); + } /* end-invoke */ method = mono_get_delegate_end_invoke (klass); - create_gsharedvt_inst (acfg, method, &ctx); - - inst = mono_class_inflate_generic_method_checked (method, &ctx, &error); - g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */ + if (method) { + create_gsharedvt_inst (acfg, method, &ctx); - m = mono_marshal_get_delegate_end_invoke (inst); - g_assert (m->is_inflated); + inst = mono_class_inflate_generic_method_checked (method, &ctx, &error); + g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */ - gshared = mini_get_shared_method_full (m, FALSE, TRUE); - add_extra_method (acfg, gshared); + m = mono_marshal_get_delegate_end_invoke (inst); + g_assert (m->is_inflated); + gshared = mini_get_shared_method_full (m, FALSE, TRUE); + add_extra_method (acfg, gshared); + } } } @@ -7178,6 +7224,12 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts) opts->llvm_only = TRUE; } else if (str_begins_with (arg, "data-outfile=")) { opts->data_outfile = g_strdup (arg + strlen ("data-outfile=")); + } else if (str_begins_with (arg, "profile=")) { + opts->profile_files = g_list_append (opts->profile_files, g_strdup (arg + strlen ("profile="))); + } else if (!strcmp (arg, "profile-only")) { + opts->profile_only = TRUE; + } else if (!strcmp (arg, "verbose")) { + opts->verbose = TRUE; } else if (str_begins_with (arg, "help") || str_begins_with (arg, "?")) { printf ("Supported options for --aot:\n"); printf (" outfile=\n"); @@ -7210,6 +7262,7 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts) printf (" stats\n"); printf (" dump\n"); printf (" info\n"); + printf (" verbose\n"); printf (" help/?\n"); exit (0); } else { @@ -7499,6 +7552,9 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) if (method->wrapper_type == MONO_WRAPPER_COMINTEROP) return; + if (acfg->aot_opts.profile_only && !method->is_inflated && !g_hash_table_lookup (acfg->profile_methods, method)) + return; + InterlockedIncrement (&acfg->stats.mcount); #if 0 @@ -7841,7 +7897,7 @@ compile_thread_main (gpointer user_data) MonoError error; MonoThread *thread = mono_thread_attach (domain); - mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "AOT compiler"), TRUE, &error); + mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "AOT compiler"), TRUE, FALSE, &error); mono_error_assert_ok (&error); for (i = 0; i < methods->len; ++i) @@ -7849,95 +7905,6 @@ compile_thread_main (gpointer user_data) return 0; } - -static void -load_profile_files (MonoAotCompile *acfg) -{ - FILE *infile; - char *tmp; - int file_index, res, method_index, i; - char ver [256]; - guint32 token; - GList *unordered, *l; - gboolean found; - - file_index = 0; - while (TRUE) { - tmp = g_strdup_printf ("%s/.mono/aot-profile-data/%s-%d", g_get_home_dir (), acfg->image->assembly_name, file_index); - - if (!g_file_test (tmp, G_FILE_TEST_IS_REGULAR)) { - g_free (tmp); - break; - } - - infile = fopen (tmp, "r"); - g_assert (infile); - - printf ("Using profile data file '%s'\n", tmp); - g_free (tmp); - - file_index ++; - - res = fscanf (infile, "%32s\n", ver); - if ((res != 1) || strcmp (ver, "#VER:2") != 0) { - printf ("Profile file has wrong version or invalid.\n"); - fclose (infile); - continue; - } - - while (TRUE) { - char name [1024]; - MonoMethodDesc *desc; - MonoMethod *method; - - if (fgets (name, 1023, infile) == NULL) - break; - - /* Kill the newline */ - if (strlen (name) > 0) - name [strlen (name) - 1] = '\0'; - - desc = mono_method_desc_new (name, TRUE); - - method = mono_method_desc_search_in_image (desc, acfg->image); - - if (method && mono_method_get_token (method)) { - token = mono_method_get_token (method); - method_index = mono_metadata_token_index (token) - 1; - - found = FALSE; - for (i = 0; i < acfg->method_order->len; ++i) { - if (g_ptr_array_index (acfg->method_order, i) == GUINT_TO_POINTER (method_index)) { - found = TRUE; - break; - } - } - if (!found) - g_ptr_array_add (acfg->method_order, GUINT_TO_POINTER (method_index)); - } else { - //printf ("No method found matching '%s'.\n", name); - } - } - fclose (infile); - } - - /* Add missing methods */ - unordered = NULL; - for (method_index = 0; method_index < acfg->image->tables [MONO_TABLE_METHOD].rows; ++method_index) { - found = FALSE; - for (i = 0; i < acfg->method_order->len; ++i) { - if (g_ptr_array_index (acfg->method_order, i) == GUINT_TO_POINTER (method_index)) { - found = TRUE; - break; - } - } - if (!found) - unordered = g_list_prepend (unordered, GUINT_TO_POINTER (method_index)); - } - unordered = g_list_reverse (unordered); - for (l = unordered; l; l = l->next) - g_ptr_array_add (acfg->method_order, l->data); -} /* Used by the LLVM backend */ guint32 @@ -9928,7 +9895,7 @@ compile_methods (MonoAotCompile *acfg) /* Compile methods added by compile_method () or all methods if nthreads == 0 */ for (i = methods_len; i < acfg->methods->len; ++i) { - /* This can new methods to acfg->methods */ + /* This can add new methods to acfg->methods */ compile_method (acfg, (MonoMethod *)g_ptr_array_index (acfg->methods, i)); } } @@ -10097,7 +10064,7 @@ compile_asm (MonoAotCompile *acfg) wrap_path (tmp_outfile_name), wrap_path (llvm_ofile), wrap_path (g_strdup_printf ("%s." AS_OBJECT_FILE_SUFFIX, acfg->tmpfname)), ld_flags); - if (acfg->llvm) { + if (acfg->aot_opts.llvm_only) { command = g_strdup_printf ("clang++ %s", args); } else { command = g_strdup_printf ("\"%sld\" %s", tool_prefix, args); @@ -10169,7 +10136,460 @@ compile_asm (MonoAotCompile *acfg) return 0; } -static void init_got_info (GotInfo *info) +static guint8 +profread_byte (FILE *infile) +{ + guint8 i; + int res; + + res = fread (&i, 1, 1, infile); + g_assert (res == 1); + return i; +} + +static int +profread_int (FILE *infile) +{ + int i, res; + + res = fread (&i, 4, 1, infile); + g_assert (res == 1); + return i; +} + +static char* +profread_string (FILE *infile) +{ + int len, res; + char buf [1024]; + char *pbuf; + + len = profread_int (infile); + if (len + 1 > 1024) + pbuf = g_malloc (len + 1); + else + pbuf = buf; + res = fread (pbuf, 1, len, infile); + g_assert (res == len); + pbuf [len] = '\0'; + if (pbuf == buf) + return g_strdup (buf); + else + return pbuf; +} + +static void +load_profile_file (MonoAotCompile *acfg, char *filename) +{ + FILE *infile; + char buf [1024]; + int res, len, version; + char magic [32]; + + infile = fopen (filename, "r"); + if (!infile) { + fprintf (stderr, "Unable to open file '%s': %s.\n", filename, strerror (errno)); + exit (1); + } + + printf ("Using profile data file '%s'\n", filename); + + sprintf (magic, AOT_PROFILER_MAGIC); + len = strlen (magic); + res = fread (buf, 1, len, infile); + magic [len] = '\0'; + buf [len] = '\0'; + if ((res != len) || strcmp (buf, magic) != 0) { + printf ("Profile file has wrong header: '%s'.\n", buf); + fclose (infile); + exit (1); + } + guint32 expected_version = (AOT_PROFILER_MAJOR_VERSION << 16) | AOT_PROFILER_MINOR_VERSION; + version = profread_int (infile); + if (version != expected_version) { + printf ("Profile file has wrong version 0x%4x, expected 0x%4x.\n", version, expected_version); + fclose (infile); + exit (1); + } + + ProfileData *data = g_new0 (ProfileData, 1); + data->images = g_hash_table_new (NULL, NULL); + data->classes = g_hash_table_new (NULL, NULL); + data->ginsts = g_hash_table_new (NULL, NULL); + data->methods = g_hash_table_new (NULL, NULL); + + while (TRUE) { + int type = profread_byte (infile); + int id = profread_int (infile); + + if (type == AOTPROF_RECORD_NONE) + break; + + switch (type) { + case AOTPROF_RECORD_IMAGE: { + ImageProfileData *idata = g_new0 (ImageProfileData, 1); + idata->name = profread_string (infile); + char *mvid = profread_string (infile); + g_free (mvid); + g_hash_table_insert (data->images, GINT_TO_POINTER (id), idata); + break; + } + case AOTPROF_RECORD_GINST: { + int i; + int len = profread_int (infile); + + GInstProfileData *gdata = g_new0 (GInstProfileData, 1); + gdata->argc = len; + gdata->argv = g_new0 (ClassProfileData*, len); + + for (i = 0; i < len; ++i) { + int class_id = profread_int (infile); + + gdata->argv [i] = g_hash_table_lookup (data->classes, GINT_TO_POINTER (class_id)); + g_assert (gdata->argv [i]); + } + g_hash_table_insert (data->ginsts, GINT_TO_POINTER (id), gdata); + break; + } + case AOTPROF_RECORD_TYPE: { + int type = profread_byte (infile); + + switch (type) { + case MONO_TYPE_CLASS: { + int image_id = profread_int (infile); + int ginst_id = profread_int (infile); + char *class_name = profread_string (infile); + + ImageProfileData *image = g_hash_table_lookup (data->images, GINT_TO_POINTER (image_id)); + g_assert (image); + + char *p = strrchr (class_name, '.'); + g_assert (p); + *p = '\0'; + + ClassProfileData *cdata = g_new0 (ClassProfileData, 1); + cdata->image = image; + cdata->ns = g_strdup (class_name); + cdata->name = g_strdup (p + 1); + + if (ginst_id != -1) { + cdata->inst = g_hash_table_lookup (data->ginsts, GINT_TO_POINTER (ginst_id)); + g_assert (cdata->inst); + } + g_free (class_name); + + g_hash_table_insert (data->classes, GINT_TO_POINTER (id), cdata); + break; + } +#if 0 + case MONO_TYPE_SZARRAY: { + int elem_id = profread_int (infile); + // FIXME: + break; + } +#endif + default: + g_assert_not_reached (); + break; + } + break; + } + case AOTPROF_RECORD_METHOD: { + int class_id = profread_int (infile); + int ginst_id = profread_int (infile); + int param_count = profread_int (infile); + char *method_name = profread_string (infile); + char *sig = profread_string (infile); + + ClassProfileData *klass = g_hash_table_lookup (data->classes, GINT_TO_POINTER (class_id)); + g_assert (klass); + + MethodProfileData *mdata = g_new0 (MethodProfileData, 1); + mdata->id = id; + mdata->klass = klass; + mdata->name = method_name; + mdata->signature = sig; + mdata->param_count = param_count; + + if (ginst_id != -1) { + mdata->inst = g_hash_table_lookup (data->ginsts, GINT_TO_POINTER (ginst_id)); + g_assert (mdata->inst); + } + g_hash_table_insert (data->methods, GINT_TO_POINTER (id), mdata); + break; + } + default: + printf ("%d\n", type); + g_assert_not_reached (); + break; + } + } + + fclose (infile); + acfg->profile_data = g_list_append (acfg->profile_data, data); +} + +static void +resolve_class (ClassProfileData *cdata); + +static void +resolve_ginst (GInstProfileData *inst_data) +{ + int i; + + if (inst_data->inst) + return; + + for (i = 0; i < inst_data->argc; ++i) { + resolve_class (inst_data->argv [i]); + if (!inst_data->argv [i]->klass) + return; + } + MonoType **args = g_new0 (MonoType*, inst_data->argc); + for (i = 0; i < inst_data->argc; ++i) + args [i] = &inst_data->argv [i]->klass->byval_arg; + + inst_data->inst = mono_metadata_get_generic_inst (inst_data->argc, args); +} + +static void +resolve_class (ClassProfileData *cdata) +{ + MonoError error; + MonoClass *klass; + + if (!cdata->image->image) + return; + + klass = mono_class_from_name_checked (cdata->image->image, cdata->ns, cdata->name, &error); + if (!klass) { + //printf ("[%s] %s.%s\n", cdata->image->name, cdata->ns, cdata->name); + return; + } + if (cdata->inst) { + resolve_ginst (cdata->inst); + if (!cdata->inst->inst) + return; + MonoGenericContext ctx; + + memset (&ctx, 0, sizeof (ctx)); + ctx.class_inst = cdata->inst->inst; + cdata->klass = mono_class_inflate_generic_class_checked (klass, &ctx, &error); + } else { + cdata->klass = klass; + } +} + +/* + * Resolve the profile data to the corresponding loaded classes/methods etc. if possible. + */ +static void +resolve_profile_data (MonoAotCompile *acfg, ProfileData *data) +{ + GHashTableIter iter; + gpointer key, value; + int i; + + if (!data) + return; + + /* Images */ + GPtrArray *assemblies = mono_domain_get_assemblies (mono_get_root_domain (), FALSE); + g_hash_table_iter_init (&iter, data->images); + while (g_hash_table_iter_next (&iter, &key, &value)) { + ImageProfileData *idata = (ImageProfileData*)value; + + for (i = 0; i < assemblies->len; ++i) { + MonoAssembly *ass = g_ptr_array_index (assemblies, i); + + if (!strcmp (ass->aname.name, idata->name)) { + idata->image = ass->image; + break; + } + } + } + g_ptr_array_free (assemblies, TRUE); + + /* Classes */ + g_hash_table_iter_init (&iter, data->classes); + while (g_hash_table_iter_next (&iter, &key, &value)) { + ClassProfileData *cdata = (ClassProfileData*)value; + + if (!cdata->image->image) { + if (acfg->aot_opts.verbose) + printf ("Unable to load class '%s.%s' because its image '%s' is not loaded.\n", cdata->ns, cdata->name, cdata->image->name); + continue; + } + + resolve_class (cdata); + /* + if (cdata->klass) + printf ("%s %s %s\n", cdata->ns, cdata->name, mono_class_full_name (cdata->klass)); + */ + } + + /* Methods */ + g_hash_table_iter_init (&iter, data->methods); + while (g_hash_table_iter_next (&iter, &key, &value)) { + MethodProfileData *mdata = (MethodProfileData*)value; + MonoClass *klass; + MonoMethod *m; + gpointer miter; + + resolve_class (mdata->klass); + klass = mdata->klass->klass; + if (!klass) { + if (acfg->aot_opts.verbose) + printf ("Unable to load method '%s' because its class '%s.%s' is not loaded.\n", mdata->name, mdata->klass->ns, mdata->klass->name); + continue; + } + miter = NULL; + while ((m = mono_class_get_methods (klass, &miter))) { + MonoError error; + + if (strcmp (m->name, mdata->name)) + continue; + MonoMethodSignature *sig = mono_method_signature (m); + if (!sig) + continue; + if (sig->param_count != mdata->param_count) + continue; + if (mdata->inst) { + resolve_ginst (mdata->inst); + if (!mdata->inst->inst) + continue; + MonoGenericContext ctx; + + memset (&ctx, 0, sizeof (ctx)); + ctx.method_inst = mdata->inst->inst; + + m = mono_class_inflate_generic_method_checked (m, &ctx, &error); + if (!m) + continue; + sig = mono_method_signature_checked (m, &error); + if (!is_ok (&error)) { + mono_error_cleanup (&error); + continue; + } + } + char *sig_str = mono_signature_full_name (sig); + gboolean match = !strcmp (sig_str, mdata->signature); + g_free (sig_str); + if (!match) + + continue; + //printf ("%s\n", mono_method_full_name (m, 1)); + mdata->method = m; + break; + } + if (!mdata->method) { + if (acfg->aot_opts.verbose) + printf ("Unable to load method '%s' from class '%s', not found.\n", mdata->name, mono_class_full_name (klass)); + } + } +} + +static gboolean +inst_references_image (MonoGenericInst *inst, MonoImage *image) +{ + int i; + + for (i = 0; i < inst->type_argc; ++i) { + MonoClass *k = mono_class_from_mono_type (inst->type_argv [i]); + if (k->image == image) + return TRUE; + if (mono_class_is_ginst (k)) { + MonoGenericInst *kinst = mono_class_get_context (k)->class_inst; + if (inst_references_image (kinst, image)) + return TRUE; + } + } + return FALSE; +} + +static gboolean +is_local_inst (MonoGenericInst *inst, MonoImage *image) +{ + int i; + + for (i = 0; i < inst->type_argc; ++i) { + MonoClass *k = mono_class_from_mono_type (inst->type_argv [i]); + if (!MONO_TYPE_IS_PRIMITIVE (inst->type_argv [i]) && k->image != image) + return FALSE; + } + return TRUE; +} + +static void +add_profile_instances (MonoAotCompile *acfg, ProfileData *data) +{ + GHashTableIter iter; + gpointer key, value; + int count = 0; + + if (!data) + return; + + if (acfg->aot_opts.profile_only) { + /* Add methods referenced by the profile */ + g_hash_table_iter_init (&iter, data->methods); + while (g_hash_table_iter_next (&iter, &key, &value)) { + MethodProfileData *mdata = (MethodProfileData*)value; + MonoMethod *m = mdata->method; + + if (!m) + continue; + if (m->is_inflated) + continue; + add_extra_method (acfg, m); + g_hash_table_insert (acfg->profile_methods, m, m); + count ++; + } + } + + /* + * Add method instances 'related' to this assembly to the AOT image. + */ + g_hash_table_iter_init (&iter, data->methods); + while (g_hash_table_iter_next (&iter, &key, &value)) { + MethodProfileData *mdata = (MethodProfileData*)value; + MonoMethod *m = mdata->method; + MonoGenericContext *ctx; + + if (!m) + continue; + if (!m->is_inflated) + continue; + + ctx = mono_method_get_context (m); + /* For simplicity, add instances which reference the assembly we are compiling */ + if (((ctx->class_inst && inst_references_image (ctx->class_inst, acfg->image)) || + (ctx->method_inst && inst_references_image (ctx->method_inst, acfg->image))) && + !mono_method_is_generic_sharable_full (m, FALSE, FALSE, FALSE)) { + //printf ("%s\n", mono_method_full_name (m, TRUE)); + add_extra_method (acfg, m); + count ++; + } else if (m->klass->image == acfg->image && + ((ctx->class_inst && is_local_inst (ctx->class_inst, acfg->image)) || + (ctx->method_inst && is_local_inst (ctx->method_inst, acfg->image))) && + !mono_method_is_generic_sharable_full (m, FALSE, FALSE, FALSE)) { + /* Add instances where the gtd is in the assembly and its inflated with types from this assembly or corlib */ + //printf ("%s\n", mono_method_full_name (m, TRUE)); + add_extra_method (acfg, m); + count ++; + } + /* + * FIXME: We might skip some instances, for example: + * Foo won't be compiled when compiling Foo's assembly since it doesn't match the first case, + * and it won't be compiled when compiling Bar's assembly if Foo's assembly is not loaded. + */ + } + + printf ("Added %d methods from profile.\n", count); +} + +static void +init_got_info (GotInfo *info) { int i; @@ -10214,6 +10634,7 @@ acfg_create (MonoAssembly *ass, guint32 opts) acfg->plt_entry_debug_sym_cache = g_hash_table_new (g_str_hash, g_str_equal); acfg->gsharedvt_in_signatures = g_hash_table_new ((GHashFunc)mono_signature_hash, (GEqualFunc)mono_metadata_signature_equal); acfg->gsharedvt_out_signatures = g_hash_table_new ((GHashFunc)mono_signature_hash, (GEqualFunc)mono_metadata_signature_equal); + acfg->profile_methods = g_hash_table_new (NULL, NULL); mono_os_mutex_init_recursive (&acfg->mutex); init_got_info (&acfg->got_info); @@ -10649,7 +11070,21 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) } } - load_profile_files (acfg); + if (acfg->aot_opts.profile_files) { + GList *l; + + for (l = acfg->aot_opts.profile_files; l; l = l->next) { + load_profile_file (acfg, (char*)l->data); + } + } + + { + int method_index; + + for (method_index = 0; method_index < acfg->image->tables [MONO_TABLE_METHOD].rows; ++method_index) { + g_ptr_array_add (acfg->method_order,GUINT_TO_POINTER (method_index)); + } + } acfg->num_trampolines [MONO_AOT_TRAMP_SPECIFIC] = mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.ntrampolines : 0; #ifdef MONO_ARCH_GSHARED_SUPPORTED @@ -10710,6 +11145,15 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options) if (!res) return 1; + { + GList *l; + + for (l = acfg->profile_data; l; l = l->next) + resolve_profile_data (acfg, (ProfileData*)l->data); + for (l = acfg->profile_data; l; l = l->next) + add_profile_instances (acfg, (ProfileData*)l->data); + } + acfg->cfgs_size = acfg->methods->len + 32; acfg->cfgs = g_new0 (MonoCompile*, acfg->cfgs_size);