Extend --compile-all to take a count parameter to recompile the same assembly multipl...
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 4 Apr 2012 15:03:13 +0000 (12:03 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 4 Apr 2012 15:15:25 +0000 (12:15 -0300)
mono/mini/driver.c

index b23fd4f6d64f9e0f5f3eaba8d4613f837e249f96..f74eb1f36310775f3888bfa11deecd75d04015fd 100644 (file)
@@ -834,10 +834,11 @@ typedef struct CompileAllThreadArgs {
        MonoAssembly *ass;
        int verbose;
        guint32 opts;
+       guint32 recompilation_times;
 } CompileAllThreadArgs;
 
 static void
-compile_all_methods_thread_main (CompileAllThreadArgs *args)
+compile_all_methods_thread_main_inner (CompileAllThreadArgs *args)
 {
        MonoAssembly *ass = args->ass;
        int verbose = args->verbose;
@@ -895,13 +896,22 @@ compile_all_methods_thread_main (CompileAllThreadArgs *args)
 }
 
 static void
-compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts)
+compile_all_methods_thread_main (CompileAllThreadArgs *args)
+{
+       guint32 i;
+       for (i = 0; i < args->recompilation_times; ++i)
+               compile_all_methods_thread_main_inner (args);
+}
+
+static void
+compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recompilation_times)
 {
        CompileAllThreadArgs args;
 
        args.ass = ass;
        args.verbose = verbose;
        args.opts = opts;
+       args.recompilation_times = recompilation_times;
 
        /* 
         * Need to create a mono thread since compilation might trigger
@@ -1081,7 +1091,7 @@ mini_usage_jitdeveloper (void)
                 "    --break METHOD         Inserts a breakpoint at METHOD entry\n"
                 "    --break-at-bb METHOD N Inserts a breakpoint in METHOD at BB N\n"
                 "    --compile METHOD       Just compile METHOD in assembly\n"
-                "    --compile-all          Compiles all the methods in the assembly\n"
+                "    --compile-all=N        Compiles all the methods in the assembly multiple times (default: 1)\n"
                 "    --ncompile N           Number of times to compile METHOD (default: 1)\n"
                 "    --print-vtable         Print the vtable of all used classes\n"
                 "    --regression           Runs the regression test contained in the assembly\n"
@@ -1389,7 +1399,7 @@ mono_main (int argc, char* argv[])
        const char* aname, *mname = NULL;
        char *config_file = NULL;
        int i, count = 1;
-       guint32 opt, action = DO_EXEC;
+       guint32 opt, action = DO_EXEC, recompilation_times = 1;
        MonoGraphOptions mono_graph_options = 0;
        int mini_verbose = 0;
        gboolean enable_profile = FALSE;
@@ -1601,6 +1611,9 @@ mono_main (int argc, char* argv[])
                        mono_compile_aot = TRUE;
                        aot_options = &argv [i][6];
 #endif
+               } else if (strncmp (argv [i], "--compile-all=", 14) == 0) {
+                       action = DO_COMPILE;
+                       recompilation_times = atoi (argv [i] + 14);
                } else if (strcmp (argv [i], "--compile-all") == 0) {
                        action = DO_COMPILE;
                } else if (strncmp (argv [i], "--runtime=", 10) == 0) {
@@ -1955,7 +1968,7 @@ mono_main (int argc, char* argv[])
                i = mono_environment_exitcode_get ();
                return i;
        } else if (action == DO_COMPILE) {
-               compile_all_methods (assembly, mini_verbose, opt);
+               compile_all_methods (assembly, mini_verbose, opt, recompilation_times);
                mini_cleanup (domain);
                return 0;
        } else if (action == DO_DEBUGGER) {