Revert "[jit] Emit code to throw method access exceptions instead of throwing them...
authorZoltan Varga <vargaz@gmail.com>
Mon, 30 May 2016 02:25:36 +0000 (22:25 -0400)
committerZoltan Varga <vargaz@gmail.com>
Mon, 30 May 2016 02:25:53 +0000 (22:25 -0400)
This reverts commit 04171d2c267d2db54b36877809dca7a890adcfc5.
Revert this as it causes test failures.

mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/method-to-ir.c
mono/mini/mini-runtime.c

index a021eace0e966b906f388d43817643b2b3feb9cf..eea343db4a75b35238914bf4a406f720891fb38e 100644 (file)
@@ -1869,12 +1869,3 @@ mono_interruption_checkpoint_from_trampoline (void)
        if (ex)
                mono_raise_exception (ex);
 }
-
-void
-mono_throw_method_access (const char *caller_name, const char *callee_name)
-{
-       MonoError error;
-
-       mono_error_set_generic_error (&error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", callee_name, caller_name);
-       mono_error_set_pending_exception (&error);
-}
index 038fff7e3d1ed032eb2c31609d800689d0dbeed7..8e2b37d367628cd1f4e3799960bd2622a77a410b 100644 (file)
@@ -224,6 +224,4 @@ MonoObject* mono_get_method_object (MonoMethod *method);
 
 double mono_ckfinite (double d);
 
-void mono_throw_method_access (const char *caller_name, const char *callee_name);
-
 #endif /* __MONO_JIT_ICALLS_H__ */
index 145766559dfb41e167448049a82e86c47e6058cc..8758d4e89af7ca3e990a8133ec99086ee84b610d 100644 (file)
                if (cfg->exception_type != MONO_EXCEPTION_NONE) \
                        goto exception_exit;                                            \
        } while (0)
+#define METHOD_ACCESS_FAILURE(method, cmethod) do {                    \
+               method_access_failure ((cfg), (method), (cmethod));                     \
+               goto exception_exit;                                                                            \
+       } while (0)
 #define FIELD_ACCESS_FAILURE(method, field) do {                                       \
                field_access_failure ((cfg), (method), (field));                        \
                goto exception_exit;    \
@@ -373,6 +377,17 @@ break_on_unverified (void)
                G_BREAKPOINT ();
 }
 
+static MONO_NEVER_INLINE void
+method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
+{
+       char *method_fname = mono_method_full_name (method, TRUE);
+       char *cil_method_fname = mono_method_full_name (cil_method, TRUE);
+       mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+       mono_error_set_generic_error (&cfg->error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", cil_method_fname, method_fname);
+       g_free (method_fname);
+       g_free (cil_method_fname);
+}
+
 static MONO_NEVER_INLINE void
 field_access_failure (MonoCompile *cfg, MonoMethod *method, MonoClassField *field)
 {
@@ -3141,28 +3156,6 @@ mono_emit_widen_call_res (MonoCompile *cfg, MonoInst *ins, MonoMethodSignature *
        return ins;
 }
 
-
-static void
-emit_method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
-{
-       char *caller_fname = mono_method_full_name (method, TRUE);
-       char *callee_fname = mono_method_full_name (cil_method, TRUE);
-       MonoInst *args [16];
-       char *n1, *n2;
-
-       n1 = mono_domain_alloc (cfg->domain, strlen (caller_fname) + 1);
-       strcmp (n1, caller_fname);
-       n2 = mono_domain_alloc (cfg->domain, strlen (callee_fname) + 1);
-       strcmp (n1, callee_fname);
-       g_free (caller_fname);
-       g_free (callee_fname);
-
-       EMIT_NEW_PCONST (cfg, args [0], n1);
-       EMIT_NEW_PCONST (cfg, args [1], n2);
-
-       mono_emit_jit_icall (cfg, mono_throw_method_access, args);
-}
-
 static MonoMethod*
 get_memcpy_method (void)
 {
@@ -9276,7 +9269,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                }
                                if (!mono_method_can_access_method (method_definition, target_method) &&
                                        !mono_method_can_access_method (method, cil_method))
-                                       emit_method_access_failure (cfg, method, cil_method);
+                                       METHOD_ACCESS_FAILURE (method, cil_method);
                        }
 
                        if (mono_security_core_clr_enabled ())
@@ -13087,7 +13080,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                                cil_method = cmethod;
                                if (!dont_verify && !cfg->skip_visibility && !mono_method_can_access_method (method, cmethod))
-                                       emit_method_access_failure (cfg, method, cil_method);
+                                       METHOD_ACCESS_FAILURE (method, cil_method);
 
                                if (mono_security_core_clr_enabled ())
                                        ensure_method_is_allowed_to_call_method (cfg, method, cmethod);
index 9bb896ee4ee78fee3cf09cbd47c8913aca853c78..b1cb79734d5b607f96df20034f6f866da27c07d9 100644 (file)
@@ -3951,7 +3951,6 @@ register_icalls (void)
        register_icall (mono_llvmonly_init_delegate_virtual, "mono_llvmonly_init_delegate_virtual", "void object object ptr", TRUE);
        register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE);
        register_icall (mono_get_method_object, "mono_get_method_object", "object ptr", TRUE);
-       register_icall (mono_throw_method_access, "mono_throw_method_access", "void ptr ptr", FALSE);
 
        register_icall_with_wrapper (mono_monitor_enter, "mono_monitor_enter", "void obj");
        register_icall_with_wrapper (mono_monitor_enter_v4, "mono_monitor_enter_v4", "void obj ptr");