[kaffe] CVS kaffe (guilhem): Fix SIGBUS on sparc.
Kaffe CVS
cvs-commits at kaffe.org
Mon Jan 10 02:34:42 PST 2005
PatchSet 5831
Date: 2005/01/10 10:30:16
Author: guilhem
Branch: HEAD
Tag: (none)
Log:
Fix SIGBUS on sparc.
* kaffe/kaffevm/jit/machine.c,
kaffe/kaffevm/jit3/machine.c
(finishInsnSequence): Align the constant pool on 8 bytes (sizeof(union
_constpoolval)). On sparc, a misalignment causes a SIGBUS in
establishConstants.
Members:
ChangeLog:1.3375->1.3376
kaffe/kaffevm/jit/machine.c:1.74->1.75
kaffe/kaffevm/jit3/machine.c:1.69->1.70
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3375 kaffe/ChangeLog:1.3376
--- kaffe/ChangeLog:1.3375 Mon Jan 10 07:14:22 2005
+++ kaffe/ChangeLog Mon Jan 10 10:30:16 2005
@@ -1,3 +1,11 @@
+2005-01-10 Guilhem Lavaux <guilhem at kaffe.org>
+
+ * kaffe/kaffevm/jit/machine.c,
+ kaffe/kaffevm/jit3/machine.c
+ (finishInsnSequence): Align the constant pool on 8 bytes (sizeof(union
+ _constpoolval)). On sparc, a misalignment causes a SIGBUS in
+ establishConstants.
+
2005-01-09 Guilhem Lavaux <guilhem at kaffe.org>
* Makefile.am
Index: kaffe/kaffe/kaffevm/jit/machine.c
diff -u kaffe/kaffe/kaffevm/jit/machine.c:1.74 kaffe/kaffe/kaffevm/jit/machine.c:1.75
--- kaffe/kaffe/kaffevm/jit/machine.c:1.74 Mon Dec 27 16:09:47 2004
+++ kaffe/kaffe/kaffevm/jit/machine.c Mon Jan 10 10:30:19 2005
@@ -450,6 +450,7 @@
#else
int exc_len = 0;
#endif
+ uintp const_align = sizeof(union _constpoolval) - 1;
uint32 constlen;
jitCodeHeader *jch;
nativecode* methblock;
@@ -457,17 +458,19 @@
/* Emit pending instructions */
generateInsnSequence(codeInfo);
- /* Okay, put this into malloc'ed memory */
+ /* Okay, put this into malloc'ed memory. We have to align the pool for
+ * some double-word aligned instructions. */
constlen = KaffeJIT_getNumberOfConstants() * sizeof(union _constpoolval);
/* Allocate some padding to align codebase if so desired
*/
- methblock = gc_malloc(sizeof(jitCodeHeader) + exc_len + constlen + CODEPC + (align ? (align - ALIGNMENT_OF_SIZE(sizeof(jdouble))) : 0), KGC_ALLOC_JITCODE);
+ methblock = gc_malloc(sizeof(jitCodeHeader) + exc_len + constlen + const_align + CODEPC + (align ? (align - ALIGNMENT_OF_SIZE(sizeof(jdouble))) : 0), KGC_ALLOC_JITCODE);
if (methblock == 0) {
postOutOfMemory(einfo);
return (false);
}
jch = (jitCodeHeader *)methblock;
jch->pool = (void *)((char *)(jch + 1)) + exc_len;
+ jch->pool = (void *)(((uintp)jch->pool + const_align) & ~const_align );
jch->code_start = ((char *)jch->pool) + constlen;
jch->code_len = CODEPC;
/* align entry point if so desired */
Index: kaffe/kaffe/kaffevm/jit3/machine.c
diff -u kaffe/kaffe/kaffevm/jit3/machine.c:1.69 kaffe/kaffe/kaffevm/jit3/machine.c:1.70
--- kaffe/kaffe/kaffevm/jit3/machine.c:1.69 Mon Dec 27 16:09:48 2004
+++ kaffe/kaffe/kaffevm/jit3/machine.c Mon Jan 10 10:30:19 2005
@@ -481,6 +481,7 @@
jitCodeHeader *jch;
nativecode* methblock;
jboolean success;
+ uintp const_align = sizeof(union _constpoolval) - 1;
/* Emit pending instructions */
success = generateInsnSequence(einfo);
@@ -490,10 +491,11 @@
relinkFakeCalls();
- /* Okay, put this into malloc'ed memory */
- constlen = KaffeJIT3_getNumberOfConstants() * sizeof(union _constpoolval);
+ /* Okay, put this into malloc'ed memory. We allocate some more
+ * memory for alignment purpose. */
+ constlen = KaffeJIT3_getNumberOfConstants() * sizeof(union _constpoolval);
methblock = gc_malloc(sizeof(jitCodeHeader) +
- constlen +
+ constlen + const_align +
CODEPC,
KGC_ALLOC_JITCODE);
if (methblock == 0) {
@@ -503,6 +505,7 @@
jch = (jitCodeHeader *)methblock;
jch->pool = (void *)(jch + 1);
+ jch->pool = (void *) ( ((unsigned long)(jch->pool) + const_align) & ~const_align);
jch->code_start = ((char *)jch->pool) + constlen;
jch->code_len = CODEPC;
memcpy(jch->code_start, codeblock, jch->code_len);
More information about the kaffe
mailing list