[amd64] Instead of saving callee saved registers in the LMF in trampoline frames...
[mono.git] / mono / mini / mini-amd64.h
index dd88c135a41cef99a04bebe91883d422ad877370..22d0098d74318e83ad555fc412745e3a15327ffa 100644 (file)
 /* image-writer.c doesn't happen                       */
 #define kNaClLengthOfCallImm kNaClAlignmentAMD64
 
-int is_nacl_call_reg_sequence(guint8* code);
+int is_nacl_call_reg_sequence (guint8* code);
+void amd64_nacl_clear_legacy_prefix_tag ();
+void amd64_nacl_tag_legacy_prefix (guint8* code);
+void amd64_nacl_tag_rex (guint8* code);
+guint8* amd64_nacl_get_legacy_prefix_tag ();
+guint8* amd64_nacl_get_rex_tag ();
+void amd64_nacl_instruction_pre ();
+void amd64_nacl_instruction_post (guint8 **start, guint8 **end);
+void amd64_nacl_membase_handler (guint8** code, gint8 basereg, gint32 offset, gint8 dreg);
 #endif
 
 #ifdef HOST_WIN32
@@ -89,8 +97,6 @@ struct sigcontext {
 };
 #endif  // sun, Solaris x86
 
-#define MONO_ARCH_SUPPORT_SIMD_INTRINSICS 1
-
 #ifndef DISABLE_SIMD
 #define MONO_ARCH_SIMD_INTRINSICS 1
 #define MONO_ARCH_NEED_SIMD_BANK 1
@@ -99,7 +105,11 @@ struct sigcontext {
 
 
 
+#if defined(__APPLE__)
+#define MONO_ARCH_SIGNAL_STACK_SIZE MINSIGSTKSZ
+#else
 #define MONO_ARCH_SIGNAL_STACK_SIZE (16 * 1024)
+#endif
 
 #define MONO_ARCH_HAVE_RESTORE_STACK_SUPPORT 1
 
@@ -149,16 +159,15 @@ 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__)
@@ -179,6 +188,12 @@ struct MonoLMF {
 #endif
 };
 
+/* LMF structure used by the JIT trampolines */
+typedef struct {
+       struct MonoLMF lmf;
+       guint64 *regs;
+} MonoLMFTramp;
+
 typedef struct MonoCompileArch {
        gint32 localloc_offset;
        gint32 reg_save_area_offset;
@@ -191,6 +206,7 @@ typedef struct MonoCompileArch {
 #ifdef HOST_WIN32
        gpointer        unwindinfo;
 #endif
+       gpointer seq_point_info_var;
        gpointer ss_trigger_page_var;
        gpointer lmf_var;
 } MonoCompileArch;
@@ -275,6 +291,10 @@ typedef struct MonoCompileArch {
 
 #define MONO_ARCH_NOMAP32BIT
 
+#elif defined (__DragonFly__)
+
+#define MONO_ARCH_NOMAP32BIT
+
 #elif defined (__FreeBSD__)
 
 #define REG_RAX 7
@@ -319,7 +339,9 @@ 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
@@ -336,7 +358,7 @@ typedef struct MonoCompileArch {
  * used by the trampoline as a scratch register and hence might be
  * clobbered across method call boundaries.
  */
-#define MONO_ARCH_RGCTX_REG AMD64_R10
+#define MONO_ARCH_RGCTX_REG MONO_ARCH_IMT_REG
 #define MONO_ARCH_HAVE_CMOV_OPS 1
 #define MONO_ARCH_HAVE_NOTIFY_PENDING_EXC 1
 #define MONO_ARCH_HAVE_EXCEPTIONS_INIT 1
@@ -348,14 +370,11 @@ typedef struct MonoCompileArch {
 #if !defined(HOST_WIN32)
 #define MONO_ARCH_MONITOR_OBJECT_REG MONO_AMD64_ARG_REG1
 #endif
-#define MONO_ARCH_HAVE_STATIC_RGCTX_TRAMPOLINE 1
 #define MONO_ARCH_HAVE_GET_TRAMPOLINES 1
 
 #define MONO_ARCH_AOT_SUPPORTED 1
 #if !defined( HOST_WIN32 ) && !defined( __native_client__ )
 #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1
-#else
-#define DISABLE_DEBUGGER_AGENT 1
 #endif
 
 #if !defined(HOST_WIN32) || defined(__sun)
@@ -379,11 +398,14 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_CARD_TABLE_WBARRIER 1
 #define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
 #define MONO_ARCH_GC_MAPS_SUPPORTED 1
+#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
 
-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)
+#if defined(TARGET_OSX) || defined(__linux__)
+#define MONO_ARCH_HAVE_TLS_GET_REG 1
+#endif
 
 /* Used for optimization, not complete */
 #define MONO_ARCH_IS_OP_MEMBASE(opcode) ((opcode) == OP_X86_PUSH_MEMBASE)
@@ -425,6 +447,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_INTERNAL;
+
 typedef struct {
        guint8 *address;
        guint8 saved_byte;