History log of /libcore/luni/src/main/java/java/nio/MappedByteBufferAdapter.java
Revision Date Author Comments
bdd17cde8cf675f5d5703aad4dfb565932fb4c50 08-Feb-2012 Elliott Hughes <enh@google.com> Fix an ICS regression with hasArray on a JNI-allocated DirectByteBuffer.

Bug: http://code.google.com/p/android/issues/detail?id=24327
Change-Id: Ib31b60fe01e3d0b5a1ed7125ddf047e09fd64056
5a1e8cc38e1cc6c3f2fc66f039ca0fc5309a0dc3 16-Dec-2010 Elliott Hughes <enh@google.com> MappedByteBuffer get(byte[]) and get(byte[], int, int) weren't updating 'position'.

The majority of this change is work to extend our tests to cover
MappedByteBuffer too, plus new tests to check that 'position' is
always updated correctly by ByteBuffer's relative get/put methods.

Bug: 3291927
Change-Id: I58217de45ba65675730f30771fba592cb2af28ff
43a9f774d075e0e441d8b996e3f6c81ea483ec89 19-Oct-2010 Elliott Hughes <enh@google.com> BufferIterator support for byte[].

Bug: 3032515
Change-Id: I040a92c3ce241aa97719ff94e3cc31c62473bf46
ae704b984c10a63883cc366e823d53902d6ac7a9 21-Sep-2010 Elliott Hughes <enh@google.com> Minor tidy-up.

The nio implementation is still a bit of a mess because Java doesn't have any
kind of "module" concept, nor "friend". But this makes it a little less untidy,
and makes the deliberate access control subversions a little more explicit, and
makes various things less accessible than they were.

Change-Id: I514b1e24000b91f86b768ed408fedae115dc3080
f714d3767875c96c5122683ef8c75cc9d5f1259f 13-Sep-2010 Elliott Hughes <enh@google.com> Make MappedByteBuffer.get(byte[], int, int) orders of magnitude faster.

Even with the misleading logarithmic scale graphs, this stood out like
a sore thumb. Other than this, our MappedByteBuffer looks like it's just a
layer or two of missing inlining away from DirectByteBuffer performance.

Bug: 2935622
Change-Id: Ie4ed153fad6d19a2c83748fee2e364c3e86d40f3
dbb973b7f1dc6d3e86c6f9528a2aadff1e01c0cb 10-Sep-2010 Elliott Hughes <enh@google.com> Fix MappedByteBufferAdapter.

I broke MappedByteBufferAdapter in https://android-git.corp.google.com/g/65226
because I didn't move the position-setting to _before_ the delegated gets (the
puts were correct). This was spotted in review, but I'd already submitted to
unblock a later change.

