IA-64 port

John R. Daily john at geekhavoc.com
Mon Dec 10 20:43:13 PST 2001


I put in a little more work, with little to show for it. GCDIAG
didn't display anything, so I passed it -vmdebug all. A little
_too_ much debugging information that way.

I couldn't get the gcstate macro to fully print out any
structures; I'm not sure if I'm giving it the wrong variables, or
whether there's a pointer issue still hidden somewhere.

Here's a sample:
----
Breakpoint 2, gc_heap_malloc (sz=44) at mem/gc-mem.c:315
(gdb) print *blk
$3 = {magic = 3504261854, free = 0x60000000000982c0, next = 0x0, nfree = 0x0, 
  inuse = 1, size = 48, nr = 327, avail = 326, 
  funcs = 0x6000000000098000 "\f\f", state = 0x6000000000098147 "\001", 
  data = 0x6000000000098290 ""}
(gdb) gcstate blk
Magic: 0xfc50
$gcBlock: 0x600000000000c000:: blockSize: 1073741824; index: 2147483647
Cannot access memory at address 0x400000008000fc7f
----

Unlike Alpha, Linux/IA-64 uses the full 64 bits for pointer
addresses. On Linux/Alpha, you can get away with casting a 64-bit
pointer to a 32-bit integer, because the high-order bits don't
happen to be used. On IA-64, one doesn't have that luxury.

It's been a source of significant pain, let me tell you. Missing
header files account for lots of subtle bugs, because functions
which return pointers are assumed by the compiler to return
integers. The pointers are then truncated at run-time. As an
example of a significant bug provoked by that behavior: bash
would segfault when a background process was terminated, which
led to other strange build failures.

I'm attaching the non-Debian-specific and non-IA-64-specific
patches that I and my co-worker have generated thus far. It
should illustrate some of the non-64-bit clean code I've located,
through compiler warnings and errors.

Thanks for the help thus far; I'll tackle this again tomorrow.

-John

-------------- next part --------------
diff -Naur kaffe.orig/config/config-std.h kaffe-1.0.6/config/config-std.h
--- kaffe.orig/config/config-std.h	Thu Mar  9 16:53:11 2000
+++ kaffe-1.0.6/config/config-std.h	Mon Dec 10 15:33:10 2001
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <string.h>
 
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
diff -Naur kaffe.orig/kaffe/xprof/memorySamples.c kaffe-1.0.6/kaffe/xprof/memorySamples.c
--- kaffe.orig/kaffe/xprof/memorySamples.c	Tue May 23 12:55:37 2000
+++ kaffe-1.0.6/kaffe/xprof/memorySamples.c	Mon Dec 10 15:44:09 2001
@@ -16,6 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <jtypes.h>
+#include <stdint.h> /* uintptr_t for pointer to integer casts */
 
 #include "jmalloc.h"
 
@@ -39,21 +40,21 @@
 
 /* Macros for computing branches/leaf indexes */
 #define SAMPLE_BRANCH(addr, level) \
-	((((int)addr) >> (SAMPLE_ADDRESS_BITS - (SAMPLE_BIT_COUNT * \
+	((((uintptr_t)addr) >> (SAMPLE_ADDRESS_BITS - (SAMPLE_BIT_COUNT * \
 						 ((level) + 1)))) \
 	 & SAMPLE_BIT_MASK)
-#define SAMPLE_BIN(addr) ((((int)addr) & 0xfe) >> 1)
+#define SAMPLE_BIN(addr) ((((uintptr_t)addr) & 0xfe) >> 1)
 /* Set the index for some level in a pointer value */
 #define SET_ADDR_LEVEL(addr, level, value) \
-	((void *)((((int)(addr)) & \
+	((void *)((((uintptr_t)(addr)) & \
 		   ~(SAMPLE_BIT_MASK << \
 		     (((SAMPLE_BRANCH_LEVELS) - (level)) * \
 		      SAMPLE_BIT_COUNT))) | \
-		  (((int)(value)) << \
+		  (((uintptr_t)(value)) << \
 		   (((SAMPLE_BRANCH_LEVELS) - (level)) * \
 		      SAMPLE_BIT_COUNT))))
 /* Align the address to something that's sample-able */
-#define ALIGN_ADDR(addr) ((char *)((int)((addr) + 2) & ~1))
+#define ALIGN_ADDR(addr) ((char *)((uintptr_t)((addr) + 2) & ~1))
 
 #define min(x,y) ((x < y) ? x : y)
 #define max(x,y) ((x > y) ? x : y)
diff -Naur kaffe.orig/kaffe/kaffevm/debug.h kaffe-1.0.6/kaffe/kaffevm/debug.h
--- kaffe.orig/kaffe/kaffevm/debug.h	Mon Dec 10 16:01:11 2001
+++ kaffe-1.0.6/kaffe/kaffevm/debug.h	Mon Dec 10 22:54:36 2001
@@ -21,6 +21,8 @@
 #ifndef __kaffevm_debug_h
 #define __kaffevm_debug_h
 
+#include "jtypes.h"
+
 /* Pascal Bourguignon <pjb at imaginet.fr> writes:
  * We include stdio here because on Linux, stdio defines dprintf.
  * Hence, we can override it with a macro defined here. (stdio.h
@@ -153,7 +155,7 @@
 /* --- Debugging is enabled --- */
 
 /* Defines what debugging output is seen. Needs to be 64-bit. */
-extern long long kaffevmDebugMask;
+extern jlong kaffevmDebugMask;
 
 # define DBGIF(statement)  statement
 
@@ -202,11 +204,7 @@
 #endif /* defined(NDEBUG) || !defined(DEBUG) */
 
 /* Set the debugging mask to use. (give the mask) */
-#if defined(__alpha)
-void dbgSetMask(long mask);
-#else
-void dbgSetMask(long long mask);
-#endif
+void dbgSetMask(jlong mask);
 
 /* 
  * Set the debugging mask to use. (give a string, useful for


More information about the kaffe mailing list