[jit] Avoid emitting two AOT_CONST instructions for managed TLS access.
authorZoltan Varga <vargaz@gmail.com>
Thu, 28 Nov 2013 12:10:50 +0000 (13:10 +0100)
committerZoltan Varga <vargaz@gmail.com>
Thu, 28 Nov 2013 12:10:50 +0000 (13:10 +0100)
mono/mini/method-to-ir.c

index 03ee64790aa1aa6c31d1ad81583d5bcac03762a8..ae37dfe389a104d5336a2f9e58843096d7a1d934 100644 (file)
@@ -9814,6 +9814,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        gboolean is_special_static;
                        MonoType *ftype;
                        MonoInst *store_val = NULL;
+                       MonoInst *thread_ins;
 
                        op = *ip;
                        is_instance = (op == CEE_LDFLD || op == CEE_LDFLDA || op == CEE_STFLD);
@@ -10093,8 +10094,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                        is_special_static = mono_class_field_is_special_static (field);
 
+                       if (is_special_static && ((gsize)addr & 0x80000000) == 0)
+                               thread_ins = mono_get_thread_intrinsic (cfg);
+                       else
+                               thread_ins = NULL;
+
                        /* Generate IR to compute the field address */
-                       if (is_special_static && ((gsize)addr & 0x80000000) == 0 && mono_get_thread_intrinsic (cfg) && !(cfg->opt & MONO_OPT_SHARED) && !context_used) {
+                       if (is_special_static && ((gsize)addr & 0x80000000) == 0 && thread_ins && !(cfg->opt & MONO_OPT_SHARED) && !context_used) {
                                /*
                                 * Fast access to TLS data
                                 * Inline version of get_thread_static_data () in
@@ -10102,15 +10108,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                 */
                                guint32 offset;
                                int idx, static_data_reg, array_reg, dreg;
-                               MonoInst *thread_ins;
 
                                GSHAREDVT_FAILURE (op);
 
                                // offset &= 0x7fffffff;
                                // idx = (offset >> 24) - 1;
                                //      return ((char*) thread->static_data [idx]) + (offset & 0xffffff);
-
-                               thread_ins = mono_get_thread_intrinsic (cfg);
                                MONO_ADD_INS (cfg->cbb, thread_ins);
                                static_data_reg = alloc_ireg (cfg);
                                MONO_EMIT_NEW_LOAD_MEMBASE (cfg, static_data_reg, thread_ins->dreg, G_STRUCT_OFFSET (MonoInternalThread, static_data));