* roottypes.cs: Rename from tree.cs.
[mono.git] / mono / mini / driver.c
index 4783d28eded1db04d0923617153b3d112ecd8266..58f900e7bc0f44b46e1bbb508208ca4c7220bf89 100644 (file)
@@ -6,7 +6,7 @@
  *   Dietmar Maurer (dietmar@ximian.com)
  *
  * (C) 2002-2003 Ximian, Inc.
- * (C) 2003-2004 Novell, Inc.
+ * (C) 2003-2006 Novell, Inc.
  */
 
 #include <config.h>
@@ -38,6 +38,7 @@
 #include <mono/metadata/mono-debug.h>
 #include <mono/metadata/security-manager.h>
 #include <mono/os/gc_wrapper.h>
+#include "mono/utils/mono-counters.h"
 
 #include "mini.h"
 #include "jit.h"
@@ -50,6 +51,10 @@ static FILE *mini_stats_fd = NULL;
 
 static void mini_usage (void);
 
+extern int mini_wapi_hps (int argc, char **argv);
+extern int mini_wapi_semdel (int argc, char **argv);
+extern int mini_wapi_seminfo (int argc, char **argv);
+
 /* This turns off command line globbing under win32 */
 #ifdef PLATFORM_WIN32
 int _CRT_glob = 0;
@@ -87,12 +92,18 @@ opt_names [] = {
        {"abcrem",     "Array bound checks removal"},   
        {"ssapre",     "SSA based Partial Redundancy Elimination"},
        {"exception",  "Optimize exception catch blocks"},
-       {"ssa",        "Build and use SSA form"}
+       {"ssa",        "Use plain SSA form"},
+       {"treeprop",   "Tree propagation"}
 };
 
 #define DEFAULT_OPTIMIZATIONS (        \
        MONO_OPT_PEEPHOLE |     \
        MONO_OPT_CFOLD |        \
+       MONO_OPT_INLINE |       \
+       MONO_OPT_CONSPROP |     \
+       MONO_OPT_COPYPROP |     \
+       MONO_OPT_TREEPROP |     \
+       MONO_OPT_DEADCE |       \
        MONO_OPT_BRANCH |       \
        MONO_OPT_LINEARS |      \
        MONO_OPT_INTRINS |  \
@@ -241,6 +252,7 @@ opt_sets [] = {
        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_EXCEPTION | MONO_OPT_ABCREM,
        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_EXCEPTION | MONO_OPT_ABCREM | MONO_OPT_SSAPRE,
        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,
+       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_TREEPROP,
        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_SSAPRE,
        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 | MONO_OPT_SHARED
 };
@@ -331,7 +343,7 @@ mini_regression (MonoImage *image, int verbose, int *total_run) {
                                comp_time -= start_time; 
                                cfg = mini_method_compile (method, opt_flags, mono_get_root_domain (), TRUE, FALSE, 0);
                                comp_time += g_timer_elapsed (timer, NULL);
-                               if (cfg) {
+                               if (cfg->exception_type == MONO_EXCEPTION_NONE) {
                                        if (verbose >= 2)
                                                g_print ("Running '%s' ...\n", method->name);
 #ifdef MONO_USE_AOT_COMPILER
@@ -499,7 +511,12 @@ mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[
        }
 
        method = mono_get_method (image, entry, NULL);
-
+       if (method == NULL){
+               g_print ("The entry point method could not be loaded\n");
+               mono_environment_exitcode_set (1);
+               return 1;
+       }
+       
        return mono_runtime_run_main (method, argc, argv, NULL);
 }
 
@@ -555,6 +572,7 @@ mini_usage_jitdeveloper (void)
                 "    --regression           Runs the regression test contained in the assembly\n"
                 "    --statfile FILE        Sets the stat file to FILE\n"
                 "    --stats                Print statistics about the JIT operations\n"
+                "    --wapi=hps|semdel      IO-layer maintenance\n"
                 "\n"
                 "Other options:\n" 
                 "    --graph[=TYPE] METHOD  Draws a graph of the specified method:\n");
@@ -616,30 +634,19 @@ mini_trace_usage (void)
                 "    disabled             Don't print any output until toggled via SIGUSR2\n");
 }
 
-static const char *info = ""
+static const char info[] =
 #ifdef HAVE_KW_THREAD
        "\tTLS:           __thread\n"
 #else
        "\tTLS:           normal\n"
 #endif /* HAVE_KW_THREAD */
