diff options
author | Andy McFadden <fadden@android.com> | 2009-07-25 10:11:54 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-07-25 10:11:54 -0700 |
commit | bd38a2ffefa8d526a69f95a787b6f5935ae7c1a2 (patch) | |
tree | 9ec12b76d68fd8f67ff1c1252a841a34615f87f7 /nio | |
parent | a710680c11ffb9d604484fece737f17b165ba268 (diff) | |
parent | bd8ecd863aa83df50d7ce8f5950d8645ab6356af (diff) | |
download | libcore-bd38a2ffefa8d526a69f95a787b6f5935ae7c1a2.zip libcore-bd38a2ffefa8d526a69f95a787b6f5935ae7c1a2.tar.gz libcore-bd38a2ffefa8d526a69f95a787b6f5935ae7c1a2.tar.bz2 |
am 8e696dc0: JNI direct buffer function speedup, part 3.
Merge commit '8e696dc0271299433cb3297e7aafc7bd0ee1b2b7'
* commit '8e696dc0271299433cb3297e7aafc7bd0ee1b2b7':
JNI direct buffer function speedup, part 3.
Diffstat (limited to 'nio')
9 files changed, 50 insertions, 8 deletions
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java index 9e870e4..19d8969 100644 --- a/nio/src/main/java/java/nio/Buffer.java +++ b/nio/src/main/java/java/nio/Buffer.java @@ -111,6 +111,16 @@ public abstract class Buffer { int _arrayOffset() { return 0; } + + /** + * For direct buffers, the effective address of the data. This is set + * on first use. If the field is zero, this is either not a direct + * buffer or the field has not been initialized, and you need to issue + * the getEffectiveAddress() call and use the result of that. + * + * This is strictly an optimization. + */ + int effectiveDirectAddress = 0; // END android-added /** diff --git a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java index 14a48ff..bd340be 100644 --- a/nio/src/main/java/java/nio/CharToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/CharToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class CharToByteBufferAdapter extends CharBuffer implements DirectBuffer { public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; diff --git a/nio/src/main/java/java/nio/DirectByteBuffer.java b/nio/src/main/java/java/nio/DirectByteBuffer.java index 46529a5..dcdb3c1 100644 --- a/nio/src/main/java/java/nio/DirectByteBuffer.java +++ b/nio/src/main/java/java/nio/DirectByteBuffer.java @@ -247,7 +247,11 @@ abstract class DirectByteBuffer extends BaseByteBuffer implements DirectBuffer { * previously. */ public final PlatformAddress getEffectiveAddress() { - return getBaseAddress().offsetBytes(offset); + // BEGIN android-changed + PlatformAddress addr = getBaseAddress().offsetBytes(offset); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } /** diff --git a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java index 336488b..70406ba 100644 --- a/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/DoubleToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class DoubleToByteBufferAdapter extends DoubleBuffer implements DirectBuff public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; diff --git a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java index 97c0528..75b9d84 100644 --- a/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/FloatToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class FloatToByteBufferAdapter extends FloatBuffer implements DirectBuffer public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; diff --git a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java index 91b9311..e77bec6 100644 --- a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer { public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; diff --git a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java index 0bd3ce4..bcdeb2b 100644 --- a/nio/src/main/java/java/nio/LongToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/LongToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class LongToByteBufferAdapter extends LongBuffer implements DirectBuffer { public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; diff --git a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java index 83a51c1..84866dc 100644 --- a/nio/src/main/java/java/nio/MappedByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/MappedByteBufferAdapter.java @@ -148,7 +148,11 @@ final class MappedByteBufferAdapter extends MappedByteBuffer implements DirectBu } public PlatformAddress getEffectiveAddress() { - return ((DirectBuffer) this.wrapped).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer) this.wrapped).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } public float getFloat() { diff --git a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java index 41ce50c..a608bc9 100644 --- a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java @@ -65,7 +65,11 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer public PlatformAddress getEffectiveAddress() { if (byteBuffer instanceof DirectBuffer) { - return ((DirectBuffer)byteBuffer).getEffectiveAddress(); + // BEGIN android-changed + PlatformAddress addr = ((DirectBuffer)byteBuffer).getEffectiveAddress(); + effectiveDirectAddress = addr.toInt(); + return addr; + // END android-changed } else { assert false : byteBuffer; return null; |