Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mono / mini / driver.c
index 17354b52ad03055914c7ac1c7a49beeeb7569383..310c89a4583418d40f69a7bf2e5754777dd31fff 100644 (file)
@@ -137,6 +137,7 @@ extern char *nacl_mono_path;
     MONO_OPT_CMOV |  \
        MONO_OPT_GSHARED |      \
        MONO_OPT_SIMD | \
+       MONO_OPT_ALIAS_ANALYSIS | \
        MONO_OPT_AOT)
 
 #define EXCLUDED_FROM_ALL (MONO_OPT_SHARED | MONO_OPT_PRECOMP | MONO_OPT_UNSAFE | MONO_OPT_GSHAREDVT)
@@ -309,16 +310,19 @@ opt_sets [] = {
        MONO_OPT_BRANCH,
        MONO_OPT_CFOLD,
        MONO_OPT_FCMOV,
+       MONO_OPT_ALIAS_ANALYSIS,
 #ifdef MONO_ARCH_SIMD_INTRINSICS
        MONO_OPT_SIMD,
        MONO_OPT_SSE2,
        MONO_OPT_SIMD | MONO_OPT_SSE2,
 #endif
        MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_INTRINS,
+       MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_INTRINS | MONO_OPT_ALIAS_ANALYSIS,
        MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS,
        MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP,
        MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_CFOLD,
        MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE,
+       MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_ALIAS_ANALYSIS,
        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_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_TAILC,
        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_SSA,
@@ -342,33 +346,6 @@ domain_dump_native_code (MonoDomain *domain) {
 }
 #endif
 
-static gboolean do_single_method_regression = FALSE;
-static guint32 single_method_regression_opt;
-static MonoMethod *current_single_method = NULL;
-static GSList *single_method_list = NULL;
-static GHashTable *single_method_hash = NULL;
-
-guint32
-mono_get_optimizations_for_method (MonoMethod *method, guint32 default_opt)
-{
-       g_assert (method);
-
-       if (!do_single_method_regression)
-               return default_opt;
-       if (!current_single_method) {
-               if (!single_method_hash)
-                       single_method_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
-               if (!g_hash_table_lookup (single_method_hash, method)) {
-                       g_hash_table_insert (single_method_hash, method, method);
-                       single_method_list = g_slist_prepend (single_method_list, method);
-               }
-               return default_opt;
-       }
-       if (method == current_single_method)
-               return single_method_regression_opt;
-       return default_opt;
-}
-
 static void
 mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
                guint32 opt_flags,
@@ -388,10 +365,12 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
        comp_time = elapsed = 0.0;
 
        /* fixme: ugly hack - delete all previously compiled methods */
-       g_hash_table_destroy (domain_jit_info (domain)->jit_trampoline_hash);
-       domain_jit_info (domain)->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
-       mono_internal_hash_table_destroy (&(domain->jit_code_hash));
-       mono_jit_code_hash_init (&(domain->jit_code_hash));
+       if (domain_jit_info (domain)) {
+               g_hash_table_destroy (domain_jit_info (domain)->jit_trampoline_hash);
+               domain_jit_info (domain)->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
+               mono_internal_hash_table_destroy (&(domain->jit_code_hash));
+               mono_jit_code_hash_init (&(domain->jit_code_hash));
+       }
 
        g_timer_start (timer);
        if (mini_stats_fd)
@@ -407,7 +386,7 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
                        run++;
                        start_time = g_timer_elapsed (timer, NULL);
                        comp_time -= start_time;
-                       cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, opt_flags), mono_get_root_domain (), TRUE, FALSE, 0);
+                       cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, opt_flags), mono_get_root_domain (), JIT_FLAG_RUN_CCTORS, 0);
                        comp_time += g_timer_elapsed (timer, NULL);
                        if (cfg->exception_type == MONO_EXCEPTION_NONE) {
                                if (verbose >= 2)
@@ -506,7 +485,7 @@ mini_regression (MonoImage *image, int verbose, int *total_run)
 
        total = 0;
        *total_run = 0;
-       if (do_single_method_regression) {
+       if (mono_do_single_method_regression) {
                GSList *iter;
 
                mini_regression_step (image, verbose, total_run, &total,
@@ -514,14 +493,14 @@ mini_regression (MonoImage *image, int verbose, int *total_run)
                                timer, domain);
                if (total)
                        return total;
-               g_print ("Single method regression: %d methods\n", g_slist_length (single_method_list));
+               g_print ("Single method regression: %d methods\n", g_slist_length (mono_single_method_list));
 
-               for (iter = single_method_list; iter; iter = g_slist_next (iter)) {
+               for (iter = mono_single_method_list; iter; iter = g_slist_next (iter)) {
                        char *method_name;
 
-                       current_single_method = iter->data;
+                       mono_current_single_method = iter->data;
 
-                       method_name = mono_method_full_name (current_single_method, TRUE);
+                       method_name = mono_method_full_name (mono_current_single_method, TRUE);
                        g_print ("Current single method: %s\n", method_name);
                        g_free (method_name);
 
@@ -956,7 +935,7 @@ compile_all_methods_thread_main_inner (CompileAllThreadArgs *args)
                        g_print ("Compiling %d %s\n", count, desc);
                        g_free (desc);
                }
-               cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, args->opts), mono_get_root_domain (), FALSE, FALSE, 0);
+               cfg = mini_method_compile (method, mono_get_optimizations_for_method (method, args->opts), mono_get_root_domain (), 0, 0);
                if (cfg->exception_type != MONO_EXCEPTION_NONE) {
                        printf ("Compilation of %s failed with exception '%s':\n", mono_method_full_name (cfg->method, TRUE), cfg->exception_message);
                        fail_count ++;
@@ -1307,9 +1286,6 @@ static const char info[] =
 #ifdef MONO_BIG_ARRAYS
        "bigarrays "
 #endif
-#ifdef MONO_DEBUGGER_SUPPORTED
-       "debugger "
-#endif
 #if defined(MONO_ARCH_SOFT_DEBUG_SUPPORTED) && !defined(DISABLE_SOFT_DEBUG)
        "softdebug "
 #endif
@@ -1346,7 +1322,7 @@ BOOL APIENTRY DllMain (HMODULE module_handle, DWORD reason, LPVOID reserved)
                        FreeLibrary (coree_module_handle);
                break;
        case DLL_THREAD_DETACH:
-               mono_thread_info_dettach ();
+               mono_thread_info_detach ();
                break;
        
        }
@@ -1558,7 +1534,7 @@ mono_main (int argc, char* argv[])
                } else if (strncmp (argv [i], "--single-method=", 16) == 0) {
                        char *full_opts = g_strdup_printf ("-all,%s", argv [i] + 16);
                        action = DO_SINGLE_METHOD_REGRESSION;
-                       single_method_regression_opt = parse_optimizations (full_opts);
+                       mono_single_method_regression_opt = parse_optimizations (full_opts);
                        g_free (full_opts);
                } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) {
                        mini_verbose++;
@@ -1566,7 +1542,7 @@ mono_main (int argc, char* argv[])
                        char *build = mono_get_runtime_build_info ();
                        char *gc_descr;
 
-                       g_print ("Mono Runtime Engine version %s\nCopyright (C) 2002-2013 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
+                       g_print ("Mono JIT compiler version %s\nCopyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com\n", build);
                        g_free (build);
                        g_print (info);
                        gc_descr = mono_gc_get_description ();
@@ -1878,9 +1854,6 @@ mono_main (int argc, char* argv[])
 #endif
 #endif
 
-       if ((action == DO_EXEC) && mono_debug_using_mono_debugger ())
-               action = DO_DEBUGGER;
-
        if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
                g_set_prgname (argv[i]);
        }
@@ -1909,23 +1882,11 @@ mono_main (int argc, char* argv[])
 
        if (action == DO_DEBUGGER) {
                enable_debugging = TRUE;
-
-#ifdef MONO_DEBUGGER_SUPPORTED
-               mono_debug_init (MONO_DEBUG_FORMAT_DEBUGGER);
-#else
-               g_print ("The Mono Debugger is not supported on this platform.\n");
+               g_print ("The Mono Debugger is no longer supported.\n");
                return 1;
-#endif
        } else if (enable_debugging)
                mono_debug_init (MONO_DEBUG_FORMAT_MONO);
 
-#ifdef MONO_DEBUGGER_SUPPORTED
-       if (enable_debugging) {
-               if ((opt & MONO_OPT_GSHARED) == 0)
-                       mini_debugger_set_attach_ok ();
-       }
-#endif
-
 #ifdef HOST_WIN32
        if (mixed_mode)
                mono_load_coree (argv [i]);
@@ -1953,7 +1914,7 @@ mono_main (int argc, char* argv[])
        
        switch (action) {
        case DO_SINGLE_METHOD_REGRESSION:
-               do_single_method_regression = TRUE;
+               mono_do_single_method_regression = TRUE;
        case DO_REGRESSION:
                if (mini_regression_list (mini_verbose, argc -i, argv + i)) {
                        g_print ("Regression ERRORS!\n");
@@ -2084,22 +2045,7 @@ mono_main (int argc, char* argv[])
                mini_cleanup (domain);
                return 0;
        } else if (action == DO_DEBUGGER) {
-#ifdef MONO_DEBUGGER_SUPPORTED
-               const char *error;
-
-               error = mono_check_corlib_version ();
-               if (error) {
-                       fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error);
-                       fprintf (stderr, "Download a newer corlib or a newer runtime at http://www.go-mono.com/daily.\n");
-                       exit (1);
-               }
-
-               mini_debugger_main (domain, assembly, argc - i, argv + i);
-               mini_cleanup (domain);
-               return 0;
-#else
                return 1;
-#endif
        }
        desc = mono_method_desc_new (mname, 0);
        if (!desc) {
@@ -2140,10 +2086,10 @@ mono_main (int argc, char* argv[])
                        (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
                        MonoMethod *nm;
                        nm = mono_marshal_get_native_wrapper (method, TRUE, FALSE);
-                       cfg = mini_method_compile (nm, opt, mono_get_root_domain (), FALSE, FALSE, part);
+                       cfg = mini_method_compile (nm, opt, mono_get_root_domain (), 0, part);
                }
                else
-                       cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, FALSE, part);
+                       cfg = mini_method_compile (method, opt, mono_get_root_domain (), 0, part);
                if ((mono_graph_options & MONO_GRAPH_CFG_SSA) && !(cfg->comp_done & MONO_COMP_SSA)) {
                        g_warning ("no SSA info available (use -O=deadce)");
                        return 1;
@@ -2175,7 +2121,7 @@ mono_main (int argc, char* argv[])
                                opt = opt_sets [i];
                                g_timer_start (timer);
                                for (j = 0; j < count; ++j) {
-                                       cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, FALSE, 0);
+                                       cfg = mini_method_compile (method, opt, mono_get_root_domain (), 0, 0);
                                        mono_destroy_compile (cfg);
                                }
                                g_timer_stop (timer);
@@ -2198,12 +2144,12 @@ mono_main (int argc, char* argv[])
                                        (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                                        method = mono_marshal_get_native_wrapper (method, TRUE, FALSE);
 
-                               cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, FALSE, 0);
+                               cfg = mini_method_compile (method, opt, mono_get_root_domain (), 0, 0);
                                mono_destroy_compile (cfg);
                        }
                }
        } else {
-               cfg = mini_method_compile (method, opt, mono_get_root_domain (), FALSE, FALSE, 0);
+               cfg = mini_method_compile (method, opt, mono_get_root_domain (), 0, 0);
                mono_destroy_compile (cfg);
        }
 #endif