| | |
| | | import java.security.AccessController; |
| | | import java.security.PrivilegedAction; |
| | | |
| | | import sun.misc.Unsafe; |
| | | import sun.misc.VM; |
| | | |
| | | /** |
| | |
| | | |
| | | // -- Processor and memory-system properties -- |
| | | private static ByteOrder byteOrder = null; |
| | | private static int pageSize = -1; |
| | | private static boolean unaligned; |
| | | private static boolean unalignedKnown = false; |
| | | private static int pageSize = -1; |
| | | private static boolean unaligned; |
| | | private static boolean unalignedKnown = false; |
| | | |
| | | // -- Direct memory management -- |
| | | // A user-settable upper limit on the maximum amount of allocatable |
| | | // direct buffer memory. This value may be changed during VM |
| | | // direct buffer memory. This value may be changed during VM |
| | | // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>". |
| | | private static volatile long maxMemory = VM.maxDirectMemory(); |
| | | private static volatile long maxMemory = VM.maxDirectMemory(); |
| | | private static volatile long reservedMemory = 0; |
| | | private static boolean memoryLimitSet = false; |
| | | private static boolean memoryLimitSet = false; |
| | | |
| | | private Bits() |
| | | { |
| | |
| | | |
| | | public static int getHiInt(long qwValue) |
| | | { |
| | | return ((int)(qwValue >>> 32)); |
| | | return ((int) (qwValue >>> 32)); |
| | | } |
| | | |
| | | public static int getLoInt(long qwValue) |
| | | { |
| | | return ((int) (qwValue & 0xFFFFFFFF)); |
| | | } |
| | | |
| | | |
| | | private static byte long7(long x) |
| | | { |
| | | return (byte) (x >> 56); |
| | |
| | | return byteOrder; |
| | | } |
| | | */ |
| | | |
| | | static boolean unaligned() |
| | | { |
| | | if (unalignedKnown) |
| | |
| | | return unaligned; |
| | | } |
| | | |
| | | PrivilegedAction pa = new sun.security.action.GetPropertyAction("os.arch"); |
| | | String arch = (String) AccessController.doPrivileged(pa); |
| | | PrivilegedAction pa = new sun.security.action.GetPropertyAction("os.arch"); |
| | | String arch = (String) AccessController.doPrivileged(pa); |
| | | |
| | | unaligned = arch.equals("i386") || arch.equals("x86"); |
| | | unaligned = arch.equals("i386") || arch.equals("x86"); |
| | | unalignedKnown = true; |
| | | |
| | | return unaligned; |
| | |
| | | { |
| | | if (!memoryLimitSet && VM.isBooted()) |
| | | { |
| | | maxMemory = VM.maxDirectMemory(); |
| | | maxMemory = VM.maxDirectMemory(); |
| | | memoryLimitSet = true; |
| | | } |
| | | |
| | |
| | | if (reservedMemory > 0) |
| | | { |
| | | reservedMemory -= size; |
| | | assert(reservedMemory > -1); |
| | | assert (reservedMemory > -1); |
| | | } |
| | | } |
| | | } |