summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorred5_2@hotmail.com <unknown>2007-04-01 16:31:32 +0000
committerred5_2@hotmail.com <unknown>2007-04-01 16:31:32 +0000
commitb321da7d6a94582b5d59399a639af1b36e2e7a3b (patch)
treed39c474e6de94f347a1697f2db9c6f9da0b90927 /rts
parent4cf6fdd28fea80bd8e2bb86f2f5da15fd851f783 (diff)
downloadhaskell-b321da7d6a94582b5d59399a639af1b36e2e7a3b.tar.gz
fix adjustor generation on ia64 (test case ffi009)
Some fixes to adjustor functions. The 8-byte address returned by the allocator is adjusted to be aligned to 16-byte boundaries. Fixed a typo in inserting an immediate address into an instruction. This fixes the calls to 5-argument and 6-argument functions in ffi009. Some functions still break. I suspect it's related to passing arguments on the stack.
Diffstat (limited to 'rts')
-rw-r--r--rts/Adjustor.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/rts/Adjustor.c b/rts/Adjustor.c
index 813fcfed56..841f75c5d0 100644
--- a/rts/Adjustor.c
+++ b/rts/Adjustor.c
@@ -957,8 +957,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;
@@ -967,11 +971,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;