[runtime] Defer destruction of MonoCompile until patches have been emitted
authorAlexander Kyte <alexmkyte@fastmail.com>
Thu, 23 Jun 2016 16:23:29 +0000 (12:23 -0400)
committerAlexander Kyte <alkyte@microsoft.com>
Wed, 6 Jul 2016 21:13:31 +0000 (17:13 -0400)
mono/mini/aot-compiler.c
mono/mini/mini.c

index f28ce19fc6d2feccba5a7978905508fae121ba33..44f9d6a785ec6919451b5ecb68efbb7c304b2dd9 100644 (file)
@@ -7468,7 +7468,6 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                if (acfg->aot_opts.print_skipped_methods)
                        printf ("Skip (disabled): %s\n", mono_method_get_full_name (method));
                InterlockedIncrement (&acfg->stats.ocount);
-               mono_destroy_compile (cfg);
                return;
        }
        cfg->method_index = index;
@@ -7511,7 +7510,6 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                if (acfg->aot_opts.print_skipped_methods)
                        printf ("Skip (abs call): %s\n", mono_method_get_full_name (method));
                InterlockedIncrement (&acfg->stats.abscount);
-               mono_destroy_compile (cfg);
                return;
        }
 
@@ -7540,7 +7538,6 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                if (acfg->aot_opts.print_skipped_methods)
                        printf ("Skip (patches): %s\n", mono_method_get_full_name (method));
                acfg->stats.ocount++;
-               mono_destroy_compile (cfg);
                mono_acfg_unlock (acfg);
                return;
        }
@@ -7721,6 +7718,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
        }
 
        /* Free some fields used by cfg to conserve memory */
+       mono_free_loop_info (cfg);
        mono_mempool_destroy (cfg->mempool);
        cfg->mempool = NULL;
        g_free (cfg->varinfo);
@@ -10050,8 +10048,10 @@ acfg_free (MonoAotCompile *acfg)
        mono_img_writer_destroy (acfg->w);
        for (i = 0; i < acfg->nmethods; ++i)
                if (acfg->cfgs [i])
-                       g_free (acfg->cfgs [i]);
+                       mono_destroy_compile (acfg->cfgs [i]);
+
        g_free (acfg->cfgs);
+
        g_free (acfg->static_linking_symbol);
        g_free (acfg->got_symbol);
        g_free (acfg->plt_symbol);
index 5105c46d1912940068cb0081c71edd8e2f29eabb..b6b8eb8e1f23430abc2c511dbb5f4053a74d8549 100644 (file)
@@ -1907,7 +1907,9 @@ mono_destroy_compile (MonoCompile *cfg)
        g_hash_table_destroy (cfg->token_info_hash);
        if (cfg->abs_patches)
                g_hash_table_destroy (cfg->abs_patches);
-       mono_mempool_destroy (cfg->mempool);
+
+       if (cfg->mempool)
+               mono_mempool_destroy (cfg->mempool);
 
        mono_debug_free_method (cfg);