[jit] Pass a MonoError* instead of a MonoException** to mono_jit_compile_method_inner ().
authorZoltan Varga <vargaz@gmail.com>
Wed, 27 Jan 2016 22:48:28 +0000 (17:48 -0500)
committerZoltan Varga <vargaz@gmail.com>
Wed, 27 Jan 2016 22:48:28 +0000 (17:48 -0500)
mono/mini/mini-runtime.c
mono/mini/mini.c
mono/mini/mini.h

index 159e3e4affb4f6dac53956c4a74c4d234028c34c..edd3669a82d0014924d583180a527c3ecaa229c5 100644 (file)
@@ -1846,7 +1846,7 @@ no_gsharedvt_in_wrapper (void)
 }
 
 static gpointer
-mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException **ex)
+mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoError *error)
 {
        MonoDomain *target_domain, *domain = mono_domain_get ();
        MonoJitInfo *info;
@@ -1855,6 +1855,8 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException
        MonoJitICallInfo *callinfo = NULL;
        WrapperInfo *winfo = NULL;
 
+       mono_error_init (error);
+
        /*
         * ICALL wrappers are handled specially, since there is only one copy of them
         * shared by all appdomains.
@@ -1887,9 +1889,8 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException
                                ctx = mono_method_get_context (method);
                        method = info->d.synchronized_inner.method;
                        if (ctx) {
-                               MonoError error;
-                               method = mono_class_inflate_generic_method_checked (method, ctx, &error);
-                               g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+                               method = mono_class_inflate_generic_method_checked (method, ctx, error);
+                               g_assert (mono_error_ok (error)); /* FIXME don't swallow the error */
                        }
                }
        }
@@ -1904,9 +1905,9 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException
                        mono_jit_stats.methods_lookups++;
                        vtable = mono_class_vtable (domain, method->klass);
                        g_assert (vtable);
-                       tmpEx = mono_runtime_class_init_full (vtable, ex == NULL);
+                       tmpEx = mono_runtime_class_init_full (vtable, FALSE);
                        if (tmpEx) {
-                               *ex = tmpEx;
+                               mono_error_set_exception_instance (error, tmpEx);
                                return NULL;
                        }
                        return mono_create_ftnptr (target_domain, info->code_start);
@@ -1937,7 +1938,9 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException
 #endif
 
        if (!code)
