This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Alignment of stack traces


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 ());
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]