[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Jamvm-general] Re: jamvm + classpath CVS
From: |
Mark Wielaard |
Subject: |
RE: [Jamvm-general] Re: jamvm + classpath CVS |
Date: |
Fri, 10 Dec 2004 12:57:18 +0100 |
Hi,
On Fri, 2004-12-10 at 12:40, Jeroen Frijters wrote:
> I meant to say: "I should have changed String...".
Better also change StringBuffer. I needed to change it to also not call
System.arraycopy() directly (didn't investigate when/why it was
triggered, but it solved my initialization problem). Patch attached.
I wonder if we can use this for a small optimisation.
Currently we directly call VMSystem.arraycopy() from System.arraycopy()
and let VMSystem.arraycopy() do the bounds checking and arraystore
checking. Since with String and StringBuffer we can guarantee (I have to
carefully check all instances) that this will be used with correct
bounds and only with char arrays we might want to add a
VMSystem.chararraycopy() that String and StringBuffer can use.
Such micro optimisations without first measuring whether or not it makes
a difference might be a wrong idea, but it seems to make sense since
String and StringBuffer are so often used and arraycopy() is much more
generic than either of them need. (Default implementation can just fall
back to normal arraycopy of course.)
Cheers,
Mark
Index: java/lang/String.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/String.java,v
retrieving revision 1.59
diff -u -r1.59 String.java
--- java/lang/String.java 17 Nov 2004 14:46:24 -0000 1.59
+++ java/lang/String.java 10 Dec 2004 11:52:38 -0000
@@ -414,7 +414,7 @@
if ((count << 2) < buffer.value.length)
{
value = new char[count];
- System.arraycopy(buffer.value, 0, value, 0, count);
+ VMSystem.arraycopy(buffer.value, 0, value, 0, count);
}
else
{
@@ -446,7 +446,7 @@
else
{
value = new char[count];
- System.arraycopy(data, offset, value, 0, count);
+ VMSystem.arraycopy(data, offset, value, 0, count);
this.offset = 0;
}
this.count = count;
@@ -496,7 +496,7 @@
{
if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count)
throw new StringIndexOutOfBoundsException();
- System.arraycopy(value, srcBegin + offset,
+ VMSystem.arraycopy(value, srcBegin + offset,
dst, dstBegin, srcEnd - srcBegin);
}
@@ -1056,8 +1056,8 @@
if (count == 0)
return str;
char[] newStr = new char[count + str.count];
- System.arraycopy(value, offset, newStr, 0, count);
- System.arraycopy(str.value, str.offset, newStr, count, str.count);
+ VMSystem.arraycopy(value, offset, newStr, 0, count);
+ VMSystem.arraycopy(str.value, str.offset, newStr, count, str.count);
// Package constructor avoids an array copy.
return new String(newStr, 0, newStr.length, true);
}
@@ -1398,7 +1398,7 @@
// if (count == value.length)
// return (char[]) value.clone();
char[] copy = new char[count];
- System.arraycopy(value, offset, copy, 0, count);
+ VMSystem.arraycopy(value, offset, copy, 0, count);
return copy;
}
@@ -1637,7 +1637,7 @@
{
int count = s.count;
value = new char[count];
- System.arraycopy(s.value, s.offset, value, 0, count);
+ VMSystem.arraycopy(s.value, s.offset, value, 0, count);
}
return value;
Index: java/lang/StringBuffer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/StringBuffer.java,v
retrieving revision 1.28
diff -u -r1.28 StringBuffer.java
--- java/lang/StringBuffer.java 22 Oct 2004 18:02:06 -0000 1.28
+++ java/lang/StringBuffer.java 10 Dec 2004 11:52:38 -0000
@@ -263,7 +263,7 @@
{
if (srcOffset < 0 || srcEnd > count || srcEnd < srcOffset)
throw new StringIndexOutOfBoundsException();
- System.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
+ VMSystem.arraycopy(value, srcOffset, dst, dstOffset, srcEnd - srcOffset);
}
/**
@@ -334,7 +334,7 @@
{
int len = stringBuffer.count;
ensureCapacity_unsynchronized(count + len);
- System.arraycopy(stringBuffer.value, 0, value, count, len);
+ VMSystem.arraycopy(stringBuffer.value, 0, value, count, len);
count += len;
}
return this;
@@ -374,7 +374,7 @@
if (offset < 0 || count < 0 || offset > data.length - count)
throw new StringIndexOutOfBoundsException();
ensureCapacity_unsynchronized(this.count + count);
- System.arraycopy(data, offset, value, this.count, count);
+ VMSystem.arraycopy(data, offset, value, this.count, count);
this.count += count;
return this;
}
@@ -483,7 +483,7 @@
// This will unshare if required.
ensureCapacity_unsynchronized(count);
if (count - end != 0)
- System.arraycopy(value, end, value, start, count - end);
+ VMSystem.arraycopy(value, end, value, start, count - end);
count -= end - start;
return this;
}
@@ -526,7 +526,7 @@
ensureCapacity_unsynchronized(count + delta);
if (delta != 0 && end < count)
- System.arraycopy(value, end, value, end + delta, count - end);
+ VMSystem.arraycopy(value, end, value, end + delta, count - end);
str.getChars(0, len, value, start);
count += delta;
@@ -613,8 +613,8 @@
|| str_offset < 0 || str_offset > str.length - len)
throw new StringIndexOutOfBoundsException();
ensureCapacity_unsynchronized(count + len);
- System.arraycopy(value, offset, value, offset + len, count - offset);
- System.arraycopy(str, str_offset, value, offset, len);
+ VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
+ VMSystem.arraycopy(str, str_offset, value, offset, len);
count += len;
return this;
}
@@ -653,7 +653,7 @@
str = "null";
int len = str.count;
ensureCapacity_unsynchronized(count + len);
- System.arraycopy(value, offset, value, offset + len, count - offset);
+ VMSystem.arraycopy(value, offset, value, offset + len, count - offset);
str.getChars(0, len, value, offset);
count += len;
return this;
@@ -704,7 +704,7 @@
if (offset < 0 || offset > count)
throw new StringIndexOutOfBoundsException(offset);
ensureCapacity_unsynchronized(count + 1);
- System.arraycopy(value, offset, value, offset + 1, count - offset);
+ VMSystem.arraycopy(value, offset, value, offset + 1, count - offset);
value[offset] = ch;
count++;
return this;
@@ -900,7 +900,7 @@
: value.length);
minimumCapacity = (minimumCapacity < max ? max : minimumCapacity);
char[] nb = new char[minimumCapacity];
- System.arraycopy(value, 0, nb, 0, count);
+ VMSystem.arraycopy(value, 0, nb, 0, count);
value = nb;
shared = false;
}
Index: vm/reference/gnu/classpath/VMSystemProperties.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/vm/reference/gnu/classpath/VMSystemProperties.java,v
retrieving revision 1.2
diff -u -r1.2 VMSystemProperties.java
--- vm/reference/gnu/classpath/VMSystemProperties.java 7 Dec 2004 08:43:53
-0000 1.2
+++ vm/reference/gnu/classpath/VMSystemProperties.java 10 Dec 2004 11:52:38
-0000
@@ -91,5 +91,8 @@
* a good idea to process the properties specified on the command
* line here.
*/
- static native void postInit(Properties properties);
+ static void postInit(Properties properties)
+ {
+ }
+
}
signature.asc
Description: This is a digitally signed message part