[mini] Add new JIT flag JIT_FLAG_DISCARD_RESULTS to reduce the noise when profiling...
[mono.git] / mono / mini / mini.c
index 0f26b72293a7e9548bd6c1dd720f2406f906f66c..e770092c95a5225e86fc49a19f6544909194af33 100644 (file)
@@ -77,6 +77,7 @@
 #include "debugger-agent.h"
 #include "llvm-runtime.h"
 #include "mini-llvm.h"
+#include "lldb.h"
 
 MonoTraceSpec *mono_jit_trace_calls;
 MonoMethodDesc *mono_inject_async_exc_method;
@@ -1957,104 +1958,6 @@ mono_destroy_compile (MonoCompile *cfg)
        g_free (cfg);
 }
 
-static MonoInst*
-mono_create_tls_get_offset (MonoCompile *cfg, int offset)
-{
-       MonoInst* ins;
-
-       if (!cfg->backend->have_tls_get)
-               return NULL;
-
-       if (offset == -1)
-               return NULL;
-
-       MONO_INST_NEW (cfg, ins, OP_TLS_GET);
-       ins->dreg = mono_alloc_preg (cfg);
-       ins->inst_offset = offset;
-       return ins;
-}
-
-gboolean
-mini_tls_get_supported (MonoCompile *cfg, MonoTlsKey key)
-{
-       if (!cfg->backend->have_tls_get)
-               return FALSE;
-
-       if (cfg->compile_aot)
-               return cfg->backend->have_tls_get_reg;
-       else
-               return mini_get_tls_offset (key) != -1;
-}
-
-MonoInst*
-mono_create_tls_get (MonoCompile *cfg, MonoTlsKey key)
-{
-       if (!cfg->backend->have_tls_get)
-               return NULL;
-
-#ifdef HAVE_KW_THREAD
-       /*
-        * MONO_THREAD_VAR_OFFSET definitions don't work when loading mono as a
-        * dynamic library. This means that we need to be conservative and don't
-        * aot code that contains these tls chunks.
-        *
-        * FIXME Remove HAVE_KW_THREAD altogether and use only pthread since it
-        * simplifies the code alot.
-        */
-       if (!cfg->full_aot)
-               cfg->disable_aot = TRUE;
-#endif
-       /*
-        * TLS offsets might be different at AOT time, so load them from a GOT slot and
-        * use a different opcode.
-        */
-       if (cfg->compile_aot) {
-               if (cfg->backend->have_tls_get_reg) {
-                       MonoInst *ins, *c;
-
-                       EMIT_NEW_TLS_OFFSETCONST (cfg, c, key);
-                       MONO_INST_NEW (cfg, ins, OP_TLS_GET_REG);
-                       ins->dreg = mono_alloc_preg (cfg);
-                       ins->sreg1 = c->dreg;
-                       return ins;
-               } else {
-                       return NULL;
-               }
-       }
-
-       return mono_create_tls_get_offset (cfg, mini_get_tls_offset (key));
-}
-
-MonoInst*
-mono_get_jit_tls_intrinsic (MonoCompile *cfg)
-{
-       return mono_create_tls_get (cfg, TLS_KEY_JIT_TLS);
-}
-
-MonoInst*
-mono_get_domain_intrinsic (MonoCompile* cfg)
-{
-       return mono_create_tls_get (cfg, TLS_KEY_DOMAIN);
-}
-
-MonoInst*
-mono_get_thread_intrinsic (MonoCompile* cfg)
-{
-       return mono_create_tls_get (cfg, TLS_KEY_THREAD);
-}
-
-MonoInst*
-mono_get_lmf_intrinsic (MonoCompile* cfg)
-{
-       return mono_create_tls_get (cfg, TLS_KEY_LMF);
-}
-
-MonoInst*
-mono_get_lmf_addr_intrinsic (MonoCompile* cfg)
-{
-       return mono_create_tls_get (cfg, TLS_KEY_LMF_ADDR);
-}
-
 void
 mono_add_patch_info (MonoCompile *cfg, int ip, MonoJumpInfoType type, gconstpointer target)
 {
@@ -3150,11 +3053,6 @@ init_backend (MonoBackend *backend)
 #endif
 #ifdef MONO_ARCH_GSHARED_SUPPORTED
        backend->gshared_supported = 1;
-#endif
-       if (MONO_ARCH_HAVE_TLS_GET)
-               backend->have_tls_get = 1;
-#ifdef MONO_ARCH_HAVE_TLS_GET_REG
-               backend->have_tls_get_reg = 1;
 #endif
        if (MONO_ARCH_USE_FPSTACK)
                backend->use_fpstack = 1;
@@ -3983,20 +3881,21 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        }
 #endif
 
-       if (!cfg->compile_aot)
-               mono_save_xdebug_info (cfg);
-
        MONO_TIME_TRACK (mono_jit_stats.jit_gc_create_gc_map, mini_gc_create_gc_map (cfg));
        MONO_TIME_TRACK (mono_jit_stats.jit_save_seq_point_info, mono_save_seq_point_info (cfg));
 
+       if (!cfg->compile_aot) {
+               mono_save_xdebug_info (cfg);
+               mono_lldb_save_method_info (cfg);
+       }
+
        if (cfg->verbose_level >= 2) {
                char *id =  mono_method_full_name (cfg->method, FALSE);
                mono_disassemble_code (cfg, cfg->native_code, cfg->code_len, id + 3);
                g_free (id);
        }
 
-       if (!cfg->compile_aot) {
+       if (!cfg->compile_aot && !(flags & JIT_FLAG_DISCARD_RESULTS)) {
                mono_domain_lock (cfg->domain);
                mono_jit_info_table_add (cfg->domain, cfg->jit_info);