[aot] Avoid raising exceptions in the AOT runtime. (#3043)
[mono.git] / mono / mini / driver.c
index 5e6e71e26adecaf495bf6e37ae05a5477906aea2..7b37da2a67705dae962975399db081541af1392f 100644 (file)
@@ -124,9 +124,6 @@ opt_funcs [sizeof (int) * 8] = {
        NULL
 };
 
-#ifdef __native_client_codegen__
-extern gint8 nacl_align_byte;
-#endif
 #ifdef __native_client__
 extern char *nacl_mono_path;
 #endif
@@ -402,7 +399,7 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
                                if (verbose >= 2)
                                        g_print ("Running '%s' ...\n", method->name);
 #ifdef MONO_USE_AOT_COMPILER
-                               if ((func = (TestMethod)mono_aot_get_method (mono_get_root_domain (), method)))
+                               if ((func = (TestMethod)mono_aot_get_method_checked (mono_get_root_domain (), method, &error)))
                                        ;
                                else
 #endif
@@ -851,6 +848,7 @@ small_id_thread_func (gpointer arg)
 static void
 jit_info_table_test (MonoDomain *domain)
 {
+       MonoError error;
        int i;
 
        g_print ("testing jit_info_table\n");
@@ -879,8 +877,10 @@ jit_info_table_test (MonoDomain *domain)
        sleep (2);
        */
 
-       for (i = 0; i < num_threads; ++i)
-               mono_thread_create (domain, test_thread_func, &thread_datas [i]);
+       for (i = 0; i < num_threads; ++i) {
+               mono_thread_create_checked (domain, test_thread_func, &thread_datas [i], &error);
+               mono_error_assert_ok (&error);
+       }
 }
 #endif
 
@@ -973,6 +973,7 @@ compile_all_methods_thread_main (CompileAllThreadArgs *args)
 static void
 compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recompilation_times)
 {
+       MonoError error;
        CompileAllThreadArgs args;
 
        args.ass = ass;
@@ -984,7 +985,8 @@ compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recom
         * Need to create a mono thread since compilation might trigger
         * running of managed code.
         */
-       mono_thread_create (mono_domain_get (), compile_all_methods_thread_main, &args);
+       mono_thread_create_checked (mono_domain_get (), compile_all_methods_thread_main, &args, &error);
+       mono_error_assert_ok (&error);
 
        mono_thread_manage ();
 }
@@ -1162,13 +1164,18 @@ load_agent (MonoDomain *domain, char *desc)
                return 1;
        }
        
-       g_free (agent);
 
        pa [0] = main_args;
        /* Pass NULL as 'exc' so unhandled exceptions abort the runtime */
        mono_runtime_invoke_checked (method, NULL, pa, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       if (!is_ok (&error)) {
+               g_print ("The entry point method of assembly '%s' could not execute due to %s\n", agent, mono_error_get_message (&error));
+               mono_error_cleanup (&error);
+               g_free (agent);
+               return 1;
+       }
 
+       g_free (agent);
        return 0;
 }
 
@@ -1231,9 +1238,6 @@ mini_usage (void)
                "    --trace[=EXPR]         Enable tracing, use --help-trace for details\n"
                "    --jitmap               Output a jit method map to /tmp/perf-PID.map\n"
                "    --help-devel           Shows more options available to developers\n"
-#ifdef __native_client_codegen__
-               "    --nacl-align-mask-off  Turn off Native Client 32-byte alignment mask (for debug only)\n"
-#endif
                "\n"
                "Runtime:\n"
                "    --config FILE          Loads FILE as the Mono config\n"
@@ -1899,10 +1903,6 @@ mono_main (int argc, char* argv[])
 #endif
                } else if (strcmp (argv [i], "--nollvm") == 0){
                        mono_use_llvm = FALSE;
-#ifdef __native_client_codegen__
-               } else if (strcmp (argv [i], "--nacl-align-mask-off") == 0){
-                       nacl_align_byte = -1; /* 0xff */
-#endif
 #ifdef __native_client__
                } else if (strcmp (argv [i], "--nacl-mono-path") == 0){
                        nacl_mono_path = g_strdup(argv[++i]);
@@ -1917,17 +1917,13 @@ mono_main (int argc, char* argv[])
        }
 
 #ifdef __native_client_codegen__
-       if (g_getenv ("MONO_NACL_ALIGN_MASK_OFF"))
-       {
-               nacl_align_byte = -1; /* 0xff */
-       }
        if (!nacl_null_checks_off) {
                MonoDebugOptions *opt = mini_get_debug_options ();
                opt->explicit_null_checks = TRUE;
        }
 #endif
 
-#ifdef DISABLE_HW_TRAPS
+#if defined(DISABLE_HW_TRAPS) || defined(MONO_ARCH_DISABLE_HW_TRAPS)
        // Signal handlers not available
        {
                MonoDebugOptions *opt = mini_get_debug_options ();
@@ -1985,7 +1981,7 @@ mono_main (int argc, char* argv[])
         * We only set the native name of the thread since MS.NET leaves the
         * managed thread name for the main thread as null.
         */
-       mono_thread_info_set_name (mono_native_thread_id_get (), "Main");
+       mono_native_thread_set_name (mono_native_thread_id_get (), "Main");
 
        if (enable_profile) {
                mono_profiler_load (profile_options);