--- old/src/java.base/share/classes/jdk/internal/misc/Unsafe.java 2018-12-07 12:57:57.000000000 -0800 +++ new/src/java.base/share/classes/jdk/internal/misc/Unsafe.java 2018-12-07 12:57:56.000000000 -0800 @@ -181,6 +181,15 @@ return c.isValue() && c == c.asValueType(); } + private static final int JVM_ACC_FLATTENED = 0x00008000; // HotSpot-specific bit + + /** + * Returns true if the given field is flattened. + */ + public boolean isFlattened(Field f) { + return (f.getModifiers() & JVM_ACC_FLATTENED) == JVM_ACC_FLATTENED; + } + /** * Returns true if the given class is a flattened array. */ @@ -250,6 +259,88 @@ */ public native void putValue(Object o, long offset, Class vc, V v); + /** + * Starts a private buffer + */ + public native V startPrivateBuffer(V value); + + public native V finishPrivateBuffer(V value); + + /** + * Updates an int field of a value instance of type {@code V} + * addressed by the given {@code o} object at the given offset + * with {@code x} and returns the new value. + * + * Unless the reference {@code o} being stored is either null + * or matches the field type, the results are undefined. + * + * @param vc Value class V + * @param o Java heap object in which the variable resides, if any, else + * null + * @param offset indication of where the variable resides in a Java heap + * object, if any, else a memory address locating the variable + * statically + * @param x the value to store into the indicated Java variable + * @param Value class + * @return an instance of the given value class + */ + public native V withInt(Class vc, Object o, long offset, int x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withBoolean(Class vc, Object o, long offset, boolean x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withByte(Class vc, Object o, long offset, byte x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withShort(Class vc, Object o, long offset, short x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withChar(Class vc, Object o, long offset, char x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withLong(Class vc, Object o, long offset, long x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withFloat(Class vc, Object o, long offset, float x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withDouble(Class vc, Object o, long offset, double x); + + /** @see #withInt(Class, Object, long, int) */ + public native V withReference(Class vc, Object o, long offset, Object x); + + /** + * Updates a field of a value instance of type {@code V} addressed by + * the given {@code o} object at the given offset with {@code x} + * and returns the new value. + * + * Unless the reference {@code o} being stored is either null + * or matches the field type, the results are undefined. + * + * @param vc Value class V + * @param o Java heap object in which the variable resides, if any, else null + * @param vc_offset indication of where the variable resides in a Java heap + * object, if any, else a memory address locating the variable + * statically + * @param xc_offset offset from the field addressed by o and vc_offset + * @param xc The type of the field to be updated + * @param x the value to store into the indicated Java variable + * @param the containing class + * @param the field type + * @return an instance of the given containing class + */ + public native V withValue(Class vc, Object o, long vc_offset, long xc_offset, Class xc, X x); + + /** + * Returns the header size of the given value class + * + * @param vc Value class + * @param value clas + * @return the header size of the value class + */ + public native long valueHeaderSize(Class vc); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native boolean getBoolean(Object o, long offset);