2010-06-06 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sun, 6 Jun 2010 20:48:14 +0000 (20:48 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sun, 6 Jun 2010 20:48:14 +0000 (20:48 -0000)
* mini.c (mini_method_compile): Move the LLVM checks to a function in mini-llvm.c.

svn path=/trunk/mono/; revision=158571

mono/mini/ChangeLog
mono/mini/mini-llvm.c
mono/mini/mini.c
mono/mini/mini.h

index d6a832a90a21f5fab6db6ff1cbdc42ee0dda7c53..a6548be29f348b1bd9baa39004460eaf6bc484fc 100755 (executable)
@@ -1,5 +1,7 @@
 2010-06-06  Zoltan Varga  <vargaz@gmail.com>
 
+       * mini.c (mini_method_compile): Move the LLVM checks to a function in mini-llvm.c.
+
        * mini.c (mono_jit_runtime_invoke): Initialize *exc to NULL before calling the wrapper,
        so it doesn't have to do it.
 
index f31bd058ad89e59d11de63177a4edf4c0dc428ea..b2fa4242eb3f298614bd64c15931741e72f1d193 100644 (file)
@@ -3467,6 +3467,43 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
        return;
 }
 
+/*
+ * mono_llvm_check_method_supported:
+ *
+ *   Do some quick checks to decide whenever cfg->method can be compiled by LLVM, to avoid
+ * compiling a method twice.
+ */
+void
+mono_llvm_check_method_supported (MonoCompile *cfg)
+{
+       if (cfg->generic_sharing_context && !IS_LLVM_MONO_BRANCH) {
+               /* No way to obtain location info for this/rgctx */
+               cfg->exception_message = g_strdup ("gshared");
+               cfg->disable_llvm = TRUE;
+       }
+
+       if (cfg->method->save_lmf) {
+               cfg->exception_message = g_strdup ("lmf");
+               cfg->disable_llvm = TRUE;
+       }
+
+       if (cfg->header->num_clauses > 1 || !LLVM_CHECK_VERSION (2, 8)) {
+               /*
+                * FIXME: LLLVM 2.6 no longer seems to generate correct exception info
+                * for JITted code.
+                * FIXME: Some tests still fail with nested clauses.
+                */
+               cfg->exception_message = g_strdup ("clauses");
+               cfg->disable_llvm = TRUE;
+       }
+
+       /* FIXME: */
+       if (cfg->method->dynamic) {
+               cfg->exception_message = g_strdup ("dynamic.");
+               cfg->disable_llvm = TRUE;
+       }
+}
+
 /*
  * mono_llvm_emit_method:
  *
index 8509ae61f03a74eeb6b1d8e77dc8055d75d06c72..dcee20c402f30ff8f47e75995a77a7e5c31ee784 100644 (file)
@@ -3824,24 +3824,6 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                return cfg;
        }
 
-       if (cfg->compile_llvm) {
-               if (try_generic_shared && !IS_LLVM_MONO_BRANCH) {
-                       cfg->exception_message = g_strdup ("gshared");
-                       cfg->disable_llvm = TRUE;
-               }
-
-               if (cfg->method->save_lmf) {
-                       cfg->exception_message = g_strdup ("lmf");
-                       cfg->disable_llvm = TRUE;
-               }
-
-               /* FIXME: */
-               if (cfg->method->dynamic) {
-                       cfg->exception_message = g_strdup ("dynamic.");
-                       cfg->disable_llvm = TRUE;
-               }
-       }
-
        header = cfg->header;
        if (!header) {
                MonoLoaderError *error;
@@ -3857,16 +3839,6 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                return cfg;
        }
 
-       if (header->num_clauses > 1 || !LLVM_CHECK_VERSION (2, 8)) {
-               /*
-                * FIXME: LLLVM 2.6 no longer seems to generate correct exception info
-                * for JITted code.
-                * FIXME: Some tests still fail when this is enabled.
-                */
-               cfg->exception_message = g_strdup ("clauses");
-               cfg->disable_llvm = TRUE;
-       }
-
 #ifdef ENABLE_LLVM
        {
                static gboolean inited;
@@ -3876,21 +3848,24 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                        mono_counters_register ("Methods JITted using mono JIT", MONO_COUNTER_JIT | MONO_COUNTER_INT, &methods_without_llvm);
                        inited = TRUE;
                }
-       
+
                /* 
                 * Check for methods which cannot be compiled by LLVM early, to avoid
                 * the extra compilation pass.
                 */
-               if (COMPILE_LLVM (cfg) && cfg->disable_llvm) {
-                       if (cfg->verbose_level >= 1) {
-                               //nm = mono_method_full_name (cfg->method, TRUE);
-                               printf ("LLVM failed for '%s': %s\n", method->name, cfg->exception_message);
-                               //g_free (nm);
+               if (COMPILE_LLVM (cfg)) {
+                       mono_llvm_check_method_supported (cfg);
+                       if (cfg->disable_llvm) {
+                               if (cfg->verbose_level >= 1) {
+                                       //nm = mono_method_full_name (cfg->method, TRUE);
+                                       printf ("LLVM failed for '%s': %s\n", method->name, cfg->exception_message);
+                                       //g_free (nm);
+                               }
+                               InterlockedIncrement (&methods_without_llvm);
+                               mono_destroy_compile (cfg);
+                               try_llvm = FALSE;
+                               goto restart_compile;
                        }
-                       InterlockedIncrement (&methods_without_llvm);
-                       mono_destroy_compile (cfg);
-                       try_llvm = FALSE;
-                       goto restart_compile;
                }
        }
 #endif
index 8b665054fe057cc03f3a41452d8c732385516d6a..9eb07603ccfd135c84aba76e92ca55d862d03cdf 100644 (file)
@@ -1621,6 +1621,7 @@ void     mono_llvm_emit_method              (MonoCompile *cfg) MONO_INTERNAL;
 void     mono_llvm_emit_call                (MonoCompile *cfg, MonoCallInst *call) MONO_INTERNAL;
 void     mono_llvm_create_aot_module        (const char *got_symbol) MONO_INTERNAL;
 void     mono_llvm_emit_aot_module          (const char *filename, int got_size) MONO_INTERNAL;
+void     mono_llvm_check_method_supported   (MonoCompile *cfg) MONO_INTERNAL;
 
 gboolean  mono_method_blittable             (MonoMethod *method) MONO_INTERNAL;
 gboolean  mono_method_same_domain           (MonoJitInfo *caller, MonoJitInfo *callee) MONO_INTERNAL;