/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Access to bits, native and otherwise.
*/
private Bits() { }
// -- Swapping --
static short swap(short x) {
return Short.reverseBytes(x);
}
static char swap(char x) {
return Character.reverseBytes(x);
}
static int swap(int x) {
return Integer.reverseBytes(x);
}
static long swap(long x) {
return Long.reverseBytes(x);
}
}
}
static char getCharL(long a) {
_get(a ));
}
}
static char getCharB(long a) {
_get(a + 1));
}
}
}
private static byte char0(char x) { return (byte)(x ); }
}
static void putCharL(long a, char x) {
}
}
static void putCharB(long a, char x) {
}
if (bigEndian)
else
}
if (bigEndian)
putCharB(a, x);
else
putCharL(a, x);
}
}
}
static short getShortL(long a) {
_get(a ));
}
}
static short getShortB(long a) {
_get(a + 1));
}
}
}
private static byte short0(short x) { return (byte)(x ); }
}
static void putShortL(long a, short x) {
}
}
static void putShortB(long a, short x) {
}
if (bigEndian)
else
}
if (bigEndian)
putShortB(a, x);
else
putShortL(a, x);
}
return (((b3 ) << 24) |
((b0 & 0xff) ));
}
}
static int getIntL(long a) {
_get(a + 2),
_get(a + 1),
_get(a ));
}
}
static int getIntB(long a) {
_get(a + 1),
_get(a + 2),
_get(a + 3));
}
}
}
private static byte int0(int x) { return (byte)(x ); }
}
static void putIntL(long a, int x) {
}
}
static void putIntB(long a, int x) {
}
if (bigEndian)
else
}
if (bigEndian)
putIntB(a, x);
else
putIntL(a, x);
}
{
return ((((long)b7 ) << 56) |
(((long)b0 & 0xff) ));
}
}
static long getLongL(long a) {
_get(a + 6),
_get(a + 5),
_get(a + 4),
_get(a + 3),
_get(a + 2),
_get(a + 1),
_get(a ));
}
}
static long getLongB(long a) {
_get(a + 1),
_get(a + 2),
_get(a + 3),
_get(a + 4),
_get(a + 5),
_get(a + 6),
_get(a + 7));
}
}
}
private static byte long0(long x) { return (byte)(x ); }
}
static void putLongL(long a, long x) {
}
}
static void putLongB(long a, long x) {
}
if (bigEndian)
else
}
if (bigEndian)
putLongB(a, x);
else
putLongL(a, x);
}
}
static float getFloatL(long a) {
}
}
static float getFloatB(long a) {
}
}
}
}
static void putFloatL(long a, float x) {
}
}
static void putFloatB(long a, float x) {
}
if (bigEndian)
else
}
if (bigEndian)
putFloatB(a, x);
else
putFloatL(a, x);
}
}
static double getDoubleL(long a) {
}
}
static double getDoubleB(long a) {
}
}
}
}
static void putDoubleL(long a, double x) {
}
}
static void putDoubleB(long a, double x) {
}
if (bigEndian)
else
}
if (bigEndian)
putDoubleB(a, x);
else
putDoubleL(a, x);
}
// -- Unsafe access --
private static byte _get(long a) {
}
private static void _put(long a, byte b) {
}
return unsafe;
}
// -- Processor and memory-system properties --
throw new Error("Unknown byte order");
return byteOrder;
}
static {
try {
switch (b) {
default:
assert false;
}
} finally {
unsafe.freeMemory(a);
}
}
static int pageSize() {
if (pageSize == -1)
return pageSize;
}
}
private static boolean unaligned;
private static boolean unalignedKnown = false;
static boolean unaligned() {
if (unalignedKnown)
return unaligned;
unalignedKnown = true;
return unaligned;
}
// -- Direct memory management --
// A user-settable upper limit on the maximum amount of allocatable
// direct buffer memory. This value may be changed during VM
// initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
private static volatile long reservedMemory;
private static volatile long totalCapacity;
private static volatile long count;
private static boolean memoryLimitSet = false;
// These methods should be called whenever direct memory is allocated or
// freed. They allow the user to control the amount of direct memory
// which a process may access. All sizes are specified in bytes.
synchronized (Bits.class) {
memoryLimitSet = true;
}
// -XX:MaxDirectMemorySize limits the total capacity rather than the
// actual memory usage, which will differ when buffers are page
// aligned.
reservedMemory += size;
totalCapacity += cap;
count++;
return;
}
}
try {
} catch (InterruptedException x) {
// Restore interrupt status
}
synchronized (Bits.class) {
throw new OutOfMemoryError("Direct buffer memory");
reservedMemory += size;
totalCapacity += cap;
count++;
}
}
if (reservedMemory > 0) {
reservedMemory -= size;
totalCapacity -= cap;
count--;
assert (reservedMemory > -1);
}
}
// -- Monitoring of direct buffer usage --
static {
// setup access to this package in SharedSecrets
return "direct";
}
public long getCount() {
}
public long getTotalCapacity() {
return Bits.totalCapacity;
}
public long getMemoryUsed() {
return Bits.reservedMemory;
}
};
}
}
}
});
}
// These numbers represent the point at which we have empirically
// determined that the average cost of a JNI call exceeds the expense
// of an element by element copy. These numbers may change over time.
// This number limits the number of bytes to copy per call to Unsafe's
// copyMemory method. A limit is imposed to allow for safepoint polling
// during a large copy
// These methods do no bounds checking. Verification that the copy will not
// result in memory corruption should be done prior to invocation.
// All positions and lengths are specified in bytes.
/**
* Copy from given source array to destination address.
*
* @param src
* source array
* @param srcBaseOffset
* offset of first element of storage in source array
* @param srcPos
* offset within source array of the first element to read
* @param dstAddr
* destination address
* @param length
* number of bytes to copy
*/
{
while (length > 0) {
}
}
/**
* Copy from source address into given destination array.
*
* @param srcAddr
* source address
* @param dst
* destination array
* @param dstBaseOffset
* offset of first element of storage in destination array
* @param dstPos
* offset within destination array of the first element to write
* @param length
* number of bytes to copy
*/
long length)
{
while (length > 0) {
}
}
long length)
{
}
long length)
{
}
long length);
long length);
long length);
long length);
long length);
long length);
}