Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono] Enable AOT to print out the list of compiled methods #81567

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ typedef struct MonoAotOptions {
char *llvm_outfile;
char *data_outfile;
char *export_symbols_outfile;
char *compiled_methods_outpath;
GList *profile_files;
GList *mibc_profile_files;
gboolean save_temps;
Expand Down Expand Up @@ -404,6 +405,7 @@ typedef struct MonoAotCompile {
FILE *logfile;
FILE *instances_logfile;
FILE *data_outfile;
FILE *compiled_methods_outfile;
int datafile_offset;
int gc_name_offset;
// In this mode, we are emitting dedupable methods that we encounter
Expand Down Expand Up @@ -8433,6 +8435,8 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts)
opts->llvm_outfile = g_strdup (arg + strlen ("llvm-outfile="));
} else if (str_begins_with (arg, "export-symbols-outfile=")) {
opts->export_symbols_outfile = g_strdup (arg + strlen ("export-symbols-outfile="));
} else if (str_begins_with (arg, "compiled-methods-outpath=")) {
opts->compiled_methods_outpath = g_strdup (arg + strlen ("compiled-methods-outpath="));
} else if (str_begins_with (arg, "temp-path=")) {
opts->temp_path = clean_path (g_strdup (arg + strlen ("temp-path=")));
} else if (str_begins_with (arg, "save-temps")) {
Expand Down Expand Up @@ -9425,6 +9429,11 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
mono_acfg_unlock (acfg);

mono_atomic_inc_i32 (&acfg->stats.ccount);

if (acfg->aot_opts.compiled_methods_outpath){
if (!mono_method_is_generic_impl (method))
fprintf (acfg->compiled_methods_outfile, "%x\n", method->token);
}
}

static mono_thread_start_return_t WINAPI
Expand Down Expand Up @@ -14142,6 +14151,14 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options)
acfg->logfile = fopen (acfg->aot_opts.logfile, "a+");
}

if (acfg->aot_opts.compiled_methods_outpath) {
fanyang-mono marked this conversation as resolved.
Show resolved Hide resolved
char *assembly_file_name = g_path_get_basename (image->name);
g_strdelimit (assembly_file_name, '.', '_');
char *filename = g_strconcat (assembly_file_name, "_compiled_methods.txt", (const char*)NULL);
char *fullpath = g_strconcat (acfg->aot_opts.compiled_methods_outpath, G_DIR_SEPARATOR_S, filename, (const char*)NULL);
acfg->compiled_methods_outfile = fopen (fullpath, "w+");
}

if (acfg->aot_opts.data_outfile) {
acfg->data_outfile = fopen (acfg->aot_opts.data_outfile, "w+");
if (!acfg->data_outfile) {
Expand Down Expand Up @@ -14455,6 +14472,10 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options)

current_acfg = NULL;

if (acfg->aot_opts.compiled_methods_outpath) {
fclose (acfg->compiled_methods_outfile);
fanyang-mono marked this conversation as resolved.
Show resolved Hide resolved
}

return emit_aot_image (acfg);
}

Expand Down Expand Up @@ -14818,6 +14839,13 @@ mono_aot_assemblies (MonoAssembly **assemblies, int nassemblies, guint32 jit_opt
dedup_methods = g_hash_table_new (NULL, NULL);
}

if (aot_opts.compiled_methods_outpath) {
if (g_ensure_directory_exists (aot_opts.compiled_methods_outpath) == FALSE) {
fprintf (stderr, "AOT : failed to create the directory to save the compiled method names: %s\n", aot_opts.compiled_methods_outpath);
exit (1);
}
}

for (int i = 0; i < nassemblies; ++i) {
res = aot_assembly (assemblies [i], jit_opts, &aot_opts);
if (res != 0) {
Expand Down