Alignment of stack traces
Andrew Haley
aph@redhat.com
Thu Mar 1 12:26:00 GMT 2001
Boehm, Hans writes:
> Are there enough other uses for this that it's worth doing?
>
> Java primitive arrays almost fit the bill here, except that there's no way
> to say "an array of pointer-sized integers. Java object arrays would work,
> but add extra scanning time.
>
> For now I'm using an array of Java longs, which doesn't appear to have
> broken anything on Itanium. But I haven't even rebuilt on X86 yet.
An array of Java longs ought to do it, but it may not always work; a
pointer doesn't have to be the same size as a jlong.
The cleanest way to fix this is probably to copy the data from the
byte array to an array of pointers when it's time to print the stack
trace. The difference in efficiency is so marginal as not to be worth
worrying about.
Is this OK?
Andrew.
2001年03月01日 Andrew Haley <aph@redhat.com>
* java/lang/natThrowable.cc (printRawStackTrace): Copy the
stackTrace buffer to a correctly aligned pointer array.
Index: java/lang/natThrowable.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
retrieving revision 1.8
diff -u -r1.8 natThrowable.cc
--- natThrowable.cc 2000年12月22日 06:19:24 1.8
+++ natThrowable.cc 2001年03月01日 20:23:04
@@ -83,8 +83,9 @@
if (!stackTrace)
return;
- void **p = (void **)elements (stackTrace);
int depth = stackTrace->length / sizeof p[0];
+ void *p[depth];
+ memcpy (p, elements (stackTrace), stackTrace->length);
_Jv_name_finder finder (_Jv_ThisExecutable ());
More information about the Java
mailing list