This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: Alignment of stack traces
- To: "'Andrew Haley'" <aph at redhat dot com>, "Boehm, Hans" <hans_boehm at hp dot com>
- Subject: RE: Alignment of stack traces
- From: "Boehm, Hans" <hans_boehm at hp dot com>
- Date: Thu, 1 Mar 2001 15:34:49 -0800
- Cc: "'Jeff Sturm'" <jsturm at one-point dot com>, Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>, "'java at gcc dot gnu dot org'" <java at gcc dot gnu dot org>
My patch was actually trying to deal with the fact that pointers and jlongs
may not be the same size. But yours is simpler, and I prefer it. Here's a
slightly revised version that fixes a problem with a forward reference to p.
It built and passed a superficial test on Linux/X86.
I would vote for putting it in both branches now, and reverting it in the
development tree if we decide to do something more substantial.
Hans
Index: natThrowable.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
retrieving revision 1.8
diff -r1.8 natThrowable.cc
68c68
< // ??? Might this cause a problem if the byte array isn't aligned?
---
> // We copy the array below to deal with alignment issues.
86,87c86,89
< void **p = (void **)elements (stackTrace);
< int depth = stackTrace->length / sizeof p[0];
---
> int depth = stackTrace->length / sizeof(void *);
> void *p[depth];
>
> memcpy (p, elements (stackTrace), stackTrace->length);
> -----Original Message-----
> From: Andrew Haley [mailto:aph@redhat.com]
> Sent: Thursday, March 01, 2001 12:26 PM
> To: Boehm, Hans
> Cc: 'Jeff Sturm'; Bryce McKinlay; 'java@gcc.gnu.org'
> Subject: 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 ());
>
>