This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch for Review: JvGetStringUTF and JvTempCString
Mohan Embar writes:
> Hi Andrew,
>
> > > 1. So are we okay with the approach where:
> > >
> > > - the helper class allocates 256 bytes on the stack and tries to cram
> > > the string in there if it fits
> >
> >Up to 256 bytes; don't allocate memory that you won't use.
>
> How would I parameterize the 256 in this class? (I'm sure you wouldn't
> want to make this a template class....)
Use a macro. Create the temp and pass it to the constructor.
> > > 2. Shall I try to run some crude timings so see whether _Jv_Malloc() or
> > > _Jv_AllocBytes() is a faster?
> >
> >It might be interesting, but it isn't very important.
>
> My gut feeling is to avoid _Jv_AllocBytes() in order to avoid the
> extra GC bookkeeping. Bryce brought up the issues about thread-local
> allocation, but this might be less critical because the stack-allocated
> buffer will presumably handle the majority of cases in the library
> code where this class is intended to be used.
Exactly. Optimize the well-trodden path, but make sure the system
will still work for the weird ones.
So, if someone passes you a one megabyte string, keep working, don't
crash, but don't worry if it slows down a bit. :-)
Andrew.