aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/sun/java2d
diff options
context:
space:
mode:
authorjgodinez <none@none>2009-04-15 08:47:21 -0700
committerjgodinez <none@none>2009-04-15 08:47:21 -0700
commitcae1240123e5933a4f3913af22c120b1703babc7 (patch)
treeb96b00cdc4b96f847d5746e891d88716428a1528 /src/share/classes/sun/java2d
parentd5367ebe0efaef8419e416a330b774ea4c877029 (diff)
6827989: Use Unsafe.copyMemory for array->Unsafe copy operations in RenderBuffer
Reviewed-by: campbell, flar Contributed-by: linuxhippy <linuxhippy@gmail.com>
Diffstat (limited to 'src/share/classes/sun/java2d')
-rw-r--r--src/share/classes/sun/java2d/pipe/RenderBuffer.java36
1 files changed, 11 insertions, 25 deletions
diff --git a/src/share/classes/sun/java2d/pipe/RenderBuffer.java b/src/share/classes/sun/java2d/pipe/RenderBuffer.java
index 62026e490..f0b8069a5 100644
--- a/src/share/classes/sun/java2d/pipe/RenderBuffer.java
+++ b/src/share/classes/sun/java2d/pipe/RenderBuffer.java
@@ -63,7 +63,7 @@ public class RenderBuffer {
* (This value can be adjusted if the cost of JNI downcalls is reduced
* in a future release.)
*/
- private static final int COPY_FROM_ARRAY_THRESHOLD = 28;
+ private static final int COPY_FROM_ARRAY_THRESHOLD = 6;
protected final Unsafe unsafe;
protected final long baseAddress;
@@ -93,20 +93,6 @@ public class RenderBuffer {
}
/**
- * Copies length bytes from the Java-level srcArray to the native
- * memory located at dstAddr. Note that this method performs no bounds
- * checking. Verification that the copy will not result in memory
- * corruption should be done by the caller prior to invocation.
- *
- * @param srcArray the source array
- * @param srcPos the starting position of the source array (in bytes)
- * @param dstAddr pointer to the destination block of native memory
- * @param length the number of bytes to copy from source to destination
- */
- private static native void copyFromArray(Object srcArray, long srcPos,
- long dstAddr, long length);
-
- /**
* The behavior (and names) of the following methods are nearly
* identical to their counterparts in the various NIO Buffer classes.
*/
@@ -147,9 +133,9 @@ public class RenderBuffer {
public RenderBuffer put(byte[] x, int offset, int length) {
if (length > COPY_FROM_ARRAY_THRESHOLD) {
- long offsetInBytes = offset * SIZEOF_BYTE;
+ long offsetInBytes = offset * SIZEOF_BYTE + Unsafe.ARRAY_BYTE_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_BYTE;
- copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+ unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
@@ -178,9 +164,9 @@ public class RenderBuffer {
public RenderBuffer put(short[] x, int offset, int length) {
// assert (position() % SIZEOF_SHORT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
- long offsetInBytes = offset * SIZEOF_SHORT;
+ long offsetInBytes = offset * SIZEOF_SHORT + Unsafe.ARRAY_SHORT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_SHORT;
- copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+ unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
@@ -215,9 +201,9 @@ public class RenderBuffer {
public RenderBuffer put(int[] x, int offset, int length) {
// assert (position() % SIZEOF_INT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
- long offsetInBytes = offset * SIZEOF_INT;
+ long offsetInBytes = offset * SIZEOF_INT + Unsafe.ARRAY_INT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_INT;
- copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+ unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
@@ -246,9 +232,9 @@ public class RenderBuffer {
public RenderBuffer put(float[] x, int offset, int length) {
// assert (position() % SIZEOF_FLOAT == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
- long offsetInBytes = offset * SIZEOF_FLOAT;
+ long offsetInBytes = offset * SIZEOF_FLOAT + Unsafe.ARRAY_FLOAT_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_FLOAT;
- copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+ unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;
@@ -277,9 +263,9 @@ public class RenderBuffer {
public RenderBuffer put(long[] x, int offset, int length) {
// assert (position() % SIZEOF_LONG == 0);
if (length > COPY_FROM_ARRAY_THRESHOLD) {
- long offsetInBytes = offset * SIZEOF_LONG;
+ long offsetInBytes = offset * SIZEOF_LONG + Unsafe.ARRAY_LONG_BASE_OFFSET;
long lengthInBytes = length * SIZEOF_LONG;
- copyFromArray(x, offsetInBytes, curAddress, lengthInBytes);
+ unsafe.copyMemory(x, offsetInBytes, null, curAddress, lengthInBytes);
position(position() + lengthInBytes);
} else {
int end = offset + length;