Merge pull request #5095 from kumpera/fix_fullaot
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Thu, 22 Jun 2017 21:55:52 +0000 (14:55 -0700)
committerGitHub <noreply@github.com>
Thu, 22 Jun 2017 21:55:52 +0000 (14:55 -0700)
[aot] Fix the name of the mono_gc_wbarrier_range_copy icall. FullAOT with direct calls requires it.

mono/mini/method-to-ir.c
mono/mini/mini-arm.c
mono/profiler/log.c
mono/profiler/log.h
mono/profiler/mprof-report.c

index 619b1e68aa41d5d950a2c877a9f4df482b3c6a4f..5c1c7d2db055f1fdd9a98bdbae731dcd8a5ee494 100644 (file)
@@ -7701,18 +7701,25 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                if ((cfg->method == method) && cfg->coverage_info) {
                        guint32 cil_offset = ip - header->code;
+                       gpointer counter = &cfg->coverage_info->data [cil_offset].count;
                        cfg->coverage_info->data [cil_offset].cil_code = ip;
 
-                       /* TODO: Use an increment here */
-#if defined(TARGET_X86)
-                       MONO_INST_NEW (cfg, ins, OP_STORE_MEM_IMM);
-                       ins->inst_p0 = &(cfg->coverage_info->data [cil_offset].count);
-                       ins->inst_imm = 1;
-                       MONO_ADD_INS (cfg->cbb, ins);
-#else
-                       EMIT_NEW_PCONST (cfg, ins, &(cfg->coverage_info->data [cil_offset].count));
-                       MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STORE_MEMBASE_IMM, ins->dreg, 0, 1);
-#endif
+                       if (mono_arch_opcode_supported (OP_ATOMIC_ADD_I4)) {
+                               MonoInst *one_ins, *load_ins;
+
+                               EMIT_NEW_PCONST (cfg, load_ins, counter);
+                               EMIT_NEW_ICONST (cfg, one_ins, 1);
+                               MONO_INST_NEW (cfg, ins, OP_ATOMIC_ADD_I4);
+                               ins->dreg = mono_alloc_ireg (cfg);
+                               ins->inst_basereg = load_ins->dreg;
+                               ins->inst_offset = 0;
+                               ins->sreg2 = one_ins->dreg;
+                               ins->type = STACK_I4;
+                               MONO_ADD_INS (cfg->cbb, ins);
+                       } else {
+                               EMIT_NEW_PCONST (cfg, ins, counter);
+                               MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STORE_MEMBASE_IMM, ins->dreg, 0, 1);
+                       }
                }
 
                if (cfg->verbose_level > 3)
index 06598ee0e37e3848aaf51e85c7b7ff644c8fbb8d..1328e762a65dc7059bf0315ff6ab3e85b0531a83 100644 (file)
@@ -121,7 +121,6 @@ static int vfp_scratch2 = ARM_VFP_D1;
 static int i8_align;
 
 static gpointer single_step_tramp, breakpoint_tramp;
-static gpointer get_tls_tramp;
 
 /*
  * The code generated for sequence points reads from this location, which is
@@ -216,6 +215,19 @@ emit_big_add (guint8 *code, int dreg, int sreg, int imm)
        return code;
 }
 
+static guint8*
+emit_ldr_imm (guint8 *code, int dreg, int sreg, int imm)
+{
+       if (!arm_is_imm12 (imm)) {
+               g_assert (dreg != sreg);
+               code = emit_big_add (code, dreg, sreg, imm);
+               ARM_LDR_IMM (code, dreg, dreg, 0);
+       } else {
+               ARM_LDR_IMM (code, dreg, sreg, imm);
+       }
+       return code;
+}
+
 /* If dreg == sreg, this clobbers IP */
 static guint8*
 emit_sub_imm (guint8 *code, int dreg, int sreg, int imm)
