author | psandoz |
Wed, 20 Dec 2017 09:14:52 -0800 | |
changeset 48356 | 29e165bdf669 |
parent 47216 | 71c04702a3d5 |
child 49210 | 7c795d301dbf |
permissions | -rw-r--r-- |
2 | 1 |
/* |
40180
e53a90882a23
8151163: All Buffer implementations should leverage Unsafe unaligned accessors
psandoz
parents:
25859
diff
changeset
|
2 |
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#warn This file is preprocessed before being compiled |
|
27 |
||
28 |
class XXX { |
|
29 |
||
30 |
#begin |
|
31 |
||
32 |
#if[rw] |
|
33 |
||
34 |
private $type$ get$Type$(long a) { |
|
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
35 |
$memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian); |
40180
e53a90882a23
8151163: All Buffer implementations should leverage Unsafe unaligned accessors
psandoz
parents:
25859
diff
changeset
|
36 |
return $fromBits$(x); |
2 | 37 |
} |
38 |
||
39 |
public $type$ get$Type$() { |
|
40 |
return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$))); |
|
41 |
} |
|
42 |
||
43 |
public $type$ get$Type$(int i) { |
|
44 |
return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$))); |
|
45 |
} |
|
46 |
||
47 |
#end[rw] |
|
48 |
||
49 |
private ByteBuffer put$Type$(long a, $type$ x) { |
|
50 |
#if[rw] |
|
40180
e53a90882a23
8151163: All Buffer implementations should leverage Unsafe unaligned accessors
psandoz
parents:
25859
diff
changeset
|
51 |
$memtype$ y = $toBits$(x); |
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
52 |
UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian); |
2 | 53 |
return this; |
54 |
#else[rw] |
|
55 |
throw new ReadOnlyBufferException(); |
|
56 |
#end[rw] |
|
57 |
} |
|
58 |
||
59 |
public ByteBuffer put$Type$($type$ x) { |
|
60 |
#if[rw] |
|
61 |
put$Type$(ix(nextPutIndex($BYTES_PER_VALUE$)), x); |
|
62 |
return this; |
|
63 |
#else[rw] |
|
64 |
throw new ReadOnlyBufferException(); |
|
65 |
#end[rw] |
|
66 |
} |
|
67 |
||
68 |
public ByteBuffer put$Type$(int i, $type$ x) { |
|
69 |
#if[rw] |
|
70 |
put$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)), x); |
|
71 |
return this; |
|
72 |
#else[rw] |
|
73 |
throw new ReadOnlyBufferException(); |
|
74 |
#end[rw] |
|
75 |
} |
|
76 |
||
77 |
public $Type$Buffer as$Type$Buffer() { |
|
78 |
int off = this.position(); |
|
79 |
int lim = this.limit(); |
|
80 |
assert (off <= lim); |
|
81 |
int rem = (off <= lim ? lim - off : 0); |
|
82 |
||
83 |
int size = rem >> $LG_BYTES_PER_VALUE$; |
|
48356
29e165bdf669
8193085: Vectorize the nio Buffer equals and compareTo implementations
psandoz
parents:
47216
diff
changeset
|
84 |
if (!UNALIGNED && ((address + off) % $BYTES_PER_VALUE$ != 0)) { |
2 | 85 |
return (bigEndian |
86 |
? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this, |
|
87 |
-1, |
|
88 |
0, |
|
89 |
size, |
|
90 |
size, |
|
40195
a13e4945de1d
8162458: Buffer view implementations use incorrect offset for Unsafe access
psandoz
parents:
40180
diff
changeset
|
91 |
address + off)) |
2 | 92 |
: ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$L(this, |
93 |
-1, |
|
94 |
0, |
|
95 |
size, |
|
96 |
size, |
|
40195
a13e4945de1d
8162458: Buffer view implementations use incorrect offset for Unsafe access
psandoz
parents:
40180
diff
changeset
|
97 |
address + off))); |
2 | 98 |
} else { |
99 |
return (nativeByteOrder |
|
100 |
? ($Type$Buffer)(new Direct$Type$Buffer$RW$U(this, |
|
101 |
-1, |
|
102 |
0, |
|
103 |
size, |
|
104 |
size, |
|
105 |
off)) |
|
106 |
: ($Type$Buffer)(new Direct$Type$Buffer$RW$S(this, |
|
107 |
-1, |
|
108 |
0, |
|
109 |
size, |
|
110 |
size, |
|
111 |
off))); |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
#end |
|
116 |
||
117 |
} |