src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template
author bpb
Wed, 20 Feb 2019 10:57:22 -0800
changeset 53855 7c362992527a
parent 51318 60f9b6b5ad86
child 53959 1542e63eb537
permissions -rw-r--r--
5029431: (bf) Add absolute bulk put and get methods Reviewed-by: alanb, darcy, chegar, rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
     2
 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4115
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#warn This file is preprocessed before being compiled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
package java.nio;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
    30
import java.io.FileDescriptor;
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
    31
import java.lang.ref.Reference;
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
    32
import java.util.Objects;
34882
ce2a8ec851c1 8145544: Move sun.misc.VM to jdk.internal.misc
chegar
parents: 33660
diff changeset
    33
import jdk.internal.misc.VM;
35641
da165fd9c886 8148117: Move sun.misc.Cleaner to jdk.internal.ref
chegar
parents: 34882
diff changeset
    34
import jdk.internal.ref.Cleaner;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.nio.ch.DirectBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
class Direct$Type$Buffer$RW$$BO$
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    extends {#if[byte]?Mapped$Type$Buffer:$Type$Buffer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    extends Direct$Type$Buffer$BO$
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    implements DirectBuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
1151
4070cecdb99d 6570619: (bf) DirectByteBuffer.get/put(byte[]) does not scale well
alanb
parents: 1143
diff changeset
    49
    // Cached array base offset
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
    50
    private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset($type$[].class);
1151
4070cecdb99d 6570619: (bf) DirectByteBuffer.get/put(byte[]) does not scale well
alanb
parents: 1143
diff changeset
    51
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // Cached unaligned-access capability
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
    53
    protected static final boolean UNALIGNED = Bits.unaligned();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    // Base address, used in all indexing calculations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    //    protected long address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    59
    // An object attached to this buffer. If this buffer is a view of another
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    60
    // buffer then we use this field to keep a reference to that buffer to
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    61
    // ensure that its memory isn't freed before we are done with it.
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    62
    private final Object att;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    64
    public Object attachment() {
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
    65
        return att;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static class Deallocator
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        implements Runnable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        private long address;
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
    75
        private long size;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        private int capacity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
    78
        private Deallocator(long address, long size, int capacity) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            assert (address != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            this.address = address;
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
    81
            this.size = size;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            this.capacity = capacity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            if (address == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
                // Paranoia
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            }
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
    90
            UNSAFE.freeMemory(address);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            address = 0;
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
    92
            Bits.unreserveMemory(size, capacity);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private final Cleaner cleaner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public Cleaner cleaner() { return cleaner; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#else[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public Cleaner cleaner() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    // Primary constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    Direct$Type$Buffer$RW$(int cap) {                   // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#if[rw]
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   115
        super(-1, 0, cap, cap);
6902
3352f8839320 4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents: 5506
diff changeset
   116
        boolean pa = VM.isDirectMemoryPageAligned();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        int ps = Bits.pageSize();
6902
3352f8839320 4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents: 5506
diff changeset
   118
        long size = Math.max(1L, (long)cap + (pa ? ps : 0));
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
   119
        Bits.reserveMemory(size, cap);
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
   120
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        long base = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        try {
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   123
            base = UNSAFE.allocateMemory(size);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        } catch (OutOfMemoryError x) {
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
   125
            Bits.unreserveMemory(size, cap);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            throw x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   128
        UNSAFE.setMemory(base, size, (byte) 0);
6902
3352f8839320 4837564: (bf) Please make DirectByteBuffer performance enhancements
alanb
parents: 5506
diff changeset
   129
        if (pa && (base % ps != 0)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            // Round up to page boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            address = base + ps - (base & (ps - 1));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            address = base;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
1143
645d4b930f93 6682020: (bf) Support monitoring of direct and mapped buffer usage
alanb
parents: 2
diff changeset
   135
        cleaner = Cleaner.create(this, new Deallocator(base, size, cap));
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   136
        att = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        super(cap);
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   139
        this.isReadOnly = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   145
    // Invoked to construct a direct ByteBuffer referring to the block of
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   146
    // memory. A given arbitrary object may also be attached to the buffer.
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   147
    //
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   148
    Direct$Type$Buffer(long addr, int cap, Object ob) {
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   149
        super(-1, 0, cap, cap);
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   150
        address = addr;
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   151
        cleaner = null;
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   152
        att = ob;
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   153
    }
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   154
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   155
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    // Invoked only by JNI: NewDirectByteBuffer(void*, long)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    private Direct$Type$Buffer(long addr, int cap) {
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   159
        super(-1, 0, cap, cap);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        address = addr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        cleaner = null;
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   162
        att = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    // For memory-mapped buffers -- invoked by FileChannelImpl via reflection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    //
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   169
    protected Direct$Type$Buffer$RW$(int cap, long addr,
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   170
                                     FileDescriptor fd,
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   171
                                     Runnable unmapper)
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   172
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
#if[rw]
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   174
        super(-1, 0, cap, cap, fd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        address = addr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        cleaner = Cleaner.create(this, unmapper);
10325
b72c20cd583a 7047325: Internal API to improve management of direct buffers
coffeys
parents: 7668
diff changeset
   177
        att = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
#else[rw]
7025
6e002f9a2899 6816049: (bf) MappedByteBuffer.force() method does not flush data correctly
alanb
parents: 6902
diff changeset
   179
        super(cap, addr, fd, unmapper);
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   180
        this.isReadOnly = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    // For duplicates and slices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    Direct$Type$Buffer$RW$$BO$(DirectBuffer db,         // package-private
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                               int mark, int pos, int lim, int cap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                               int off)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        super(mark, pos, lim, cap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        address = db.address() + off;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        cleaner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
#end[byte]
51318
60f9b6b5ad86 8208362: (bf) Long chains created by direct Buffer::slice
fweimer
parents: 49210
diff changeset
   198
        Object attachment = db.attachment();
60f9b6b5ad86 8208362: (bf) Long chains created by direct Buffer::slice
fweimer
parents: 49210
diff changeset
   199
        att = (attachment == null ? db : attachment);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        super(db, mark, pos, lim, cap, off);
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   202
        this.isReadOnly = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   206
    @Override
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   207
    Object base() {
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   208
        return null;
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   209
    }
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   210
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public $Type$Buffer slice() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        int pos = this.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        int lim = this.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        int rem = (pos <= lim ? lim - pos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        int off = (pos << $LG_BYTES_PER_VALUE$);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        assert (off >= 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, off);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
36933
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   221
#if[byte]
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   222
    public $Type$Buffer slice(int pos, int lim) {
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   223
        assert (pos >= 0);
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   224
        assert (pos <= lim);
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   225
        int rem = lim - pos;
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   226
        return new Direct$Type$Buffer$RW$$BO$(this, -1, 0, rem, rem, pos);
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   227
    }
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   228
#end[byte]
3e6453e2d833 8149469: ByteBuffer API and implementation enhancements for VarHandles
psandoz
parents: 36222
diff changeset
   229
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public $Type$Buffer duplicate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        return new Direct$Type$Buffer$RW$$BO$(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                              this.markValue(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                                              this.position(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                                              this.limit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                                              this.capacity(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                                              0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public $Type$Buffer asReadOnlyBuffer() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        return new Direct$Type$BufferR$BO$(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                           this.markValue(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                           this.position(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                                           this.limit(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                           this.capacity(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                           0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return duplicate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public long address() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return address;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    private long ix(int i) {
33300
bb014fdf246b 8130891: (bf) More direct buffering
bpb
parents: 31873
diff changeset
   259
        return address + ((long)i << $LG_BYTES_PER_VALUE$);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public $type$ get() {
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   263
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   264
            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex()))));
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   265
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   266
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   267
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public $type$ get(int i) {
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   271
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   272
            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i)))));
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   273
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   274
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   275
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
17922
d56eec572de5 8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents: 10325
diff changeset
   278
#if[streamableType]
d56eec572de5 8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents: 10325
diff changeset
   279
    $type$ getUnchecked(int i) {
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   280
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   281
            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i))));
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   282
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   283
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   284
        }
17922
d56eec572de5 8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents: 10325
diff changeset
   285
    }
d56eec572de5 8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents: 10325
diff changeset
   286
#end[streamableType]
d56eec572de5 8014854: (bf) CharBuffer.chars too slow with default implementation
alanb
parents: 10325
diff changeset
   287
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public $Type$Buffer get($type$[] dst, int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
#if[rw]
33300
bb014fdf246b 8130891: (bf) More direct buffering
bpb
parents: 31873
diff changeset
   290
        if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            checkBounds(offset, length, dst.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            int pos = position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            int lim = limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            int rem = (pos <= lim ? lim - pos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            if (length > rem)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                throw new BufferUnderflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   299
            long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   300
            try {
1151
4070cecdb99d 6570619: (bf) DirectByteBuffer.get/put(byte[]) does not scale well
alanb
parents: 1143
diff changeset
   301
#if[!byte]
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   302
                if (order() != ByteOrder.nativeOrder())
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   303
                    UNSAFE.copySwapMemory(null,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   304
                                          ix(pos),
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   305
                                          dst,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   306
                                          dstOffset,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   307
                                          (long)length << $LG_BYTES_PER_VALUE$,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   308
                                          (long)1 << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   309
                else
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   310
#end[!byte]
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   311
                    UNSAFE.copyMemory(null,
36222
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   312
                                      ix(pos),
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   313
                                      dst,
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   314
                                      dstOffset,
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   315
                                      (long)length << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   316
            } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   317
                Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   318
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            position(pos + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            super.get(dst, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   329
    public $Type$Buffer get(int index, $type$[] dst, int offset, int length) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   330
#if[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   331
        if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   332
            Objects.checkFromIndexSize(index, length, limit());
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   333
            Objects.checkFromIndexSize(offset, length, dst.length);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   334
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   335
            long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   336
            try {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   337
#if[!byte]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   338
                if (order() != ByteOrder.nativeOrder())
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   339
                    UNSAFE.copySwapMemory(null,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   340
                                          ix(index),
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   341
                                          dst,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   342
                                          dstOffset,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   343
                                          (long)length << $LG_BYTES_PER_VALUE$,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   344
                                          (long)1 << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   345
                else
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   346
#end[!byte]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   347
                    UNSAFE.copyMemory(null,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   348
                                      ix(index),
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   349
                                      dst,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   350
                                      dstOffset,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   351
                                      (long)length << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   352
            } finally {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   353
                Reference.reachabilityFence(this);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   354
            }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   355
        } else {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   356
            super.get(index, dst, offset, length);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   357
        }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   358
        return this;
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   359
#else[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   360
        throw new ReadOnlyBufferException();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   361
#end[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   362
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public $Type$Buffer put($type$ x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
#if[rw]
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   367
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   368
            UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   369
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   370
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   371
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public $Type$Buffer put(int i, $type$ x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
#if[rw]
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   380
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   381
            UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   382
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   383
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   384
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    public $Type$Buffer put($Type$Buffer src) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        if (src instanceof Direct$Type$Buffer$BO$) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            if (src == this)
31873
87b015c2cd36 8065556: (bf) Buffer.position and other methods should include detail in IAE
bpb
parents: 25859
diff changeset
   395
                throw createSameBufferException();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            Direct$Type$Buffer$RW$$BO$ sb = (Direct$Type$Buffer$RW$$BO$)src;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            int spos = sb.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            int slim = sb.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            assert (spos <= slim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            int srem = (spos <= slim ? slim - spos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            int pos = position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            int lim = limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            int rem = (pos <= lim ? lim - pos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            if (srem > rem)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                throw new BufferOverflowException();
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   410
            try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   411
                UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   412
            } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   413
                Reference.reachabilityFence(sb);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   414
                Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   415
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            sb.position(spos + srem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            position(pos + srem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        } else if (src.hb != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            int spos = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            int slim = src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            assert (spos <= slim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            int srem = (spos <= slim ? slim - spos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            put(src.hb, src.offset + spos, srem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            src.position(spos + srem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            super.put(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    public $Type$Buffer put($type$[] src, int offset, int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
#if[rw]
33300
bb014fdf246b 8130891: (bf) More direct buffering
bpb
parents: 31873
diff changeset
   439
        if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            checkBounds(offset, length, src.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            int pos = position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            int lim = limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            int rem = (pos <= lim ? lim - pos : 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            if (length > rem)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                throw new BufferOverflowException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   448
            long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   449
            try {
1151
4070cecdb99d 6570619: (bf) DirectByteBuffer.get/put(byte[]) does not scale well
alanb
parents: 1143
diff changeset
   450
#if[!byte]
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   451
                if (order() != ByteOrder.nativeOrder())
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   452
                    UNSAFE.copySwapMemory(src,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   453
                                          srcOffset,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   454
                                          null,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   455
                                          ix(pos),
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   456
                                          (long)length << $LG_BYTES_PER_VALUE$,
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   457
                                          (long)1 << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   458
                else
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   459
#end[!byte]
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   460
                    UNSAFE.copyMemory(src,
36222
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   461
                                      srcOffset,
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   462
                                      null,
dfed693e648b 8149596: Remove java.nio.Bits copy wrapper methods
mikael
parents: 35641
diff changeset
   463
                                      ix(pos),
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   464
                                      (long)length << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   465
            } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   466
                Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   467
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            position(pos + length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            super.put(src, offset, length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
53855
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   478
    public $Type$Buffer put(int index, $type$[] src, int offset, int length) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   479
#if[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   480
        if (((long)length << $LG_BYTES_PER_VALUE$) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   481
            Objects.checkFromIndexSize(index, length, limit());
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   482
            Objects.checkFromIndexSize(offset, length, src.length);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   483
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   484
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   485
            long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   486
            try {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   487
#if[!byte]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   488
                if (order() != ByteOrder.nativeOrder())
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   489
                    UNSAFE.copySwapMemory(src,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   490
                                          srcOffset,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   491
                                          null,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   492
                                          ix(index),
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   493
                                          (long)length << $LG_BYTES_PER_VALUE$,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   494
                                          (long)1 << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   495
                else
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   496
#end[!byte]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   497
                    UNSAFE.copyMemory(src,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   498
                                      srcOffset,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   499
                                      null,
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   500
                                      ix(index),
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   501
                                      (long)length << $LG_BYTES_PER_VALUE$);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   502
            } finally {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   503
                Reference.reachabilityFence(this);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   504
            }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   505
        } else {
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   506
            super.put(index, src, offset, length);
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   507
        }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   508
        return this;
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   509
#else[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   510
        throw new ReadOnlyBufferException();
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   511
#end[rw]
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   512
    }
7c362992527a 5029431: (bf) Add absolute bulk put and get methods
bpb
parents: 51318
diff changeset
   513
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public $Type$Buffer compact() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
#if[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        int pos = position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        int lim = limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        int rem = (pos <= lim ? lim - pos : 0);
49210
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   520
        try {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   521
            UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   522
        } finally {
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   523
            Reference.reachabilityFence(this);
7c795d301dbf 8199462: Use Reference.reachabilityFence in direct ByteBuffer methods
psandoz
parents: 48356
diff changeset
   524
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        position(rem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        limit(capacity());
1634
3871c2046043 6593946: (bf) X-Buffer.compact() does not discard mark as specified
alanb
parents: 1247
diff changeset
   527
        discardMark();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
#else[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        throw new ReadOnlyBufferException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
#end[rw]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    public boolean isDirect() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    public boolean isReadOnly() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        return {#if[rw]?false:true};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
#if[char]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    public String toString(int start, int end) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        if ((end > limit()) || (start > end))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            throw new IndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            int len = end - start;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            char[] ca = new char[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            CharBuffer cb = CharBuffer.wrap(ca);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            CharBuffer db = this.duplicate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            db.position(start);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            db.limit(end);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            cb.put(db);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            return new String(ca);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        } catch (StringIndexOutOfBoundsException x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            throw new IndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    // --- Methods to support CharSequence ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
1224
8c1bc7c5dd00 6733145: (bf) CharBuffer.subSequence can be updated to take advantage of covariant returns
martin
parents: 1151
diff changeset
   565
    public CharBuffer subSequence(int start, int end) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        int pos = position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        int lim = limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        assert (pos <= lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        pos = (pos <= lim ? pos : lim);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        int len = lim - pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        if ((start < 0) || (end > len) || (start > end))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            throw new IndexOutOfBoundsException();
2593
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   574
        return new DirectCharBuffer$RW$$BO$(this,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   575
                                            -1,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   576
                                            pos + start,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   577
                                            pos + end,
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   578
                                            capacity(),
76032557be03 6795561: (bf) CharBuffer.subSequence() uses wrong capacity value for new buffer
alanb
parents: 1634
diff changeset
   579
                                            offset);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
#end[char]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
#if[!byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public ByteOrder order() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
#if[boS]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
#end[boS]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
#if[boU]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
#end[boU]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
#end[!byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
48356
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   601
#if[char]
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   602
    ByteOrder charRegionOrder() {
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   603
        return order();
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   604
    }
29e165bdf669 8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents: 47216
diff changeset
   605
#end[char]
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    // #BIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    // Binary-data access methods  for short, char, int, long, float,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    // and double will be inserted here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
}