-#ifdef HAVE_BOEHM_GC
-#ifdef USE_INCLUDED_LIBGC
-       "\tGC:            Included Boehm (with typed GC)\n"
-#else
-#if HAVE_GC_GCJ_MALLOC
-       "\tGC:            System Boehm (with typed GC)\n"
-#else
-       "\tGC:            System Boehm (no typed GC available)\n"
-#endif
-#endif
-#else
-       "\tGC:            none\n"
-#endif /* HAVE_BOEHM_GC */
+       "\tGC:            " USED_GC_NAME "\n"
 #ifdef MONO_ARCH_SIGSEGV_ON_ALTSTACK
-    "\tSIGSEGV      : altstack\n"
+    "\tSIGSEGV:       altstack\n"
 #else
-    "\tSIGSEGV      : normal\n"
+    "\tSIGSEGV:       normal\n"
 #endif
+       "\tDisabled:      " DISABLED_FEATURES "\n"
        "";
 
 int
@@ -694,7 +701,7 @@ mono_main (int argc, char* argv[])
                } else if (strcmp (argv [i], "--verbose") == 0 || strcmp (argv [i], "-v") == 0) {
                        mini_verbose++;
                } else if (strcmp (argv [i], "--version") == 0 || strcmp (argv [i], "-V") == 0) {
-                       g_print ("Mono JIT compiler version %s, (C) 2002-2005 Novell, Inc and Contributors. www.mono-project.com\n", VERSION);
+                       g_print ("Mono JIT compiler version %s, (C) 2002-2006 Novell, Inc and Contributors. www.mono-project.com\n", VERSION);
                        g_print (info);
                        if (mini_verbose) {
                                const char *cerror;
@@ -762,6 +769,7 @@ mono_main (int argc, char* argv[])
                } else if (strcmp (argv [i], "--print-vtable") == 0) {
                        mono_print_vtable = TRUE;
                } else if (strcmp (argv [i], "--stats") == 0) {
+                       mono_counters_enable (-1);
                        mono_stats.enabled = TRUE;
                        mono_jit_stats.enabled = TRUE;
 #ifndef DISABLE_AOT
@@ -811,12 +819,25 @@ mono_main (int argc, char* argv[])
                        mono_use_security_manager = TRUE;
                        mono_activate_security_manager ();
                } else if (strcmp (argv [i], "--desktop") == 0) {
+#if defined (HAVE_BOEHM_GC)
                        GC_dont_expand = 1;
+#endif
                        /* Put desktop-specific optimizations here */
                } else if (strcmp (argv [i], "--server") == 0){
                        /* Put server-specific optimizations here */
                } else if (strcmp (argv [i], "--inside-mdb") == 0) {
                        action = DO_DEBUGGER;
+               } else if (strncmp (argv [i], "--wapi=", 7) == 0) {
+                       if (strcmp (argv [i] + 7, "hps") == 0) {
+                               return mini_wapi_hps (argc - i, argv + i);
+                       } else if (strcmp (argv [i] + 7, "semdel") == 0) {
+                               return mini_wapi_semdel (argc - i, argv + i);
+                       } else if (strcmp (argv [i] + 7, "seminfo") == 0) {
+                               return mini_wapi_seminfo (argc - i, argv + i);
+                       } else {
+                               fprintf (stderr, "Invalid --wapi suboption: '%s'\n", argv [i]);
+                               return 1;
+                       }
                } else {
                        fprintf (stderr, "Unknown command line option: '%s'\n", argv [i]);
                        return 1;
@@ -828,6 +849,9 @@ mono_main (int argc, char* argv[])
                return 1;
        }
 
+       if ((action == DO_EXEC) && g_getenv ("MONO_INSIDE_MDB"))
+               action = DO_DEBUGGER;
+
        if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
                g_set_prgname (argv[i]);
        }
@@ -850,6 +874,9 @@ mono_main (int argc, char* argv[])
 
        if (action == DO_DEBUGGER) {
                opt |= MONO_OPT_SHARED;
+               opt &= ~MONO_OPT_INLINE;
+               opt &= ~MONO_OPT_COPYPROP;
+               opt &= ~MONO_OPT_CONSPROP;
                enable_debugging = TRUE;
 
 #ifdef MONO_DEBUGGER_SUPPORTED
@@ -982,7 +1009,7 @@ mono_main (int argc, char* argv[])
                        exit (1);
                }
 
-               mono_debugger_main (domain, assembly, argc, argv);
+               mono_debugger_main (domain, assembly, argc - i, argv + i);
                mini_cleanup (domain);
                return 0;
 #else