Wed Jun 16 14:33:22 CEST 2004 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / mini / driver.c
index 03ffb77b6e95f67ccba29e33d7eda89e999d61ad..4e0ea2f90c279794eeb81c1b31cb66d2d14da0f1 100644 (file)
@@ -77,7 +77,8 @@ opt_names [] = {
        {"fcmov",    "Fast x86 FP compares"},
        {"leaf",     "Leaf procedures optimizations"},
        {"aot",      "Usage of Ahead Of Time compiled code"},
-       {"precomp",  "Precompile all methods before executing Main"}
+       {"precomp",  "Precompile all methods before executing Main"},
+       {"abcrem",   "Array bound checks removal"}
 };
 
 #define DEFAULT_OPTIMIZATIONS (        \
@@ -86,6 +87,7 @@ opt_names [] = {
        MONO_OPT_BRANCH |       \
        MONO_OPT_LINEARS |      \
        MONO_OPT_INTRINS |  \
+       MONO_OPT_LOOP |  \
     MONO_OPT_AOT)
 
 
@@ -139,7 +141,7 @@ parse_optimizations (const char* p)
                                if (invert)
                                        opt = 0;
                                else
-                                       opt = ~(MONO_OPT_SHARED | MONO_OPT_PRECOMP | exclude);
+                                       opt = ~(MONO_OPT_SHARED | MONO_OPT_PRECOMP | MONO_OPT_ABCREM | exclude);
                                p += 3;
                                if (*p == ',')
                                        p++;
@@ -222,7 +224,8 @@ opt_sets [] = {
        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_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_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
 };
 
 typedef int (*TestMethod) (void);
@@ -267,7 +270,7 @@ mini_regression (MonoImage *image, int verbose, int *total_run) {
        }
 
        /* load the metadata */
-       for (i = 0; i < image->tables [MONO_TABLE_METHOD].rows; ++i) {
+       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
                        method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
                mono_class_init (method->klass);
 
@@ -288,13 +291,13 @@ mini_regression (MonoImage *image, int verbose, int *total_run) {
                opt_flags = opt_sets [opt];
                mono_set_defaults (verbose, opt_flags);
                n = opt_descr (opt_flags);
-               g_print ("Test run: image=%s, opts=%s\n", image->name, n);
+               g_print ("Test run: image=%s, opts=%s\n", mono_image_get_filename (image), n);
                g_free (n);
                cfailed = failed = run = code_size = 0;
                comp_time = elapsed = 0.0;
 
                /* fixme: ugly hack - delete all previously compiled methods */
-               for (i = 0; i < image->tables [MONO_TABLE_METHOD].rows; ++i) {
+               for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
                        method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
                        method->info = NULL;
                }
@@ -302,7 +305,7 @@ mini_regression (MonoImage *image, int verbose, int *total_run) {
                g_timer_start (timer);
                if (mini_stats_fd)
                        fprintf (mini_stats_fd, "[");
-               for (i = 0; i < image->tables [MONO_TABLE_METHOD].rows; ++i) {
+               for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
                        method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
                        if (strncmp (method->name, "test_", 5) == 0) {
                                expected = atoi (method->name + 5);
@@ -373,7 +376,7 @@ mini_regression_list (int verbose, int count, char *images [])
                        g_warning ("failed to load assembly: %s", images [i]);
                        continue;
                }
-               total += mini_regression (ass->image, verbose, &run);
+               total += mini_regression (mono_assembly_get_image (ass), verbose, &run);
                total_run += run;
                mono_assembly_close (ass);
        }
@@ -387,7 +390,7 @@ enum {
        DO_REGRESSION,
        DO_COMPILE,
        DO_EXEC,
-       DO_DRAW,
+       DO_DRAW
 };
 
 typedef struct CompileAllThreadArgs {
@@ -400,11 +403,11 @@ compile_all_methods_thread_main (CompileAllThreadArgs *args)
 {
        MonoAssembly *ass = args->ass;
        int verbose = args->verbose;
-       MonoImage *image = ass->image;
+       MonoImage *image = mono_assembly_get_image (ass);
        MonoMethod *method;
        int i, count = 0;
 
-       for (i = 0; i < image->tables [MONO_TABLE_METHOD].rows; ++i) {
+       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
                method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
                if (method->flags & METHOD_ATTRIBUTE_ABSTRACT)
                        continue;
@@ -450,12 +453,12 @@ compile_all_methods (MonoAssembly *ass, int verbose)
 int 
 mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
 {
-       MonoImage *image = assembly->image;
+       MonoImage *image = mono_assembly_get_image (assembly);
        MonoMethod *method;
        guint32 entry = mono_image_get_entry_point (image);
 
        if (!entry) {
-               g_print ("Assembly '%s' doesn't have an entry point.\n", image->name);
+               g_print ("Assembly '%s' doesn't have an entry point.\n", mono_image_get_filename (image));
                /* FIXME: remove this silly requirement. */
                mono_environment_exitcode_set (1);
                return 1;
@@ -564,7 +567,7 @@ mini_trace_usage (void)
 
 static const char *info = ""
 #ifdef HAVE_KW_THREAD
-       "\tTLS:           NPTL\n"
+       "\tTLS:           __thread\n"
 #else
        "\tTLS:           normal\n"
 #endif /* HAVE_KW_THREAD */
@@ -632,7 +635,7 @@ mono_main (int argc, char* argv[])
                                const guchar *clibpath;
                                mono_init ("mono");
                                cerror = mono_check_corlib_version ();
-                               clibpath = mono_defaults.corlib? mono_defaults.corlib->name: "unknown";
+                               clibpath = mono_defaults.corlib? mono_image_get_filename (mono_defaults.corlib): "unknown";
                                if (cerror) {
                                        g_print ("The currently installed mscorlib doesn't match this runtime version.\n");
                                        g_print ("The error is: %s\n", cerror);
@@ -756,6 +759,11 @@ mono_main (int argc, char* argv[])
        if (enable_debugging)
                mono_debug_init (domain, MONO_DEBUG_FORMAT_MONO);
 
+       /* Parse gac loading options before loading assemblies. */
+       if (mono_compile_aot || action == DO_EXEC) {
+               mono_config_parse (config_file);
+       }
+
        assembly = mono_assembly_open (aname, NULL);
        if (!assembly) {
                fprintf (stderr, "cannot open assembly %s\n", aname);
@@ -775,7 +783,6 @@ mono_main (int argc, char* argv[])
        if (mono_compile_aot || action == DO_EXEC) {
                const guchar *error;
 
-               mono_config_parse (config_file);
                //mono_set_rootdir ();
 
                error = mono_check_corlib_version ();
@@ -808,7 +815,7 @@ mono_main (int argc, char* argv[])
                mini_cleanup (domain);
                return 3;
        }
-       method = mono_method_desc_search_in_image (desc, assembly->image);
+       method = mono_method_desc_search_in_image (desc, mono_assembly_get_image (assembly));
        if (!method) {
                g_print ("Cannot find method %s\n", mname);
                mini_cleanup (domain);