X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini-amd64.h;h=02005ebd9901557b466872b7a278f1b46f36fa62;hb=e4816c5c39ba39514bc57f87a22da3c749f83893;hp=982a98fbc725d821539cb47af7ddaeeb89593e85;hpb=9e1f34dd2d7be45b2a3a6b1c133a4a1de8c3d864;p=mono.git diff --git a/mono/mini/mini-amd64.h b/mono/mini/mini-amd64.h index 982a98fbc72..02005ebd990 100644 --- a/mono/mini/mini-amd64.h +++ b/mono/mini/mini-amd64.h @@ -3,8 +3,21 @@ #include #include +#include #include +#ifdef __native_client_codegen__ +#define kNaClAlignmentAMD64 32 +#define kNaClAlignmentMaskAMD64 (kNaClAlignmentAMD64 - 1) + +/* TODO: use kamd64NaClLengthOfCallImm */ +/* temporarily using kNaClAlignmentAMD64 so padding in */ +/* image-writer.c doesn't happen */ +#define kNaClLengthOfCallImm kNaClAlignmentAMD64 + +int is_nacl_call_reg_sequence(guint8* code); +#endif + #ifdef HOST_WIN32 #include /* use SIG* defines if possible */ @@ -146,7 +159,13 @@ struct MonoLMF { 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__) + /* On 64-bit compilers, default alignment is 8 for this field, */ + /* this allows the structure to match for 32-bit compilers. */ + guint64 rip __attribute__ ((aligned(8))); +#endif guint64 rbx; guint64 rbp; guint64 rsp; @@ -161,10 +180,10 @@ struct MonoLMF { }; typedef struct MonoCompileArch { - gint32 lmf_offset; gint32 localloc_offset; gint32 reg_save_area_offset; gint32 stack_alloc_size; + gint32 sp_fp_offset; gboolean omit_fp, omit_fp_computed, no_pushes; gpointer cinfo; gint32 async_point_count; @@ -173,32 +192,9 @@ typedef struct MonoCompileArch { gpointer unwindinfo; #endif gpointer ss_trigger_page_var; + gpointer lmf_var; } MonoCompileArch; -typedef struct { - guint64 rax; - guint64 rbx; - guint64 rcx; - guint64 rdx; - guint64 rbp; - guint64 rsp; - guint64 rsi; - guint64 rdi; - guint64 rip; - guint64 r12; - guint64 r13; - guint64 r14; - guint64 r15; -} MonoContext; - -#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->rip = (guint64)(ip); } while (0); -#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->rbp = (guint64)(bp); } while (0); -#define MONO_CONTEXT_SET_SP(ctx,esp) do { (ctx)->rsp = (guint64)(esp); } while (0); - -#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->rip)) -#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->rbp)) -#define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->rsp)) - #define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->rax = (gsize)exc; } while (0) #define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf) @@ -231,22 +227,13 @@ typedef struct { #endif -/* - * This structure is an extension of MonoLMF and contains extra information. - */ -typedef struct { - struct MonoLMF lmf; - gboolean debugger_invoke; - MonoContext ctx; /* if debugger_invoke is TRUE */ -} MonoLMFExt; - /* * some icalls like mono_array_new_va needs to be called using a different * calling convention. */ #define MONO_ARCH_VARARG_ICALLS 1 -#ifndef HOST_WIN32 +#if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__) #define MONO_ARCH_USE_SIGACTION 1 @@ -256,13 +243,13 @@ typedef struct { #endif -#ifdef __OpenBSD__ -#undef MONO_ARCH_USE_SIGACTION -#endif +#endif /* !HOST_WIN32 && !__native_client__ */ -#endif /* HOST_WIN32 */ +#if defined (__APPLE__) + +#define MONO_ARCH_NOMAP32BIT -#if defined (__NetBSD__) +#elif defined (__NetBSD__) #define REG_RAX 14 #define REG_RCX 3 @@ -284,7 +271,11 @@ typedef struct { #define MONO_ARCH_NOMAP32BIT -#elif defined (__FreeBSD__) || defined (__OpenBSD__) +#elif defined (__OpenBSD__) + +#define MONO_ARCH_NOMAP32BIT + +#elif defined (__FreeBSD__) #define REG_RAX 7 #define REG_RCX 4 @@ -330,18 +321,18 @@ typedef struct { #define MONO_ARCH_ENABLE_REGALLOC_IN_EH_BLOCKS 1 #define MONO_ARCH_ENABLE_MONO_LMF_VAR 1 #define MONO_ARCH_HAVE_INVALIDATE_METHOD 1 -#define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION 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 1 -#define MONO_ARCH_IMT_REG AMD64_R11 +#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 #define MONO_ARCH_VTABLE_REG MONO_AMD64_ARG_REG1 /* - * We use r10 for the rgctx register rather than r11 because r11 is + * We use r10 for the imt/rgctx register rather than r11 because r11 is * used by the trampoline as a scratch register and hence might be * clobbered across method call boundaries. */ @@ -354,18 +345,16 @@ typedef struct { #define MONO_ARCH_HAVE_LIVERANGE_OPS 1 #define MONO_ARCH_HAVE_XP_UNWIND 1 #define MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX 1 -#if !defined(HOST_WIN32) && !defined(HAVE_MOVING_COLLECTOR) +#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 -#ifndef HOST_WIN32 +#if !defined( HOST_WIN32 ) && !defined( __native_client__ ) #define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1 -#else -#define DISABLE_DEBUGGER_AGENT 1 #endif -#define MONO_ARCH_HAVE_FIND_JIT_INFO_EXT 1 #if !defined(HOST_WIN32) || defined(__sun) #define MONO_ARCH_ENABLE_MONITOR_IL_FASTPATH 1 @@ -383,8 +372,17 @@ typedef struct { #define MONO_ARCH_HAVE_LLVM_IMT_TRAMPOLINE 1 #define MONO_ARCH_LLVM_SUPPORTED 1 +#define MONO_ARCH_THIS_AS_FIRST_ARG 1 +#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1 +#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 + +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_metadata_signature_equal ((caller_sig), (callee_sig)) +#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) @@ -405,11 +403,14 @@ mono_amd64_patch (unsigned char* code, gpointer target) MONO_INTERNAL; void mono_amd64_throw_exception (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint64 dummy4, guint64 dummy5, guint64 dummy6, - MonoObject *exc, guint64 rip, guint64 rsp, - guint64 rbx, guint64 rbp, guint64 r12, guint64 r13, - guint64 r14, guint64 r15, guint64 rdi, guint64 rsi, - guint64 rax, guint64 rcx, guint64 rdx, - guint64 rethrow); + mgreg_t *regs, mgreg_t rip, + MonoObject *exc, gboolean rethrow) MONO_INTERNAL; + +void +mono_amd64_throw_corlib_exception (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint64 dummy4, + guint64 dummy5, guint64 dummy6, + mgreg_t *regs, mgreg_t rip, + guint32 ex_token_index, gint64 pc_offset) MONO_INTERNAL; guint64 mono_amd64_get_original_ip (void) MONO_INTERNAL; @@ -417,6 +418,12 @@ mono_amd64_get_original_ip (void) MONO_INTERNAL; guint8* mono_amd64_emit_tls_get (guint8* code, int dreg, int tls_offset) MONO_INTERNAL; +gboolean +mono_amd64_have_tls_get (void) MONO_INTERNAL; + +GSList* +mono_amd64_get_exception_trampolines (gboolean aot) MONO_INTERNAL; + typedef struct { guint8 *address; guint8 saved_byte;