The upstream tests didn't spot this because they mainly test buffers full of
zeros (which aren't very interesting from an endian point of view). I've raised
http://b/2991877 to get the upstream tests fixed.

I've also added a motivating comment for this admittedly weird class.

Bug: 2935622
Change-Id: I6bbf00636a5e05e7396cf94ee6985bcf50fc4552
0e1b748ecabf720065a632f28330f5d4d037d5ae 10-Sep-2010 Elliott Hughes <enh@google.com> Consistent naming for get/put/wrap arguments.

Bug: 2935622
Change-Id: Icb39392f9106f9fe5ba70ccdcb6b059dbf5617bc
0c53cf8b2c46deb41e91db50ddc17d598cc64a10 09-Sep-2010 Elliott Hughes <enh@google.com> Speed up MappedByteBuffer.

Make it possible to override limit(int) and position(int) internally, so I can
avoid updating MappedByteBufferAdapter's wrapped ByteBuffer's limit and
position on every get or put. I still need to do extra work with position if
you use the get/put overloads that don't take an index, but even that becomes
cheaper. The indexed overloads benefit the most, though. Before:

benchmark before after (both us)

ByteBuffer_getByte 830 757
ByteBuffer_getChar 940 875

ByteBuffer_getByte_indexed 800 509
ByteBuffer_getChar_indexed 936 643

Also factor out duplicated toString implementations.

Bug: 2935622
Change-Id: I4cfe206fde638bddb5a7b4a62223e2588f44b8ac
0440837fd0013373ba3476283151299e7be9e5a3 08-Sep-2010 Elliott Hughes <enh@google.com> Move the MemoryBlock up into java.nio.Buffer.

This lets me kill getBaseAddress and the (bogus) DirectBuffer interface.

Bug: 2935622
Change-Id: I51c758e7687a6cfa4a3a64ef089fb600b847b70f
eb29579498a8860f81fd38275f8657c21bb67abb 08-Sep-2010 Elliott Hughes <enh@google.com> Rename PlatformAddress to MemoryBlock.

Bug: 2935622
Change-Id: I8a09cb9be0b0ea468278f7808f1a18c3ce820b49
0f335c4ed1a0cb419c8ce82183fabb241d5dd032 07-Sep-2010 Elliott Hughes <enh@google.com> Kill getEffectiveAddress.

Set the corresponding field in the constructors.

Requires a dalvikvm change: https://android-git.corp.google.com/g/64866

Bug: 2935622
Change-Id: I26663bfcdb80db75672be71395b861c1a79c24fc
c73a5be50cdd804ff3c12e7b43da08c33cdd6f21 04-Sep-2010 Elliott Hughes <enh@google.com> Move some of the nio implementation into java.nio.

Another stepping-stone to simplifying the PlatformAddress/OSMemory situation.

Bug: 2935622
Change-Id: Ic5b941ee7c17d6b5aeda53c3c2cdf2c43cebff55
c3c38fbbccaf428200acdd819b1f7799edac54d2 04-Sep-2010 Elliott Hughes <enh@google.com> Remove nio cruft, move the implementation cost of 'free' where it belongs...

...and inline some getBaseAddress calls. The JIT doesn't manage to do that, it
seems, but being the JIT is not really my purpose: I'm trying to kill
getBaseAddress.

Bug: 2935622
Change-Id: I3cd99cd131a2c09796f5ff5bb31332287db2130f
29dbfe19b113a13b712be2bc762ef1c81cd06c47 03-Sep-2010 Elliott Hughes <enh@google.com> Use finalizers to free direct buffers.

Also switch to a cheaper scheme for avoiding double-frees (which could only
happen if library code is broken; at the moment the only caller is the
iovec-style stuff). This halves the cost of direct buffer access, at the
unimportant cost of not throwing an exception if we try to access a buffer
we freed while we still had a reference to it.

Also use named constants for the sizes of primitive types.

Also kill BufferFactory.

Bug: 2935622
Change-Id: I6021ce7531f49d8cff7635d6d2cc54851bacaf69
f46d2ce4d4c92d16e2574f57f70fc5477dc12697 02-Sep-2010 Elliott Hughes <enh@google.com> Make DirectBuffer.getEffectiveAddress cheaper.

DirectBuffer.getEffectiveAddress is used to implement the JNI function
GetDirectBufferAddress. Currently it uses reference types unnecessarily,
and we have an object pool to reduce the cost of this. Switch to using
int instead.

I'll remove the pool in a later change.

Note that this change requires a corresponding change to the
GetDirectBufferAddress implementation in dalvik:
https://android-git.corp.google.com/g/64328

Bug: 2935622
Change-Id: Ia0c20bd58c5355550f6af840feb08acff14fd4e9
8510524dab13e0acc1babf22cbc55002fb122777 17-Aug-2010 Elliott Hughes <enh@google.com> Some nio tidying.

Remove indirection on OSMemory, and use public ByteOrder and MapMode types
throughout the implementation, rather than adding our own duplication. Also
remove some unnecessary Java methods that just forwarded to identical native
methods, and an unnecessary factory class for MappedByteBuffer instances.
Also get rid of ICommonDataTypes, most of which was unused cruft.

Change-Id: I3240b02bcc19941b1b1cbba351ae7f7c1cdfc5b4
3ff29eb11a241d58c54ecc84230bb0672f4aa148 23-Apr-2010 Peter Hallam <peterhal@google.com> More merging of nio into luni

Change-Id: Ib4356b3cd57490df8ff246ea6a4bc1c269ba848b