X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FAdjustor.c;h=e2815d0d04e64c5631f23ade76b99a18b165d763;hb=eb64777602e77588cb781865f742fa23fad06d08;hp=8c950f79b477a6a5c95a2ad6ab33bdf83f866287;hpb=ab0e778ccfde61aed4c22679b24d175fc6cc9bf3;p=ghc-hetmet.git diff --git a/rts/Adjustor.c b/rts/Adjustor.c index 8c950f7..e2815d0 100644 --- a/rts/Adjustor.c +++ b/rts/Adjustor.c @@ -40,8 +40,6 @@ Haskell side. #include "Rts.h" #include "RtsExternal.h" #include "RtsUtils.h" -#include "Storage.h" -#include "Stable.h" #include #if defined(_WIN32) @@ -86,10 +84,6 @@ static void GNUC3_ATTRIBUTE(used) obscure_ccall_wrapper(void) } extern void obscure_ccall_ret_code(void); -#if defined(openbsd_HOST_OS) -static unsigned char *obscure_ccall_ret_code_dyn; -#endif - #endif #if defined(x86_64_HOST_ARCH) @@ -115,7 +109,6 @@ extern void obscure_ccall_ret_code(void); #endif #if defined(ia64_HOST_ARCH) -#include "Storage.h" /* Layout of a function descriptor */ typedef struct _IA64FunDesc { @@ -325,11 +318,7 @@ createAdjustor(int cconv, StgStablePtr hptr, adj_code[0x0a] = (unsigned char)0x68; /* pushl obscure_ccall_ret_code */ *((StgFunPtr*)(adj_code + 0x0b)) = -#if !defined(openbsd_HOST_OS) (StgFunPtr)obscure_ccall_ret_code; -#else - (StgFunPtr)obscure_ccall_ret_code_dyn; -#endif adj_code[0x0f] = (unsigned char)0xff; /* jmp *%eax */ adj_code[0x10] = (unsigned char)0xe0; @@ -960,8 +949,12 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for /* These macros distribute a long constant into the two words of an MLX bundle */ #define BITS(val,start,count) (((val) >> (start)) & ((1 << (count))-1)) #define MOVL_LOWORD(val) (BITS(val,22,18) << 46) -#define MOVL_HIWORD(val) (BITS(val,40,23) | (BITS(val,0,7) << 36) | (BITS(val,7,9) << 50) \ - | (BITS(val,16,5) << 55) | (BITS(val,21,1) << 44) | BITS(val,63,1) << 59) +#define MOVL_HIWORD(val) ( (BITS(val,0,7) << 36) \ + | (BITS(val,7,9) << 50) \ + | (BITS(val,16,5) << 45) \ + | (BITS(val,21,1) << 44) \ + | (BITS(val,40,23)) \ + | (BITS(val,63,1) << 59)) { StgStablePtr stable; @@ -970,11 +963,17 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for IA64FunDesc *fdesc; StgWord64 *code; - /* we allocate on the Haskell heap since malloc'd memory isn't executable - argh */ - adjustor = stgAllocStable(sizeof(IA64FunDesc)+18*8, &stable); + /* we allocate on the Haskell heap since malloc'd memory isn't + * executable - argh */ + /* Allocated memory is word-aligned (8 bytes) but functions on ia64 + * must be aligned to 16 bytes. We allocate an extra 8 bytes of + * wiggle room so that we can put the code on a 16 byte boundary. */ + adjustor = stgAllocStable(sizeof(IA64FunDesc)+18*8+8, &stable); fdesc = (IA64FunDesc *)adjustor; code = (StgWord64 *)(fdesc + 1); + /* add 8 bytes to code if needed to align to a 16-byte boundary */ + if ((StgWord64)code & 15) code++; fdesc->ip = (StgWord64)code; fdesc->gp = wdesc->gp; @@ -1092,21 +1091,3 @@ if ( *(unsigned char*)ptr != 0xe8 ) { freeExec(ptr); } - - -/* - * Function: initAdjustor() - * - * Perform initialisation of adjustor thunk layer (if needed.) - */ -void -initAdjustor(void) -{ -#if defined(i386_HOST_ARCH) && defined(openbsd_HOST_OS) - obscure_ccall_ret_code_dyn = allocateExec(4); - obscure_ccall_ret_code_dyn[0] = ((unsigned char *)obscure_ccall_ret_code)[0]; - obscure_ccall_ret_code_dyn[1] = ((unsigned char *)obscure_ccall_ret_code)[1]; - obscure_ccall_ret_code_dyn[2] = ((unsigned char *)obscure_ccall_ret_code)[2]; - obscure_ccall_ret_code_dyn[3] = ((unsigned char *)obscure_ccall_ret_code)[3]; -#endif -}