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]
Other format: [Raw text]

Re: gcj's IO performance vs blackdown JDK



On Dec 26, 2003, at 18:15, Mohan Embar wrote:
+jint java::io::BufferedReader::lineEnd (jint limit)
+{
+  jchar *pbuf = elements (buffer) + pos;
+  int i = pos;
+  for (; i < limit; i++)
+  {
+    jchar ch = *pbuf++;
+    if (ch == '\n' || ch == '\r')
+      break;
+  }
+  return i;
+}

By changing the above native code to this:


jint java::io::BufferedReader::lineEnd (jint limit)
{
  jchar *pbuf = elements (buffer);
  int i = pos;
  for (; i < limit; i++)
  {
    jchar ch = pbuf[i];
    if (ch == '\n' || ch == '\r')
      break;
  }
  return i;
}

Try this instead it should give you even more.
Basically gcc holds tries to find loop variants and tries to combine them together
or split them apart which is what is happening in the second and third code.


My example should be faster but it might be slower, I have not looked into it that
much.


jint java::io::BufferedReader::lineEnd (jint limit)
{
  jchar *pbuf = elements (buffer) + pos;
  int i = 0;
  limit -= pos;
  for (; i < limit; i++)
  {
    jchar ch = pbuf[i];
    if (ch == '\n' || ch == '\r')
      break;
  }
  return i+pos;
}

Thanks,
Andrew Pinski


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