@@ -764,7 +776,7 @@ mono_arch_cpu_init (void)
 void
 mono_arch_init (void)
 {
-       const char *cpu_arch;
+       char *cpu_arch;
 
 #ifdef TARGET_WATCHOS
        mini_get_debug_options ()->soft_breakpoints = TRUE;
@@ -813,7 +825,7 @@ mono_arch_init (void)
         * works. Most ARM devices have VFP units these days, so
         * normally soft float code would not be exercised much.
         */
-       const char *soft = g_getenv ("MONO_ARM_FORCE_SOFT_FLOAT");
+       char *soft = g_getenv ("MONO_ARM_FORCE_SOFT_FLOAT");
 
        if (soft && !strncmp (soft, "1", 1))
                arm_fpu = MONO_ARM_FPU_NONE;
@@ -4562,7 +4574,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                        if (cfg->compile_aot) {
                                g_assert (info_var);
                                g_assert (info_var->opcode == OP_REGOFFSET);
-                               g_assert (arm_is_imm12 (info_var->inst_offset));
                        }
 
                        if (!cfg->soft_breakpoints && !cfg->compile_aot) {
@@ -4582,9 +4593,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                        var = ss_method_var;
                                        g_assert (var);
                                        g_assert (var->opcode == OP_REGOFFSET);
-                                       g_assert (arm_is_imm12 (var->inst_offset));
-                                       ARM_LDR_IMM (code, dreg, var->inst_basereg, var->inst_offset);
-
+                                       code = emit_ldr_imm (code, dreg, var->inst_basereg, var->inst_offset);
                                        /* Read the value and check whether it is non-zero. */
                                        ARM_LDR_IMM (code, dreg, dreg, 0);
                                        ARM_CMP_REG_IMM (code, dreg, 0, 0);
@@ -4596,8 +4605,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                                var = ss_trigger_page_var;
                                                g_assert (var);
                                                g_assert (var->opcode == OP_REGOFFSET);
-                                               g_assert (arm_is_imm12 (var->inst_offset));
-                                               ARM_LDR_IMM (code, dreg, var->inst_basereg, var->inst_offset);
+                                               code = emit_ldr_imm (code, dreg, var->inst_basereg, var->inst_offset);
                                        } else {
                                                ARM_LDR_IMM (code, dreg, ARMREG_PC, 0);
                                                ARM_B (code, 0);
@@ -4615,7 +4623,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                                guint32 offset = code - cfg->native_code;
                                guint32 val;
 
-                               ARM_LDR_IMM (code, dreg, info_var->inst_basereg, info_var->inst_offset);
+                               var = info_var;
+                               code = emit_ldr_imm (code, dreg, var->inst_basereg, var->inst_offset);
                                /* Add the offset */
                                val = ((offset / 4) * sizeof (guint8*)) + MONO_STRUCT_OFFSET (SeqPointInfo, bp_addrs);
                                /* Load the info->bp_addrs [offset], which is either 0 or the address of a trigger page */
@@ -6441,9 +6450,8 @@ mono_arch_emit_prolog (MonoCompile *cfg)
 
                if (info_var) {
                        g_assert (info_var->opcode == OP_REGOFFSET);
-                       g_assert (arm_is_imm12 (info_var->inst_offset));
 
-                       ARM_LDR_IMM (code, dreg, info_var->inst_basereg, info_var->inst_offset);
+                       code = emit_ldr_imm (code, dreg, info_var->inst_basereg, info_var->inst_offset);
                        /* Load the trigger page addr */
                        ARM_LDR_IMM (code, dreg, dreg, MONO_STRUCT_OFFSET (SeqPointInfo, ss_trigger_page));
                        ARM_STR_IMM (code, dreg, ss_trigger_page_var->inst_basereg, ss_trigger_page_var->inst_offset);
index 962413326a7e9b807a7cc486a6d40766ff54a517..d84ee526ca223d52314688d838b9f6cc6b1e1ed7 100644 (file)
@@ -258,7 +258,8 @@ static MonoLinkedListSet profiler_thread_list;
  *
  * type metadata format:
  * type: TYPE_METADATA
- * exinfo: one of: TYPE_END_LOAD, TYPE_END_UNLOAD (optional for TYPE_THREAD and TYPE_DOMAIN)
+ * exinfo: one of: TYPE_END_LOAD, TYPE_END_UNLOAD (optional for TYPE_THREAD and TYPE_DOMAIN,
+ * doesn't occur for TYPE_CLASS)
  * [mtype: byte] metadata type, one of: TYPE_CLASS, TYPE_IMAGE, TYPE_ASSEMBLY, TYPE_DOMAIN,
  * TYPE_THREAD, TYPE_CONTEXT
  * [pointer: sleb128] pointer of the metadata type depending on mtype
@@ -848,11 +849,12 @@ ensure_logbuf_unsafe (MonoProfilerThread *thread, int bytes)
  * exclusive lock, and we need those to arrive with a reasonably
  * consistent frequency so that readers don't have to queue up too many
  * events between sync points.
+ *
+ * The lock does not support recursion.
  */
 static volatile gint32 buffer_lock_state;
 static volatile gint32 buffer_lock_exclusive_intent;
 
-// Can be used recursively.
 static void
 buffer_lock (void)
 {
@@ -911,7 +913,6 @@ buffer_unlock (void)
        InterlockedDecrement (&buffer_lock_state);
 }
 
-// Cannot be used recursively.
 static void
 buffer_lock_excl (void)
 {
@@ -1080,6 +1081,7 @@ emit_method_inner (LogBuffer *logbuffer, void *method)
        g_assert (logbuffer->cursor <= logbuffer->buf_end && "Why are we writing past the buffer end?");
 }
 
+// The reader lock must be held.
 static void
 register_method_local (MonoMethod *method, MonoJitInfo *ji)
 {
@@ -1092,12 +1094,8 @@ register_method_local (MonoMethod *method, MonoJitInfo *ji)
                info->ji = ji;
                info->time = current_time ();
 
-               buffer_lock ();
-
                GPtrArray *arr = thread->methods ? thread->methods : (thread->methods = g_ptr_array_new ());
                g_ptr_array_add (arr, info);
-
-               buffer_unlock ();
        }
 }
 
@@ -2004,42 +2002,6 @@ class_loaded (MonoProfiler *prof, MonoClass *klass, int result)
                g_free (name);
 }
 
-static void
-class_unloaded (MonoProfiler *prof, MonoClass *klass)
-{
-       char *name;
-
-       if (InterlockedRead (&runtime_inited))
-               name = mono_type_get_name (mono_class_get_type (klass));
-       else
-               name = type_name (klass);
-
-       int nlen = strlen (name) + 1;
-       MonoImage *image = mono_class_get_image (klass);
-
-       ENTER_LOG (&class_unloads_ctr, logbuffer,
-               EVENT_SIZE /* event */ +
-               BYTE_SIZE /* type */ +
-               LEB128_SIZE /* klass */ +
-               LEB128_SIZE /* image */ +
-               nlen /* name */
-       );
-
-       emit_event (logbuffer, TYPE_END_UNLOAD | TYPE_METADATA);
-       emit_byte (logbuffer, TYPE_CLASS);
-       emit_ptr (logbuffer, klass);
-       emit_ptr (logbuffer, image);
-       memcpy (logbuffer->cursor, name, nlen);
-       logbuffer->cursor += nlen;
-
-       EXIT_LOG;
-
-       if (runtime_inited)
-               mono_free (name);
-       else
-               g_free (name);
-}
-
 static void process_method_enter_coverage (MonoProfiler *prof, MonoMethod *method);
 
 static void
@@ -2098,7 +2060,11 @@ method_jitted (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *ji, int resu
        if (result != MONO_PROFILE_OK)
                return;
 
+       buffer_lock ();
+
        register_method_local (method, ji);
+
+       buffer_unlock ();
 }
 
 static void
@@ -4756,7 +4722,7 @@ mono_profiler_startup (const char *desc)
 
        if (config.effective_mask & PROFLOG_CLASS_EVENTS) {
                events |= MONO_PROFILE_CLASS_EVENTS;
-               mono_profiler_install_class (NULL, class_loaded, class_unloaded, NULL);
+               mono_profiler_install_class (NULL, class_loaded, NULL, NULL);
        }
 
        if (config.effective_mask & PROFLOG_JIT_COMPILATION_EVENTS) {
index d1158da7c911b8c8721e22e210c26d441ddfe4ee..5029c26c70c92c287a3226b1de8fb7de6b8b3b06 100644 (file)
@@ -66,6 +66,7 @@
                changed address field in TYPE_SAMPLE_UBIN to be based on ptr_base
                added an image pointer field to assembly load events
                added an exception object field to TYPE_CLAUSE
+               class unload events no longer exist (they were never emitted)
  */
 
 enum {
index a687f4540a0a9a2554b07a09fe8ded82f5ba585a..00254414925e5b3ea342cd1d06327e3133c51daf 100644 (file)
@@ -2480,8 +2480,7 @@ decode_buffer (ProfContext *ctx)
                                        decode_uleb128 (p, &p); /* flags */
                                if (debug)
                                        fprintf (outfile, "%s class %p (%s in %p) at %llu\n", load_str, (void*)(ptr_base + ptrdiff), p, (void*)(ptr_base + imptrdiff), (unsigned long long) time_base);
-                               if (subtype == TYPE_END_LOAD)
-                                       add_class (ptr_base + ptrdiff, (char*)p);
+                               add_class (ptr_base + ptrdiff, (char*)p);
                                while (*p) p++;
                                p++;
                        } else if (mtype == TYPE_IMAGE) {