Avoid asserts if a forced inline fails. Fix typos. Fixes #650407.
authorZoltan Varga <vargaz@gmail.com>
Sun, 31 Oct 2010 23:33:06 +0000 (00:33 +0100)
committerZoltan Varga <vargaz@gmail.com>
Sun, 31 Oct 2010 23:44:20 +0000 (00:44 +0100)
mono/mini/method-to-ir.c

index 72075d73ef239c062a11346503adc6beb8549c56..0c4d3260cb92cfb31fdfe83ff499cc063d09b4c8 100644 (file)
@@ -4772,7 +4772,7 @@ check_inline_caller_method_name_limit (MonoMethod *caller_method)
 
 static int
 inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **sp,
-               guchar *ip, guint real_offset, GList *dont_inline, gboolean inline_allways)
+               guchar *ip, guint real_offset, GList *dont_inline, gboolean inline_always)
 {
        MonoInst *ins, *rvar = NULL;
        MonoMethodHeader *cheader;
@@ -4794,11 +4794,11 @@ inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig,
        g_assert (cfg->exception_type == MONO_EXCEPTION_NONE);
 
 #if (MONO_INLINE_CALLED_LIMITED_METHODS)
-       if ((! inline_allways) && ! check_inline_called_method_name_limit (cmethod))
+       if ((! inline_always) && ! check_inline_called_method_name_limit (cmethod))
                return 0;
 #endif
 #if (MONO_INLINE_CALLER_LIMITED_METHODS)
-       if ((! inline_allways) && ! check_inline_caller_method_name_limit (cfg->method))
+       if ((! inline_always) && ! check_inline_caller_method_name_limit (cfg->method))
                return 0;
 #endif
 
@@ -4814,8 +4814,13 @@ inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig,
        cheader = mono_method_get_header (cmethod);
 
        if (cheader == NULL || mono_loader_get_last_error ()) {
+               MonoLoaderError *error = mono_loader_get_last_error ();
+
                if (cheader)
                        mono_metadata_free_mh (cheader);
+               if (inline_always && error)
+                       mono_cfg_set_exception (cfg, error->exception_type);
+
                mono_loader_clear_error ();
                return 0;
        }
@@ -4880,7 +4885,7 @@ inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig,
        cfg->ret_var_set = prev_ret_var_set;
        cfg->inline_depth --;
 
-       if ((costs >= 0 && costs < 60) || inline_allways) {
+       if ((costs >= 0 && costs < 60) || inline_always) {
                if (cfg->verbose_level > 2)
                        printf ("INLINE END %s -> %s\n", mono_method_full_name (cfg->method, TRUE), mono_method_full_name (cmethod, TRUE));
                
@@ -6796,17 +6801,17 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                            !disable_inline && mono_method_check_inlining (cfg, cmethod) &&
                                 !g_list_find (dont_inline, cmethod)) {
                                int costs;
-                               gboolean allways = FALSE;
+                               gboolean always = FALSE;
 
                                if ((cmethod->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
                                        (cmethod->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
                                        /* Prevent inlining of methods that call wrappers */
                                        INLINE_FAILURE;
                                        cmethod = mono_marshal_get_native_wrapper (cmethod, check_for_pending_exc, FALSE);
-                                       allways = TRUE;
+                                       always = TRUE;
                                }
 
-                               if ((costs = inline_method (cfg, cmethod, fsig, sp, ip, cfg->real_offset, dont_inline, allways))) {
+                               if ((costs = inline_method (cfg, cmethod, fsig, sp, ip, cfg->real_offset, dont_inline, always))) {
                                        ip += 5;
                                        cfg->real_offset += 5;
                                        bblock = cfg->cbb;
@@ -7994,7 +7999,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                iargs [0] = sp [0];
                                
                                costs = inline_method (cfg, mono_castclass, mono_method_signature (mono_castclass), 
-                                                          iargs, ip, cfg->real_offset, dont_inline, TRUE);                     
+                                                          iargs, ip, cfg->real_offset, dont_inline, TRUE);
+                               CHECK_CFG_EXCEPTION;
                                g_assert (costs > 0);
                                
                                ip += 5;
@@ -8052,7 +8058,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                iargs [0] = sp [0];
 
                                costs = inline_method (cfg, mono_isinst, mono_method_signature (mono_isinst), 
-                                                          iargs, ip, cfg->real_offset, dont_inline, TRUE);                     
+                                                          iargs, ip, cfg->real_offset, dont_inline, TRUE);
+                               CHECK_CFG_EXCEPTION;
                                g_assert (costs > 0);
                                
                                ip += 5;
@@ -8115,7 +8122,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                                        costs = inline_method (cfg, mono_castclass, mono_method_signature (mono_castclass), 
                                                                                   iargs, ip, cfg->real_offset, dont_inline, TRUE);
-                       
+                                       CHECK_CFG_EXCEPTION;
                                        g_assert (costs > 0);
                                
                                        ip += 5;
@@ -8346,6 +8353,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        if (cfg->opt & MONO_OPT_INLINE || cfg->compile_aot) {
                                                costs = inline_method (cfg, stfld_wrapper, mono_method_signature (stfld_wrapper), 
                                                                       iargs, ip, cfg->real_offset, dont_inline, TRUE);
+                                               CHECK_CFG_EXCEPTION;
                                                g_assert (costs > 0);
                                                      
                                                cfg->real_offset += 5;
@@ -8392,6 +8400,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                if (cfg->opt & MONO_OPT_INLINE || cfg->compile_aot) {
                                        costs = inline_method (cfg, wrapper, mono_method_signature (wrapper), 
                                                                                   iargs, ip, cfg->real_offset, dont_inline, TRUE);
+                                       CHECK_CFG_EXCEPTION;
                                        bblock = cfg->cbb;
                                        g_assert (costs > 0);
                                                      
@@ -9365,7 +9374,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        NEW_BBLOCK (cfg, dont_throw);
 
                                        /*
-                                        * Currently, we allways rethrow the abort exception, despite the 
+                                        * Currently, we always rethrow the abort exception, despite the 
                                         * fact that this is not correct. See thread6.cs for an example. 
                                         * But propagating the abort exception is more important than 
                                         * getting the sematics right.