This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: FYI: natFile -vs- stack
- From: Tom Tromey <tromey at redhat dot com>
- To: "Boehm, Hans" <hans_boehm at hp dot com>
- Cc: "'Bryce McKinlay '" <bryce at waitaki dot otago dot ac dot nz>, "'Java Patch List '" <java-patches at gcc dot gnu dot org>
- Date: 07 Feb 2002 22:06:28 -0700
- Subject: Re: Patch: FYI: natFile -vs- stack
- References: <40700B4C02ABD5119F000090278766443BEF8C@hplex1.hpl.hp.com>
- Reply-to: tromey at redhat dot com
>>>>> "Hans" == Boehm, Hans <hans_boehm@hp.com> writes:
Hans> I agree with Bryce that __builtin_alloca should be significantly
Hans> faster.
Thanks.
I'm checking in the appended. Now we use __builtin_alloca with the
correct buffer size. Bryce, thanks for keeping me honest.
We can revisit whether we want to cache the result if/when we change
to using the locale's encoding.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/io/natFile.cc (_access): Use __builtin_alloca.
(_stat): Likewise.
(attr): Likewise.
(getCanonicalPath): Likewise.
(performList): Likewise.
(performMkdir): Likewise.
(performSetReadOnly): Likewise.
(performRenameTo): Likewise.
(performSetLastModified): Likewise.
(performCreate): Likewise.
(performDelete): Likewise.
Index: java/io/natFile.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFile.cc,v
retrieving revision 1.16
diff -u -r1.16 natFile.cc
--- java/io/natFile.cc 2002/02/07 19:18:35 1.16
+++ java/io/natFile.cc 2002/02/08 04:43:07
@@ -39,7 +39,7 @@
jboolean
java::io::File::_access (jint query)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
JvAssert (query == READ || query == WRITE || query == EXISTS);
@@ -60,7 +60,7 @@
jboolean
java::io::File::_stat (jint query)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -83,7 +83,7 @@
jlong
java::io::File::attr (jint query)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -104,7 +104,7 @@
jstring
java::io::File::getCanonicalPath (void)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
char buf2[MAXPATHLEN];
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -135,7 +135,7 @@
/* Some systems have dirent.h, but no directory reading functions like
opendir. */
#if defined(HAVE_DIRENT_H) && defined(HAVE_OPENDIR)
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -188,7 +188,7 @@
jboolean
java::io::File::performMkdir (void)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -202,7 +202,7 @@
jboolean
java::io::File::performSetReadOnly (void)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -233,10 +233,11 @@
jboolean
java::io::File::performRenameTo (File *dest)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
- char *buf2 = (char *) _Jv_AllocBytes (JvGetStringUTFLength (dest->path) + 1);
+ char *buf2
+ = (char *) __builtin_alloca (JvGetStringUTFLength (dest->path) + 1);
total = JvGetStringUTFRegion (dest->path, 0, dest->path->length(), buf2);
buf2[total] = '\0';
@@ -253,7 +254,7 @@
#ifdef HAVE_UTIME
utimbuf tb;
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -268,7 +269,7 @@
jboolean
java::io::File::performCreate (void)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
@@ -290,7 +291,7 @@
jboolean
java::io::File::performDelete (void)
{
- char *buf = (char *) _Jv_AllocBytes (JvGetStringUTFLength (path) + 1);
+ char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (path) + 1);
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';