src/java.base/share/classes/sun/misc/Unsafe.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/java.base/share/classes/sun/misc/Unsafe.java	Mon Jun 29 11:11:57 2015
--- new/src/java.base/share/classes/sun/misc/Unsafe.java	Mon Jun 29 11:11:57 2015

*** 29,38 **** --- 29,40 ---- import java.security.ProtectionDomain; import sun.reflect.CallerSensitive; import sun.reflect.Reflection; + import jdk.internal.HotSpotIntrinsicCandidate; + /** * A collection of methods for performing low-level, unsafe operations. * Although the class and all methods are public, use of this class is * limited because only trusted code can obtain instances of it.
*** 146,155 **** --- 148,158 ---- * statically * @return the value fetched from the indicated Java variable * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} */ + @HotSpotIntrinsicCandidate public native int getInt(Object o, long offset); /** * Stores a value into a given Java variable. * <p>
*** 168,183 **** --- 171,188 ---- * statically * @param x the value to store into the indicated Java variable * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} */ + @HotSpotIntrinsicCandidate public native void putInt(Object o, long offset, int x); /** * Fetches a reference value from a given Java variable. * @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native Object getObject(Object o, long offset); /** * Stores a reference value into a given Java variable. * <p>
*** 186,224 **** --- 191,244 ---- * If the reference {@code o} is non-null, card marks or * other store barriers for that object (if the VM requires them) * are updated. * @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putObject(Object o, long offset, Object x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native boolean getBoolean(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putBoolean(Object o, long offset, boolean x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native byte getByte(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putByte(Object o, long offset, byte x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native short getShort(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putShort(Object o, long offset, short x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native char getChar(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putChar(Object o, long offset, char x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native long getLong(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putLong(Object o, long offset, long x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native float getFloat(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putFloat(Object o, long offset, float x); /** @see #getInt(Object, long) */ + @HotSpotIntrinsicCandidate public native double getDouble(Object o, long offset); /** @see #putInt(Object, long, int) */ + @HotSpotIntrinsicCandidate public native void putDouble(Object o, long offset, double x); // These read VM internal data. /**
*** 255,298 **** --- 275,332 ---- * does not point into a block obtained from {@link #allocateMemory}, the * results are undefined. * * @see #allocateMemory */ + @HotSpotIntrinsicCandidate public native byte getByte(long address); /** * Stores a value into a given memory address. If the address is zero, or * does not point into a block obtained from {@link #allocateMemory}, the * results are undefined. * * @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native void putByte(long address, byte x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native short getShort(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putShort(long address, short x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native char getChar(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putChar(long address, char x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native int getInt(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putInt(long address, int x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native long getLong(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putLong(long address, long x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native float getFloat(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putFloat(long address, float x); /** @see #getByte(long) */ + @HotSpotIntrinsicCandidate public native double getDouble(long address); /** @see #putByte(long, byte) */ + @HotSpotIntrinsicCandidate public native void putDouble(long address, double x); /** * Fetches a native pointer from a given memory address. If the address is * zero, or does not point into a block obtained from {@link
*** 305,314 **** --- 339,349 ---- * from the target address may be determined by consulting {@link * #addressSize}. * * @see #allocateMemory */ + @HotSpotIntrinsicCandidate public native long getAddress(long address); /** * Stores a native pointer into a given memory address. If the address is * zero, or does not point into a block obtained from {@link
*** 317,326 **** --- 352,362 ---- * <p>The number of bytes actually written at the target address may be * determined by consulting {@link #addressSize}. * * @see #getAddress(long) */ + @HotSpotIntrinsicCandidate public native void putAddress(long address, long x); /// wrappers for malloc, realloc, free: /**
*** 404,413 **** --- 440,450 ---- * If the effective addresses and length are (resp.) even modulo 4 or 2, * the transfer takes place in units of 'int' or 'short'. * * @since 1.7 */ + @HotSpotIntrinsicCandidate public native void copyMemory(Object srcBase, long srcOffset, Object destBase, long destOffset, long bytes); /** * Sets all bytes in a given block of memory to a copy of another
*** 649,658 **** --- 686,696 ---- /** * Allocates an instance but does not run any constructor. * Initializes the class if it has not yet been. */ + @HotSpotIntrinsicCandidate public native Object allocateInstance(Class<?> cls) throws InstantiationException; /** Throws the exception without telling the verifier. */ public native void throwException(Throwable ee);
*** 664,673 **** --- 702,712 ---- * <p>This operation has memory semantics of a {@code volatile} read * and write. Corresponds to C11 atomic_compare_exchange_strong. * * @return {@code true} if successful */ + @HotSpotIntrinsicCandidate public final native boolean compareAndSwapObject(Object o, long offset, Object expected, Object x); /**
*** 677,686 **** --- 716,726 ---- * <p>This operation has memory semantics of a {@code volatile} read * and write. Corresponds to C11 atomic_compare_exchange_strong. * * @return {@code true} if successful */ + @HotSpotIntrinsicCandidate public final native boolean compareAndSwapInt(Object o, long offset, int expected, int x); /**
*** 690,761 **** --- 730,820 ---- * <p>This operation has memory semantics of a {@code volatile} read * and write. Corresponds to C11 atomic_compare_exchange_strong. * * @return {@code true} if successful */ + @HotSpotIntrinsicCandidate public final native boolean compareAndSwapLong(Object o, long offset, long expected, long x); /** * Fetches a reference value from a given Java variable, with volatile * load semantics. Otherwise identical to {@link #getObject(Object, long)} */ + @HotSpotIntrinsicCandidate public native Object getObjectVolatile(Object o, long offset); /** * Stores a reference value into a given Java variable, with * volatile store semantics. Otherwise identical to {@link #putObject(Object, long, Object)} */ + @HotSpotIntrinsicCandidate public native void putObjectVolatile(Object o, long offset, Object x); /** Volatile version of {@link #getInt(Object, long)} */ + @HotSpotIntrinsicCandidate public native int getIntVolatile(Object o, long offset); /** Volatile version of {@link #putInt(Object, long, int)} */ + @HotSpotIntrinsicCandidate public native void putIntVolatile(Object o, long offset, int x); /** Volatile version of {@link #getBoolean(Object, long)} */ + @HotSpotIntrinsicCandidate public native boolean getBooleanVolatile(Object o, long offset); /** Volatile version of {@link #putBoolean(Object, long, boolean)} */ + @HotSpotIntrinsicCandidate public native void putBooleanVolatile(Object o, long offset, boolean x); /** Volatile version of {@link #getByte(Object, long)} */ + @HotSpotIntrinsicCandidate public native byte getByteVolatile(Object o, long offset); /** Volatile version of {@link #putByte(Object, long, byte)} */ + @HotSpotIntrinsicCandidate public native void putByteVolatile(Object o, long offset, byte x); /** Volatile version of {@link #getShort(Object, long)} */ + @HotSpotIntrinsicCandidate public native short getShortVolatile(Object o, long offset); /** Volatile version of {@link #putShort(Object, long, short)} */ + @HotSpotIntrinsicCandidate public native void putShortVolatile(Object o, long offset, short x); /** Volatile version of {@link #getChar(Object, long)} */ + @HotSpotIntrinsicCandidate public native char getCharVolatile(Object o, long offset); /** Volatile version of {@link #putChar(Object, long, char)} */ + @HotSpotIntrinsicCandidate public native void putCharVolatile(Object o, long offset, char x); /** Volatile version of {@link #getLong(Object, long)} */ + @HotSpotIntrinsicCandidate public native long getLongVolatile(Object o, long offset); /** Volatile version of {@link #putLong(Object, long, long)} */ + @HotSpotIntrinsicCandidate public native void putLongVolatile(Object o, long offset, long x); /** Volatile version of {@link #getFloat(Object, long)} */ + @HotSpotIntrinsicCandidate public native float getFloatVolatile(Object o, long offset); /** Volatile version of {@link #putFloat(Object, long, float)} */ + @HotSpotIntrinsicCandidate public native void putFloatVolatile(Object o, long offset, float x); /** Volatile version of {@link #getDouble(Object, long)} */ + @HotSpotIntrinsicCandidate public native double getDoubleVolatile(Object o, long offset); /** Volatile version of {@link #putDouble(Object, long, double)} */ + @HotSpotIntrinsicCandidate public native void putDoubleVolatile(Object o, long offset, double x); /** * Version of {@link #putObjectVolatile(Object, long, Object)} * that does not guarantee immediate visibility of the store to
*** 763,778 **** --- 822,840 ---- * underlying field is a Java volatile (or if an array cell, one * that is otherwise only accessed using volatile accesses). * * Corresponds to C11 atomic_store_explicit(..., memory_order_release). */ + @HotSpotIntrinsicCandidate public native void putOrderedObject(Object o, long offset, Object x); /** Ordered/Lazy version of {@link #putIntVolatile(Object, long, int)} */ + @HotSpotIntrinsicCandidate public native void putOrderedInt(Object o, long offset, int x); /** Ordered/Lazy version of {@link #putLongVolatile(Object, long, long)} */ + @HotSpotIntrinsicCandidate public native void putOrderedLong(Object o, long offset, long x); /** * Unblocks the given thread blocked on {@code park}, or, if it is * not blocked, causes the subsequent call to {@code park} not to
*** 783,792 **** --- 845,855 ---- * reference to the thread) but this is not nearly-automatically * so when calling from native code. * * @param thread the thread to unpark. */ + @HotSpotIntrinsicCandidate public native void unpark(Object thread); /** * Blocks current thread, returning when a balancing * {@code unpark} occurs, or a balancing {@code unpark} has
*** 796,805 **** --- 859,869 ---- * since Epoch has passed, or spuriously (i.e., returning for no * "reason"). Note: This operation is in the Unsafe class only * because {@code unpark} is, so it would be strange to place it * elsewhere. */ + @HotSpotIntrinsicCandidate public native void park(boolean isAbsolute, long time); /** * Gets the load average in the system run queue assigned * to the available processors averaged over various periods of time.
*** 829,838 **** --- 893,903 ---- * @param offset field/element offset * @param delta the value to add * @return the previous value * @since 1.8 */ + @HotSpotIntrinsicCandidate public final int getAndAddInt(Object o, long offset, int delta) { int v; do { v = getIntVolatile(o, offset); } while (!compareAndSwapInt(o, offset, v, v + delta));
*** 848,857 **** --- 913,923 ---- * @param offset field/element offset * @param delta the value to add * @return the previous value * @since 1.8 */ + @HotSpotIntrinsicCandidate public final long getAndAddLong(Object o, long offset, long delta) { long v; do { v = getLongVolatile(o, offset); } while (!compareAndSwapLong(o, offset, v, v + delta));
*** 867,876 **** --- 933,943 ---- * @param offset field/element offset * @param newValue new value * @return the previous value * @since 1.8 */ + @HotSpotIntrinsicCandidate public final int getAndSetInt(Object o, long offset, int newValue) { int v; do { v = getIntVolatile(o, offset); } while (!compareAndSwapInt(o, offset, v, newValue));
*** 886,895 **** --- 953,963 ---- * @param offset field/element offset * @param newValue new value * @return the previous value * @since 1.8 */ + @HotSpotIntrinsicCandidate public final long getAndSetLong(Object o, long offset, long newValue) { long v; do { v = getLongVolatile(o, offset); } while (!compareAndSwapLong(o, offset, v, newValue));
*** 905,914 **** --- 973,983 ---- * @param offset field/element offset * @param newValue new value * @return the previous value * @since 1.8 */ + @HotSpotIntrinsicCandidate public final Object getAndSetObject(Object o, long offset, Object newValue) { Object v; do { v = getObjectVolatile(o, offset); } while (!compareAndSwapObject(o, offset, v, newValue));
*** 926,935 **** --- 995,1005 ---- * A pure LoadLoad fence is not provided, since the addition of LoadStore * is almost always desired, and most current hardware instructions that * provide a LoadLoad barrier also provide a LoadStore barrier for free. * @since 1.8 */ + @HotSpotIntrinsicCandidate public native void loadFence(); /** * Ensures that loads and stores before the fence will not be reordered with * stores after the fence; a "StoreStore plus LoadStore barrier".
*** 940,949 **** --- 1010,1020 ---- * A pure StoreStore fence is not provided, since the addition of LoadStore * is almost always desired, and most current hardware instructions that * provide a StoreStore barrier also provide a LoadStore barrier for free. * @since 1.8 */ + @HotSpotIntrinsicCandidate public native void storeFence(); /** * Ensures that loads and stores before the fence will not be reordered * with loads and stores after the fence. Implies the effects of both
*** 951,960 **** --- 1022,1032 ---- * barrier. * * Corresponds to C11 atomic_thread_fence(memory_order_seq_cst). * @since 1.8 */ + @HotSpotIntrinsicCandidate public native void fullFence(); /** * Throws IllegalAccessError; for use by the VM for access control * error support.
*** 1008,1017 **** --- 1080,1090 ---- * @return the value fetched from the indicated object * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} * @since 1.9 */ + @HotSpotIntrinsicCandidate public final long getLongUnaligned(Object o, long offset) { if ((offset & 7) == 0) { return getLong(o, offset); } else if ((offset & 3) == 0) { return makeLong(getInt(o, offset),
*** 1046,1055 **** --- 1119,1129 ---- public final long getLongUnaligned(Object o, long offset, boolean bigEndian) { return convEndian(bigEndian, getLongUnaligned(o, offset)); } /** @see #getLongUnaligned(Object, long) */ + @HotSpotIntrinsicCandidate public final int getIntUnaligned(Object o, long offset) { if ((offset & 3) == 0) { return getInt(o, offset); } else if ((offset & 1) == 0) { return makeInt(getShort(o, offset),
*** 1065,1074 **** --- 1139,1149 ---- public final int getIntUnaligned(Object o, long offset, boolean bigEndian) { return convEndian(bigEndian, getIntUnaligned(o, offset)); } /** @see #getLongUnaligned(Object, long) */ + @HotSpotIntrinsicCandidate public final short getShortUnaligned(Object o, long offset) { if ((offset & 1) == 0) { return getShort(o, offset); } else { return makeShort(getByte(o, offset),
*** 1079,1091 **** --- 1154,1168 ---- public final short getShortUnaligned(Object o, long offset, boolean bigEndian) { return convEndian(bigEndian, getShortUnaligned(o, offset)); } /** @see #getLongUnaligned(Object, long) */ + @HotSpotIntrinsicCandidate public final char getCharUnaligned(Object o, long offset) { return (char)getShortUnaligned(o, offset); } + /** @see #getLongUnaligned(Object, long, boolean) */ public final char getCharUnaligned(Object o, long offset, boolean bigEndian) { return convEndian(bigEndian, getCharUnaligned(o, offset)); }
*** 1115,1124 **** --- 1192,1202 ---- * @param x the value to store * @throws RuntimeException No defined exceptions are thrown, not even * {@link NullPointerException} * @since 1.9 */ + @HotSpotIntrinsicCandidate public final void putLongUnaligned(Object o, long offset, long x) { if ((offset & 7) == 0) { putLong(o, offset, x); } else if ((offset & 3) == 0) { putLongParts(o, offset,
*** 1140,1149 **** --- 1218,1228 ---- (byte)(x >>> 40), (byte)(x >>> 48), (byte)(x >>> 56)); } } + /** * As {@link #putLongUnaligned(Object, long, long)} but with an additional * argument which specifies the endianness of the value as stored in memory. * @param o Java heap object in which the value resides * @param offset The offset in bytes from the start of the object
*** 1156,1165 **** --- 1235,1245 ---- public final void putLongUnaligned(Object o, long offset, long x, boolean bigEndian) { putLongUnaligned(o, offset, convEndian(bigEndian, x)); } /** @see #putLongUnaligned(Object, long, long) */ + @HotSpotIntrinsicCandidate public final void putIntUnaligned(Object o, long offset, int x) { if ((offset & 3) == 0) { putInt(o, offset, x); } else if ((offset & 1) == 0) { putIntParts(o, offset,
*** 1177,1186 **** --- 1257,1267 ---- public final void putIntUnaligned(Object o, long offset, int x, boolean bigEndian) { putIntUnaligned(o, offset, convEndian(bigEndian, x)); } /** @see #putLongUnaligned(Object, long, long) */ + @HotSpotIntrinsicCandidate public final void putShortUnaligned(Object o, long offset, short x) { if ((offset & 1) == 0) { putShort(o, offset, x); } else { putShortParts(o, offset,
*** 1192,1201 **** --- 1273,1283 ---- public final void putShortUnaligned(Object o, long offset, short x, boolean bigEndian) { putShortUnaligned(o, offset, convEndian(bigEndian, x)); } /** @see #putLongUnaligned(Object, long, long) */ + @HotSpotIntrinsicCandidate public final void putCharUnaligned(Object o, long offset, char x) { putShortUnaligned(o, offset, (short)x); } /** @see #putLongUnaligned(Object, long, long, boolean) */ public final void putCharUnaligned(Object o, long offset, char x, boolean bigEndian) {

src/java.base/share/classes/sun/misc/Unsafe.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File