Merge pull request #1287 from akoeplinger/fix-appconfig-performancecounters
[mono.git] / mono / mini / mini-amd64.h
index 5e87f02886cdc764fd071d6084374b1e2c9e0b24..e942f578226606a72ee6bcf6e940002b7745621a 100644 (file)
@@ -47,7 +47,7 @@ struct sigcontext {
        guint64 eip;
 };
 
-typedef void (* MonoW32ExceptionHandler) (int _dummy, EXCEPTION_RECORD *info, void *context);
+typedef void (* MonoW32ExceptionHandler) (int _dummy, EXCEPTION_POINTERS *info, void *context);
 void win32_seh_init(void);
 void win32_seh_cleanup(void);
 void win32_seh_set_handler(int type, MonoW32ExceptionHandler handler);
@@ -159,16 +159,14 @@ struct sigcontext {
 
 struct MonoLMF {
        /* 
-        * If the lowest bit is set to 1, then this LMF has the rip field set. Otherwise,
+        * If the lowest bit is set, then this LMF has the rip field set. Otherwise,
         * the rip field is not set, and the rsp field points to the stack location where
         * the caller ip is saved.
-        * If the second lowest bit is set to 1, then this is a MonoLMFExt structure, and
+        * If the second lowest bit is set, then this is a MonoLMFExt structure, and
         * the other fields are not valid.
+        * If the third lowest bit is set, then this is a MonoLMFTramp structure.
         */
        gpointer    previous_lmf;
-       gpointer    lmf_addr;
-       /* This is only set in trampoline LMF frames */
-       MonoMethod *method;
 #if defined(__default_codegen__) || defined(HOST_WIN32)
        guint64     rip;
 #elif defined(__native_client_codegen__)
@@ -176,24 +174,23 @@ struct MonoLMF {
        /* this allows the structure to match for 32-bit compilers.    */
        guint64     rip __attribute__ ((aligned(8)));
 #endif
-       guint64     rbx;
        guint64     rbp;
        guint64     rsp;
-       guint64     r12;
-       guint64     r13;
-       guint64     r14;
-       guint64     r15;
-#ifdef HOST_WIN32
-       guint64     rdi;
-       guint64     rsi;
-#endif
 };
 
+/* LMF structure used by the JIT trampolines */
+typedef struct {
+       struct MonoLMF lmf;
+       guint64 *regs;
+       gpointer lmf_addr;
+} MonoLMFTramp;
+
 typedef struct MonoCompileArch {
        gint32 localloc_offset;
        gint32 reg_save_area_offset;
        gint32 stack_alloc_size;
        gint32 sp_fp_offset;
+       guint32 saved_iregs;
        gboolean omit_fp, omit_fp_computed, no_pushes;
        gpointer cinfo;
        gint32 async_point_count;
@@ -203,8 +200,31 @@ typedef struct MonoCompileArch {
 #endif
        gpointer seq_point_info_var;
        gpointer ss_trigger_page_var;
+       gpointer lmf_var;
 } MonoCompileArch;
 
+
+
+#ifdef HOST_WIN32
+#define PARAM_REGS 4
+#else
+#define PARAM_REGS 6
+#endif
+
+/* Structure used by the sequence points in AOTed code */
+typedef struct {
+       gpointer ss_trigger_page;
+       gpointer bp_trigger_page;
+       gpointer bp_addrs [MONO_ZERO_LEN_ARRAY];
+} SeqPointInfo;
+
+typedef struct {
+       mgreg_t regs [PARAM_REGS];
+       mgreg_t res;
+       guint8 *ret;
+} DynCallArgs;
+
+
 #define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->rax = (gsize)exc; } while (0)
 
 #define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf)
@@ -289,7 +309,7 @@ typedef struct MonoCompileArch {
 
 #define MONO_ARCH_NOMAP32BIT
 
-#elif defined (__FreeBSD__)
+#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
 
 #define REG_RAX 7
 #define REG_RCX 4
@@ -333,16 +353,10 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_IS_INT_OVERFLOW 1
 
 #define MONO_ARCH_ENABLE_REGALLOC_IN_EH_BLOCKS 1
-#if !defined(__APPLE__)
 #define MONO_ARCH_ENABLE_MONO_LMF_VAR 1
-#endif
 #define MONO_ARCH_HAVE_INVALIDATE_METHOD 1
 #define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE 1
-#define MONO_ARCH_HAVE_ATOMIC_ADD 1
-#define MONO_ARCH_HAVE_ATOMIC_EXCHANGE 1
-#define MONO_ARCH_HAVE_ATOMIC_CAS 1
 #define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1
-#define MONO_ARCH_HAVE_IMT 1
 #define MONO_ARCH_HAVE_TLS_GET (mono_amd64_have_tls_get ())
 #define MONO_ARCH_IMT_REG AMD64_R10
 #define MONO_ARCH_IMT_SCRATCH_REG AMD64_R11
@@ -367,7 +381,7 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_GET_TRAMPOLINES 1
 
 #define MONO_ARCH_AOT_SUPPORTED 1
-#if !defined( HOST_WIN32 ) && !defined( __native_client__ )
+#if !defined( __native_client__ )
 #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
 #endif
 
@@ -395,16 +409,14 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_CONTEXT_SET_INT_REG 1
 #define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
 #define MONO_ARCH_HAVE_CREATE_LLVM_NATIVE_THUNK 1
+#define MONO_ARCH_HAVE_OP_TAIL_CALL 1
+#define MONO_ARCH_HAVE_TRANSLATE_TLS_OFFSET 1
+#define MONO_ARCH_HAVE_DUMMY_INIT 1
 
-#ifdef TARGET_OSX
+#if defined(TARGET_OSX) || defined(__linux__)
 #define MONO_ARCH_HAVE_TLS_GET_REG 1
 #endif
 
-gboolean
-mono_amd64_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL;
-
-#define MONO_ARCH_USE_OP_TAIL_CALL(caller_sig, callee_sig) mono_amd64_tail_call_supported (caller_sig, callee_sig)
-
 /* Used for optimization, not complete */
 #define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
 
@@ -445,6 +457,9 @@ mono_amd64_have_tls_get (void) MONO_INTERNAL;
 GSList*
 mono_amd64_get_exception_trampolines (gboolean aot) MONO_INTERNAL;
 
+int
+mono_amd64_get_tls_gs_offset (void) MONO_LLVM_INTERNAL;
+
 typedef struct {
        guint8 *address;
        guint8 saved_byte;