-               code = mono_jit_compile_method_inner (method, target_domain, opt, ex);
+               code = mono_jit_compile_method_inner (method, target_domain, opt, error);
+       if (!mono_error_ok (error))
+               return NULL;
 
        if (!code && mono_llvm_only) {
                if (method->wrapper_type == MONO_WRAPPER_UNKNOWN) {
@@ -1990,13 +1993,14 @@ mono_jit_compile_method_with_opt (MonoMethod *method, guint32 opt, MonoException
 gpointer
 mono_jit_compile_method (MonoMethod *method)
 {
-       MonoException *ex = NULL;
+       MonoError error;
        gpointer code;
 
-       code = mono_jit_compile_method_with_opt (method, mono_get_optimizations_for_method (method, default_opt), &ex);
+       mono_error_init (&error);
+       code = mono_jit_compile_method_with_opt (method, mono_get_optimizations_for_method (method, default_opt), &error);
        if (!code) {
-               g_assert (ex);
-               mono_raise_exception (ex);
+               g_assert (!mono_error_ok (&error));
+               mono_error_raise_exception (&error);
        }
 
        return code;
@@ -2458,16 +2462,16 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
                }
 
                if (callee) {
-                       MonoException *jit_ex = NULL;
+                       MonoError error;
 
-                       compiled_method = mono_jit_compile_method_with_opt (callee, mono_get_optimizations_for_method (callee, default_opt), &jit_ex);
+                       compiled_method = mono_jit_compile_method_with_opt (callee, mono_get_optimizations_for_method (callee, default_opt), &error);
                        if (!compiled_method) {
-                               g_assert (jit_ex);
+                               g_assert (!mono_error_ok (&error));
                                if (exc) {
-                                       *exc = (MonoObject*)jit_ex;
+                                       *exc = (MonoObject*)mono_error_convert_to_exception (&error);
                                        return NULL;
                                } else {
-                                       mono_raise_exception (jit_ex);
+                                       mono_error_raise_exception (&error);
                                        /* coverity[unreachable] */
                                }
                        }
index 8e6691ebba36f7d12539b054d4957c8fa45f9bbb..c7306b08998b45924b78fd0d593ac55fbff83b55 100644 (file)
@@ -4190,7 +4190,7 @@ create_jit_info_for_trampoline (MonoMethod *wrapper, MonoTrampInfo *info)
  *   Main entry point for the JIT.
  */
 gpointer
-mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, int opt, MonoException **jit_ex)
+mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, int opt, MonoError *error)
 {
        MonoCompile *cfg;
        gpointer code = NULL;
@@ -4201,6 +4201,8 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
        GTimer *jit_timer;
        MonoMethod *prof_method, *shared;
 
+       mono_error_init (error);
+
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
                MonoMethod *nm;
@@ -4263,7 +4265,8 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
 
                full_name = mono_method_full_name (method, TRUE);
                msg = g_strdup_printf ("Unrecognizable runtime implemented method '%s'", full_name);
-               *jit_ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", msg);
+               ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", msg);
+               mono_error_set_exception_instance (error, ex);
                g_free (full_name);
                g_free (msg);
                return NULL;
@@ -4306,7 +4309,8 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                char *fullname = mono_method_full_name (method, TRUE);
                char *msg = g_strdup_printf ("Attempting to JIT compile method '%s' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.\n", fullname);
 
-               *jit_ex = mono_get_exception_execution_engine (msg);
+               ex = mono_get_exception_execution_engine (msg);
+               mono_error_set_exception_instance (error, ex);
                g_free (fullname);
                g_free (msg);
                
@@ -4350,6 +4354,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                break;
        }
        case MONO_EXCEPTION_MONO_ERROR:
+               // FIXME: MonoError has no copy ctor
                g_assert (!mono_error_ok (&cfg->error));
                ex = mono_error_convert_to_exception (&cfg->error);
                break;
@@ -4362,7 +4367,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                        mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_FAILED);
 
                mono_destroy_compile (cfg);
-               *jit_ex = ex;
+               mono_error_set_exception_instance (error, ex);
 
                return NULL;
        }
@@ -4459,7 +4464,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
        if (!vtable) {
                ex = mono_class_get_exception_for_failure (method->klass);
                g_assert (ex);
-               *jit_ex = ex;
+               mono_error_set_exception_instance (error, ex);
                return NULL;
        }
 
@@ -4479,7 +4484,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
 
        ex = mono_runtime_class_init_full (vtable, FALSE);
        if (ex) {
-               *jit_ex = ex;
+               mono_error_set_exception_instance (error, ex);
                return NULL;
        }
        return code;
index 592d2945d2fdc1f1914c7efd5b3d4686ca7aeba4..38a78fa802cd771a65ffeaca08de76f37a28f7f0 100644 (file)
@@ -2326,7 +2326,7 @@ gpointer  mono_resolve_patch_target         (MonoMethod *method, MonoDomain *dom
 gpointer  mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji);
 gpointer  mono_jit_find_compiled_method     (MonoDomain *domain, MonoMethod *method);
 gpointer  mono_jit_compile_method           (MonoMethod *method);
-gpointer  mono_jit_compile_method_inner     (MonoMethod *method, MonoDomain *target_domain, int opt, MonoException **jit_ex);
+gpointer  mono_jit_compile_method_inner     (MonoMethod *method, MonoDomain *target_domain, int opt, MonoError *error);
 MonoLMF * mono_get_lmf                      (void);
 MonoLMF** mono_get_lmf_addr                 (void);
 void      mono_set_lmf                      (MonoLMF *lmf);