This is the mail archive of the java-discuss@sources.redhat.com 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: alloca and native code


Tom Tromey writes:
 > >>>>> "Andrew" == Andrew Haley <aph@redhat.com> writes:
 > 
 > Andrew> It would be nice if we didn't do this in embedded systems,
 > Andrew> since it breaks the nice property that Java aprograms have
 > Andrew> small stacks, and the stack is only scanned conservatively.
 > Andrew> We ought to question if this is a performance win on any
 > Andrew> system.
 > 
 > I usually do it because it is more convenient than doing an explicit
 > alloc/free of unscanned memory (eg using _Jv_Malloc).

Yeah, but if you do this you aren't gettting unscanned memory, so this
is rather deceptive.  


 > In general I only use alloca or a variable array if the size is
 > bounded (though that probably isn't always true, sigh).  But I
 > agree that revisiting this makes sense.  Maybe we should enter a
 > PR, or even make it part of our "coding standard (if we had one)".

IMO a coding standard would say "in native methods, don't use stack
space for arrays.  Howver, short strings are acceptable."

Andrew.

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