2 * driver.c: The new mono JIT compiler.
5 * Paolo Molaro (lupus@ximian.com)
6 * Dietmar Maurer (dietmar@ximian.com)
8 * (C) 2002-2003 Ximian, Inc.
9 * (C) 2003-2004 Novell, Inc.
16 #include <mono/metadata/assembly.h>
17 #include <mono/metadata/loader.h>
18 #include <mono/metadata/cil-coff.h>
19 #include <mono/metadata/tabledefs.h>
20 #include <mono/metadata/class.h>
21 #include <mono/metadata/object.h>
22 #include <mono/metadata/exception.h>
23 #include <mono/metadata/opcodes.h>
24 #include <mono/metadata/mono-endian.h>
25 #include <mono/metadata/tokentype.h>
26 #include <mono/metadata/tabledefs.h>
27 #include <mono/metadata/threads.h>
28 #include <mono/metadata/marshal.h>
29 #include <mono/metadata/socket-io.h>
30 #include <mono/metadata/appdomain.h>
31 #include <mono/metadata/debug-helpers.h>
32 #include <mono/io-layer/io-layer.h>
33 #include "mono/metadata/profiler.h"
34 #include <mono/metadata/profiler-private.h>
35 #include <mono/metadata/mono-config.h>
36 #include <mono/metadata/environment.h>
37 #include <mono/metadata/verify.h>
38 #include <mono/metadata/mono-debug.h>
39 #include <mono/metadata/mono-debug-debugger.h>
40 #include <mono/os/gc_wrapper.h>
49 static FILE *mini_stats_fd = NULL;
51 static void mini_usage (void);
53 typedef void (*OptFunc) (const char *p);
55 /* keep in sync with enum in mini.h */
64 {"peephole", "Peephole postpass"},
65 {"branch", "Branch optimizations"},
66 {"inline", "Inline method calls"},
67 {"cfold", "Constant folding"},
68 {"consprop", "Constant propagation"},
69 {"copyprop", "Copy propagation"},
70 {"deadce", "Dead code elimination"},
71 {"linears", "Linear scan global reg allocation"},
72 {"cmov", "Conditional moves"},
73 {"shared", "Emit per-domain code"},
74 {"sched", "Instruction scheduling"},
75 {"intrins", "Intrinsic method implementations"},
76 {"tailc", "Tail recursion and tail calls"},
77 {"loop", "Loop related optimizations"},
78 {"fcmov", "Fast x86 FP compares"},
79 {"leaf", "Leaf procedures optimizations"},
80 {"aot", "Usage of Ahead Of Time compiled code"},
81 {"precomp", "Precompile all methods before executing Main"},
82 {"abcrem", "Array bound checks removal"}
85 #define DEFAULT_OPTIMIZATIONS ( \
94 #define EXCLUDED_FROM_ALL (MONO_OPT_SHARED | MONO_OPT_PRECOMP)
97 parse_optimizations (const char* p)
99 /* the default value */
100 guint32 opt = DEFAULT_OPTIMIZATIONS;
105 /* call out to cpu detection code here that sets the defaults ... */
106 opt |= mono_arch_cpu_optimizazions (&exclude);
118 for (i = 0; i < G_N_ELEMENTS (opt_names); ++i) {
119 n = opt_names [i].name;
121 if (strncmp (p, n, len) == 0) {
130 } else if (*p == '=') {
132 if (opt_names [i].func)
133 opt_names [i].func (p);
134 while (*p && *p++ != ',');
141 if (i == G_N_ELEMENTS (opt_names)) {
142 if (strncmp (p, "all", 3) == 0) {
146 opt = ~(EXCLUDED_FROM_ALL | exclude);
151 fprintf (stderr, "Invalid optimization name `%s'\n", p);
162 MonoGraphOptions value;
165 static const GraphName
167 {"cfg", "Control Flow Graph (CFG)" , MONO_GRAPH_CFG},
168 {"dtree", "Dominator Tree", MONO_GRAPH_DTREE},
169 {"code", "CFG showing code", MONO_GRAPH_CFG_CODE},
170 {"ssa", "CFG showing code after SSA translation", MONO_GRAPH_CFG_SSA},
171 {"optcode", "CFG showing code after IR optimizations", MONO_GRAPH_CFG_OPTCODE}
174 static MonoGraphOptions
175 mono_parse_graph_options (const char* p)
180 for (i = 0; i < G_N_ELEMENTS (graph_names); ++i) {
181 n = graph_names [i].name;
183 if (strncmp (p, n, len) == 0)
184 return graph_names [i].value;
187 fprintf (stderr, "Invalid graph name provided: %s\n", p);
192 mono_parse_default_optimizations (const char* p)
196 opt = parse_optimizations (p);
201 opt_descr (guint32 flags) {
202 GString *str = g_string_new ("");
206 for (i = 0; i < G_N_ELEMENTS (opt_names); ++i) {
207 if (flags & (1 << i)) {
209 g_string_append_c (str, ',');
210 g_string_append (str, opt_names [i].name);
214 return g_string_free (str, FALSE);
224 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_INTRINS,
225 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS,
226 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP,
227 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_CFOLD,
228 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE,
229 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS,
230 MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_ABCREM
233 typedef int (*TestMethod) (void);
237 domain_dump_native_code (MonoDomain *domain) {
238 // need to poke into the domain, move to metadata/domain.c
239 // need to empty jit_info_table and code_mp
244 mini_regression (MonoImage *image, int verbose, int *total_run) {
245 guint32 i, opt, opt_flags;
249 int result, expected, failed, cfailed, run, code_size, total;
251 GTimer *timer = g_timer_new ();
254 fprintf (mini_stats_fd, "$stattitle = \'Mono Benchmark Results (various optimizations)\';\n");
256 fprintf (mini_stats_fd, "$graph->set_legend(qw(");
257 for (opt = 0; opt < G_N_ELEMENTS (opt_sets); opt++) {
258 opt_flags = opt_sets [opt];
259 n = opt_descr (opt_flags);
263 fprintf (mini_stats_fd, " ");
264 fprintf (mini_stats_fd, "%s", n);
268 fprintf (mini_stats_fd, "));\n");
270 fprintf (mini_stats_fd, "@data = (\n");
271 fprintf (mini_stats_fd, "[");
274 /* load the metadata */
275 for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
276 method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
277 mono_class_init (method->klass);
279 if (!strncmp (method->name, "test_", 5) && mini_stats_fd) {
280 fprintf (mini_stats_fd, "\"%s\",", method->name);
284 fprintf (mini_stats_fd, "],\n");
289 for (opt = 0; opt < G_N_ELEMENTS (opt_sets); ++opt) {
290 double elapsed, comp_time, start_time;
293 opt_flags = opt_sets [opt];
294 mono_set_defaults (verbose, opt_flags);
295 n = opt_descr (opt_flags);
296 g_print ("Test run: image=%s, opts=%s\n", mono_image_get_filename (image), n);
298 cfailed = failed = run = code_size = 0;
299 comp_time = elapsed = 0.0;
301 /* fixme: ugly hack - delete all previously compiled methods */
302 for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
303 method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
307 g_timer_start (timer);
309 fprintf (mini_stats_fd, "[");
310 for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
311 method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
312 if (strncmp (method->name, "test_", 5) == 0) {
313 expected = atoi (method->name + 5);
315 start_time = g_timer_elapsed (timer, NULL);
316 comp_time -= start_time;
317 cfg = mini_method_compile (method, opt_flags, mono_get_root_domain (), TRUE, 0);
318 comp_time += g_timer_elapsed (timer, NULL);
321 g_print ("Running '%s' ...\n", method->name);
322 #ifdef MONO_USE_AOT_COMPILER
323 if ((jinfo = mono_aot_get_method (mono_get_root_domain (), method)))
324 func = jinfo->code_start;
327 func = (TestMethod)cfg->native_code;
329 if (result != expected) {
332 g_print ("Test '%s' failed result (got %d, expected %d).\n", method->name, result, expected);
334 code_size += cfg->code_len;
335 mono_destroy_compile (cfg);
340 g_print ("Test '%s' failed compilation.\n", method->name);
343 fprintf (mini_stats_fd, "%f, ",
344 g_timer_elapsed (timer, NULL) - start_time);
348 fprintf (mini_stats_fd, "],\n");
349 g_timer_stop (timer);
350 elapsed = g_timer_elapsed (timer, NULL);
351 g_print ("Results: total tests: %d, failed: %d, cfailed: %d (pass: %.2f%%)\n",
352 run, failed, cfailed, 100.0*(run-failed-cfailed)/run);
353 g_print ("Elapsed time: %f secs (%f, %f), Code size: %d\n\n", elapsed,
354 elapsed - comp_time, comp_time, code_size);
355 total += failed + cfailed;
360 fprintf (mini_stats_fd, ");\n");
361 fflush (mini_stats_fd);
364 g_timer_destroy (timer);
369 mini_regression_list (int verbose, int count, char *images [])
371 int i, total, total_run, run;
374 total_run = total = 0;
375 for (i = 0; i < count; ++i) {
376 ass = mono_assembly_open (images [i], NULL);
378 g_warning ("failed to load assembly: %s", images [i]);
381 total += mini_regression (mono_assembly_get_image (ass), verbose, &run);
384 g_print ("Overall results: tests: %d, failed: %d, opt combinations: %d (pass: %.2f%%)\n",
385 total_run, total, (int)G_N_ELEMENTS (opt_sets), 100.0*(total_run-total)/total_run);
397 typedef struct CompileAllThreadArgs {
400 } CompileAllThreadArgs;
403 compile_all_methods_thread_main (CompileAllThreadArgs *args)
405 MonoAssembly *ass = args->ass;
406 int verbose = args->verbose;
407 MonoImage *image = mono_assembly_get_image (ass);
411 for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
412 method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
413 if (method->flags & METHOD_ATTRIBUTE_ABSTRACT)
415 if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
420 char * desc = mono_method_full_name (method, TRUE);
421 g_print ("Compiling %d %s\n", count, desc);
424 mono_compile_method (method);
430 compile_all_methods (MonoAssembly *ass, int verbose)
432 CompileAllThreadArgs args;
435 args.verbose = verbose;
438 * Need to create a mono thread since compilation might trigger
439 * running of managed code.
441 mono_thread_create (mono_domain_get (), compile_all_methods_thread_main, &args);
443 mono_thread_manage ();
448 * @assembly: reference to an assembly
449 * @argc: argument count
450 * @argv: argument vector
452 * Start execution of a program.
455 mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
457 MonoImage *image = mono_assembly_get_image (assembly);
459 guint32 entry = mono_image_get_entry_point (image);
462 g_print ("Assembly '%s' doesn't have an entry point.\n", mono_image_get_filename (image));
463 /* FIXME: remove this silly requirement. */
464 mono_environment_exitcode_set (1);
468 method = mono_get_method (image, entry, NULL);
470 return mono_runtime_run_main (method, argc, argv, NULL);
483 static void main_thread_handler (gpointer user_data)
485 MainThreadArgs *main_args = user_data;
486 MonoAssembly *assembly;
488 assembly = mono_domain_assembly_open (main_args->domain, main_args->file);
490 fprintf (stderr, "Can not open image %s\n", main_args->file);
494 if (mono_compile_aot) {
495 int res = mono_compile_assembly (assembly, main_args->opts, main_args->aot_options);
496 printf ("AOT RESULT %d\n", res);
499 * This must be done in a thread managed by mono since it can invoke
502 if (main_args->opts & MONO_OPT_PRECOMP)
503 mono_precompile_assemblies ();
505 mono_jit_exec (main_args->domain, assembly, main_args->argc, main_args->argv);
515 "Usage is: mono [options] assembly\n\n"
516 "Runtime and JIT debugging:\n"
517 " --compile METHOD Just compile METHOD in assembly\n"
518 " --ncompile N Number of times to compile METHOD (default: 1)\n"
519 " --regression Runs the regression test contained in the assembly\n"
520 " --print-vtable Print the vtable of all used classes\n"
521 " --trace[=EXPR] Enable tracing, use --help-trace for details\n"
522 " --compile-all Compiles all the methods in the assembly\n"
523 " --breakonex Inserts a breakpoint on exceptions\n"
524 " --break METHOD Inserts a breakpoint at METHOD entry\n"
525 " --debug Enable debugging support\n"
526 " --stats Print statistics about the JIT operations\n"
529 " --statfile FILE Sets the stat file to FILE\n"
530 " --aot Compiles the assembly to native code\n"
531 " --profile[=profiler] Runs in profiling mode with the specified profiler module\n"
532 " --graph[=TYPE] METHOD Draws a graph of the specified method:\n");
534 for (i = 0; i < G_N_ELEMENTS (graph_names); ++i) {
535 fprintf (stdout, " %-10s %s\n", graph_names [i].name, graph_names [i].desc);
541 " --config FILE Loads FILE as the Mono config\n"
542 " --verbose, -v Increases the verbosity level\n"
543 " --help, -h Show usage information\n"
544 " --version, -V Show version information\n"
545 " --optimize=OPT Turns on a specific optimization:\n");
547 for (i = 0; i < G_N_ELEMENTS (opt_names); ++i)
548 fprintf (stdout, " %-10s %s\n", opt_names [i].name, opt_names [i].desc);
552 mini_trace_usage (void)
556 " --trace[=EXPR] Trace every call, optional EXPR controls the scope\n"
558 "EXPR is composed of:\n"
559 " all All assemblies\n"
560 " none No assemblies\n"
561 " program Entry point assembly\n"
562 " assembly Specifies an assembly\n"
563 " M:Type:Method Specifies a method\n"
564 " N:Namespace Specifies a namespace\n"
565 " T:Type Specifies a type\n"
566 " +EXPR Includes expression\n"
567 " -EXPR Excludes expression\n");
570 static const char *info = ""
571 #ifdef HAVE_KW_THREAD
575 #endif /* HAVE_KW_THREAD */
577 #ifdef USE_INCLUDED_LIBGC
578 "\tGC: Included Boehm (with typed GC)\n"
580 #if HAVE_GC_GCJ_MALLOC
581 "\tGC: System Boehm (with typed GC)\n"
583 "\tGC: System Boehm (no typed GC available)\n"
588 #endif /* HAVE_BOEHM_GC */
589 #ifdef MONO_ARCH_SIGSEGV_ON_ALTSTACK
590 "\tSIGSEGV : altstack\n"
592 "\tSIGSEGV : normal\n"
595 "\tGlobalization: ICU\n"
597 "\tGlobalization: none\n"
598 #endif /* HAVE_ICU */
602 mono_main (int argc, char* argv[])
604 MainThreadArgs main_args;
605 MonoAssembly *assembly;
606 MonoMethodDesc *desc;
610 const char* aname, *mname = NULL;
611 char *config_file = NULL;
613 int enable_debugging = FALSE;
614 guint32 opt, action = DO_EXEC;
615 MonoGraphOptions mono_graph_options = 0;
616 int mini_verbose = 0;
617 gboolean enable_profile = FALSE;
618 char *trace_options = NULL;
619 char *profile_options;
620 char *aot_options = NULL;
622 setlocale (LC_ALL, "");
623 g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
624 g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);
626 opt = parse_optimizations (NULL);
628 for (i = 1; i < argc; ++i) {
629 if (argv [i] [0] != '-')
631 if (strcmp (argv [i], "--regression") == 0) {
632 action = DO_REGRESSION;
633 } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) {
635 } else if (strcmp (argv [i], "--version") == 0 || strcmp (argv [i], "-V") == 0) {
636 g_print ("Mono JIT compiler version %s, (C) 2002-2004 Novell, Inc and Contributors. www.go-mono.com\n", VERSION);
639 const guchar *cerror;
640 const guchar *clibpath;
642 cerror = mono_check_corlib_version ();
643 clibpath = mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown";
645 g_print ("The currently installed mscorlib doesn't match this runtime version.\n");
646 g_print ("The error is: %s\n", cerror);
647 g_print ("mscorlib.dll loaded at: %s\n", clibpath);
652 } else if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0) {
655 } else if (strcmp (argv [i], "--help-trace") == 0){
658 } else if (strncmp (argv [i], "--statfile", 10) == 0) {
659 mini_stats_fd = fopen (argv [++i], "w+");
660 } else if (strncmp (argv [i], "--optimize=", 11) == 0) {
661 opt = parse_optimizations (argv [i] + 11);
662 } else if (strncmp (argv [i], "-O=", 3) == 0) {
663 opt = parse_optimizations (argv [i] + 3);
664 } else if (strcmp (argv [i], "--config") == 0) {
665 config_file = argv [++i];
666 } else if (strcmp (argv [i], "--ncompile") == 0) {
667 count = atoi (argv [++i]);
669 } else if (strcmp (argv [i], "--trace") == 0) {
670 trace_options = (char*)"";
671 } else if (strncmp (argv [i], "--trace=", 8) == 0) {
672 trace_options = &argv [i][8];
673 } else if (strcmp (argv [i], "--breakonex") == 0) {
674 mono_break_on_exc = TRUE;
675 } else if (strcmp (argv [i], "--break") == 0) {
676 if (!mono_debugger_insert_breakpoint (argv [++i], FALSE))
677 g_error ("Invalid method name '%s'", argv [i]);
678 } else if (strcmp (argv [i], "--print-vtable") == 0) {
679 mono_print_vtable = TRUE;
680 } else if (strcmp (argv [i], "--stats") == 0) {
681 mono_stats.enabled = TRUE;
682 mono_jit_stats.enabled = TRUE;
683 } else if (strcmp (argv [i], "--aot") == 0) {
684 mono_compile_aot = TRUE;
685 } else if (strncmp (argv [i], "--aot=", 6) == 0) {
686 mono_compile_aot = TRUE;
687 aot_options = &argv [i][6];
688 } else if (strcmp (argv [i], "--compile-all") == 0) {
690 } else if (strcmp (argv [i], "--profile") == 0) {
691 enable_profile = TRUE;
692 profile_options = NULL;
693 } else if (strncmp (argv [i], "--profile=", 10) == 0) {
694 enable_profile = TRUE;
695 profile_options = argv [i] + 10;
696 } else if (strcmp (argv [i], "--compile") == 0) {
699 } else if (strncmp (argv [i], "--graph=", 8) == 0) {
700 mono_graph_options = mono_parse_graph_options (argv [i] + 8);
703 } else if (strcmp (argv [i], "--graph") == 0) {
705 mono_graph_options = MONO_GRAPH_CFG;
707 } else if (strcmp (argv [i], "--debug") == 0) {
708 enable_debugging = TRUE;
710 fprintf (stderr, "Unknown command line option: '%s'\n", argv [i]);
720 if (mono_compile_aot || action == DO_EXEC) {
721 g_set_prgname (argv[i]);
724 if (enable_profile) {
725 /* Needed because of TLS accesses in mono_profiler_load () */
727 mono_profiler_load (profile_options);
730 if (trace_options != NULL){
732 * Need to call this before mini_init () so we can trace methods
733 * compiled there too.
735 mono_jit_trace_calls = mono_trace_parse_options (assembly, trace_options);
736 if (mono_jit_trace_calls == NULL)
740 mono_set_defaults (mini_verbose, opt);
741 domain = mini_init (argv [i]);
745 if (mini_regression_list (mini_verbose, argc -i, argv + i)) {
746 g_print ("Regression ERRORS!\n");
747 mini_cleanup (domain);
750 mini_cleanup (domain);
753 if (argc - i != 1 || mname == NULL) {
754 g_print ("Usage: mini --ncompile num --compile method assembly\n");
755 mini_cleanup (domain);
763 mini_cleanup (domain);
769 if (argc - i != 1 || mname == NULL) {
771 mini_cleanup (domain);
779 mini_cleanup (domain);
786 if (enable_debugging) {
787 mono_debug_init (MONO_DEBUG_FORMAT_MONO);
788 mono_debug_init_1 (domain);
791 /* Parse gac loading options before loading assemblies. */
792 if (mono_compile_aot || action == DO_EXEC) {
793 mono_config_parse (config_file);
796 assembly = mono_assembly_open (aname, NULL);
798 fprintf (stderr, "cannot open assembly %s\n", aname);
799 mini_cleanup (domain);
803 if (enable_debugging)
804 mono_debug_init_2 (assembly);
806 if (mono_compile_aot || action == DO_EXEC) {
809 //mono_set_rootdir ();
811 error = mono_check_corlib_version ();
813 fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error);
814 fprintf (stderr, "Download a newer corlib or a newer runtime at http://www.go-mono.com/daily.\n");
818 main_args.domain = domain;
819 main_args.file = aname;
820 main_args.argc = argc - i;
821 main_args.argv = argv + i;
822 main_args.opts = opt;
823 main_args.aot_options = aot_options;
825 mono_runtime_exec_managed_code (domain, main_thread_handler, &main_args);
826 mini_cleanup (domain);
828 /* Look up return value from System.Environment.ExitCode */
829 i = mono_environment_exitcode_get ();
831 } else if (action == DO_COMPILE) {
832 compile_all_methods (assembly, mini_verbose);
833 mini_cleanup (domain);
836 desc = mono_method_desc_new (mname, 0);
838 g_print ("Invalid method name %s\n", mname);
839 mini_cleanup (domain);
842 method = mono_method_desc_search_in_image (desc, mono_assembly_get_image (assembly));
844 g_print ("Cannot find method %s\n", mname);
845 mini_cleanup (domain);
849 if (action == DO_DRAW) {
852 switch (mono_graph_options) {
853 case MONO_GRAPH_DTREE:
855 opt |= MONO_OPT_LOOP;
857 case MONO_GRAPH_CFG_CODE:
860 case MONO_GRAPH_CFG_SSA:
863 case MONO_GRAPH_CFG_OPTCODE:
870 cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, part);
871 if ((mono_graph_options & MONO_GRAPH_CFG_SSA) && !(cfg->comp_done & MONO_COMP_SSA)) {
872 g_warning ("no SSA info available (use -O=deadce)");
875 mono_draw_graph (cfg, mono_graph_options);
876 mono_destroy_compile (cfg);
878 } else if (action == DO_BENCH) {
881 double no_opt_time = 0.0;
882 GTimer *timer = g_timer_new ();
883 fprintf (mini_stats_fd, "$stattitle = \'Compilations times for %s\';\n",
884 mono_method_full_name (method, TRUE));
885 fprintf (mini_stats_fd, "@data = (\n");
886 fprintf (mini_stats_fd, "[");
887 for (i = 0; i < G_N_ELEMENTS (opt_sets); i++) {
892 fprintf (mini_stats_fd, "\"%s\",", n);
894 fprintf (mini_stats_fd, "],\n[");
896 for (i = 0; i < G_N_ELEMENTS (opt_sets); i++) {
900 g_timer_start (timer);
901 for (j = 0; j < count; ++j) {
902 cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, 0);
903 mono_destroy_compile (cfg);
905 g_timer_stop (timer);
906 elapsed = g_timer_elapsed (timer, NULL);
908 no_opt_time = elapsed;
909 fprintf (mini_stats_fd, "%f, ", elapsed);
911 fprintf (mini_stats_fd, "]");
912 if (no_opt_time > 0.0) {
913 fprintf (mini_stats_fd, ", \n[");
914 for (i = 0; i < G_N_ELEMENTS (opt_sets); i++)
915 fprintf (mini_stats_fd, "%f,", no_opt_time);
916 fprintf (mini_stats_fd, "]");
918 fprintf (mini_stats_fd, ");\n");
920 for (i = 0; i < count; ++i) {
921 if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
922 (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
923 method = mono_marshal_get_native_wrapper (method);
925 cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, 0);
926 mono_destroy_compile (cfg);
930 cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, 0);
931 mono_destroy_compile (cfg);
934 mini_cleanup (domain);
939 mono_jit_init (const char *file)
941 return mini_init (file);
945 mono_jit_cleanup (MonoDomain *domain)
947 mini_cleanup (domain);