Merge pull request #1522 from StephenMcConnel/bug-26258
[mono.git] / mono / mini / helpers.c
index 2a0b7d9e0e1d826125da9451cad191f441d99ec8..4c0950163fb8718b90cb20c9feb04f528b81fd0f 100644 (file)
@@ -3,6 +3,9 @@
  *
  * (C) 2003 Ximian, Inc.
  */
+
+#include <config.h>
+
 #include "mini.h"
 #include <ctype.h>
 #include <mono/metadata/opcodes.h>
@@ -11,6 +14,8 @@
 #include <unistd.h>
 #endif
 
+#ifndef DISABLE_JIT
+
 #ifndef DISABLE_LOGGING
 
 #ifdef MINI_OP
@@ -61,10 +66,14 @@ opnames[] = {
 #endif /* DISABLE_LOGGING */
 
 #if defined(__i386__) || defined(__x86_64__)
+#ifndef TARGET_ARM64
 #define emit_debug_info  TRUE
 #else
 #define emit_debug_info  FALSE
 #endif
+#else
+#define emit_debug_info  FALSE
+#endif
 
 /*This enables us to use the right tooling when building the cross compiler for iOS.*/
 #if defined (__APPLE__) && defined (TARGET_ARM) && (defined(__i386__) || defined(__x86_64__))
@@ -125,6 +134,9 @@ mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint
 void
 mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 {
+#if defined(__native_client__)
+       return;
+#endif
 #ifndef DISABLE_LOGGING
        GHashTable *offset_to_bb_hash = NULL;
        int i, cindex, bb_num;
@@ -202,8 +214,14 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 #else
 #if defined(sparc) && !defined(__GNUC__)
 #define DIS_CMD "dis"
-#elif defined(__i386__) || defined(__x86_64__)
+#elif defined(TARGET_X86)
 #define DIS_CMD "objdump -l -d"
+#elif defined(TARGET_AMD64)
+  #if defined(HOST_WIN32)
+  #define DIS_CMD "x86_64-w64-mingw32-objdump.exe -M x86-64 -d"
+  #else
+  #define DIS_CMD "objdump -l -d"
+  #endif
 #else
 #define DIS_CMD "objdump -d"
 #endif
@@ -229,6 +247,12 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 #  else
 #    define AS_CMD "as -gstabs"
 #  endif
+#elif defined (TARGET_ARM64)
+#  if defined (__APPLE__)
+#    define AS_CMD "clang -c -arch arm64 -g -x assembler"
+#  else
+#    define AS_CMD "as -gstabs"
+#  endif
 #elif defined(__mips__) && (_MIPS_SIM == _ABIO32)
 #define AS_CMD "as -mips32"
 #elif defined(__ppc64__)
@@ -263,11 +287,11 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
        unused = system (cmd);
        g_free (cmd);
 #endif
-       
+
        cmd = g_strdup_printf (ARCH_PREFIX DIS_CMD " %s %s", objdump_args, o_file);
        unused = system (cmd);
        g_free (cmd);
-       
+
 #ifndef HOST_WIN32
        unlink (o_file);
        unlink (as_file);
@@ -277,3 +301,11 @@ mono_disassemble_code (MonoCompile *cfg, guint8 *code, int size, char *id)
 #endif
 }
 
+#else /* DISABLE_JIT */
+
+void
+mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom)
+{
+}
+
+#endif /* DISABLE_JIT */