Path: blob/master/jcl/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
12558 views
/*[INCLUDE-IF Sidecar19-SE]*/1/*******************************************************************************2* Copyright (c) 2017, 2022 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/22package jdk.internal.misc;2324import com.ibm.oti.vm.VM;25import com.ibm.oti.vm.VMLangAccess;2627import java.lang.reflect.Field;28import java.security.ProtectionDomain;29import java.util.Objects;30/*[IF JAVA_SPEC_VERSION >= 12]*/31import java.nio.ByteBuffer;32import sun.nio.ch.DirectBuffer;33import jdk.internal.ref.Cleaner;34/*[ENDIF] JAVA_SPEC_VERSION >= 12 */3536public final class Unsafe {3738/* Prevents this class from being instantiated. */39private Unsafe() {}4041/* unsafe instance */42private static final Unsafe theUnsafe;4344/**45* Represents an invalid field offset value.46*/47public static final int INVALID_FIELD_OFFSET;4849/**50* Starting offset of byte array.51*/52public static final int ARRAY_BYTE_BASE_OFFSET;5354/**55* Starting offset of int array.56*/57public static final int ARRAY_INT_BASE_OFFSET;5859/**60* Starting offset of long array.61*/62public static final int ARRAY_LONG_BASE_OFFSET;6364/**65* Starting offset of float array.66*/67public static final int ARRAY_FLOAT_BASE_OFFSET;6869/**70* Starting offset of double array.71*/72public static final int ARRAY_DOUBLE_BASE_OFFSET;7374/**75* Starting offset of short array.76*/77public static final int ARRAY_SHORT_BASE_OFFSET;7879/**80* Starting offset of char array.81*/82public static final int ARRAY_CHAR_BASE_OFFSET;8384/**85* Starting offset of boolean array.86*/87public static final int ARRAY_BOOLEAN_BASE_OFFSET;8889/**90* Starting offset of Object array.91*/92public static final int ARRAY_OBJECT_BASE_OFFSET;9394/**95* Index size of byte array in bytes.96*/97public static final int ARRAY_BYTE_INDEX_SCALE;9899/**100* Index size of int array in bytes.101*/102public static final int ARRAY_INT_INDEX_SCALE;103104/**105* Index size of long array in bytes.106*/107public static final int ARRAY_LONG_INDEX_SCALE;108109/**110* Index size of float array in bytes.111*/112public static final int ARRAY_FLOAT_INDEX_SCALE;113114/**115* Index size of double array in bytes.116*/117public static final int ARRAY_DOUBLE_INDEX_SCALE;118119/**120* Index size of short array in bytes.121*/122public static final int ARRAY_SHORT_INDEX_SCALE;123124/**125* Index size of char array in bytes.126*/127public static final int ARRAY_CHAR_INDEX_SCALE;128129/**130* Index size of boolean array in bytes.131*/132public static final int ARRAY_BOOLEAN_INDEX_SCALE;133134/**135* Index size of Object array in bytes.136*/137public static final int ARRAY_OBJECT_INDEX_SCALE;138139/**140* Size of address on machine in use.141*/142public static final int ADDRESS_SIZE;143144/*145* internal helpers146*/147/* true if machine is big endian, false otherwise. */148private static final boolean IS_BIG_ENDIAN;149/* true if addresses are aligned in memory, false otherwise. */150private static final boolean UNALIGNED_ACCESS;151152/* Size of int in bytes. */153private static final int BYTES_IN_INT = 4;154/* Number of bits in a short. */155private static final int BITS_IN_SHORT = 16;156/* Number of bits in a byte. */157private static final int BITS_IN_BYTE = 8;158159/* 8 bit mask (long) */160private static final long BYTE_MASK = 0xFFL;161/* 32 bit mask (long) */162private static final long INT_MASK = 0xFFFFFFFFL;163/* 16 bit mask (long) */164private static final long SHORT_MASK = 0xFFFFL;165/* 8 bit mask (int) */166private static final int BYTE_MASK_INT = (int) BYTE_MASK;167/* 16 bit mask (int) */168private static final int SHORT_MASK_INT = (int) SHORT_MASK;169170/* Mask aligns offset to be int addressable (all but bottom two bits). */171private static final int INT_OFFSET_ALIGN_MASK = 0xFFFFFFFC;172173/*174* For int shift instructions (ishr, iushr, ishl), only the low 5 bits of the175* shift amount are considered.176*/177private static final int BC_SHIFT_INT_MASK = 0b11111;178179/*180* For long shift instructions (lshr, lushr, lshl) only the low 6 bits of the181* shift amount are considered.182*/183private static final int BC_SHIFT_LONG_MASK = 0b111111;184185/* Mask byte offset of an int. */186private static final long BYTE_OFFSET_MASK = 0b11L;187188static {189registerNatives();190191theUnsafe = new Unsafe();192193INVALID_FIELD_OFFSET = -1;194195/* All OpenJ9 array types have the same array base offset. To limit196* JNI calls arrayBaseOffset is only called once in this block and the197* value used for each array base offset variable.198*/199ARRAY_BYTE_BASE_OFFSET = theUnsafe.arrayBaseOffset(byte[].class);200ARRAY_INT_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;201ARRAY_LONG_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;202ARRAY_FLOAT_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;203ARRAY_DOUBLE_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;204ARRAY_SHORT_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;205ARRAY_CHAR_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;206ARRAY_BOOLEAN_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;207ARRAY_OBJECT_BASE_OFFSET = ARRAY_BYTE_BASE_OFFSET;208209ARRAY_BYTE_INDEX_SCALE = theUnsafe.arrayIndexScale(byte[].class);210ARRAY_INT_INDEX_SCALE = theUnsafe.arrayIndexScale(int[].class);211ARRAY_LONG_INDEX_SCALE = theUnsafe.arrayIndexScale(long[].class);212ARRAY_FLOAT_INDEX_SCALE = theUnsafe.arrayIndexScale(float[].class);213ARRAY_DOUBLE_INDEX_SCALE = theUnsafe.arrayIndexScale(double[].class);214ARRAY_SHORT_INDEX_SCALE = theUnsafe.arrayIndexScale(short[].class);215ARRAY_CHAR_INDEX_SCALE = theUnsafe.arrayIndexScale(char[].class);216ARRAY_BOOLEAN_INDEX_SCALE = theUnsafe.arrayIndexScale(boolean[].class);217ARRAY_OBJECT_INDEX_SCALE = theUnsafe.arrayIndexScale(Object[].class);218219ADDRESS_SIZE = VM.ADDRESS_SIZE;220IS_BIG_ENDIAN = VM.IS_BIG_ENDIAN;221222/* Unaligned access is currently supported on all platforms */223UNALIGNED_ACCESS = true;224}225226/* Attach jdk.internal.misc.Unsafe natives. */227private static native void registerNatives();228229/**230* Gets the value of the byte in the obj parameter referenced by offset.231* This is a non-volatile operation.232*233* @param obj object from which to retrieve the value234* @param offset position of the value in obj235* @return byte value stored in obj236*/237public native byte getByte(Object obj, long offset);238239/**240* Sets the value of the byte in the obj parameter at memory offset.241* This is a non-volatile operation.242*243* @param obj object into which to store the value244* @param offset position of the value in obj245* @param value byte to store in obj246*/247public native void putByte(Object obj, long offset, byte value);248249/**250* Gets the value of the int in the obj parameter referenced by offset.251* This is a non-volatile operation.252*253* @param obj object from which to retrieve the value254* @param offset position of the value in obj255* @return int value stored in obj256*/257public native int getInt(Object obj, long offset);258259/**260* Sets the value of the int in the obj parameter at memory offset.261* This is a non-volatile operation.262*263* @param obj object into which to store the value264* @param offset position of the value in obj265* @param value int to store in obj266*/267public native void putInt(Object obj, long offset, int value);268269/**270* Gets the value of the long in the obj parameter referenced by offset.271* This is a non-volatile operation.272*273* @param obj object from which to retrieve the value274* @param offset position of the value in obj275* @return long value stored in obj276*/277public native long getLong(Object obj, long offset);278279/**280* Sets the value of the long in the obj parameter at memory offset.281* This is a non-volatile operation.282*283* @param obj object into which to store the value284* @param offset position of the value in obj285* @param value long to store in obj286*/287public native void putLong(Object obj, long offset, long value);288289/**290* Gets the value of the float in the obj parameter referenced by offset.291* This is a non-volatile operation.292*293* @param obj object from which to retrieve the value294* @param offset position of the value in obj295* @return float value stored in obj296*/297public native float getFloat(Object obj, long offset);298299/**300* Sets the value of the float in the obj parameter at memory offset.301* This is a non-volatile operation.302*303* @param obj object into which to store the value304* @param offset position of the value in obj305* @param value float to store in obj306*/307public native void putFloat(Object obj, long offset, float value);308309/**310* Gets the value of the double in the obj parameter referenced by offset.311* This is a non-volatile operation.312*313* @param obj object from which to retrieve the value314* @param offset position of the value in obj315* @return double value stored in obj316*/317public native double getDouble(Object obj, long offset);318319/**320* Sets the value of the double in the obj parameter at memory offset.321* This is a non-volatile operation.322*323* @param obj object into which to store the value324* @param offset position of the value in obj325* @param value double to store in obj326*/327public native void putDouble(Object obj, long offset, double value);328329/**330* Gets the value of the short in the obj parameter referenced by offset.331* This is a non-volatile operation.332*333* @param obj object from which to retrieve the value334* @param offset position of the value in obj335* @return short value stored in obj336*/337public native short getShort(Object obj, long offset);338339/**340* Sets the value of the short in the obj parameter at memory offset.341* This is a non-volatile operation.342*343* @param obj object into which to store the value344* @param offset position of the value in obj345* @param value short to store in obj346*/347public native void putShort(Object obj, long offset, short value);348349/**350* Gets the value of the char in the obj parameter referenced by offset.351* This is a non-volatile operation.352*353* @param obj object from which to retrieve the value354* @param offset position of the value in obj355* @return char value stored in obj356*/357public native char getChar(Object obj, long offset);358359/**360* Sets the value of the char in the obj parameter at memory offset.361* This is a non-volatile operation.362*363* @param obj object into which to store the value364* @param offset position of the value in obj365* @param value char to store in obj366*/367public native void putChar(Object obj, long offset, char value);368369/**370* Gets the value of the boolean in the obj parameter referenced by offset.371* This is a non-volatile operation.372*373* @param obj object from which to retrieve the value374* @param offset position of the value in obj375* @return boolean value stored in obj376*/377public native boolean getBoolean(Object obj, long offset);378379/**380* Sets the value of the boolean in the obj parameter at memory offset.381* This is a non-volatile operation.382*383* @param obj object into which to store the value384* @param offset position of the value in obj385* @param value boolean to store in obj386*/387public native void putBoolean(Object obj, long offset, boolean value);388389/**390* Gets the value of the Object in the obj parameter referenced by offset.391* This is a non-volatile operation.392*393* @param obj object from which to retrieve the value394* @param offset position of the value in obj395* @return Object value stored in obj396*/397public native Object getObject(Object obj, long offset);398399/**400* Sets the value of the Object in the obj parameter at memory offset.401* This is a non-volatile operation.402*403* @param obj object into which to store the value404* @param offset position of the value in obj405* @param value Object to store in obj406*/407public native void putObject(Object obj, long offset, Object value);408409/*[IF JAVA_SPEC_VERSION >= 12]*/410/**411* Gets the value of the Object in the obj parameter referenced by offset.412* This is a non-volatile operation.413*414* @param obj object from which to retrieve the value415* @param offset position of the value in obj416* @return Object value stored in obj417*/418public native Object getReference(Object obj, long offset);419420/**421* Sets the value of the Object in the obj parameter at memory offset.422* This is a non-volatile operation.423*424* @param obj object into which to store the value425* @param offset position of the value in obj426* @param value Object to store in obj427*/428public native void putReference(Object obj, long offset, Object value);429/*[ENDIF] JAVA_SPEC_VERSION >= 12 */430431/**432* Gets the value of the Object in memory referenced by address.433* This is a non-volatile operation.434*435* NOTE: native implementation is a stub.436*437* @param address position of the object in memory438* @return Object value stored in memory439*/440public native Object getUncompressedObject(long address);441442/**443* Allocates a block of memory444*445* @param size number of bytes to allocate446* @return address of allocated buffer447*448* @throws IllegalArgumentException if size is negative449*/450public native long allocateDBBMemory(long size);451452/**453* Reallocates a block of memory.454*455* @param address of old buffer456* @param size new size of buffer to allocate457* @return address of new buffer458*459* @throws IllegalArgumentException if size is negative460*/461public native long reallocateDBBMemory(long address, long size);462463/**464* Removes the block from the list. Note that the pointers are located465* immediately before the address value.466*467* @param address of buffer468*/469public native void freeDBBMemory(long address);470471/**472* Returns the size of a page in memory in bytes.473*474* @return size of memory page475*/476public native int pageSize();477478/**479* Creates a class out of a given array of bytes with a ProtectionDomain.480*481* @param name binary name of the class, null if the name is not known482* @param b a byte array of the class data. The bytes should have the format of a valid483* class file as defined by The JVM Spec484* @param offset offset of the start of the class data in b485* @param bLength length of the class data486* @param cl used to load the class being built. If null, the default487* system ClassLoader will be used488* @param pd ProtectionDomain for new class489* @return the Class created from the byte array and ProtectionDomain parameters490*491* @throws IndexOutOfBoundsException if offset or bLength is negative, or if offset + bLength492* is greater than the length of b493*/494public native Class<?> defineClass0(String name, byte[] b, int offset, int bLength, ClassLoader cl,495ProtectionDomain pd);496497/**498* Allocate instance of class parameter.499*500* @param c class to allocate501* @return instance of class c502*503* @throws InstantiationException if class c cannot be instantiated504*/505public native Object allocateInstance(Class<?> c) throws InstantiationException;506507/**508* Throw Throwable parameter.509*510* @param t Throwable to execute511*512* @throws NullPointerException if Throwable is null513*/514public native void throwException(Throwable t);515516/**517* Atomically sets the parameter value at offset in obj if the compare value518* matches the existing value in the object.519* The get operation has memory semantics of getVolatile.520* The set operation has the memory semantics of setVolatile.521*522* @param obj object into which to store the value523* @param offset location to compare and store value in obj524* @param compareValue value that is expected to be in obj at offset525* @param setValue value that will be set in obj at offset if compare is successful526* @return boolean value indicating whether the field was updated527*/528public final native boolean compareAndSetInt(Object obj, long offset, int compareValue, int setValue);529530/**531* Atomically sets the parameter value at offset in obj if the compare value532* matches the existing value in the object.533* The get operation has memory semantics of getVolatile.534* The set operation has the memory semantics of setVolatile.535*536* @param obj object into which to store the value537* @param offset location to compare and store value in obj538* @param compareValue value that is expected to be in obj at offset539* @param exchangeValue value that will be set in obj at offset if compare is successful540* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful541*/542public final native int compareAndExchangeInt(Object obj, long offset, int compareValue, int exchangeValue);543544/**545* Atomically sets the parameter value at offset in obj if the compare value546* matches the existing value in the object.547* The get operation has memory semantics of getVolatile.548* The set operation has the memory semantics of setVolatile.549*550* @param obj object into which to store the value551* @param offset location to compare and store value in obj552* @param compareValue value that is expected to be in obj at offset553* @param setValue value that will be set in obj at offset if compare is successful554* @return boolean value indicating whether the field was updated555*/556public final native boolean compareAndSetLong(Object obj, long offset, long compareValue, long setValue);557558/**559* Atomically sets the parameter value at offset in obj if the compare value560* matches the existing value in the object.561* The get operation has memory semantics of getVolatile.562* The set operation has the memory semantics of setVolatile.563*564* @param obj object into which to store the value565* @param offset location to compare and store value in obj566* @param compareValue value that is expected to be in obj at offset567* @param exchangeValue value that will be set in obj at offset if compare is successful568* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful569*/570public final native long compareAndExchangeLong(Object obj, long offset, long compareValue, long exchangeVale);571572/**573* Atomically sets the parameter value at offset in obj if the compare value574* matches the existing value in the object.575* The get operation has memory semantics of getVolatile.576* The set operation has the memory semantics of setVolatile.577*578* @param obj object into which to store the value579* @param offset location to compare and store value in obj580* @param compareValue value that is expected to be in obj at offset581* @param setValue value that will be set in obj at offset if compare is successful582* @return boolean value indicating whether the field was updated583*/584public final native boolean compareAndSetObject(Object obj, long offset, Object compareValue, Object setValue);585586/**587* Atomically sets the parameter value at offset in obj if the compare value588* matches the existing value in the object.589* The get operation has memory semantics of getVolatile.590* The set operation has the memory semantics of setVolatile.591*592* @param obj object into which to store the value593* @param offset location to compare and store value in obj594* @param compareValue value that is expected to be in obj at offset595* @param exchangeValue value that will be set in obj at offset if compare is successful596* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful597*/598public final native Object compareAndExchangeObject(Object obj, long offset, Object compareValue,599Object exchangeValue);600601/*[IF JAVA_SPEC_VERSION >= 12]*/602/**603* Atomically sets the parameter value at offset in obj if the compare value604* matches the existing value in the object.605* The get operation has memory semantics of getVolatile.606* The set operation has the memory semantics of setVolatile.607*608* @param obj object into which to store the value609* @param offset location to compare and store value in obj610* @param compareValue value that is expected to be in obj at offset611* @param setValue value that will be set in obj at offset if compare is successful612* @return boolean value indicating whether the field was updated613*/614public final native boolean compareAndSetReference(Object obj, long offset, Object compareValue, Object setValue);615616/**617* Atomically sets the parameter value at offset in obj if the compare value618* matches the existing value in the object.619* The get operation has memory semantics of getVolatile.620* The set operation has the memory semantics of setVolatile.621*622* @param obj object into which to store the value623* @param offset location to compare and store value in obj624* @param compareValue value that is expected to be in obj at offset625* @param exchangeValue value that will be set in obj at offset if compare is successful626* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful627*/628public final native Object compareAndExchangeReference(Object obj, long offset, Object compareValue,629Object exchangeValue);630/*[ENDIF] JAVA_SPEC_VERSION >= 12 */631632/**633* Atomically gets the value of the byte in the obj parameter referenced by offset.634*635* @param obj object from which to retrieve the value636* @param offset position of the value in obj637* @return byte value stored in obj638*/639public native byte getByteVolatile(Object obj, long offset);640641/**642* Atomically sets the value of the byte in the obj parameter at memory offset.643*644* @param obj object into which to store the value645* @param offset position of the value in obj646* @param value byte to store in obj647*/648public native void putByteVolatile(Object obj, long offset, byte value);649650/**651* Atomically gets the value of the int in the obj parameter referenced by offset.652*653* @param obj object from which to retrieve the value654* @param offset position of the value in obj655* @return int value stored in obj656*/657public native int getIntVolatile(Object obj, long offset);658659/**660* Atomically sets the value of the int in the obj parameter at memory offset.661*662* @param obj object into which to store the value663* @param offset position of the value in obj664* @param value int to store in obj665*/666public native void putIntVolatile(Object obj, long offset, int value);667668/**669* Atomically gets the value of the long in the obj parameter referenced by offset.670*671* @param obj object from which to retrieve the value672* @param offset position of the value in obj673* @return long value stored in obj674*/675public native long getLongVolatile(Object obj, long offset);676677/**678* Atomically sets the value of the long in the obj parameter at memory offset.679*680* @param obj object into which to store the value681* @param offset position of the value in obj682* @param value long to store in obj683*/684public native void putLongVolatile(Object obj, long offset, long value);685686/**687* Atomically gets the value of the float in the obj parameter referenced by offset.688*689* @param obj object from which to retrieve the value690* @param offset position of the value in obj691* @return float value stored in obj692*/693public native float getFloatVolatile(Object obj, long offset);694695/**696* Atomically sets the value of the float in the obj parameter at memory offset.697*698* @param obj object into which to store the value699* @param offset position of the value in obj700* @param value float to store in obj701*/702public native void putFloatVolatile(Object obj, long offset, float value);703704/**705* Atomically gets the value of the double in the obj parameter referenced by offset.706*707* @param obj object from which to retrieve the value708* @param offset position of the value in obj709* @return double value stored in obj710*/711public native double getDoubleVolatile(Object obj, long offset);712713/**714* Atomically sets the value of the double in the obj parameter at memory offset.715*716* @param obj object into which to store the value717* @param offset position of the value in obj718* @param value double to store in obj719*/720public native void putDoubleVolatile(Object obj, long offset, double value);721722/**723* Atomically gets the value of the short in the obj parameter referenced by offset.724*725* @param obj object from which to retrieve the value726* @param offset position of the value in obj727* @return short value stored in obj728*/729public native short getShortVolatile(Object obj, long offset);730731/**732* Atomically sets the value of the short in the obj parameter at memory offset.733*734* @param obj object into which to store the value735* @param offset position of the value in obj736* @param value short to store in obj737*/738public native void putShortVolatile(Object obj, long offset, short value);739740/**741* Atomically gets the value of the char in the obj parameter referenced by offset.742*743* @param obj object from which to retrieve the value744* @param offset position of the value in obj745* @return char value stored in obj746*/747public native char getCharVolatile(Object obj, long offset);748749/**750* Atomically sets the value of the char in the obj parameter at memory offset.751*752* @param obj object into which to store the value753* @param offset position of the value in obj754* @param value char to store in obj755*/756public native void putCharVolatile(Object obj, long offset, char value);757758/**759* Atomically gets the value of the boolean in the obj parameter referenced by offset.760*761* @param obj object from which to retrieve the value762* @param offset position of the value in obj763* @return boolean value stored in obj764*/765public native boolean getBooleanVolatile(Object obj, long offset);766767/**768* Atomically sets the value of the boolean in the obj parameter at memory offset.769*770* @param obj object into which to store the value771* @param offset position of the value in obj772* @param value boolean to store in obj773*/774public native void putBooleanVolatile(Object obj, long offset, boolean value);775776/**777* Atomically gets the value of the Object in the obj parameter referenced by offset.778*779* @param obj object from which to retrieve the value780* @param offset position of the value in obj781* @return Object value stored in obj782*/783public native Object getObjectVolatile(Object obj, long offset);784785/**786* Atomically sets the value of the Object in the obj parameter at memory offset.787*788* @param obj object into which to store the value789* @param offset position of the value in obj790* @param value Object to store in obj791*/792public native void putObjectVolatile(Object obj, long offset, Object value);793794/*[IF JAVA_SPEC_VERSION >= 12]*/795/**796* Atomically gets the value of the Object in the obj parameter referenced by offset.797*798* @param obj object from which to retrieve the value799* @param offset position of the value in obj800* @return Object value stored in obj801*/802public native Object getReferenceVolatile(Object obj, long offset);803804/**805* Atomically sets the value of the Object in the obj parameter at memory offset.806*807* @param obj object into which to store the value808* @param offset position of the value in obj809* @param value Object to store in obj810*/811public native void putReferenceVolatile(Object obj, long offset, Object value);812/*[ENDIF] JAVA_SPEC_VERSION >= 12 */813814/**815* Makes permit available for thread parameter.816*817* @param thread the thread to unpark. If null, method has no effect818*/819public native void unpark(Object thread);820821/**822* Disables current thread unless permit is available. Thread will not be823* scheduled until unpark provides permit.824*825* @param isAbsolute if true park timeout should be absolute826* @param time parks for time in ns.827* ms is expected if isAbsolute is set to true.828*/829public native void park(boolean isAbsolute, long time);830831/**832* Inserts an acquire memory fence, ensuring that no loads before this fence833* are reordered with any loads/stores after the fence.834*/835public native void loadFence();836837/**838* Inserts a release memory fence, ensuring that no stores before this fence839* are reordered with any loads/stores after the fence.840*/841public native void storeFence();842843/**844* Inserts a complete memory fence, ensuring that no loads/stores before this845* fence are reordered with any loads/stores after the fence.846*/847public native void fullFence();848849/*850* jdk.internal.misc.Unsafe natives851*/852/*853* Allocates a block of memory.854* If size passed is 0, no memory will be allocated.855*856* @param size requested size of memory in bytes857* @return starting address of memory858*859* @throws IllegalArgumentException if size is not valid860*/861private native long allocateMemory0(long size);862863/*864* Reallocates a block of memory.865* If size passed is 0, no memory will be allocated.866*867* @param size requested size of memory in bytes868* @return starting address of memory869*870* @throws IllegalArgumentException if size is not valid871*/872private native long reallocateMemory0(long address, long size);873874/*875* Removes the block from the list. Note that the pointers are located876* immediately before the startIndex value.877*878* @param startIndex memory address879*880* @throws IllegalArgumentException if startIndex is not valid881*/882private native void freeMemory0(long startIndex);883884/*885* Set object at offset in obj parameter.886*887* @param obj object into which to store the value888* @param startIndex position of the value in obj889* @param size the number of bytes to be set to the value890* @param replace overwrite memory with this value891*892* @throws IllegalArgumentException if startIndex is illegal in obj, or if size is invalid893*/894private native void setMemory0(Object obj, long startIndex, long size, byte replace);895896/*897* Copy bytes from source object to destination.898*899* @param srcObj object to copy from900* @param srcOffset location in srcObj to start copy901* @param destObj object to copy into902* @param destOffset location in destObj to start copy903* @param size the number of bytes to be copied904*905* @throws IllegalArgumentException if srcOffset is illegal in srcObj,906* if destOffset is illegal in destObj, or if size is invalid907*/908private native void copyMemory0(Object srcObj, long srcOffset, Object destObj, long destOffset, long size);909910/*911* Copy bytes from source object to destination in reverse order.912* Memory is reversed in elementSize chunks.913*914* @param srcObj object to copy from915* @param srcOffset location in srcObj to start copy916* @param destObj object to copy into917* @param destOffset location in destObj to start copy918* @param copySize the number of bytes to be copied, a multiple of elementSize919* @param elementSize the size in bytes of elements that will be reversed920*921* @throws IllegalArgumentException if srcOffset is illegal in srcObj,922* if destOffset is illegal in destObj, if copySize is invalid or copySize is not923* a multiple of elementSize924*/925private native void copySwapMemory0(Object srcObj, long srcOffset, Object destObj, long destOffset, long copySize,926long elementSize);927928/*929* Returns byte offset to field.930*931* @param field which contains desired class or interface932* @return offset to start of class or interface933*934* @throws IllegalArgumentException if field is static935*/936private native long objectFieldOffset0(Field field);937938/*[IF JAVA_SPEC_VERSION >= 10]*/939/*940* Returns byte offset to field.941*942* @param class with desired field943* @param string name of desired field944* @return offset to start of class or interface945*946* @throws IllegalArgumentException if field is static947*/948private native long objectFieldOffset1(Class<?> c, String fieldName);949/*[ENDIF] JAVA_SPEC_VERSION >= 10 */950951/*952* Returns byte offset to start of static class or interface.953*954* @param field which contains desired class or interface955* @return offset to start of class or interface956*957* @throws NullPointerException if field parameter is null958* @throws IllegalArgumentException if field is not static959*/960private native long staticFieldOffset0(Field field);961962/*963* Returns class or interface described by static Field.964*965* @param field contains desired class or interface966* @return class or interface in static field967*968* @throws NullPointerException if field parameter is null969* @throws IllegalArgumentException if field is not static970*/971private native Object staticFieldBase0(Field field);972973/*974* Determines whether class has been initialized.975*976* @param class to verify977* @return true if method has not been initialized, false otherwise978*/979private native boolean shouldBeInitialized0(Class<?> c);980981/*982* Initializes class parameter if it has not been already.983*984* @param c class to initialize if not already985*986* @throws NullPointerException if class is null987*/988private native void ensureClassInitialized0(Class<?> c);989990/*991* Return offset in array object at which the array data storage begins.992*993* @param c class array994* @return offset at base of array995*996* @throws NullPointerException if the class parameter is null997* @throws IllegalArgumentException if class is not an array998*/999private native int arrayBaseOffset0(Class<?> c);10001001/*1002* Return index size of array in bytes.1003*1004* @param c class array1005* @return returns index size of array in bytes1006*1007* @throws NullPointerException if class is null1008* @throws IllegalArgumentException if class is not an array1009*/1010private native int arrayIndexScale0(Class<?> c);10111012/* @return size of address on machine in use */1013private native int addressSize0();10141015/*[IF JAVA_SPEC_VERSION < 17]*/1016/*1017* Define a class without making it known to the class loader.1018*1019* @param hostingClass the context for class loader + linkage, and1020* access control + protection domain1021* @param bytecodes class file bytes1022* @param constPatches entries that are not "null" are replacements1023* for the corresponding const pool entries in the 'bytecodes' data1024* @return class created from bytecodes and constPatches1025*/1026private native Class<?> defineAnonymousClass0(Class<?> hostingClass, byte[] bytecodes, Object[] constPatches);1027/*[ENDIF] JAVA_SPEC_VERSION < 17 */10281029/*1030* Get the load average in the system.1031*1032* NOTE: native implementation is a stub.1033*1034* @param loadavg array of elements1035* @param numberOfElements number of samples1036* @return load average1037*/1038private native int getLoadAverage0(double[] loadavg, int numberOfElements);10391040/* @return true if addresses are aligned in memory, false otherwise */1041private native boolean unalignedAccess0();10421043/* @return true if machine is big endian, false otherwise */1044private native boolean isBigEndian0();10451046/*[IF JAVA_SPEC_VERSION >= 14]*/1047/**1048* Make sure that the virtual memory at address "addr" for length "len" has1049* been written back from the cache to physical memory.1050* Throw RuntimeException if cache flushing is not enabled on the runtime OS.1051*1052* @param addr address to the start of the block of virtual memory to be flushed1053* @param len length of the block of virtual memory to be flushed1054* @throws RuntimeException if cache flushing not enabled1055*/1056public native void writebackMemory(long addr, long len);10571058/**1059* Check if cache writeback is possible on the runtime platform by checking1060* if there is OS and/or CPU support.1061*1062* @return true if cache writeback is possible, else false1063*/1064public static native boolean isWritebackEnabled();1065/*[ENDIF] JAVA_SPEC_VERSION >= 14 */10661067/**1068* Getter for unsafe instance.1069*1070* @return unsafe instance1071*/1072public static Unsafe getUnsafe() {1073return theUnsafe;1074}10751076/**1077* Gets the address in the obj parameter referenced by offset.1078* This is a non-volatile operation.1079*1080* @param obj object from which to retrieve the address1081* @param address location to retrieve the address in obj1082* @return address stored in obj1083*/1084public long getAddress(Object obj, long address) {1085long result;10861087if (BYTES_IN_INT == ADDRESS_SIZE) {1088result = Integer.toUnsignedLong(getInt(obj, address));1089} else {1090result = getLong(obj, address);1091}10921093return result;1094}10951096/**1097* Sets an address in the obj parameter at memory offset.1098* This is a non-volatile operation.1099*1100* @param obj object into which to store the address1101* @param address position to store value in obj1102* @param value address to store in obj1103*/1104public void putAddress(Object obj, long address, long value) {1105if (BYTES_IN_INT == ADDRESS_SIZE) {1106putInt(obj, address, (int) value);1107} else {1108putLong(obj, address, value);1109}1110}11111112/**1113* Gets the value of the byte in memory referenced by offset.1114* This is a non-volatile operation.1115*1116* @param locations where to retrieve value in memory1117* @return byte value stored in memory1118*/1119public byte getByte(long offset) {1120return getByte(null, offset);1121}11221123/**1124* Sets the value of the byte at memory offset.1125* This is a non-volatile operation.1126*1127* @param offset location to retrieve value in memory1128* @param value byte to store in memory1129*/1130public void putByte(long offset, byte value) {1131putByte(null, offset, value);1132}11331134/**1135* Gets the value of the int in memory referenced by offset.1136* This is a non-volatile operation.1137*1138* @param offset location to retrieve value in memory1139* @return int value stored in memory1140*/1141public int getInt(long offset) {1142return getInt(null, offset);1143}11441145/**1146* Sets the value of the int at memory offset.1147* This is a non-volatile operation.1148*1149* @param offset location to retrieve value in memory1150* @param value int to store in memory1151*/1152public void putInt(long offset, int value) {1153putInt(null, offset, value);1154}11551156/**1157* Gets the value of the long in memory referenced by offset.1158* This is a non-volatile operation.1159*1160* @param offset location to retrieve value in memory1161* @return long value stored in memory1162*/1163public long getLong(long offset) {1164return getLong(null, offset);1165}11661167/**1168* Sets the value of the long at memory offset.1169* This is a non-volatile operation.1170*1171* @param offset location to retrieve value in memory1172* @param value long to store in memory1173*/1174public void putLong(long offset, long value) {1175putLong(null, offset, value);1176}11771178/**1179* Gets the value of the float in memory referenced by offset.1180* This is a non-volatile operation.1181*1182* @param offset location to retrieve value in memory1183* @return float value stored in memory1184*/1185public float getFloat(long offset) {1186return getFloat(null, offset);1187}11881189/**1190* Sets the value of the float at memory offset.1191* This is a non-volatile operation.1192*1193* @param offset location to retrieve value in memory1194* @param value float to store in memory1195*/1196public void putFloat(long offset, float value) {1197putFloat(null, offset, value);1198}11991200/**1201* Gets the value of the double in memory referenced by offset.1202* This is a non-volatile operation.1203*1204* @param offset location to retrieve value in memory1205* @return double value stored in memory1206*/1207public double getDouble(long offset) {1208return getDouble(null, offset);1209}12101211/**1212* Sets the value of the double at memory offset.1213* This is a non-volatile operation.1214*1215* @param offset location to retrieve value in memory1216* @param value double to store in memory1217*/1218public void putDouble(long offset, double value) {1219putDouble(null, offset, value);1220}12211222/**1223* Gets the value of the short in memory referenced by offset.1224* This is a non-volatile operation.1225*1226* @param offset location to retrieve value in memory1227* @return short value stored in memory1228*/1229public short getShort(long offset) {1230return getShort(null, offset);1231}12321233/**1234* Sets the value of the short at memory offset.1235* This is a non-volatile operation.1236*1237* @param offset location to retrieve value in memory1238* @param value short to store in memory1239*/1240public void putShort(long offset, short value) {1241putShort(null, offset, value);1242}12431244/**1245* Gets the value of the char in memory referenced by offset.1246* This is a non-volatile operation.1247*1248* @param offset location to retrieve value in memory1249* @return char value stored in memory1250*/1251public char getChar(long offset) {1252return getChar(null, offset);1253}12541255/**1256* Sets the value of the char at memory offset.1257* This is a non-volatile operation.1258*1259* @param offset location to retrieve value in memory1260* @param value char to store in memory1261*/1262public void putChar(long offset, char value) {1263putChar(null, offset, value);1264}12651266/**1267* Gets the address value in memory at location of address parameter.1268* This is a non-volatile operation.1269*1270* @param address location to retrieve the address in memory1271* @return address stored in obj1272*/1273public long getAddress(long address) {1274return getAddress(null, address);12751276}12771278/**1279* Sets an address value at the location by the address parameter.1280* This is a non-volatile operation.1281*1282* @param address location to store value in memory1283* @param value address to store at address parameter1284*/1285public void putAddress(long address, long value) {1286putAddress(null, address, value);1287}12881289/**1290* Allocates a block of memory.1291* If size passed is 0, no memory will be allocated.1292*1293* @param size requested size of memory in bytes1294* @return starting address of memory, or 0 if size is 01295*1296* @throws OutOfMemoryError if no memory can be allocated1297* @throws IllegalArgumentException if size is not valid1298*/1299public long allocateMemory(long size) {1300allocateMemoryChecks(size);13011302if (0L == size) {1303return 0L;1304}13051306long address = allocateMemory0(size);13071308if (0L == address) {1309throw new OutOfMemoryError();1310}13111312return address;1313}13141315/**1316* Reallocates a block of memory.1317* If size passed is 0, no memory will be allocated.1318*1319* @param size requested size of memory in bytes1320* @return starting address of memory, or 0 if size is 01321*1322* @throws OutOfMemoryError if no memory can be allocated1323* @throws IllegalArgumentException if size is not valid1324*/1325public long reallocateMemory(long address, long size) {1326reallocateMemoryChecks(address, size);13271328if (0L == size) {1329freeMemory(address);1330return 0L;1331}13321333long addressNew;1334if (0L == address) {1335addressNew = allocateMemory0(size);1336} else {1337addressNew = reallocateMemory0(address, size);1338}13391340if (0L == addressNew) {1341throw new OutOfMemoryError();1342}13431344return addressNew;1345}13461347/**1348* Set the byte at the index and size in obj parameter.1349*1350* @param obj object into which to store the value1351* @param startIndex position of the value in obj1352* @param size the number of bytes to be set to the value1353* @param replace overwrite memory with this value1354*1355* @throws IllegalArgumentException if startIndex is illegal in obj, or if size is invalid1356*/1357public void setMemory(Object obj, long startIndex, long size, byte replace) {1358setMemoryChecks(obj, startIndex, size, replace);13591360if (0 != size) {1361setMemory0(obj, startIndex, size, replace);1362}1363}13641365/**1366* Set the byte at the index and size.1367*1368* @param startAddress location to store value in memory1369* @param size the number of bytes to be set to the value1370* @param replace overwrite memory with this value1371*1372* @throws IllegalArgumentException if startIndex is illegal, or if size is invalid1373*/1374public void setMemory(long startAddress, long size, byte replace) {1375setMemory(null, startAddress, size, replace);1376}13771378/**1379* Copy bytes from source object to destination.1380*1381* @param srcObj object to copy from1382* @param srcOffset location in srcObj to start copy1383* @param destObj object to copy into1384* @param destOffset location in destObj to start copy1385* @param size the number of bytes to be copied1386*1387* @throws IllegalArgumentException if srcOffset is illegal in srcObj,1388* if destOffset is illegal in destObj, or if size is invalid1389*/1390public void copyMemory(Object srcObj, long srcOffset, Object destObj, long destOffset, long size) {1391copyMemoryChecks(srcObj, srcOffset, destObj, destOffset, size);13921393if (0 != size) {1394copyMemory0(srcObj, srcOffset, destObj, destOffset, size);1395}1396}13971398/**1399* Copy bytes from source address to destination.1400*1401* @param srcAddress address to start copy1402* @param destAddress address to start copy1403* @param size the number of bytes to be copied1404*1405* @throws IllegalArgumentException if srcAddress or destAddress1406* is illegal, or if size is invalid1407*/1408public void copyMemory(long srcAddress, long destAddress, long size) {1409copyMemory(null, srcAddress, null, destAddress, size);1410}14111412/**1413* Copy bytes from source object to destination in reverse order.1414* Memory is reversed in elementSize chunks.1415*1416* @param srcObj object to copy from1417* @param srcOffset location in srcObj to start copy1418* @param destObj object to copy into1419* @param destOffset location in destObj to start copy1420* @param copySize the number of bytes to be copied, a multiple of elementSize1421* @param elementSize the size in bytes of elements that will be reversed1422*1423* @throws IllegalArgumentException if srcOffset is illegal in srcObj,1424* if destOffset is illegal in destObj, if copySize is invalid or copySize is not1425* a multiple of elementSize1426*/1427public void copySwapMemory(Object srcObj, long srcOffset, Object destObj, long destOffset, long copySize,1428long elementSize) {1429copySwapMemoryChecks(srcObj, srcOffset, destObj, destOffset, copySize, elementSize);14301431if (0 != copySize) {1432copySwapMemory0(srcObj, srcOffset, destObj, destOffset, copySize, elementSize);1433}1434}14351436/**1437* Copy bytes from source address to destination in reverse order.1438* Memory is reversed in elementSize chunks.1439*1440* @param srcAddress location to start copy1441* @param destAddress location to start copy1442* @param copySize the number of bytes to be copied, a multiple of elementSize1443* @param elementSize the size in bytes of elements that will be reversed1444*1445* @throws IllegalArgumentException if srcAddress or destAddress is illegal,1446* if copySize is invalid or copySize is not a multiple of elementSize1447*/1448public void copySwapMemory(long srcAddress, long destAddress, long copySize, long elementSize) {1449copySwapMemory(null, srcAddress, null, destAddress, copySize, elementSize);1450}14511452/**1453* Removes the block from the list. Note that the pointers are located1454* immediately before the startIndex value.1455*1456* @param startIndex memory address1457*1458* @throws IllegalArgumentException if startIndex is not valid1459*/1460public void freeMemory(long startIndex) {1461freeMemoryChecks(startIndex);14621463if (0 != startIndex) {1464freeMemory0(startIndex);1465}1466}14671468/**1469* Returns byte offset to field.1470*1471* @param field which contains desired class or interface1472* @return offset to start of class or interface1473*1474* @throws NullPointerException if field parameter is null1475* @throws IllegalArgumentException if field is static1476*/1477public long objectFieldOffset(Field field) {1478Objects.requireNonNull(field);1479return objectFieldOffset0(field);1480}14811482/*[IF JAVA_SPEC_VERSION >= 10]*/1483/**1484* Returns byte offset to field.1485*1486* @param class with desired field1487* @param string name of desired field1488* @return offset to start of class or interface1489*1490* @throws NullPointerException if field parameter is null1491* @throws IllegalArgumentException if field is static1492*/1493public long objectFieldOffset(Class<?> c, String fieldName) {1494Objects.requireNonNull(c);1495Objects.requireNonNull(fieldName);1496return objectFieldOffset1(c, fieldName);1497}1498/*[ENDIF] JAVA_SPEC_VERSION >= 10 */14991500/**1501* Returns byte offset to start of static class or interface.1502*1503* @param field which contains desired class or interface1504* @return offset to start of class or interface1505*1506* @throws NullPointerException if field parameter is null1507* @throws IllegalArgumentException if field is not static1508*/1509public long staticFieldOffset(Field field) {1510Objects.requireNonNull(field);1511return staticFieldOffset0(field);1512}15131514/**1515* Returns class or interface described by static Field.1516*1517* @param field contains desired class or interface1518* @return class or interface in static field1519*1520* @throws NullPointerException if field parameter is null1521* @throws IllegalArgumentException if field is not static1522*/1523public Object staticFieldBase(Field field) {1524Objects.requireNonNull(field);1525return staticFieldBase0(field);1526}15271528/**1529* Determines whether class has been initialized.1530*1531* @param class to verify1532* @return true if method has not been initialized, false otherwise1533*1534* @throws NullPointerException if class is null1535*/1536public boolean shouldBeInitialized(Class<?> c) {1537Objects.requireNonNull(c);1538return shouldBeInitialized0(c);1539}15401541/**1542* Initializes class parameter if it has not been already.1543*1544* @param c class to initialize if not already1545*1546* @throws NullPointerException if class is null1547*/1548public void ensureClassInitialized(Class<?> c) {1549Objects.requireNonNull(c);1550ensureClassInitialized0(c);1551}15521553/**1554* Return offset in array object at which the array data storage begins.1555*1556* @param c class array1557* @return offset at base of array1558*1559* @throws NullPointerException if the class parameter is null1560* @throws IllegalArgumentException if class is not an array1561*/1562public int arrayBaseOffset(Class<?> c) {1563Objects.requireNonNull(c);1564return arrayBaseOffset0(c);1565}15661567/**1568* Return index size of array in bytes.1569*1570* @param c class array1571* @return returns index size of array in bytes1572*1573* @throws NullPointerException if class is null1574* @throws IllegalArgumentException if class is not an array1575* @throws RuntimeException if index scale is not a power of 21576*/1577public int arrayIndexScale(Class<?> c) {1578Objects.requireNonNull(c);1579int indexScale = arrayIndexScale0(c);1580if (indexScale == 0 || (indexScale & (indexScale - 1)) != 0) {1581throw new RuntimeException("The class array index scale is not a power of two");1582}1583return indexScale;1584}15851586/**1587* @return size of address on machine in use1588*/1589public int addressSize() {1590return ADDRESS_SIZE;1591}15921593/**1594* Creates a class out of a given array of bytes with a ProtectionDomain.1595*1596* @param name binary name of the class, null if the name is not known1597* @param b a byte array of the class data. The bytes should have the format of a1598* valid class file as defined by The JVM Spec1599* @param offset offset of the start of the class data in b1600* @param bLength length of the class data1601* @param cl ClassLoader used to load the class being built. If null, the default1602* system ClassLoader will be used1603* @param pd ProtectionDomain for new class1604* @return class created from the byte array and ProtectionDomain parameters1605*1606* @throws NullPointerException if b array of data is null1607* @throws ArrayIndexOutOfBoundsException if bLength is negative1608* @throws IndexOutOfBoundsException if offset + bLength is greater than the1609* length of b1610*/1611public Class<?> defineClass(String name, byte[] b, int offset, int bLength, ClassLoader cl, ProtectionDomain pd) {1612Objects.requireNonNull(b);16131614if (bLength < 0) {1615throw new ArrayIndexOutOfBoundsException();1616}16171618Class<?> result = defineClass0(name, b, offset, bLength, cl, pd);1619VMLangAccess access = VM.getVMLangAccess();1620access.addPackageToList(result, cl);1621return result;1622}16231624/*[IF JAVA_SPEC_VERSION < 17]*/1625/**1626* Define a class without making it known to the class loader.1627*1628* @param hostingClass the context for class loader + linkage, and1629* access control + protection domain1630* @param bytecodes class file bytes1631* @param constPatches entries that are not "null" are replacements1632* for the corresponding const pool entries in the 'bytecodes' data1633* @return class created from bytecodes and constPatches1634*1635* @throws NullPointerException if hostingClass or bytecodes is null1636* @throws IllegalArgumentException if hostingClass is an array or primitive1637*/1638public Class<?> defineAnonymousClass(Class<?> hostingClass, byte[] bytecodes, Object[] constPatches) {1639Objects.requireNonNull(hostingClass);1640Objects.requireNonNull(bytecodes);16411642if (hostingClass.isArray() || hostingClass.isPrimitive()) {1643throw invalidInput();1644}16451646return defineAnonymousClass0(hostingClass, bytecodes, constPatches);1647}1648/*[ENDIF] JAVA_SPEC_VERSION < 17 */16491650/**1651* Allocate new array of same type as class parameter and1652* length of int parameter.1653*1654* @param c class of same type as desired array1655* @param length desired length of array1656* @return allocated array of desired length and type1657*1658* @throws IllegalArgumentException if class is null, if class1659* is not primitive, or if length is negative1660*/1661public Object allocateUninitializedArray(Class<?> c, int length) {1662if (null == c) {1663/*[MSG "K0701", "Component type is null"]*/1664throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0701")); //$NON-NLS-1$1665}16661667if (!c.isPrimitive()) {1668/*[MSG "K0702", "Component type is not primitive"]*/1669throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0702")); //$NON-NLS-1$1670}16711672if (length < 0) {1673/*[MSG "K0703", "Negative length"]*/1674throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0703")); //$NON-NLS-1$1675}16761677return allocateUninitializedArray0(c, length);1678}167916801681/**1682* Atomically sets the parameter value at offset in obj if the compare value1683* matches the existing value in the object.1684* The get operation has memory semantics of get.1685* The set operation has the memory semantics of set.1686*1687* @param obj object into which to store the value1688* @param offset location to compare and store value in obj1689* @param compareValue value that is expected to be in obj at offset1690* @param exchangeValue value that will be set in obj at offset if compare is successful1691* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1692*/1693public final byte compareAndExchangeByte(Object obj, long offset, byte compareValue, byte exchangeValue) {1694return compareAndExchange8bits(obj, offset, compareValue, exchangeValue);1695}16961697/**1698* Atomically sets the parameter value at offset in obj if the compare value1699* matches the existing value in the object.1700* The get operation has memory semantics of getVolatile.1701* The set operation has the memory semantics of setVolatile.1702*1703* @param obj object into which to store the value1704* @param offset location to compare and store value in obj1705* @param compareValue value that is expected to be in obj at offset1706* @param setValue value that will be set in obj at offset if compare is successful1707* @return boolean value indicating whether the field was updated1708*/1709public final boolean compareAndSetByte(Object obj, long offset, byte compareValue, byte setValue) {1710byte exchangedValue = compareAndExchangeByte(obj, offset, compareValue, setValue);1711return (compareValue == exchangedValue);1712}17131714/**1715* Sets the parameter value at offset in obj if the compare value1716* matches the existing value in the object.1717* The get operation has memory semantics of get.1718* The set operation has the memory semantics of set.1719*1720* @param obj object into which to store the value1721* @param offset location to compare and store value in obj1722* @param compareValue value that is expected to be in obj at offset1723* @param setValue value that will be set in obj at offset if compare is successful1724* @return boolean value indicating whether the field was updated1725*/1726public final boolean weakCompareAndSetByte(Object obj, long offset, byte compareValue, byte setValue) {1727return compareAndSetByte(obj, offset, compareValue, setValue);1728}17291730/**1731* Sets the parameter value at offset in obj if the compare value1732* matches the existing value in the object.1733* The get operation has memory semantics of getAcquire.1734* The set operation has the memory semantics of set.1735*1736* @param obj object into which to store the value1737* @param offset location to compare and store value in obj1738* @param compareValue value that is expected to be in obj at offset1739* @param setValue value that will be set in obj at offset if compare is successful1740* @return boolean value indicating whether the field was updated1741*/1742public final boolean weakCompareAndSetByteAcquire(Object obj, long offset, byte compareValue, byte setValue) {1743return weakCompareAndSetByte(obj, offset, compareValue, setValue);1744}17451746/**1747* Sets the parameter value at offset in obj if the compare value1748* matches the existing value in the object.1749* The get operation has memory semantics of get.1750* The set operation has the memory semantics of setRelease.1751*1752* @param obj object into which to store the value1753* @param offset location to compare and store value in obj1754* @param compareValue value that is expected to be in obj at offset1755* @param setValue value that will be set in obj at offset if compare is successful1756* @return boolean value indicating whether the field was updated1757*/1758public final boolean weakCompareAndSetByteRelease(Object obj, long offset, byte compareValue, byte setValue) {1759return weakCompareAndSetByte(obj, offset, compareValue, setValue);1760}17611762/**1763* Sets the parameter value at offset in obj if the compare value1764* matches the existing value in the object.1765* The get operation has memory semantics of get.1766* The set operation has the memory semantics of set.1767*1768* @param obj object into which to store the value1769* @param offset location to compare and store value in obj1770* @param compareValue value that is expected to be in obj at offset1771* @param setValue value that will be set in obj at offset if compare is successful1772* @return boolean value indicating whether the field was updated1773*/1774public final boolean weakCompareAndSetBytePlain(Object obj, long offset, byte compareValue, byte setValue) {1775return weakCompareAndSetByte(obj, offset, compareValue, setValue);1776}17771778/**1779* Atomically sets the parameter value at offset in obj if the compare value1780* matches the existing value in the object.1781* The get operation has memory semantics of getAcquire.1782* The set operation has the memory semantics of set.1783*1784* @param obj object into which to store the value1785* @param offset location to compare and store value in obj1786* @param compareValue value that is expected to be in obj at offset1787* @param exchangeValue value that will be set in obj at offset if compare is successful1788* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1789*/1790public final byte compareAndExchangeByteAcquire(Object obj, long offset, byte compareValue, byte exchangeValue) {1791return compareAndExchangeByte(obj, offset, compareValue, exchangeValue);1792}17931794/**1795* Atomically sets the parameter value at offset in obj if the compare value1796* matches the existing value in the object.1797* The get operation has memory semantics of get.1798* The set operation has the memory semantics of setRelease.1799*1800* @param obj object into which to store the value1801* @param offset location to compare and store value in obj1802* @param compareValue value that is expected to be in obj at offset1803* @param exchangeValue value that will be set in obj at offset if compare is successful1804* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1805*/1806public final byte compareAndExchangeByteRelease(Object obj, long offset, byte compareValue, byte exchangeValue) {1807return compareAndExchangeByte(obj, offset, compareValue, exchangeValue);1808}18091810/**1811* Atomically sets the parameter value at offset in obj if the compare value1812* matches the existing value in the object.1813* The get operation has memory semantics of getAcquire.1814* The set operation has the memory semantics of set.1815*1816* @param obj object into which to store the value1817* @param offset location to compare and store value in obj1818* @param compareValue value that is expected to be in obj at offset1819* @param exchangeValue value that will be set in obj at offset if compare is successful1820* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1821*/1822public final int compareAndExchangeIntAcquire(Object obj, long offset, int compareValue, int exchangeValue) {1823return compareAndExchangeInt(obj, offset, compareValue, exchangeValue);1824}18251826/**1827* Atomically sets the parameter value at offset in obj if the compare value1828* matches the existing value in the object.1829* The get operation has memory semantics of get.1830* The set operation has the memory semantics of setRelease.1831*1832* @param obj object into which to store the value1833* @param offset location to compare and store value in obj1834* @param compareValue value that is expected to be in obj at offset1835* @param exchangeValue value that will be set in obj at offset if compare is successful1836* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1837*/1838public final int compareAndExchangeIntRelease(Object obj, long offset, int compareValue, int exchangeValue) {1839return compareAndExchangeInt(obj, offset, compareValue, exchangeValue);1840}18411842/**1843* Sets the parameter value at offset in obj if the compare value1844* matches the existing value in the object.1845* The get operation has memory semantics of get.1846* The set operation has the memory semantics of set.1847*1848* @param obj object into which to store the value1849* @param offset location to compare and store value in obj1850* @param compareValue value that is expected to be in obj at offset1851* @param setValue value that will be set in obj at offset if compare is successful1852* @return boolean value indicating whether the field was updated1853*/1854public final boolean weakCompareAndSetIntPlain(Object obj, long offset, int compareValue, int setValue) {1855return compareAndSetInt(obj, offset, compareValue, setValue);1856}18571858/**1859* Sets the parameter value at offset in obj if the compare value1860* matches the existing value in the object.1861* The get operation has memory semantics of getAcquire.1862* The set operation has the memory semantics of set.1863*1864* @param obj object into which to store the value1865* @param offset location to compare and store value in obj1866* @param compareValue value that is expected to be in obj at offset1867* @param setValue value that will be set in obj at offset if compare is successful1868* @return boolean value indicating whether the field was updated1869*/1870public final boolean weakCompareAndSetIntAcquire(Object obj, long offset, int compareValue, int setValue) {1871return compareAndSetInt(obj, offset, compareValue, setValue);1872}18731874/**1875* Sets the parameter value at offset in obj if the compare value1876* matches the existing value in the object.1877* The get operation has memory semantics of get.1878* The set operation has the memory semantics of setRelease.1879*1880* @param obj object into which to store the value1881* @param offset location to compare and store value in obj1882* @param compareValue value that is expected to be in obj at offset1883* @param setValue value that will be set in obj at offset if compare is successful1884* @return boolean value indicating whether the field was updated1885*/1886public final boolean weakCompareAndSetIntRelease(Object obj, long offset, int compareValue, int setValue) {1887return compareAndSetInt(obj, offset, compareValue, setValue);1888}18891890/**1891* Sets the parameter value at offset in obj if the compare value1892* matches the existing value in the object.1893* The get operation has memory semantics of get.1894* The set operation has the memory semantics of set.1895*1896* @param obj object into which to store the value1897* @param offset location to compare and store value in obj1898* @param compareValue value that is expected to be in obj at offset1899* @param setValue value that will be set in obj at offset if compare is successful1900* @return boolean value indicating whether the field was updated1901*/1902public final boolean weakCompareAndSetInt(Object obj, long offset, int compareValue, int setValue) {1903return compareAndSetInt(obj, offset, compareValue, setValue);1904}19051906/**1907* Atomically sets the parameter value at offset in obj if the compare value1908* matches the existing value in the object.1909* The get operation has memory semantics of getAcquire.1910* The set operation has the memory semantics of set.1911*1912* @param obj object into which to store the value1913* @param offset location to compare and store value in obj1914* @param compareValue value that is expected to be in obj at offset1915* @param exchangeValue value that will be set in obj at offset if compare is successful1916* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1917*/1918public final long compareAndExchangeLongAcquire(Object obj, long offset, long compareValue, long exchangeValue) {1919return compareAndExchangeLong(obj, offset, compareValue, exchangeValue);1920}19211922/**1923* Atomically sets the parameter value at offset in obj if the compare value1924* matches the existing value in the object.1925* The get operation has memory semantics of get.1926* The set operation has the memory semantics of setRelease.1927*1928* @param obj object into which to store the value1929* @param offset location to compare and store value in obj1930* @param compareValue value that is expected to be in obj at offset1931* @param exchangeValue value that will be set in obj at offset if compare is successful1932* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful1933*/1934public final long compareAndExchangeLongRelease(Object obj, long offset, long compareValue, long exchangeValue) {1935return compareAndExchangeLong(obj, offset, compareValue, exchangeValue);1936}19371938/**1939* Sets the parameter value at offset in obj if the compare value1940* matches the existing value in the object.1941* The get operation has memory semantics of get.1942* The set operation has the memory semantics of set.1943*1944* @param obj object into which to store the value1945* @param offset location to compare and store value in obj1946* @param compareValue value that is expected to be in obj at offset1947* @param setValue value that will be set in obj at offset if compare is successful1948* @return boolean value indicating whether the field was updated1949*/1950public final boolean weakCompareAndSetLongPlain(Object obj, long offset, long compareValue, long setValue) {1951return compareAndSetLong(obj, offset, compareValue, setValue);1952}19531954/**1955* Sets the parameter value at offset in obj if the compare value1956* matches the existing value in the object.1957* The get operation has memory semantics of getAcquire.1958* The set operation has the memory semantics of set.1959*1960* @param obj object into which to store the value1961* @param offset location to compare and store value in obj1962* @param compareValue value that is expected to be in obj at offset1963* @param setValue value that will be set in obj at offset if compare is successful1964* @return boolean value indicating whether the field was updated1965*/1966public final boolean weakCompareAndSetLongAcquire(Object obj, long offset, long compareValue, long setValue) {1967return compareAndSetLong(obj, offset, compareValue, setValue);1968}19691970/**1971* Sets the parameter value at offset in obj if the compare value1972* matches the existing value in the object.1973* The get operation has memory semantics of get.1974* The set operation has the memory semantics of setRelease.1975*1976* @param obj object into which to store the value1977* @param offset location to compare and store value in obj1978* @param compareValue value that is expected to be in obj at offset1979* @param setValue value that will be set in obj at offset if compare is successful1980* @return boolean value indicating whether the field was updated1981*/1982public final boolean weakCompareAndSetLongRelease(Object obj, long offset, long compareValue, long setValue) {1983return compareAndSetLong(obj, offset, compareValue, setValue);1984}19851986/**1987* Sets the parameter value at offset in obj if the compare value1988* matches the existing value in the object.1989* The get operation has memory semantics of get.1990* The set operation has the memory semantics of set.1991*1992* @param obj object into which to store the value1993* @param offset location to compare and store value in obj1994* @param compareValue value that is expected to be in obj at offset1995* @param setValue value that will be set in obj at offset if compare is successful1996* @return boolean value indicating whether the field was updated1997*/1998public final boolean weakCompareAndSetLong(Object obj, long offset, long compareValue, long setValue) {1999return compareAndSetLong(obj, offset, compareValue, setValue);2000}20012002/**2003* Atomically sets the parameter value at offset in obj if the compare value2004* matches the existing value in the object.2005* The get operation has memory semantics of getVolatile.2006* The set operation has the memory semantics of setVolatile.2007*2008* @param obj object into which to store the value2009* @param offset location to compare and store value in obj2010* @param compareValue value that is expected to be in obj at offset2011* @param setValue value that will be set in obj at offset if compare is successful2012* @return boolean value indicating whether the field was updated2013*/2014public final boolean compareAndSetFloat(Object obj, long offset, float compareValue, float setValue) {2015return compareAndSetInt(obj, offset, Float.floatToRawIntBits(compareValue), Float.floatToRawIntBits(setValue));2016}20172018/**2019* Atomically sets the parameter value at offset in obj if the compare value2020* matches the existing value in the object.2021* The get operation has memory semantics of get.2022* The set operation has the memory semantics of set.2023*2024* @param obj object into which to store the value2025* @param offset location to compare and store value in obj2026* @param compareValue value that is expected to be in obj at offset2027* @param exchangeValue value that will be set in obj at offset if compare is successful2028* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2029*/2030public final float compareAndExchangeFloat(Object obj, long offset, float compareValue, float exchangeValue) {2031int result = compareAndExchangeInt(obj, offset, Float.floatToRawIntBits(compareValue),2032Float.floatToRawIntBits(exchangeValue));2033return Float.intBitsToFloat(result);2034}20352036/**2037* Atomically sets the parameter value at offset in obj if the compare value2038* matches the existing value in the object.2039* The get operation has memory semantics of getAcquire.2040* The set operation has the memory semantics of set.2041*2042* @param obj object into which to store the value2043* @param offset location to compare and store value in obj2044* @param compareValue value that is expected to be in obj at offset2045* @param exchangeValue value that will be set in obj at offset if compare is successful2046* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2047*/2048public final float compareAndExchangeFloatAcquire(Object obj, long offset, float compareValue,2049float exchangeValue) {2050int result = compareAndExchangeIntAcquire(obj, offset, Float.floatToRawIntBits(compareValue),2051Float.floatToRawIntBits(exchangeValue));2052return Float.intBitsToFloat(result);2053}20542055/**2056* Atomically sets the parameter value at offset in obj if the compare value2057* matches the existing value in the object.2058* The get operation has memory semantics of get.2059* The set operation has the memory semantics of setRelease.2060*2061* @param obj object into which to store the value2062* @param offset location to compare and store value in obj2063* @param compareValue value that is expected to be in obj at offset2064* @param exchangeValue value that will be set in obj at offset if compare is successful2065* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2066*/2067public final float compareAndExchangeFloatRelease(Object obj, long offset, float compareValue,2068float exchangeValue) {2069int result = compareAndExchangeIntRelease(obj, offset, Float.floatToRawIntBits(compareValue),2070Float.floatToRawIntBits(exchangeValue));2071return Float.intBitsToFloat(result);2072}20732074/**2075* Sets the parameter value at offset in obj if the compare value2076* matches the existing value in the object.2077* The get operation has memory semantics of get.2078* The set operation has the memory semantics of set.2079*2080* @param obj object into which to store the value2081* @param offset location to compare and store value in obj2082* @param compareValue value that is expected to be in obj at offset2083* @param setValue value that will be set in obj at offset if compare is successful2084* @return boolean value indicating whether the field was updated2085*/2086public final boolean weakCompareAndSetFloatPlain(Object obj, long offset, float compareValue, float setValue) {2087return weakCompareAndSetIntPlain(obj, offset, Float.floatToRawIntBits(compareValue),2088Float.floatToRawIntBits(setValue));2089}20902091/**2092* Sets the parameter value at offset in obj if the compare value2093* matches the existing value in the object.2094* The get operation has memory semantics of getAcquire.2095* The set operation has the memory semantics of set.2096*2097* @param obj object into which to store the value2098* @param offset location to compare and store value in obj2099* @param compareValue value that is expected to be in obj at offset2100* @param setValue value that will be set in obj at offset if compare is successful2101* @return boolean value indicating whether the field was updated2102*/2103public final boolean weakCompareAndSetFloatAcquire(Object obj, long offset, float compareValue, float setValue) {2104return weakCompareAndSetIntAcquire(obj, offset, Float.floatToRawIntBits(compareValue),2105Float.floatToRawIntBits(setValue));2106}21072108/**2109* Sets the parameter value at offset in obj if the compare value2110* matches the existing value in the object.2111* The get operation has memory semantics of get.2112* The set operation has the memory semantics of setRelease.2113*2114* @param obj object into which to store the value2115* @param offset location to compare and store value in obj2116* @param compareValue value that is expected to be in obj at offset2117* @param setValue value that will be set in obj at offset if compare is successful2118* @return boolean value indicating whether the field was updated2119*/2120public final boolean weakCompareAndSetFloatRelease(Object obj, long offset, float compareValue, float setValue) {2121return weakCompareAndSetIntRelease(obj, offset, Float.floatToRawIntBits(compareValue),2122Float.floatToRawIntBits(setValue));2123}21242125/**2126* Sets the parameter value at offset in obj if the compare value2127* matches the existing value in the object.2128* The get operation has memory semantics of get.2129* The set operation has the memory semantics of set.2130*2131* @param obj object into which to store the value2132* @param offset location to compare and store value in obj2133* @param compareValue value that is expected to be in obj at offset2134* @param setValue value that will be set in obj at offset if compare is successful2135* @return boolean value indicating whether the field was updated2136*/2137public final boolean weakCompareAndSetFloat(Object obj, long offset, float compareValue, float setValue) {2138return weakCompareAndSetInt(obj, offset, Float.floatToRawIntBits(compareValue),2139Float.floatToRawIntBits(setValue));2140}21412142/**2143* Atomically sets the parameter value at offset in obj if the compare value2144* matches the existing value in the object.2145* The get operation has memory semantics of getVolatile.2146* The set operation has the memory semantics of setVolatile.2147*2148* @param obj object into which to store the value2149* @param offset location to compare and store value in obj2150* @param compareValue value that is expected to be in obj at offset2151* @param setValue value that will be set in obj at offset if compare is successful2152* @return boolean value indicating whether the field was updated2153*/2154public final boolean compareAndSetDouble(Object obj, long offset, double compareValue, double setValue) {2155return compareAndSetLong(obj, offset, Double.doubleToRawLongBits(compareValue),2156Double.doubleToRawLongBits(setValue));2157}21582159/**2160* Atomically sets the parameter value at offset in obj if the compare value2161* matches the existing value in the object.2162* The get operation has memory semantics of get.2163* The set operation has the memory semantics of set.2164*2165* @param obj object into which to store the value2166* @param offset location to compare and store value in obj2167* @param compareValue value that is expected to be in obj at offset2168* @param exchangeValue value that will be set in obj at offset if compare is successful2169* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2170*/2171public final double compareAndExchangeDouble(Object obj, long offset, double compareValue, double exchangeValue) {2172long result = compareAndExchangeLong(obj, offset, Double.doubleToRawLongBits(compareValue),2173Double.doubleToRawLongBits(exchangeValue));2174return Double.longBitsToDouble(result);2175}21762177/**2178* Atomically sets the parameter value at offset in obj if the compare value2179* matches the existing value in the object.2180* The get operation has memory semantics of getAcquire.2181* The set operation has the memory semantics of set.2182*2183* @param obj object into which to store the value2184* @param offset location to compare and store value in obj2185* @param compareValue value that is expected to be in obj at offset2186* @param exchangeValue value that will be set in obj at offset if compare is successful2187* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2188*/2189public final double compareAndExchangeDoubleAcquire(Object obj, long offset, double compareValue,2190double exchangeValue) {2191long result = compareAndExchangeLongAcquire(obj, offset, Double.doubleToRawLongBits(compareValue),2192Double.doubleToRawLongBits(exchangeValue));2193return Double.longBitsToDouble(result);2194}21952196/**2197* Atomically sets the parameter value at offset in obj if the compare value2198* matches the existing value in the object.2199* The get operation has memory semantics of get.2200* The set operation has the memory semantics of setRelease.2201*2202* @param obj object into which to store the value2203* @param offset location to compare and store value in obj2204* @param compareValue value that is expected to be in obj at offset2205* @param exchangeValue value that will be set in obj at offset if compare is successful2206* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2207*/2208public final double compareAndExchangeDoubleRelease(Object obj, long offset, double compareValue,2209double exchangeValue) {2210long result = compareAndExchangeLongRelease(obj, offset, Double.doubleToRawLongBits(compareValue),2211Double.doubleToRawLongBits(exchangeValue));2212return Double.longBitsToDouble(result);2213}22142215/**2216* Sets the parameter value at offset in obj if the compare value2217* matches the existing value in the object.2218* The get operation has memory semantics of get.2219* The set operation has the memory semantics of set.2220*2221* @param obj object into which to store the value2222* @param offset location to compare and store value in obj2223* @param compareValue value that is expected to be in obj at offset2224* @param setValue value that will be set in obj at offset if compare is successful2225* @return boolean value indicating whether the field was updated2226*/2227public final boolean weakCompareAndSetDoublePlain(Object obj, long offset, double compareValue, double swapValue) {2228return weakCompareAndSetLongPlain(obj, offset, Double.doubleToRawLongBits(compareValue),2229Double.doubleToRawLongBits(swapValue));2230}22312232/**2233* Sets the parameter value at offset in obj if the compare value2234* matches the existing value in the object.2235* The get operation has memory semantics of getAcquire.2236* The set operation has the memory semantics of set.2237*2238* @param obj object into which to store the value2239* @param offset location to compare and store value in obj2240* @param compareValue value that is expected to be in obj at offset2241* @param setValue value that will be set in obj at offset if compare is successful2242* @return boolean value indicating whether the field was updated2243*/2244public final boolean weakCompareAndSetDoubleAcquire(Object obj, long offset, double compareValue,2245double swapValue) {2246return weakCompareAndSetLongAcquire(obj, offset, Double.doubleToRawLongBits(compareValue),2247Double.doubleToRawLongBits(swapValue));2248}22492250/**2251* Sets the parameter value at offset in obj if the compare value2252* matches the existing value in the object.2253* The get operation has memory semantics of get.2254* The set operation has the memory semantics of setRelease.2255*2256* @param obj object into which to store the value2257* @param offset location to compare and store value in obj2258* @param compareValue value that is expected to be in obj at offset2259* @param setValue value that will be set in obj at offset if compare is successful2260* @return boolean value indicating whether the field was updated2261*/2262public final boolean weakCompareAndSetDoubleRelease(Object obj, long offset, double compareValue,2263double swapValue) {2264return weakCompareAndSetLongRelease(obj, offset, Double.doubleToRawLongBits(compareValue),2265Double.doubleToRawLongBits(swapValue));2266}22672268/**2269* Sets the parameter value at offset in obj if the compare value2270* matches the existing value in the object.2271* The get operation has memory semantics of get.2272* The set operation has the memory semantics of set.2273*2274* @param obj object into which to store the value2275* @param offset location to compare and store value in obj2276* @param compareValue value that is expected to be in obj at offset2277* @param setValue value that will be set in obj at offset if compare is successful2278* @return boolean value indicating whether the field was updated2279*/2280public final boolean weakCompareAndSetDouble(Object obj, long offset, double compareValue, double swapValue) {2281return weakCompareAndSetLong(obj, offset, Double.doubleToRawLongBits(compareValue),2282Double.doubleToRawLongBits(swapValue));2283}22842285/**2286* Atomically sets the parameter value at offset in obj if the compare value2287* matches the existing value in the object.2288* The get operation has memory semantics of get.2289* The set operation has the memory semantics of set.2290*2291* @param obj object into which to store the value2292* @param offset location to compare and store value in obj2293* @param compareValue value that is expected to be in obj at offset2294* @param exchangeValue value that will be set in obj at offset if compare is successful2295* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2296*2297* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2298*/2299public final short compareAndExchangeShort(Object obj, long offset, short compareValue, short exchangeValue) {2300compareAndExchange16BitsOffsetChecks(offset);2301return compareAndExchange16bits(obj, offset, compareValue, exchangeValue);2302}23032304/**2305* Atomically sets the parameter value at offset in obj if the compare value2306* matches the existing value in the object.2307* The get operation has memory semantics of getVolatile.2308* The set operation has the memory semantics of setVolatile.2309*2310* @param obj object into which to store the value2311* @param offset location to compare and store value in obj2312* @param compareValue value that is expected to be in obj at offset2313* @param setValue value that will be set in obj at offset if compare is successful2314* @return boolean value indicating whether the field was updated2315*2316* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2317*/2318public final boolean compareAndSetShort(Object obj, long offset, short compareValue, short setValue) {2319short exchangedValue = compareAndExchangeShort(obj, offset, compareValue, setValue);2320return (compareValue == exchangedValue);2321}23222323/**2324* Sets the parameter value at offset in obj if the compare value2325* matches the existing value in the object.2326* The get operation has memory semantics of get.2327* The set operation has the memory semantics of set.2328*2329* @param obj object into which to store the value2330* @param offset location to compare and store value in obj2331* @param compareValue value that is expected to be in obj at offset2332* @param setValue value that will be set in obj at offset if compare is successful2333* @return boolean value indicating whether the field was updated2334*2335* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2336*/2337public final boolean weakCompareAndSetShort(Object obj, long offset, short compareValue, short setValue) {2338return compareAndSetShort(obj, offset, compareValue, setValue);2339}23402341/**2342* Sets the parameter value at offset in obj if the compare value2343* matches the existing value in the object.2344* The get operation has memory semantics of getAcquire.2345* The set operation has the memory semantics of set.2346*2347* @param obj object into which to store the value2348* @param offset location to compare and store value in obj2349* @param compareValue value that is expected to be in obj at offset2350* @param setValue value that will be set in obj at offset if compare is successful2351* @return boolean value indicating whether the field was updated2352*2353* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2354*/2355public final boolean weakCompareAndSetShortAcquire(Object obj, long offset, short compareValue, short setValue) {2356return weakCompareAndSetShort(obj, offset, compareValue, setValue);2357}23582359/**2360* Sets the parameter value at offset in obj if the compare value2361* matches the existing value in the object.2362* The get operation has memory semantics of get.2363* The set operation has the memory semantics of setRelease.2364*2365* @param obj object into which to store the value2366* @param offset location to compare and store value in obj2367* @param compareValue value that is expected to be in obj at offset2368* @param setValue value that will be set in obj at offset if compare is successful2369* @return boolean value indicating whether the field was updated2370*2371* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2372*/2373public final boolean weakCompareAndSetShortRelease(Object obj, long offset, short compareValue, short setValue) {2374return weakCompareAndSetShort(obj, offset, compareValue, setValue);2375}23762377/**2378* Sets the parameter value at offset in obj if the compare value2379* matches the existing value in the object.2380* The get operation has memory semantics of get.2381* The set operation has the memory semantics of set.2382*2383* @param obj object into which to store the value2384* @param offset location to compare and store value in obj2385* @param compareValue value that is expected to be in obj at offset2386* @param setValue value that will be set in obj at offset if compare is successful2387* @return boolean value indicating whether the field was updated2388*2389* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2390*/2391public final boolean weakCompareAndSetShortPlain(Object obj, long offset, short compareValue, short setValue) {2392return weakCompareAndSetShort(obj, offset, compareValue, setValue);2393}23942395/**2396* Atomically sets the parameter value at offset in obj if the compare value2397* matches the existing value in the object.2398* The get operation has memory semantics of get.2399* The set operation has the memory semantics of set.2400*2401* @param obj object into which to store the value2402* @param offset location to compare and store value in obj2403* @param compareValue value that is expected to be in obj at offset2404* @param exchangeValue value that will be set in obj at offset if compare is successful2405* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2406*2407* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2408*/2409public final short compareAndExchangeShortAcquire(Object obj, long offset, short compareValue,2410short exchangeValue) {2411return compareAndExchangeShort(obj, offset, compareValue, exchangeValue);2412}24132414/**2415* Atomically sets the parameter value at offset in obj if the compare value2416* matches the existing value in the object.2417* The get operation has memory semantics of get.2418* The set operation has the memory semantics of set.2419*2420* @param obj object into which to store the value2421* @param offset location to compare and store value in obj2422* @param compareValue value that is expected to be in obj at offset2423* @param exchangeValue value that will be set in obj at offset if compare is successful2424* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2425*2426* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2427*/2428public final short compareAndExchangeShortRelease(Object obj, long offset, short compareValue,2429short exchangeValue) {2430return compareAndExchangeShort(obj, offset, compareValue, exchangeValue);2431}24322433/**2434* Atomically sets the parameter value at offset in obj if the compare value2435* matches the existing value in the object.2436* The get operation has memory semantics of getVolatile.2437* The set operation has the memory semantics of setVolatile.2438*2439* @param obj object into which to store the value2440* @param offset location to compare and store value in obj2441* @param compareValue value that is expected to be in obj at offset2442* @param setValue value that will be set in obj at offset if compare is successful2443* @return boolean value indicating whether the field was updated2444*2445* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2446*/2447public final boolean compareAndSetChar(Object obj, long offset, char compareValue, char setValue) {2448char exchangedValue = compareAndExchangeChar(obj, offset, compareValue, setValue);2449return (compareValue == exchangedValue);2450}24512452/**2453* Atomically sets the parameter value at offset in obj if the compare value2454* matches the existing value in the object.2455* The get operation has memory semantics of get.2456* The set operation has the memory semantics of set.2457*2458* @param obj object into which to store the value2459* @param offset location to compare and store value in obj2460* @param compareValue value that is expected to be in obj at offset2461* @param exchangeValue value that will be set in obj at offset if compare is successful2462* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2463*2464* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2465*/2466public final char compareAndExchangeChar(Object obj, long offset, char compareValue, char exchangeValue) {2467compareAndExchange16BitsOffsetChecks(offset);2468short result = compareAndExchange16bits(obj, offset, compareValue, exchangeValue);2469return s2c(result);2470}24712472/**2473* Atomically sets the parameter value at offset in obj if the compare value2474* matches the existing value in the object.2475* The get operation has memory semantics of getAcquire.2476* The set operation has the memory semantics of set.2477*2478* @param obj object into which to store the value2479* @param offset location to compare and store value in obj2480* @param compareValue value that is expected to be in obj at offset2481* @param exchangeValue value that will be set in obj at offset if compare is successful2482* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2483*2484* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2485*/2486public final char compareAndExchangeCharAcquire(Object obj, long offset, char compareValue, char exchangeValue) {2487return compareAndExchangeChar(obj, offset, compareValue, exchangeValue);2488}24892490/**2491* Atomically sets the parameter value at offset in obj if the compare value2492* matches the existing value in the object.2493* The get operation has memory semantics of get.2494* The set operation has the memory semantics of setRelease.2495*2496* @param obj object into which to store the value2497* @param offset location to compare and store value in obj2498* @param compareValue value that is expected to be in obj at offset2499* @param exchangeValue value that will be set in obj at offset if compare is successful2500* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2501*2502* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2503*/2504public final char compareAndExchangeCharRelease(Object obj, long offset, char compareValue, char exchangeValue) {2505return compareAndExchangeChar(obj, offset, compareValue, exchangeValue);2506}25072508/**2509* Sets the parameter value at offset in obj if the compare value2510* matches the existing value in the object.2511* The get operation has memory semantics of get.2512* The set operation has the memory semantics of set.2513*2514* @param obj object into which to store the value2515* @param offset location to compare and store value in obj2516* @param compareValue value that is expected to be in obj at offset2517* @param setValue value that will be set in obj at offset if compare is successful2518* @return boolean value indicating whether the field was updated2519*2520* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2521*/2522public final boolean weakCompareAndSetChar(Object obj, long offset, char compareValue, char setValue) {2523return compareAndSetChar(obj, offset, compareValue, setValue);2524}25252526/**2527* Sets the parameter value at offset in obj if the compare value2528* matches the existing value in the object.2529* The get operation has memory semantics of getAcquire.2530* The set operation has the memory semantics of set.2531*2532* @param obj object into which to store the value2533* @param offset location to compare and store value in obj2534* @param compareValue value that is expected to be in obj at offset2535* @param setValue value that will be set in obj at offset if compare is successful2536* @return boolean value indicating whether the field was updated2537*2538* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2539*/2540public final boolean weakCompareAndSetCharAcquire(Object obj, long offset, char compareValue, char setValue) {2541return weakCompareAndSetChar(obj, offset, compareValue, setValue);2542}25432544/**2545* Sets the parameter value at offset in obj if the compare value2546* matches the existing value in the object.2547* The get operation has memory semantics of get.2548* The set operation has the memory semantics of setRelease.2549*2550* @param obj object into which to store the value2551* @param offset location to compare and store value in obj2552* @param compareValue value that is expected to be in obj at offset2553* @param setValue value that will be set in obj at offset if compare is successful2554* @return boolean value indicating whether the field was updated2555*2556* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2557*/2558public final boolean weakCompareAndSetCharRelease(Object obj, long offset, char compareValue, char setValue) {2559return weakCompareAndSetChar(obj, offset, compareValue, setValue);2560}25612562/**2563* Sets the parameter value at offset in obj if the compare value2564* matches the existing value in the object.2565* The get operation has memory semantics of get.2566* The set operation has the memory semantics of set.2567*2568* @param obj object into which to store the value2569* @param offset location to compare and store value in obj2570* @param compareValue value that is expected to be in obj at offset2571* @param setValue value that will be set in obj at offset if compare is successful2572* @return boolean value indicating whether the field was updated2573*2574* @throws IllegalArgumentException if value at offset spans over multiple aligned words (4 bytes) in memory2575*/2576public final boolean weakCompareAndSetCharPlain(Object obj, long offset, char compareValue, char setValue) {2577return weakCompareAndSetChar(obj, offset, compareValue, setValue);2578}25792580/**2581* Atomically sets the parameter value at offset in obj if the compare value2582* matches the existing value in the object.2583* The get operation has memory semantics of getVolatile.2584* The set operation has the memory semantics of setVolatile.2585*2586* @param obj object into which to store the value2587* @param offset location to compare and store value in obj2588* @param compareValue value that is expected to be in obj at offset2589* @param setValue value that will be set in obj at offset if compare is successful2590* @return boolean value indicating whether the field was updated2591*/2592public final boolean compareAndSetBoolean(Object obj, long offset, boolean compareValue, boolean setValue) {2593return compareAndSetByte(obj, offset, bool2byte(compareValue), bool2byte(setValue));2594}25952596/**2597* Atomically sets the parameter value at offset in obj if the compare value2598* matches the existing value in the object.2599* The get operation has memory semantics of get.2600* The set operation has the memory semantics of set.2601*2602* @param obj object into which to store the value2603* @param offset location to compare and store value in obj2604* @param compareValue value that is expected to be in obj at offset2605* @param exchangeValue value that will be set in obj at offset if compare is successful2606* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2607*/2608public final boolean compareAndExchangeBoolean(Object obj, long offset, boolean compareValue,2609boolean exchangeValue) {2610byte result = compareAndExchange8bits(obj, offset, bool2byte(compareValue), bool2byte(exchangeValue));2611return byte2bool(result);2612}26132614/**2615* Atomically sets the parameter value at offset in obj if the compare value2616* matches the existing value in the object.2617* The get operation has memory semantics of getAcquire.2618* The set operation has the memory semantics of set.2619*2620* @param obj object into which to store the value2621* @param offset location to compare and store value in obj2622* @param compareValue value that is expected to be in obj at offset2623* @param exchangeValue value that will be set in obj at offset if compare is successful2624* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2625*/2626public final boolean compareAndExchangeBooleanAcquire(Object obj, long offset, boolean compareValue,2627boolean exchangeValue) {2628byte result = compareAndExchangeByteAcquire(obj, offset, bool2byte(compareValue), bool2byte(exchangeValue));2629return byte2bool(result);2630}26312632/**2633* Atomically sets the parameter value at offset in obj if the compare value2634* matches the existing value in the object.2635* The get operation has memory semantics of get.2636* The set operation has the memory semantics of setRelease.2637*2638* @param obj object into which to store the value2639* @param offset location to compare and store value in obj2640* @param compareValue value that is expected to be in obj at offset2641* @param exchangeValue value that will be set in obj at offset if compare is successful2642* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2643*/2644public final boolean compareAndExchangeBooleanRelease(Object obj, long offset, boolean compareValue,2645boolean exchangeValue) {2646byte result = compareAndExchangeByteRelease(obj, offset, bool2byte(compareValue), bool2byte(exchangeValue));2647return byte2bool(result);2648}26492650/**2651* Sets the parameter value at offset in obj if the compare value2652* matches the existing value in the object.2653* The get operation has memory semantics of get.2654* The set operation has the memory semantics of set.2655*2656* @param obj object into which to store the value2657* @param offset location to compare and store value in obj2658* @param compareValue value that is expected to be in obj at offset2659* @param setValue value that will be set in obj at offset if compare is successful2660* @return boolean value indicating whether the field was updated2661*/2662public final boolean weakCompareAndSetBoolean(Object obj, long offset, boolean compareValue, boolean setValue) {2663return weakCompareAndSetByte(obj, offset, bool2byte(compareValue), bool2byte(setValue));2664}26652666/**2667* Sets the parameter value at offset in obj if the compare value2668* matches the existing value in the object.2669* The get operation has memory semantics of getAcquire.2670* The set operation has the memory semantics of set.2671*2672* @param obj object into which to store the value2673* @param offset location to compare and store value in obj2674* @param compareValue value that is expected to be in obj at offset2675* @param setValue value that will be set in obj at offset if compare is successful2676* @return boolean value indicating whether the field was updated2677*/2678public final boolean weakCompareAndSetBooleanAcquire(Object obj, long offset, boolean compareValue,2679boolean setValue) {2680return weakCompareAndSetByteAcquire(obj, offset, bool2byte(compareValue), bool2byte(setValue));2681}26822683/**2684* Sets the parameter value at offset in obj if the compare value2685* matches the existing value in the object.2686* The get operation has memory semantics of get.2687* The set operation has the memory semantics of setRelease.2688*2689* @param obj object into which to store the value2690* @param offset location to compare and store value in obj2691* @param compareValue value that is expected to be in obj at offset2692* @param setValue value that will be set in obj at offset if compare is successful2693* @return boolean value indicating whether the field was updated2694*/2695public final boolean weakCompareAndSetBooleanRelease(Object obj, long offset, boolean compareValue,2696boolean setValue) {2697return weakCompareAndSetByteRelease(obj, offset, bool2byte(compareValue), bool2byte(setValue));2698}26992700/**2701* Sets the parameter value at offset in obj if the compare value2702* matches the existing value in the object.2703* The get operation has memory semantics of get.2704* The set operation has the memory semantics of set.2705*2706* @param obj object into which to store the value2707* @param offset location to compare and store value in obj2708* @param compareValue value that is expected to be in obj at offset2709* @param setValue value that will be set in obj at offset if compare is successful2710* @return boolean value indicating whether the field was updated2711*/2712public final boolean weakCompareAndSetBooleanPlain(Object obj, long offset, boolean compareValue,2713boolean setValue) {2714return weakCompareAndSetBytePlain(obj, offset, bool2byte(compareValue), bool2byte(setValue));2715}27162717/**2718* Atomically sets the parameter value at offset in obj if the compare value2719* matches the existing value in the object.2720* The get operation has memory semantics of getAcquire.2721* The set operation has the memory semantics of set.2722*2723* @param obj object into which to store the value2724* @param offset location to compare and store value in obj2725* @param compareValue value that is expected to be in obj at offset2726* @param exchangeValue value that will be set in obj at offset if compare is successful2727* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2728*/2729public final Object compareAndExchangeObjectAcquire(Object obj, long offset, Object compareValue,2730Object exchangeValue) {2731return compareAndExchangeObject(obj, offset, compareValue, exchangeValue);2732}27332734/**2735* Atomically sets the parameter value at offset in obj if the compare value2736* matches the existing value in the object.2737* The get operation has memory semantics of get.2738* The set operation has the memory semantics of setRelease.2739*2740* @param obj object into which to store the value2741* @param offset location to compare and store value in obj2742* @param compareValue value that is expected to be in obj at offset2743* @param exchangeValue value that will be set in obj at offset if compare is successful2744* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2745*/2746public final Object compareAndExchangeObjectRelease(Object obj, long offset, Object compareValue,2747Object exchangeValue) {2748return compareAndExchangeObject(obj, offset, compareValue, exchangeValue);2749}27502751/**2752* Sets the parameter value at offset in obj if the compare value2753* matches the existing value in the object.2754* The get operation has memory semantics of get.2755* The set operation has the memory semantics of set.2756*2757* @param obj object into which to store the value2758* @param offset location to compare and store value in obj2759* @param compareValue value that is expected to be in obj at offset2760* @param setValue value that will be set in obj at offset if compare is successful2761* @return boolean value indicating whether the field was updated2762*/2763public final boolean weakCompareAndSetObjectPlain(Object obj, long offset, Object compareValue, Object setValue) {2764return compareAndSetObject(obj, offset, compareValue, setValue);2765}27662767/**2768* Sets the parameter value at offset in obj if the compare value2769* matches the existing value in the object.2770* The get operation has memory semantics of getAcquire.2771* The set operation has the memory semantics of set.2772*2773* @param obj object into which to store the value2774* @param offset location to compare and store value in obj2775* @param compareValue value that is expected to be in obj at offset2776* @param setValue value that will be set in obj at offset if compare is successful2777* @return boolean value indicating whether the field was updated2778*/2779public final boolean weakCompareAndSetObjectAcquire(Object obj, long offset, Object compareValue, Object setValue) {2780return compareAndSetObject(obj, offset, compareValue, setValue);2781}27822783/**2784* Sets the parameter value at offset in obj if the compare value2785* matches the existing value in the object.2786* The get operation has memory semantics of get.2787* The set operation has the memory semantics of setRelease.2788*2789* @param obj object into which to store the value2790* @param offset location to compare and store value in obj2791* @param compareValue value that is expected to be in obj at offset2792* @param setValue value that will be set in obj at offset if compare is successful2793* @return boolean value indicating whether the field was updated2794*/2795public final boolean weakCompareAndSetObjectRelease(Object obj, long offset, Object compareValue, Object setValue) {2796return compareAndSetObject(obj, offset, compareValue, setValue);2797}27982799/**2800* Sets the parameter value at offset in obj if the compare value2801* matches the existing value in the object.2802* The get operation has memory semantics of get.2803* The set operation has the memory semantics of set.2804*2805* @param obj object into which to store the value2806* @param offset location to compare and store value in obj2807* @param compareValue value that is expected to be in obj at offset2808* @param setValue value that will be set in obj at offset if compare is successful2809* @return boolean value indicating whether the field was updated2810*/2811public final boolean weakCompareAndSetObject(Object obj, long offset, Object compareValue, Object setValue) {2812return compareAndSetObject(obj, offset, compareValue, setValue);2813}28142815/*[IF JAVA_SPEC_VERSION >= 12]*/2816/**2817* Atomically sets the parameter value at offset in obj if the compare value2818* matches the existing value in the object.2819* The get operation has memory semantics of getAcquire.2820* The set operation has the memory semantics of set.2821*2822* @param obj object into which to store the value2823* @param offset location to compare and store value in obj2824* @param compareValue value that is expected to be in obj at offset2825* @param exchangeValue value that will be set in obj at offset if compare is successful2826* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2827*/2828public final Object compareAndExchangeReferenceAcquire(Object obj, long offset, Object compareValue,2829Object exchangeValue) {2830return compareAndExchangeReference(obj, offset, compareValue, exchangeValue);2831}28322833/**2834* Atomically sets the parameter value at offset in obj if the compare value2835* matches the existing value in the object.2836* The get operation has memory semantics of get.2837* The set operation has the memory semantics of setRelease.2838*2839* @param obj object into which to store the value2840* @param offset location to compare and store value in obj2841* @param compareValue value that is expected to be in obj at offset2842* @param exchangeValue value that will be set in obj at offset if compare is successful2843* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful2844*/2845public final Object compareAndExchangeReferenceRelease(Object obj, long offset, Object compareValue,2846Object exchangeValue) {2847return compareAndExchangeReference(obj, offset, compareValue, exchangeValue);2848}28492850/**2851* Sets the parameter value at offset in obj if the compare value2852* matches the existing value in the object.2853* The get operation has memory semantics of get.2854* The set operation has the memory semantics of set.2855*2856* @param obj object into which to store the value2857* @param offset location to compare and store value in obj2858* @param compareValue value that is expected to be in obj at offset2859* @param setValue value that will be set in obj at offset if compare is successful2860* @return boolean value indicating whether the field was updated2861*/2862public final boolean weakCompareAndSetReferencePlain(Object obj, long offset, Object compareValue, Object setValue) {2863return compareAndSetReference(obj, offset, compareValue, setValue);2864}28652866/**2867* Sets the parameter value at offset in obj if the compare value2868* matches the existing value in the object.2869* The get operation has memory semantics of getAcquire.2870* The set operation has the memory semantics of set.2871*2872* @param obj object into which to store the value2873* @param offset location to compare and store value in obj2874* @param compareValue value that is expected to be in obj at offset2875* @param setValue value that will be set in obj at offset if compare is successful2876* @return boolean value indicating whether the field was updated2877*/2878public final boolean weakCompareAndSetReferenceAcquire(Object obj, long offset, Object compareValue, Object setValue) {2879return compareAndSetReference(obj, offset, compareValue, setValue);2880}28812882/**2883* Sets the parameter value at offset in obj if the compare value2884* matches the existing value in the object.2885* The get operation has memory semantics of get.2886* The set operation has the memory semantics of setRelease.2887*2888* @param obj object into which to store the value2889* @param offset location to compare and store value in obj2890* @param compareValue value that is expected to be in obj at offset2891* @param setValue value that will be set in obj at offset if compare is successful2892* @return boolean value indicating whether the field was updated2893*/2894public final boolean weakCompareAndSetReferenceRelease(Object obj, long offset, Object compareValue, Object setValue) {2895return compareAndSetReference(obj, offset, compareValue, setValue);2896}28972898/**2899* Sets the parameter value at offset in obj if the compare value2900* matches the existing value in the object.2901* The get operation has memory semantics of get.2902* The set operation has the memory semantics of set.2903*2904* @param obj object into which to store the value2905* @param offset location to compare and store value in obj2906* @param compareValue value that is expected to be in obj at offset2907* @param setValue value that will be set in obj at offset if compare is successful2908* @return boolean value indicating whether the field was updated2909*/2910public final boolean weakCompareAndSetReference(Object obj, long offset, Object compareValue, Object setValue) {2911return compareAndSetReference(obj, offset, compareValue, setValue);2912}2913/*[ENDIF] JAVA_SPEC_VERSION >= 12 */29142915/**2916* Gets the value of the byte in the obj parameter referenced by offset using acquire semantics.2917* Preceding loads will not be reordered with subsequent loads/stores.2918*2919* @param obj object from which to retrieve the value2920* @param offset position of the value in obj2921* @return byte value stored in obj2922*/2923public final byte getByteAcquire(Object obj, long offset) {2924return getByteVolatile(obj, offset);2925}29262927/**2928* Gets the value of the int in the obj parameter referenced by offset using acquire semantics.2929* Preceding loads will not be reordered with subsequent loads/stores.2930*2931* @param obj object from which to retrieve the value2932* @param offset position of the value in obj2933* @return int value stored in obj2934*/2935public final int getIntAcquire(Object obj, long offset) {2936return getIntVolatile(obj, offset);2937}29382939/**2940* Gets the value of the long in the obj parameter referenced by offset using acquire semantics.2941* Preceding loads will not be reordered with subsequent loads/stores.2942*2943* @param obj object from which to retrieve the value2944* @param offset position of the value in obj2945* @return long value stored in obj2946*/2947public final long getLongAcquire(Object obj, long offset) {2948return getLongVolatile(obj, offset);2949}29502951/**2952* Gets the value of the float in the obj parameter referenced by offset using acquire semantics.2953* Preceding loads will not be reordered with subsequent loads/stores.2954*2955* @param obj object from which to retrieve the value2956* @param offset position of the value in obj2957* @return float value stored in obj2958*/2959public final float getFloatAcquire(Object obj, long offset) {2960return getFloatVolatile(obj, offset);2961}29622963/**2964* Gets the value of the double in the obj parameter referenced by offset using acquire semantics.2965* Preceding loads will not be reordered with subsequent loads/stores.2966*2967* @param obj object from which to retrieve the value2968* @param offset position of the value in obj2969* @return double value stored in obj2970*/2971public final double getDoubleAcquire(Object obj, long offset) {2972return getDoubleVolatile(obj, offset);2973}29742975/**2976* Gets the value of the short in the obj parameter referenced by offset using acquire semantics.2977* Preceding loads will not be reordered with subsequent loads/stores.2978*2979* @param obj object from which to retrieve the value2980* @param offset position of the value in obj2981* @return short value stored in obj2982*/2983public final short getShortAcquire(Object obj, long offset) {2984return getShortVolatile(obj, offset);2985}29862987/**2988* Gets the value of the char in the obj parameter referenced by offset using acquire semantics.2989* Preceding loads will not be reordered with subsequent loads/stores.2990*2991* @param obj object from which to retrieve the value2992* @param offset position of the value in obj2993* @return char value stored in obj2994*/2995public final char getCharAcquire(Object obj, long offset) {2996return getCharVolatile(obj, offset);2997}29982999/**3000* Gets the value of the boolean in the obj parameter referenced by offset using acquire semantics.3001* Preceding loads will not be reordered with subsequent loads/stores.3002*3003* @param obj object from which to retrieve the value3004* @param offset position of the value in obj3005* @return boolean value stored in obj3006*/3007public final boolean getBooleanAcquire(Object obj, long offset) {3008return getBooleanVolatile(obj, offset);3009}30103011/**3012* Gets the value of the Object in the obj parameter referenced by offset using acquire semantics.3013* Preceding loads will not be reordered with subsequent loads/stores.3014*3015* @param obj object from which to retrieve the value3016* @param offset position of the value in obj3017* @return Object value stored in obj3018*/3019public final Object getObjectAcquire(Object obj, long offset) {3020return getObjectVolatile(obj, offset);3021}30223023/*[IF JAVA_SPEC_VERSION >= 12]*/3024/**3025* Gets the value of the Object in the obj parameter referenced by offset using acquire semantics.3026* Preceding loads will not be reordered with subsequent loads/stores.3027*3028* @param obj object from which to retrieve the value3029* @param offset position of the value in obj3030* @return Object value stored in obj3031*/3032public final Object getReferenceAcquire(Object obj, long offset) {3033return getReferenceVolatile(obj, offset);3034}3035/*[ENDIF] JAVA_SPEC_VERSION >= 12 */30363037/**3038* Sets the value of the byte in the obj parameter at memory offset using acquire semantics.3039* Preceding stores will not be reordered with subsequent loads/stores.3040*3041* @param obj object into which to store the value3042* @param offset position of the value in obj3043* @param value byte to store in obj3044*/3045public final void putByteRelease(Object obj, long offset, byte value) {3046putByteVolatile(obj, offset, value);3047}30483049/**3050* Sets the value of the int in the obj parameter at memory offset using acquire semantics.3051* Preceding stores will not be reordered with subsequent loads/stores.3052*3053* @param obj object into which to store the value3054* @param offset position of the value in obj3055* @param value int to store in obj3056*/3057public final void putIntRelease(Object obj, long offset, int value) {3058putIntVolatile(obj, offset, value);3059}30603061/**3062* Sets the value of the long in the obj parameter at memory offset using acquire semantics.3063* Preceding stores will not be reordered with subsequent loads/stores.3064*3065* @param obj object into which to store the value3066* @param offset position of the value in obj3067* @param value long to store in obj3068*/3069public final void putLongRelease(Object obj, long offset, long value) {3070putLongVolatile(obj, offset, value);3071}30723073/**3074* Sets the value of the float in the obj parameter at memory offset using acquire semantics.3075* Preceding stores will not be reordered with subsequent loads/stores.3076*3077* @param obj object into which to store the value3078* @param offset position of the value in obj3079* @param value float to store in obj3080*/3081public final void putFloatRelease(Object obj, long offset, float value) {3082putFloatVolatile(obj, offset, value);3083}30843085/**3086* Sets the value of the double in the obj parameter at memory offset using acquire semantics.3087* Preceding stores will not be reordered with subsequent loads/stores.3088*3089* @param obj object into which to store the value3090* @param offset position of the value in obj3091* @param value double to store in obj3092*/3093public final void putDoubleRelease(Object obj, long offset, double value) {3094putDoubleVolatile(obj, offset, value);3095}30963097/**3098* Sets the value of the short in the obj parameter at memory offset using acquire semantics.3099* Preceding stores will not be reordered with subsequent loads/stores.3100*3101* @param obj object into which to store the value3102* @param offset position of the value in obj3103* @param value short to store in obj3104*/3105public final void putShortRelease(Object obj, long offset, short value) {3106putShortVolatile(obj, offset, value);3107}31083109/**3110* Sets the value of the char in the obj parameter at memory offset using acquire semantics.3111* Preceding stores will not be reordered with subsequent loads/stores.3112*3113* @param obj object into which to store the value3114* @param offset position of the value in obj3115* @param value char to store in obj3116*/3117public final void putCharRelease(Object obj, long offset, char value) {3118putCharVolatile(obj, offset, value);3119}31203121/**3122* Sets the value of the boolean in the obj parameter at memory offset using acquire semantics.3123* Preceding stores will not be reordered with subsequent loads/stores.3124*3125* @param obj object into which to store the value3126* @param offset position of the value in obj3127* @param value boolean to store in obj3128*/3129public final void putBooleanRelease(Object obj, long offset, boolean value) {3130putBooleanVolatile(obj, offset, value);3131}31323133/**3134* Sets the value of the Object in the obj parameter at memory offset using acquire semantics.3135* Preceding stores will not be reordered with subsequent loads/stores.3136*3137* @param obj object into which to store the value3138* @param offset position of the value in obj3139* @param value Object to store in obj3140*/3141public final void putObjectRelease(Object obj, long offset, Object value) {3142putObjectVolatile(obj, offset, value);3143}31443145/*[IF JAVA_SPEC_VERSION >= 12]*/3146/**3147* Sets the value of the Object in the obj parameter at memory offset using acquire semantics.3148* Preceding stores will not be reordered with subsequent loads/stores.3149*3150* @param obj object into which to store the value3151* @param offset position of the value in obj3152* @param value Object to store in obj3153*/3154public final void putReferenceRelease(Object obj, long offset, Object value) {3155putReferenceVolatile(obj, offset, value);3156}3157/*[ENDIF] JAVA_SPEC_VERSION >= 12 */31583159/**3160* Gets the value of the byte in the obj parameter referenced by offset.3161* The operation is in program order, but does enforce ordering with respect to other threads.3162*3163* @param obj object from which to retrieve the value3164* @param offset position of the value in obj3165* @return byte value stored in obj3166*/3167public final byte getByteOpaque(Object obj, long offset) {3168return getByteVolatile(obj, offset);3169}31703171/**3172* Gets the value of the int in the obj parameter referenced by offset.3173* The operation is in program order, but does enforce ordering with respect to other threads.3174*3175* @param obj object from which to retrieve the value3176* @param offset position of the value in obj3177* @return int value stored in obj3178*/3179public final int getIntOpaque(Object obj, long offset) {3180return getIntVolatile(obj, offset);3181}31823183/**3184* Gets the value of the long in the obj parameter referenced by offset.3185* The operation is in program order, but does enforce ordering with respect to other threads.3186*3187* @param obj object from which to retrieve the value3188* @param offset position of the value in obj3189* @return long value stored in obj3190*/3191public final long getLongOpaque(Object obj, long offset) {3192return getLongVolatile(obj, offset);3193}31943195/**3196* Gets the value of the float in the obj parameter referenced by offset.3197* The operation is in program order, but does enforce ordering with respect to other threads.3198*3199* @param obj object from which to retrieve the value3200* @param offset position of the value in obj3201* @return float value stored in obj3202*/3203public final float getFloatOpaque(Object obj, long offset) {3204return getFloatVolatile(obj, offset);3205}32063207/**3208* Gets the value of the double in the obj parameter referenced by offset.3209* The operation is in program order, but does enforce ordering with respect to other threads.3210*3211* @param obj object from which to retrieve the value3212* @param offset position of the value in obj3213* @return double value stored in obj3214*/3215public final double getDoubleOpaque(Object obj, long offset) {3216return getDoubleVolatile(obj, offset);3217}32183219/**3220* Gets the value of the short in the obj parameter referenced by offset.3221* The operation is in program order, but does enforce ordering with respect to other threads.3222*3223* @param obj object from which to retrieve the value3224* @param offset position of the value in obj3225* @return short value stored in obj3226*/3227public final short getShortOpaque(Object obj, long offset) {3228return getShortVolatile(obj, offset);3229}32303231/**3232* Gets the value of the char in the obj parameter referenced by offset.3233* The operation is in program order, but does enforce ordering with respect to other threads.3234*3235* @param obj object from which to retrieve the value3236* @param offset position of the value in obj3237* @return char value stored in obj3238*/3239public final char getCharOpaque(Object obj, long offset) {3240return getCharVolatile(obj, offset);3241}32423243/**3244* Gets the value of the boolean in the obj parameter referenced by offset.3245* The operation is in program order, but does enforce ordering with respect to other threads.3246*3247* @param obj object from which to retrieve the value3248* @param offset position of the value in obj3249* @return boolean value stored in obj3250*/3251public final boolean getBooleanOpaque(Object obj, long offset) {3252return getBooleanVolatile(obj, offset);3253}32543255/**3256* Gets the value of the Object in the obj parameter referenced by offset.3257* The operation is in program order, but does enforce ordering with respect to other threads.3258*3259* @param obj object from which to retrieve the value3260* @param offset position of the value in obj3261* @return Object value stored in obj3262*/3263public final Object getObjectOpaque(Object obj, long offset) {3264return getObjectVolatile(obj, offset);3265}32663267/*[IF JAVA_SPEC_VERSION >= 12]*/3268/**3269* Gets the value of the Object in the obj parameter referenced by offset.3270* The operation is in program order, but does enforce ordering with respect to other threads.3271*3272* @param obj object from which to retrieve the value3273* @param offset position of the value in obj3274* @return Object value stored in obj3275*/3276public final Object getReferenceOpaque(Object obj, long offset) {3277return getReferenceVolatile(obj, offset);3278}3279/*[ENDIF] JAVA_SPEC_VERSION >= 12 */32803281/**3282* Sets the value of the byte in the obj parameter at memory offset.3283* The operation is in program order, but does enforce ordering with respect to other threads.3284*3285* @param obj object into which to store the value3286* @param offset position of the value in obj3287* @param value byte to store in obj3288*/3289public final void putByteOpaque(Object obj, long offset, byte value) {3290putByteVolatile(obj, offset, value);3291}32923293/**3294* Sets the value of the int in the obj parameter at memory offset.3295* The operation is in program order, but does enforce ordering with respect to other threads.3296*3297* @param obj object into which to store the value3298* @param offset position of the value in obj3299* @param value int to store in obj3300*/3301public final void putIntOpaque(Object obj, long offset, int value) {3302putIntVolatile(obj, offset, value);3303}33043305/**3306* Sets the value of the long in the obj parameter at memory offset.3307* The operation is in program order, but does enforce ordering with respect to other threads.3308*3309* @param obj object into which to store the value3310* @param offset position of the value in obj3311* @param value long to store in obj3312*/3313public final void putLongOpaque(Object obj, long offset, long value) {3314putLongVolatile(obj, offset, value);3315}33163317/**3318* Sets the value of the float in the obj parameter at memory offset.3319* The operation is in program order, but does enforce ordering with respect to other threads.3320*3321* @param obj object into which to store the value3322* @param offset position of the value in obj3323* @param value float to store in obj3324*/3325public final void putFloatOpaque(Object obj, long offset, float value) {3326putFloatVolatile(obj, offset, value);3327}33283329/**3330* Sets the value of the double in the obj parameter at memory offset.3331* The operation is in program order, but does enforce ordering with respect to other threads.3332*3333* @param obj object into which to store the value3334* @param offset position of the value in obj3335* @param value double to store in obj3336*/3337public final void putDoubleOpaque(Object obj, long offset, double value) {3338putDoubleVolatile(obj, offset, value);3339}33403341/**3342* Sets the value of the short in the obj parameter at memory offset.3343* The operation is in program order, but does enforce ordering with respect to other threads.3344*3345* @param obj object into which to store the value3346* @param offset position of the value in obj3347* @param value short to store in obj3348*/3349public final void putShortOpaque(Object obj, long offset, short value) {3350putShortVolatile(obj, offset, value);3351}33523353/**3354* Sets the value of the char in the obj parameter at memory offset.3355* The operation is in program order, but does enforce ordering with respect to other threads.3356*3357* @param obj object into which to store the value3358* @param offset position of the value in obj3359* @param value char to store in obj3360*/3361public final void putCharOpaque(Object obj, long offset, char value) {3362putCharVolatile(obj, offset, value);3363}33643365/**3366* Sets the value of the boolean in the obj parameter at memory offset.3367* The operation is in program order, but does enforce ordering with respect to other threads.3368*3369* @param obj object into which to store the value3370* @param offset position of the value in obj3371* @param value boolean to store in obj3372*/3373public final void putBooleanOpaque(Object obj, long offset, boolean value) {3374putBooleanVolatile(obj, offset, value);3375}33763377/**3378* Sets the value of the Object in the obj parameter at memory offset.3379* The operation is in program order, but does enforce ordering with respect to other threads.3380*3381* @param obj object into which to store the value3382* @param offset position of the value in obj3383* @param value Object to store in obj3384*/3385public final void putObjectOpaque(Object obj, long offset, Object value) {3386putObjectVolatile(obj, offset, value);3387}33883389/*[IF JAVA_SPEC_VERSION >= 12]*/3390/**3391* Sets the value of the Object in the obj parameter at memory offset.3392* The operation is in program order, but does enforce ordering with respect to other threads.3393*3394* @param obj object into which to store the value3395* @param offset position of the value in obj3396* @param value Object to store in obj3397*/3398public final void putReferenceOpaque(Object obj, long offset, Object value) {3399putReferenceVolatile(obj, offset, value);3400}3401/*[ENDIF] JAVA_SPEC_VERSION >= 12 */34023403/**3404* Get the load average in the system.3405*3406* NOTE: native implementation is a stub.3407*3408* @param loadavg array of elements3409* @param numberOfElements number of samples3410* @return load average3411*3412* @throws ArrayIndexOutOfBoundsException if numberOfElements is negative, more than three, or3413* the length of the loadavg array is greater than the numberOfElements3414*/3415public int getLoadAverage(double[] loadavg, int numberOfElements) {3416if ((numberOfElements < 0) || (numberOfElements > 3) || (loadavg.length > numberOfElements)) {3417throw new ArrayIndexOutOfBoundsException();3418}34193420return getLoadAverage0(loadavg, numberOfElements);3421}34223423/**3424* Atomically adds to the current value of the field at offset in obj3425* and returns the value of the field prior to the update.3426* The get operation has the memory semantics of getVolatile.3427* The set operation has the memory semantics of setVolatile.3428*3429* @param obj object into which to add the value3430* @param offset location to add value in obj3431* @param value to add to existing value in field3432* @return value of field in obj at offset before update3433*/3434public final byte getAndAddByte(Object obj, long offset, byte value) {3435for (;;) {3436byte byteAtOffset = getByteVolatile(obj, offset);3437if (weakCompareAndSetByte(obj, offset, byteAtOffset, (byte) (byteAtOffset + value))) {3438return byteAtOffset;3439}3440}3441}34423443/**3444* Atomically adds to the current value of the field at offset in obj3445* and returns the value of the field prior to the update.3446* The get operation has the memory semantics of get.3447* The set operation has the memory semantics of setRelease.3448*3449* @param obj object into which to add the value3450* @param offset location to add value in obj3451* @param value to add to existing value in field3452* @return value of field in obj at offset before update3453*/3454public final byte getAndAddByteRelease(Object obj, long offset, byte value) {3455for (;;) {3456byte byteAtOffset = getByte(obj, offset);3457if (weakCompareAndSetByteRelease(obj, offset, byteAtOffset, (byte) (byteAtOffset + value))) {3458return byteAtOffset;3459}3460}3461}34623463/**3464* Atomically adds to the current value of the field at offset in obj3465* and returns the value of the field prior to the update.3466* The get operation has the memory semantics of getAcquire.3467* The set operation has the memory semantics of set.3468*3469* @param obj object into which to add the value3470* @param offset location to add value in obj3471* @param value to add to existing value in field3472* @return value of field in obj at offset before update3473*/3474public final byte getAndAddByteAcquire(Object obj, long offset, byte value) {3475for (;;) {3476byte byteAtOffset = getByteAcquire(obj, offset);3477if (weakCompareAndSetByteAcquire(obj, offset, byteAtOffset, (byte) (byteAtOffset + value))) {3478return byteAtOffset;3479}3480}3481}34823483/**3484* Atomically adds to the current value of the field at offset in obj3485* and returns the value of the field prior to the update.3486* The get operation has the memory semantics of getVolatile.3487* The set operation has the memory semantics of setVolatile.3488*3489* @param obj object into which to add the value3490* @param offset location to add value in obj3491* @param value to add to existing value in field3492* @return value of field in obj at offset before update3493*/3494public final int getAndAddInt(Object obj, long offset, int value) {3495for (;;) {3496int intAtOffset = getIntVolatile(obj, offset);3497if (weakCompareAndSetInt(obj, offset, intAtOffset, intAtOffset + value)) {3498return intAtOffset;3499}3500}3501}35023503/**3504* Atomically adds to the current value of the field at offset in obj3505* and returns the value of the field prior to the update.3506* The get operation has the memory semantics of get.3507* The set operation has the memory semantics of setRelease.3508*3509* @param obj object into which to add the value3510* @param offset location to add value in obj3511* @param value to add to existing value in field3512* @return value of field in obj at offset before update3513*/3514public final int getAndAddIntRelease(Object obj, long offset, int value) {3515for (;;) {3516int intAtOffset = getInt(obj, offset);3517if (weakCompareAndSetIntRelease(obj, offset, intAtOffset, intAtOffset + value)) {3518return intAtOffset;3519}3520}3521}35223523/**3524* Atomically adds to the current value of the field at offset in obj3525* and returns the value of the field prior to the update.3526* The get operation has the memory semantics of getAcquire.3527* The set operation has the memory semantics of set.3528*3529* @param obj object into which to add the value3530* @param offset location to add value in obj3531* @param value to add to existing value in field3532* @return value of field in obj at offset before update3533*/3534public final int getAndAddIntAcquire(Object obj, long offset, int value) {3535for (;;) {3536int intAtOffset = getIntAcquire(obj, offset);3537if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset, intAtOffset + value)) {3538return intAtOffset;3539}3540}3541}35423543/**3544* Atomically adds to the current value of the field at offset in obj3545* and returns the value of the field prior to the update.3546* The get operation has the memory semantics of getVolatile.3547* The set operation has the memory semantics of setVolatile.3548*3549* @param obj object into which to add the value3550* @param offset location to add value in obj3551* @param value to add to existing value in field3552* @return value of field in obj at offset before update3553*/3554public final long getAndAddLong(Object obj, long offset, long value) {3555for (;;) {3556long longAtOffset = getLongVolatile(obj, offset);3557if (weakCompareAndSetLong(obj, offset, longAtOffset, longAtOffset + value)) {3558return longAtOffset;3559}3560}3561}35623563/**3564* Atomically adds to the current value of the field at offset in obj3565* and returns the value of the field prior to the update.3566* The get operation has the memory semantics of get.3567* The set operation has the memory semantics of setRelease.3568*3569* @param obj object into which to add the value3570* @param offset location to add value in obj3571* @param value to add to existing value in field3572* @return value of field in obj at offset before update3573*/3574public final long getAndAddLongRelease(Object obj, long offset, long value) {3575for (;;) {3576long longAtOffset = getLong(obj, offset);3577if (weakCompareAndSetLongRelease(obj, offset, longAtOffset, longAtOffset + value)) {3578return longAtOffset;3579}3580}3581}35823583/**3584* Atomically adds to the current value of the field at offset in obj3585* and returns the value of the field prior to the update.3586* The get operation has the memory semantics of getAcquire.3587* The set operation has the memory semantics of set.3588*3589* @param obj object into which to add the value3590* @param offset location to add value in obj3591* @param value to add to existing value in field3592* @return value of field in obj at offset before update3593*/3594public final long getAndAddLongAcquire(Object obj, long offset, long value) {3595for (;;) {3596long longAtOffset = getLongAcquire(obj, offset);3597if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset, longAtOffset + value)) {3598return longAtOffset;3599}3600}3601}36023603/**3604* Atomically adds to the current value of the field at offset in obj3605* and returns the value of the field prior to the update.3606* The get operation has the memory semantics of getVolatile.3607* The set operation has the memory semantics of setVolatile.3608*3609* @param obj object into which to add the value3610* @param offset location to add value in obj3611* @param value to add to existing value in field3612* @return value of field in obj at offset before update3613*/3614public final float getAndAddFloat(Object obj, long offset, float value) {3615for (;;) {3616int intAtOffset = getIntVolatile(obj, offset);3617float floatAtOffset = Float.intBitsToFloat(intAtOffset);3618if (weakCompareAndSetInt(obj, offset, intAtOffset,3619Float.floatToRawIntBits(floatAtOffset + value))) {3620return floatAtOffset;3621}3622}3623}36243625/**3626* Atomically adds to the current value of the field at offset in obj3627* and returns the value of the field prior to the update.3628* The get operation has the memory semantics of get.3629* The set operation has the memory semantics of setRelease.3630*3631* @param obj object into which to add the value3632* @param offset location to add value in obj3633* @param value to add to existing value in field3634* @return value of field in obj at offset before update3635*/3636public final float getAndAddFloatRelease(Object obj, long offset, float value) {3637for (;;) {3638int intAtOffset = getInt(obj, offset);3639float floatAtOffset = Float.intBitsToFloat(intAtOffset);3640if (weakCompareAndSetIntRelease(obj, offset, intAtOffset,3641Float.floatToRawIntBits(floatAtOffset + value))) {3642return floatAtOffset;3643}3644}3645}36463647/**3648* Atomically adds to the current value of the field at offset in obj3649* and returns the value of the field prior to the update.3650* The get operation has the memory semantics of getAcquire.3651* The set operation has the memory semantics of set.3652*3653* @param obj object into which to add the value3654* @param offset location to add value in obj3655* @param value to add to existing value in field3656* @return value of field in obj at offset before update3657*/3658public final float getAndAddFloatAcquire(Object obj, long offset, float value) {3659for (;;) {3660int intAtOffset = getIntAcquire(obj, offset);3661float floatAtOffset = Float.intBitsToFloat(intAtOffset);3662if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset,3663Float.floatToRawIntBits(floatAtOffset + value))) {3664return floatAtOffset;3665}3666}3667}36683669/**3670* Atomically adds to the current value of the field at offset in obj3671* and returns the value of the field prior to the update.3672* The get operation has the memory semantics of getVolatile.3673* The set operation has the memory semantics of setVolatile.3674*3675* @param obj object into which to add the value3676* @param offset location to add value in obj3677* @param value to add to existing value in field3678* @return value of field in obj at offset before update3679*/3680public final double getAndAddDouble(Object obj, long offset, double value) {3681for (;;) {3682long longAtOffset = getLongVolatile(obj, offset);3683double doubleAtOffset = Double.longBitsToDouble(longAtOffset);3684if (weakCompareAndSetLong(obj, offset, longAtOffset,3685Double.doubleToRawLongBits(doubleAtOffset + value))) {3686return doubleAtOffset;3687}3688}3689}36903691/**3692* Atomically adds to the current value of the field at offset in obj3693* and returns the value of the field prior to the update.3694* The get operation has the memory semantics of get.3695* The set operation has the memory semantics of setRelease.3696*3697* @param obj object into which to add the value3698* @param offset location to add value in obj3699* @param value to add to existing value in field3700* @return value of field in obj at offset before update3701*/3702public final double getAndAddDoubleRelease(Object obj, long offset, double value) {3703for (;;) {3704long longAtOffset = getLong(obj, offset);3705double doubleAtOffset = Double.longBitsToDouble(longAtOffset);3706if (weakCompareAndSetLongRelease(obj, offset, longAtOffset,3707Double.doubleToRawLongBits(doubleAtOffset + value))) {3708return doubleAtOffset;3709}3710}3711}37123713/**3714* Atomically adds to the current value of the field at offset in obj3715* and returns the value of the field prior to the update.3716* The get operation has the memory semantics of getAcquire.3717* The set operation has the memory semantics of set.3718*3719* @param obj object into which to add the value3720* @param offset location to add value in obj3721* @param value to add to existing value in field3722* @return value of field in obj at offset before update3723*/3724public final double getAndAddDoubleAcquire(Object obj, long offset, double value) {3725for (;;) {3726long longAtOffset = getLongAcquire(obj, offset);3727double doubleAtOffset = Double.longBitsToDouble(longAtOffset);3728if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset,3729Double.doubleToRawLongBits(doubleAtOffset + value))) {3730return doubleAtOffset;3731}3732}3733}37343735/**3736* Atomically adds to the current value of the field at offset in obj3737* and returns the value of the field prior to the update.3738* The get operation has the memory semantics of getVolatile.3739* The set operation has the memory semantics of setVolatile.3740*3741* @param obj object into which to add the value3742* @param offset location to add value in obj3743* @param value to add to existing value in field3744* @return value of field in obj at offset before update3745*/3746public final short getAndAddShort(Object obj, long offset, short value) {3747for (;;) {3748short shortAtOffset = getShortVolatile(obj, offset);3749if (weakCompareAndSetShort(obj, offset, shortAtOffset, (short) (shortAtOffset + value))) {3750return shortAtOffset;3751}3752}3753}37543755/**3756* Atomically adds to the current value of the field at offset in obj3757* and returns the value of the field prior to the update.3758* The get operation has the memory semantics of get.3759* The set operation has the memory semantics of setRelease.3760*3761* @param obj object into which to add the value3762* @param offset location to add value in obj3763* @param value to add to existing value in field3764* @return value of field in obj at offset before update3765*/3766public final short getAndAddShortRelease(Object obj, long offset, short value) {3767for (;;) {3768short shortAtOffset = getShort(obj, offset);3769if (weakCompareAndSetShortRelease(obj, offset, shortAtOffset, (short) (shortAtOffset + value))) {3770return shortAtOffset;3771}3772}3773}37743775/**3776* Atomically adds to the current value of the field at offset in obj3777* and returns the value of the field prior to the update.3778* The get operation has the memory semantics of getAcquire.3779* The set operation has the memory semantics of set.3780*3781* @param obj object into which to add the value3782* @param offset location to add value in obj3783* @param value to add to existing value in field3784* @return value of field in obj at offset before update3785*/3786public final short getAndAddShortAcquire(Object obj, long offset, short value) {3787for (;;) {3788short shortAtOffset = getShortAcquire(obj, offset);3789if (weakCompareAndSetShortAcquire(obj, offset, shortAtOffset, (short) (shortAtOffset + value))) {3790return shortAtOffset;3791}3792}3793}37943795/**3796* Atomically adds to the current value of the field at offset in obj3797* and returns the value of the field prior to the update.3798* The get operation has the memory semantics of getVolatile.3799* The set operation has the memory semantics of setVolatile.3800*3801* @param obj object into which to add the value3802* @param offset location to add value in obj3803* @param value to add to existing value in field3804* @return value of field in obj at offset before update3805*/3806public final char getAndAddChar(Object obj, long offset, char value) {3807for (;;) {3808char charAtOffset = getCharVolatile(obj, offset);3809if (weakCompareAndSetChar(obj, offset, charAtOffset, (char) (charAtOffset + value))) {3810return charAtOffset;3811}3812}3813}38143815/**3816* Atomically adds to the current value of the field at offset in obj3817* and returns the value of the field prior to the update.3818* The get operation has the memory semantics of get.3819* The set operation has the memory semantics of setRelease.3820*3821* @param obj object into which to add the value3822* @param offset location to add value in obj3823* @param value to add to existing value in field3824* @return value of field in obj at offset before update3825*/3826public final char getAndAddCharRelease(Object obj, long offset, char value) {3827for (;;) {3828char charAtOffset = getChar(obj, offset);3829if (weakCompareAndSetCharRelease(obj, offset, charAtOffset, (char) (charAtOffset + value))) {3830return charAtOffset;3831}3832}3833}38343835/**3836* Atomically adds to the current value of the field at offset in obj3837* and returns the value of the field prior to the update.3838* The get operation has the memory semantics of getAcquire.3839* The set operation has the memory semantics of set.3840*3841* @param obj object into which to add the value3842* @param offset location to add value in obj3843* @param value to add to existing value in field3844* @return value of field in obj at offset before update3845*/3846public final char getAndAddCharAcquire(Object obj, long offset, char value) {3847for (;;) {3848char charAtOffset = getCharAcquire(obj, offset);3849if (weakCompareAndSetCharAcquire(obj, offset, charAtOffset, (char) (charAtOffset + value))) {3850return charAtOffset;3851}3852}3853}38543855/**3856* Atomically sets value at offset in obj3857* and returns the value of the field prior to the update.3858* The get operation has the memory semantics of getVolatile.3859* The set operation has the memory semantics of setVolatile.3860*3861* @param obj object into which to set the value3862* @param offset location to set value in obj3863* @param value to set in obj memory3864* @return value of field in obj at offset before update3865*/3866public final byte getAndSetByte(Object obj, long offset, byte value) {3867for (;;) {3868byte byteAtOffset = getByteVolatile(obj, offset);3869if (compareAndSetByte(obj, offset, byteAtOffset, value)) {3870return byteAtOffset;3871}3872}3873}38743875/**3876* Atomically sets value at offset in obj3877* and returns the value of the field prior to the update.3878* The get operation has the memory semantics of get.3879* The set operation has the memory semantics of setRelease.3880*3881* @param obj object into which to set the value3882* @param offset location to set value in obj3883* @param value to set in obj memory3884* @return value of field in obj at offset before update3885*/3886public final byte getAndSetByteRelease(Object obj, long offset, byte value) {3887for (;;) {3888byte byteAtOffset = getByte(obj, offset);3889if (weakCompareAndSetByteRelease(obj, offset, byteAtOffset, value)) {3890return byteAtOffset;3891}3892}3893}38943895/**3896* Atomically sets value at offset in obj3897* and returns the value of the field prior to the update.3898* The get operation has the memory semantics of getAcquire.3899* The set operation has the memory semantics of set.3900*3901* @param obj object into which to set the value3902* @param offset location to set value in obj3903* @param value to set in obj memory3904* @return value of field in obj at offset before update3905*/3906public final byte getAndSetByteAcquire(Object obj, long offset, byte value) {3907for (;;) {3908byte byteAtOffset = getByteAcquire(obj, offset);3909if (weakCompareAndSetByteAcquire(obj, offset, byteAtOffset, value)) {3910return byteAtOffset;3911}3912}3913}39143915/**3916* Atomically sets value at offset in obj3917* and returns the value of the field prior to the update.3918* The get operation has the memory semantics of getVolatile.3919* The set operation has the memory semantics of setVolatile.3920*3921* @param obj object into which to set the value3922* @param offset location to set value in obj3923* @param value to set in obj memory3924* @return value of field in obj at offset before update3925*/3926public final int getAndSetInt(Object obj, long offset, int value) {3927for (;;) {3928int intAtOffset = getIntVolatile(obj, offset);3929if (compareAndSetInt(obj, offset, intAtOffset, value)) {3930return intAtOffset;3931}3932}3933}39343935/**3936* Atomically sets value at offset in obj3937* and returns the value of the field prior to the update.3938* The get operation has the memory semantics of get.3939* The set operation has the memory semantics of setRelease.3940*3941* @param obj object into which to set the value3942* @param offset location to set value in obj3943* @param value to set in obj memory3944* @return value of field in obj at offset before update3945*/3946public final int getAndSetIntRelease(Object obj, long offset, int value) {3947for (;;) {3948int intAtOffset = getInt(obj, offset);3949if (weakCompareAndSetIntRelease(obj, offset, intAtOffset, value)) {3950return intAtOffset;3951}3952}3953}39543955/**3956* Atomically sets value at offset in obj3957* and returns the value of the field prior to the update.3958* The get operation has the memory semantics of getAcquire.3959* The set operation has the memory semantics of set.3960*3961* @param obj object into which to set the value3962* @param offset location to set value in obj3963* @param value to set in obj memory3964* @return value of field in obj at offset before update3965*/3966public final int getAndSetIntAcquire(Object obj, long offset, int value) {3967for (;;) {3968int intAtOffset = getIntAcquire(obj, offset);3969if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset, value)) {3970return intAtOffset;3971}3972}3973}39743975/**3976* Atomically sets value at offset in obj3977* and returns the value of the field prior to the update.3978* The get operation has the memory semantics of getVolatile.3979* The set operation has the memory semantics of setVolatile.3980*3981* @param obj object into which to set the value3982* @param offset location to set value in obj3983* @param value to set in obj memory3984* @return value of field in obj at offset before update3985*/3986public final long getAndSetLong(Object obj, long offset, long value) {3987for (;;) {3988long longAtOffset = getLongVolatile(obj, offset);3989if (compareAndSetLong(obj, offset, longAtOffset, value)) {3990return longAtOffset;3991}3992}3993}39943995/**3996* Atomically sets value at offset in obj3997* and returns the value of the field prior to the update.3998* The get operation has the memory semantics of get.3999* The set operation has the memory semantics of setRelease.4000*4001* @param obj object into which to set the value4002* @param offset location to set value in obj4003* @param value to set in obj memory4004* @return value of field in obj at offset before update4005*/4006public final long getAndSetLongRelease(Object obj, long offset, long value) {4007for (;;) {4008long longAtOffset = getLong(obj, offset);4009if (weakCompareAndSetLongRelease(obj, offset, longAtOffset, value)) {4010return longAtOffset;4011}4012}4013}40144015/**4016* Atomically sets value at offset in obj4017* and returns the value of the field prior to the update.4018* The get operation has the memory semantics of getAcquire.4019* The set operation has the memory semantics of set.4020*4021* @param obj object into which to set the value4022* @param offset location to set value in obj4023* @param value to set in obj memory4024* @return value of field in obj at offset before update4025*/4026public final long getAndSetLongAcquire(Object obj, long offset, long value) {4027for (;;) {4028long longAtOffset = getLongAcquire(obj, offset);4029if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset, value)) {4030return longAtOffset;4031}4032}4033}40344035/**4036* Atomically sets value at offset in obj4037* and returns the value of the field prior to the update.4038* The get operation has the memory semantics of getVolatile.4039* The set operation has the memory semantics of setVolatile.4040*4041* @param obj object into which to set the value4042* @param offset location to set value in obj4043* @param value to set in obj memory4044* @return value of field in obj at offset before update4045*/4046public final float getAndSetFloat(Object obj, long offset, float value) {4047int result = getAndSetInt(obj, offset, Float.floatToRawIntBits(value));4048return Float.intBitsToFloat(result);4049}40504051/**4052* Atomically sets value at offset in obj4053* and returns the value of the field prior to the update.4054* The get operation has the memory semantics of get.4055* The set operation has the memory semantics of setRelease.4056*4057* @param obj object into which to set the value4058* @param offset location to set value in obj4059* @param value to set in obj memory4060* @return value of field in obj at offset before update4061*/4062public final float getAndSetFloatRelease(Object obj, long offset, float value) {4063int result = getAndSetIntRelease(obj, offset, Float.floatToRawIntBits(value));4064return Float.intBitsToFloat(result);4065}40664067/**4068* Atomically sets value at offset in obj4069* and returns the value of the field prior to the update.4070* The get operation has the memory semantics of getAcquire.4071* The set operation has the memory semantics of set.4072*4073* @param obj object into which to set the value4074* @param offset location to set value in obj4075* @param value to set in obj memory4076* @return value of field in obj at offset before update4077*/4078public final float getAndSetFloatAcquire(Object obj, long offset, float value) {4079int result = getAndSetIntAcquire(obj, offset, Float.floatToRawIntBits(value));4080return Float.intBitsToFloat(result);4081}40824083/**4084* Atomically sets value at offset in obj4085* and returns the value of the field prior to the update.4086* The get operation has the memory semantics of getVolatile.4087* The set operation has the memory semantics of setVolatile.4088*4089* @param obj object into which to set the value4090* @param offset location to set value in obj4091* @param value to set in obj memory4092* @return value of field in obj at offset before update4093*/4094public final double getAndSetDouble(Object obj, long offset, double value) {4095long result = getAndSetLong(obj, offset, Double.doubleToRawLongBits(value));4096return Double.longBitsToDouble(result);4097}40984099/**4100* Atomically sets value at offset in obj4101* and returns the value of the field prior to the update.4102* The get operation has the memory semantics of get.4103* The set operation has the memory semantics of setRelease.4104*4105* @param obj object into which to set the value4106* @param offset location to set value in obj4107* @param value to set in obj memory4108* @return value of field in obj at offset before update4109*/4110public final double getAndSetDoubleRelease(Object obj, long offset, double value) {4111long result = getAndSetLongRelease(obj, offset, Double.doubleToRawLongBits(value));4112return Double.longBitsToDouble(result);4113}41144115/**4116* Atomically sets value at offset in obj4117* and returns the value of the field prior to the update.4118* The get operation has the memory semantics of getAcquire.4119* The set operation has the memory semantics of set.4120*4121* @param obj object into which to set the value4122* @param offset location to set value in obj4123* @param value to set in obj memory4124* @return value of field in obj at offset before update4125*/4126public final double getAndSetDoubleAcquire(Object obj, long offset, double value) {4127long result = getAndSetLongAcquire(obj, offset, Double.doubleToRawLongBits(value));4128return Double.longBitsToDouble(result);4129}41304131/**4132* Atomically sets value at offset in obj4133* and returns the value of the field prior to the update.4134* The get operation has the memory semantics of getVolatile.4135* The set operation has the memory semantics of setVolatile.4136*4137* @param obj object into which to set the value4138* @param offset location to set value in obj4139* @param value to set in obj memory4140* @return value of field in obj at offset before update4141*/4142public final short getAndSetShort(Object obj, long offset, short value) {4143for (;;) {4144short shortAtOffset = getShortVolatile(obj, offset);4145if (compareAndSetShort(obj, offset, shortAtOffset, value)) {4146return shortAtOffset;4147}4148}4149}41504151/**4152* Atomically sets value at offset in obj4153* and returns the value of the field prior to the update.4154* The get operation has the memory semantics of get.4155* The set operation has the memory semantics of setRelease.4156*4157* @param obj object into which to set the value4158* @param offset location to set value in obj4159* @param value to set in obj memory4160* @return value of field in obj at offset before update4161*/4162public final short getAndSetShortRelease(Object obj, long offset, short value) {4163for (;;) {4164short shortAtOffset = getShort(obj, offset);4165if (weakCompareAndSetShortRelease(obj, offset, shortAtOffset, value)) {4166return shortAtOffset;4167}4168}4169}41704171/**4172* Atomically sets value at offset in obj4173* and returns the value of the field prior to the update.4174* The get operation has the memory semantics of getAcquire.4175* The set operation has the memory semantics of set.4176*4177* @param obj object into which to set the value4178* @param offset location to set value in obj4179* @param value to set in obj memory4180* @return value of field in obj at offset before update4181*/4182public final short getAndSetShortAcquire(Object obj, long offset, short value) {4183for (;;) {4184short shortAtOffset = getShortAcquire(obj, offset);4185if (weakCompareAndSetShortAcquire(obj, offset, shortAtOffset, value)) {4186return shortAtOffset;4187}4188}4189}41904191/**4192* Atomically sets value at offset in obj4193* and returns the value of the field prior to the update.4194* The get operation has the memory semantics of getVolatile.4195* The set operation has the memory semantics of setVolatile.4196*4197* @param obj object into which to set the value4198* @param offset location to set value in obj4199* @param value to set in obj memory4200* @return value of field in obj at offset before update4201*/4202public final char getAndSetChar(Object obj, long offset, char value) {4203for (;;) {4204char charAtOffset = getCharVolatile(obj, offset);4205if (compareAndSetChar(obj, offset, charAtOffset, value)) {4206return charAtOffset;4207}4208}4209}42104211/**4212* Atomically sets value at offset in obj4213* and returns the value of the field prior to the update.4214* The get operation has the memory semantics of get.4215* The set operation has the memory semantics of setRelease.4216*4217* @param obj object into which to set the value4218* @param offset location to set value in obj4219* @param value to set in obj memory4220* @return value of field in obj at offset before update4221*/4222public final char getAndSetCharRelease(Object obj, long offset, char value) {4223for (;;) {4224char charAtOffset = getChar(obj, offset);4225if (weakCompareAndSetCharRelease(obj, offset, charAtOffset, value)) {4226return charAtOffset;4227}4228}4229}42304231/**4232* Atomically sets value at offset in obj4233* and returns the value of the field prior to the update.4234* The get operation has the memory semantics of getAcquire.4235* The set operation has the memory semantics of set.4236*4237* @param obj object into which to set the value4238* @param offset location to set value in obj4239* @param value to set in obj memory4240* @return value of field in obj at offset before update4241*/4242public final char getAndSetCharAcquire(Object obj, long offset, char value) {4243for (;;) {4244char charAtOffset = getCharAcquire(obj, offset);4245if (weakCompareAndSetCharAcquire(obj, offset, charAtOffset, value)) {4246return charAtOffset;4247}4248}4249}42504251/**4252* Atomically sets value at offset in obj4253* and returns the value of the field prior to the update.4254* The get operation has the memory semantics of getVolatile.4255* The set operation has the memory semantics of setVolatile.4256*4257* @param obj object into which to set the value4258* @param offset location to set value in obj4259* @param value to set in obj memory4260* @return value of field in obj at offset before update4261*/4262public final boolean getAndSetBoolean(Object obj, long offset, boolean value) {4263byte result = getAndSetByte(obj, offset, bool2byte(value));4264return byte2bool(result);4265}42664267/**4268* Atomically sets value at offset in obj4269* and returns the value of the field prior to the update.4270* The get operation has the memory semantics of get.4271* The set operation has the memory semantics of setRelease.4272*4273* @param obj object into which to set the value4274* @param offset location to set value in obj4275* @param value to set in obj memory4276* @return value of field in obj at offset before update4277*/4278public final boolean getAndSetBooleanRelease(Object obj, long offset, boolean value) {4279byte result = getAndSetByteRelease(obj, offset, bool2byte(value));4280return byte2bool(result);4281}42824283/**4284* Atomically sets value at offset in obj4285* and returns the value of the field prior to the update.4286* The get operation has the memory semantics of getAcquire.4287* The set operation has the memory semantics of set.4288*4289* @param obj object into which to set the value4290* @param offset location to set value in obj4291* @param value to set in obj memory4292* @return value of field in obj at offset before update4293*/4294public final boolean getAndSetBooleanAcquire(Object obj, long offset, boolean value) {4295byte result = getAndSetByteAcquire(obj, offset, bool2byte(value));4296return byte2bool(result);4297}42984299/**4300* Atomically sets value at offset in obj4301* and returns the value of the field prior to the update.4302* The get operation has the memory semantics of getVolatile.4303* The set operation has the memory semantics of setVolatile.4304*4305* @param obj object into which to set the value4306* @param offset location to set value in obj4307* @param value to set in obj memory4308* @return value of field in obj at offset before update4309*/4310public final Object getAndSetObject(Object obj, long offset, Object value) {4311for (;;) {4312Object objectAtOffset = getObjectVolatile(obj, offset);4313if (compareAndSetObject(obj, offset, objectAtOffset, value)) {4314return objectAtOffset;4315}4316}4317}43184319/**4320* Atomically sets value at offset in obj4321* and returns the value of the field prior to the update.4322* The get operation has the memory semantics of get.4323* The set operation has the memory semantics of setRelease.4324*4325* @param obj object into which to set the value4326* @param offset location to set value in obj4327* @param value to set in obj memory4328* @return value of field in obj at offset before update4329*/4330public final Object getAndSetObjectRelease(Object obj, long offset, Object value) {4331for (;;) {4332Object objectAtOffset = getObject(obj, offset);4333if (weakCompareAndSetObjectRelease(obj, offset, objectAtOffset, value)) {4334return objectAtOffset;4335}4336}4337}43384339/**4340* Atomically sets value at offset in obj4341* and returns the value of the field prior to the update.4342* The get operation has the memory semantics of getAcquire.4343* The set operation has the memory semantics of set.4344*4345* @param obj object into which to set the value4346* @param offset location to set value in obj4347* @param value to set in obj memory4348* @return value of field in obj at offset before update4349*/4350public final Object getAndSetObjectAcquire(Object obj, long offset, Object value) {4351for (;;) {4352Object objectAtOffset = getObjectAcquire(obj, offset);4353if (weakCompareAndSetObjectAcquire(obj, offset, objectAtOffset, value)) {4354return objectAtOffset;4355}4356}4357}43584359/*[IF JAVA_SPEC_VERSION >= 12]*/4360/**4361* Atomically sets value at offset in obj4362* and returns the value of the field prior to the update.4363* The get operation has the memory semantics of getVolatile.4364* The set operation has the memory semantics of setVolatile.4365*4366* @param obj object into which to set the value4367* @param offset location to set value in obj4368* @param value to set in obj memory4369* @return value of field in obj at offset before update4370*/4371public final Object getAndSetReference(Object obj, long offset, Object value) {4372for (;;) {4373Object objectAtOffset = getReferenceVolatile(obj, offset);4374if (compareAndSetReference(obj, offset, objectAtOffset, value)) {4375return objectAtOffset;4376}4377}4378}43794380/**4381* Atomically sets value at offset in obj4382* and returns the value of the field prior to the update.4383* The get operation has the memory semantics of get.4384* The set operation has the memory semantics of setRelease.4385*4386* @param obj object into which to set the value4387* @param offset location to set value in obj4388* @param value to set in obj memory4389* @return value of field in obj at offset before update4390*/4391public final Object getAndSetReferenceRelease(Object obj, long offset, Object value) {4392for (;;) {4393Object objectAtOffset = getReference(obj, offset);4394if (weakCompareAndSetReferenceRelease(obj, offset, objectAtOffset, value)) {4395return objectAtOffset;4396}4397}4398}43994400/**4401* Atomically sets value at offset in obj4402* and returns the value of the field prior to the update.4403* The get operation has the memory semantics of getAcquire.4404* The set operation has the memory semantics of set.4405*4406* @param obj object into which to set the value4407* @param offset location to set value in obj4408* @param value to set in obj memory4409* @return value of field in obj at offset before update4410*/4411public final Object getAndSetReferenceAcquire(Object obj, long offset, Object value) {4412for (;;) {4413Object objectAtOffset = getReferenceAcquire(obj, offset);4414if (weakCompareAndSetReferenceAcquire(obj, offset, objectAtOffset, value)) {4415return objectAtOffset;4416}4417}4418}4419/*[ENDIF] JAVA_SPEC_VERSION >= 12 */44204421/**4422* Atomically OR's the given value to the current value of the4423* field at offset in obj and returns the value of the field prior4424* to the update.4425* The get operation has the memory semantics of getVolatile.4426* The set operation has the memory semantics of setVolatile.4427*4428* @param obj object into which to OR the value4429* @param offset location to OR value in obj4430* @param value to OR to existing value in field4431* @return value of field in obj at offset before update4432*/4433public final byte getAndBitwiseOrByte(Object obj, long offset, byte value) {4434for (;;) {4435byte byteAtOffset = getByteVolatile(obj, offset);4436if (weakCompareAndSetByte(obj, offset, byteAtOffset, (byte) (byteAtOffset | value))) {4437return byteAtOffset;4438}4439}4440}44414442/**4443* Atomically OR's the given value to the current value of the4444* field at offset in obj and returns the value of the field prior4445* to the update.4446* The get operation has the memory semantics of get.4447* The set operation has the memory semantics of setRelease.4448*4449* @param obj object into which to OR the value4450* @param offset location to OR value in obj4451* @param value to OR to existing value in field4452* @return value of field in obj at offset before update4453*/4454public final byte getAndBitwiseOrByteRelease(Object obj, long offset, byte value) {4455for (;;) {4456byte byteAtOffset = getByte(obj, offset);4457if (weakCompareAndSetByteRelease(obj, offset, byteAtOffset, (byte) (byteAtOffset | value))) {4458return byteAtOffset;4459}4460}4461}44624463/**4464* Atomically OR's the given value to the current value of the4465* field at offset in obj and returns the value of the field prior4466* to the update.4467* The get operation has the memory semantics of getAcquire.4468* The set operation has the memory semantics of set.4469*4470* @param obj object into which to OR the value4471* @param offset location to OR value in obj4472* @param value to OR to existing value in field4473* @return value of field in obj at offset before update4474*/4475public final byte getAndBitwiseOrByteAcquire(Object obj, long offset, byte value) {4476for (;;) {4477byte byteAtOffset = getByte(obj, offset);4478if (weakCompareAndSetByteAcquire(obj, offset, byteAtOffset, (byte) (byteAtOffset | value))) {4479return byteAtOffset;4480}4481}4482}44834484/**4485* Atomically AND's the given value to the current value of the4486* field at offset in obj and returns the value of the field prior4487* to the update.4488* The get operation has the memory semantics of getVolatile.4489* The set operation has the memory semantics of setVolatile.4490*4491* @param obj object into which to AND the value4492* @param offset location to AND value in obj4493* @param value to AND to existing value in field4494* @return value of field in obj at offset before update4495*/4496public final byte getAndBitwiseAndByte(Object obj, long offset, byte value) {4497for (;;) {4498byte byteAtOffset = getByteVolatile(obj, offset);4499if (weakCompareAndSetByte(obj, offset, byteAtOffset, (byte) (byteAtOffset & value))) {4500return byteAtOffset;4501}4502}4503}45044505/**4506* Atomically AND's the given value to the current value of the4507* field at offset in obj and returns the value of the field prior4508* to the update.4509* The get operation has the memory semantics of get.4510* The set operation has the memory semantics of setRelease.4511*4512* @param obj object into which to AND the value4513* @param offset location to AND value in obj4514* @param value to AND to existing value in field4515* @return value of field in obj at offset before update4516*/4517public final byte getAndBitwiseAndByteRelease(Object obj, long offset, byte value) {4518for (;;) {4519byte byteAtOffset = getByte(obj, offset);4520if (weakCompareAndSetByteRelease(obj, offset, byteAtOffset, (byte) (byteAtOffset & value))) {4521return byteAtOffset;4522}4523}4524}45254526/**4527* Atomically AND's the given value to the current value of the4528* field at offset in obj and returns the value of the field prior4529* to the update.4530* The get operation has the memory semantics of getAcquire.4531* The set operation has the memory semantics of set.4532*4533* @param obj object into which to AND the value4534* @param offset location to AND value in obj4535* @param value to AND to existing value in field4536* @return value of field in obj at offset before update4537*/4538public final byte getAndBitwiseAndByteAcquire(Object obj, long offset, byte value) {4539for (;;) {4540byte byteAtOffset = getByte(obj, offset);4541if (weakCompareAndSetByteAcquire(obj, offset, byteAtOffset, (byte) (byteAtOffset & value))) {4542return byteAtOffset;4543}4544}4545}45464547/**4548* Atomically XOR's the given value to the current value of the4549* field at offset in obj and returns the value of the field prior4550* to the update.4551* The get operation has the memory semantics of getVolatile.4552* The set operation has the memory semantics of setVolatile.4553*4554* @param obj object into which to XOR the value4555* @param offset location to XOR value in obj4556* @param value to XOR to existing value in field4557* @return value of field in obj at offset before update4558*/4559public final byte getAndBitwiseXorByte(Object obj, long offset, byte value) {4560for (;;) {4561byte byteAtOffset = getByteVolatile(obj, offset);4562if (weakCompareAndSetByte(obj, offset, byteAtOffset, (byte) (byteAtOffset ^ value))) {4563return byteAtOffset;4564}4565}4566}45674568/**4569* Atomically XOR's the given value to the current value of the4570* field at offset in obj and returns the value of the field prior4571* to the update.4572* The get operation has the memory semantics of get.4573* The set operation has the memory semantics of setRelease.4574*4575* @param obj object into which to XOR the value4576* @param offset location to XOR value in obj4577* @param value to XOR to existing value in field4578* @return value of field in obj at offset before update4579*/4580public final byte getAndBitwiseXorByteRelease(Object obj, long offset, byte value) {4581for (;;) {4582byte byteAtOffset = getByte(obj, offset);4583if (weakCompareAndSetByteRelease(obj, offset, byteAtOffset, (byte) (byteAtOffset ^ value))) {4584return byteAtOffset;4585}4586}4587}45884589/**4590* Atomically XOR's the given value to the current value of the4591* field at offset in obj and returns the value of the field prior4592* to the update.4593* The get operation has the memory semantics of getAcquire.4594* The set operation has the memory semantics of set.4595*4596* @param obj object into which to XOR the value4597* @param offset location to XOR value in obj4598* @param value to XOR to existing value in field4599* @return value of field in obj at offset before update4600*/4601public final byte getAndBitwiseXorByteAcquire(Object obj, long offset, byte value) {4602for (;;) {4603byte byteAtOffset = getByte(obj, offset);4604if (weakCompareAndSetByteAcquire(obj, offset, byteAtOffset, (byte) (byteAtOffset ^ value))) {4605return byteAtOffset;4606}4607}4608}46094610/**4611* Atomically OR's the given value to the current value of the4612* field at offset in obj and returns the value of the field prior4613* to the update.4614* The get operation has the memory semantics of getVolatile.4615* The set operation has the memory semantics of setVolatile.4616*4617* @param obj object into which to OR the value4618* @param offset location to OR value in obj4619* @param value to OR to existing value in field4620* @return value of field in obj at offset before update4621*/4622public final int getAndBitwiseOrInt(Object obj, long offset, int value) {4623for (;;) {4624int intAtOffset = getIntVolatile(obj, offset);4625if (weakCompareAndSetInt(obj, offset, intAtOffset, intAtOffset | value)) {4626return intAtOffset;4627}4628}4629}46304631/**4632* Atomically OR's the given value to the current value of the4633* field at offset in obj and returns the value of the field prior4634* to the update.4635* The get operation has the memory semantics of get.4636* The set operation has the memory semantics of setRelease.4637*4638* @param obj object into which to OR the value4639* @param offset location to OR value in obj4640* @param value to OR to existing value in field4641* @return value of field in obj at offset before update4642*/4643public final int getAndBitwiseOrIntRelease(Object obj, long offset, int value) {4644for (;;) {4645int intAtOffset = getInt(obj, offset);4646if (weakCompareAndSetIntRelease(obj, offset, intAtOffset, intAtOffset | value)) {4647return intAtOffset;4648}4649}4650}46514652/**4653* Atomically OR's the given value to the current value of the4654* field at offset in obj and returns the value of the field prior4655* to the update.4656* The get operation has the memory semantics of getAcquire.4657* The set operation has the memory semantics of set.4658*4659* @param obj object into which to OR the value4660* @param offset location to OR value in obj4661* @param value to OR to existing value in field4662* @return value of field in obj at offset before update4663*/4664public final int getAndBitwiseOrIntAcquire(Object obj, long offset, int value) {4665for (;;) {4666int intAtOffset = getInt(obj, offset);4667if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset, intAtOffset | value)) {4668return intAtOffset;4669}4670}4671}46724673/**4674* Atomically AND's the given value to the current value of the4675* field at offset in obj and returns the value of the field prior4676* to the update.4677* The get operation has the memory semantics of getVolatile.4678* The set operation has the memory semantics of setVolatile.4679*4680* @param obj object into which to AND the value4681* @param offset location to AND value in obj4682* @param value to AND to existing value in field4683* @return value of field in obj at offset before update4684*/4685public final int getAndBitwiseAndInt(Object obj, long offset, int value) {4686for (;;) {4687int intAtOffset = getIntVolatile(obj, offset);4688if (weakCompareAndSetInt(obj, offset, intAtOffset, intAtOffset & value)) {4689return intAtOffset;4690}4691}4692}46934694/**4695* Atomically AND's the given value to the current value of the4696* field at offset in obj and returns the value of the field prior4697* to the update.4698* The get operation has the memory semantics of get.4699* The set operation has the memory semantics of setRelease.4700*4701* @param obj object into which to AND the value4702* @param offset location to AND value in obj4703* @param value to AND to existing value in field4704* @return value of field in obj at offset before update4705*/4706public final int getAndBitwiseAndIntRelease(Object obj, long offset, int value) {4707for (;;) {4708int intAtOffset = getInt(obj, offset);4709if (weakCompareAndSetIntRelease(obj, offset, intAtOffset, intAtOffset & value)) {4710return intAtOffset;4711}4712}4713}47144715/**4716* Atomically AND's the given value to the current value of the4717* field at offset in obj and returns the value of the field prior4718* to the update.4719* The get operation has the memory semantics of getAcquire.4720* The set operation has the memory semantics of set.4721*4722* @param obj object into which to AND the value4723* @param offset location to AND value in obj4724* @param value to AND to existing value in field4725* @return value of field in obj at offset before update4726*/4727public final int getAndBitwiseAndIntAcquire(Object obj, long offset, int value) {4728for (;;) {4729int intAtOffset = getInt(obj, offset);4730if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset, intAtOffset & value)) {4731return intAtOffset;4732}4733}4734}47354736/**4737* Atomically XOR's the given value to the current value of the4738* field at offset in obj and returns the value of the field prior4739* to the update.4740* The get operation has the memory semantics of getVolatile.4741* The set operation has the memory semantics of setVolatile.4742*4743* @param obj object into which to XOR the value4744* @param offset location to XOR value in obj4745* @param value to XOR to existing value in field4746* @return value of field in obj at offset before update4747*/4748public final int getAndBitwiseXorInt(Object obj, long offset, int value) {4749for (;;) {4750int intAtOffset = getIntVolatile(obj, offset);4751if (weakCompareAndSetInt(obj, offset, intAtOffset, intAtOffset ^ value)) {4752return intAtOffset;4753}4754}4755}47564757/**4758* Atomically XOR's the given value to the current value of the4759* field at offset in obj and returns the value of the field prior4760* to the update.4761* The get operation has the memory semantics of get.4762* The set operation has the memory semantics of setRelease.4763*4764* @param obj object into which to XOR the value4765* @param offset location to XOR value in obj4766* @param value to XOR to existing value in field4767* @return value of field in obj at offset before update4768*/4769public final int getAndBitwiseXorIntRelease(Object obj, long offset, int value) {4770for (;;) {4771int intAtOffset = getInt(obj, offset);4772if (weakCompareAndSetIntRelease(obj, offset, intAtOffset, intAtOffset ^ value)) {4773return intAtOffset;4774}4775}4776}47774778/**4779* Atomically XOR's the given value to the current value of the4780* field at offset in obj and returns the value of the field prior4781* to the update.4782* The get operation has the memory semantics of getAcquire.4783* The set operation has the memory semantics of set.4784*4785* @param obj object into which to XOR the value4786* @param offset location to XOR value in obj4787* @param value to XOR to existing value in field4788* @return value of field in obj at offset before update4789*/4790public final int getAndBitwiseXorIntAcquire(Object obj, long offset, int value) {4791for (;;) {4792int intAtOffset = getInt(obj, offset);4793if (weakCompareAndSetIntAcquire(obj, offset, intAtOffset, intAtOffset ^ value)) {4794return intAtOffset;4795}4796}4797}47984799/**4800* Atomically OR's the given value to the current value of the4801* field at offset in obj and returns the value of the field prior4802* to the update.4803* The get operation has the memory semantics of getVolatile.4804* The set operation has the memory semantics of setVolatile.4805*4806* @param obj object into which to OR the value4807* @param offset location to OR value in obj4808* @param value to OR to existing value in field4809* @return value of field in obj at offset before update4810*/4811public final long getAndBitwiseOrLong(Object obj, long offset, long value) {4812for (;;) {4813long longAtOffset = getLongVolatile(obj, offset);4814if (weakCompareAndSetLong(obj, offset, longAtOffset, longAtOffset | value)) {4815return longAtOffset;4816}4817}4818}48194820/**4821* Atomically OR's the given value to the current value of the4822* field at offset in obj and returns the value of the field prior4823* to the update.4824* The get operation has the memory semantics of get.4825* The set operation has the memory semantics of setRelease.4826*4827* @param obj object into which to OR the value4828* @param offset location to OR value in obj4829* @param value to OR to existing value in field4830* @return value of field in obj at offset before update4831*/4832public final long getAndBitwiseOrLongRelease(Object obj, long offset, long value) {4833for (;;) {4834long longAtOffset = getLong(obj, offset);4835if (weakCompareAndSetLongRelease(obj, offset, longAtOffset, longAtOffset | value)) {4836return longAtOffset;4837}4838}4839}48404841/**4842* Atomically OR's the given value to the current value of the4843* field at offset in obj and returns the value of the field prior4844* to the update.4845* The get operation has the memory semantics of getAcquire.4846* The set operation has the memory semantics of set.4847*4848* @param obj object into which to OR the value4849* @param offset location to OR value in obj4850* @param value to OR to existing value in field4851* @return value of field in obj at offset before update4852*/4853public final long getAndBitwiseOrLongAcquire(Object obj, long offset, long value) {4854for (;;) {4855long longAtOffset = getLong(obj, offset);4856if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset, longAtOffset | value)) {4857return longAtOffset;4858}4859}4860}48614862/**4863* Atomically AND's the given value to the current value of the4864* field at offset in obj and returns the value of the field prior4865* to the update.4866* The get operation has the memory semantics of getVolatile.4867* The set operation has the memory semantics of setVolatile.4868*4869* @param obj object into which to AND the value4870* @param offset location to AND value in obj4871* @param value to AND to existing value in field4872* @return value of field in obj at offset before update4873*/4874public final long getAndBitwiseAndLong(Object obj, long offset, long value) {4875for (;;) {4876long longAtOffset = getLongVolatile(obj, offset);4877if (weakCompareAndSetLong(obj, offset, longAtOffset, longAtOffset & value)) {4878return longAtOffset;4879}4880}4881}48824883/**4884* Atomically AND's the given value to the current value of the4885* field at offset in obj and returns the value of the field prior4886* to the update.4887* The get operation has the memory semantics of get.4888* The set operation has the memory semantics of setRelease.4889*4890* @param obj object into which to AND the value4891* @param offset location to AND value in obj4892* @param value to AND to existing value in field4893* @return value of field in obj at offset before update4894*/4895public final long getAndBitwiseAndLongRelease(Object obj, long offset, long value) {4896for (;;) {4897long longAtOffset = getLong(obj, offset);4898if (weakCompareAndSetLongRelease(obj, offset, longAtOffset, longAtOffset & value)) {4899return longAtOffset;4900}4901}4902}49034904/**4905* Atomically AND's the given value to the current value of the4906* field at offset in obj and returns the value of the field prior4907* to the update.4908* The get operation has the memory semantics of getAcquire.4909* The set operation has the memory semantics of set.4910*4911* @param obj object into which to AND the value4912* @param offset location to AND value in obj4913* @param value to AND to existing value in field4914* @return value of field in obj at offset before update4915*/4916public final long getAndBitwiseAndLongAcquire(Object obj, long offset, long value) {4917for (;;) {4918long longAtOffset = getLong(obj, offset);4919if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset, longAtOffset & value)) {4920return longAtOffset;4921}4922}4923}49244925/**4926* Atomically XOR's the given value to the current value of the4927* field at offset in obj and returns the value of the field prior4928* to the update.4929* The get operation has the memory semantics of getVolatile.4930* The set operation has the memory semantics of setVolatile.4931*4932* @param obj object into which to XOR the value4933* @param offset location to XOR value in obj4934* @param value to XOR to existing value in field4935* @return value of field in obj at offset before update4936*/4937public final long getAndBitwiseXorLong(Object obj, long offset, long value) {4938for (;;) {4939long longAtOffset = getLongVolatile(obj, offset);4940if (weakCompareAndSetLong(obj, offset, longAtOffset, longAtOffset ^ value)) {4941return longAtOffset;4942}4943}4944}49454946/**4947* Atomically XOR's the given value to the current value of the4948* field at offset in obj and returns the value of the field prior4949* to the update.4950* The get operation has the memory semantics of get.4951* The set operation has the memory semantics of setRelease.4952*4953* @param obj object into which to XOR the value4954* @param offset location to XOR value in obj4955* @param value to XOR to existing value in field4956* @return value of field in obj at offset before update4957*/4958public final long getAndBitwiseXorLongRelease(Object obj, long offset, long value) {4959for (;;) {4960long longAtOffset = getLong(obj, offset);4961if (weakCompareAndSetLongRelease(obj, offset, longAtOffset, longAtOffset ^ value)) {4962return longAtOffset;4963}4964}4965}49664967/**4968* Atomically XOR's the given value to the current value of the4969* field at offset in obj and returns the value of the field prior4970* to the update.4971* The get operation has the memory semantics of getAcquire.4972* The set operation has the memory semantics of set.4973*4974* @param obj object into which to XOR the value4975* @param offset location to XOR value in obj4976* @param value to XOR to existing value in field4977* @return value of field in obj at offset before update4978*/4979public final long getAndBitwiseXorLongAcquire(Object obj, long offset, long value) {4980for (;;) {4981long longAtOffset = getLong(obj, offset);4982if (weakCompareAndSetLongAcquire(obj, offset, longAtOffset, longAtOffset ^ value)) {4983return longAtOffset;4984}4985}4986}49874988/**4989* Atomically OR's the given value to the current value of the4990* field at offset in obj and returns the value of the field prior4991* to the update.4992* The get operation has the memory semantics of getVolatile.4993* The set operation has the memory semantics of setVolatile.4994*4995* @param obj object into which to OR the value4996* @param offset location to OR value in obj4997* @param value to OR to existing value in field4998* @return value of field in obj at offset before update4999*/5000public final short getAndBitwiseOrShort(Object obj, long offset, short value) {5001for (;;) {5002short shortAtOffset = getShortVolatile(obj, offset);5003if (weakCompareAndSetShort(obj, offset, shortAtOffset, (short) (shortAtOffset | value))) {5004return shortAtOffset;5005}5006}5007}50085009/**5010* Atomically OR's the given value to the current value of the5011* field at offset in obj and returns the value of the field prior5012* to the update.5013* The get operation has the memory semantics of get.5014* The set operation has the memory semantics of setRelease.5015*5016* @param obj object into which to OR the value5017* @param offset location to OR value in obj5018* @param value to OR to existing value in field5019* @return value of field in obj at offset before update5020*/5021public final short getAndBitwiseOrShortRelease(Object obj, long offset, short value) {5022for (;;) {5023short shortAtOffset = getShort(obj, offset);5024if (weakCompareAndSetShortRelease(obj, offset, shortAtOffset, (short) (shortAtOffset | value))) {5025return shortAtOffset;5026}5027}5028}50295030/**5031* Atomically OR's the given value to the current value of the5032* field at offset in obj and returns the value of the field prior5033* to the update.5034* The get operation has the memory semantics of getAcquire.5035* The set operation has the memory semantics of set.5036*5037* @param obj object into which to OR the value5038* @param offset location to OR value in obj5039* @param value to OR to existing value in field5040* @return value of field in obj at offset before update5041*/5042public final short getAndBitwiseOrShortAcquire(Object obj, long offset, short value) {5043for (;;) {5044short shortAtOffset = getShort(obj, offset);5045if (weakCompareAndSetShortAcquire(obj, offset, shortAtOffset, (short) (shortAtOffset | value))) {5046return shortAtOffset;5047}5048}5049}50505051/**5052* Atomically AND's the given value to the current value of the5053* field at offset in obj and returns the value of the field prior5054* to the update.5055* The get operation has the memory semantics of getVolatile.5056* The set operation has the memory semantics of setVolatile.5057*5058* @param obj object into which to AND the value5059* @param offset location to AND value in obj5060* @param value to AND to existing value in field5061* @return value of field in obj at offset before update5062*/5063public final short getAndBitwiseAndShort(Object obj, long offset, short value) {5064for (;;) {5065short shortAtOffset = getShortVolatile(obj, offset);5066if (weakCompareAndSetShort(obj, offset, shortAtOffset, (short) (shortAtOffset & value))) {5067return shortAtOffset;5068}5069}5070}50715072/**5073* Atomically AND's the given value to the current value of the5074* field at offset in obj and returns the value of the field prior5075* to the update.5076* The get operation has the memory semantics of get.5077* The set operation has the memory semantics of setRelease.5078*5079* @param obj object into which to AND the value5080* @param offset location to AND value in obj5081* @param value to AND to existing value in field5082* @return value of field in obj at offset before update5083*/5084public final short getAndBitwiseAndShortRelease(Object obj, long offset, short value) {5085for (;;) {5086short shortAtOffset = getShort(obj, offset);5087if (weakCompareAndSetShortRelease(obj, offset, shortAtOffset, (short) (shortAtOffset & value))) {5088return shortAtOffset;5089}5090}5091}50925093/**5094* Atomically AND's the given value to the current value of the5095* field at offset in obj and returns the value of the field prior5096* to the update.5097* The get operation has the memory semantics of getAcquire.5098* The set operation has the memory semantics of set.5099*5100* @param obj object into which to AND the value5101* @param offset location to AND value in obj5102* @param value to AND to existing value in field5103* @return value of field in obj at offset before update5104*/5105public final short getAndBitwiseAndShortAcquire(Object obj, long offset, short value) {5106for (;;) {5107short shortAtOffset = getShort(obj, offset);5108if (weakCompareAndSetShortAcquire(obj, offset, shortAtOffset, (short) (shortAtOffset & value))) {5109return shortAtOffset;5110}5111}5112}51135114/**5115* Atomically XOR's the given value to the current value of the5116* field at offset in obj and returns the value of the field prior5117* to the update.5118* The get operation has the memory semantics of getVolatile.5119* The set operation has the memory semantics of setVolatile.5120*5121* @param obj object into which to XOR the value5122* @param offset location to XOR value in obj5123* @param value to XOR to existing value in field5124* @return value of field in obj at offset before update5125*/5126public final short getAndBitwiseXorShort(Object obj, long offset, short value) {5127for (;;) {5128short shortAtOffset = getShortVolatile(obj, offset);5129if (weakCompareAndSetShort(obj, offset, shortAtOffset, (short) (shortAtOffset ^ value))) {5130return shortAtOffset;5131}5132}5133}51345135/**5136* Atomically XOR's the given value to the current value of the5137* field at offset in obj and returns the value of the field prior5138* to the update.5139* The get operation has the memory semantics of get.5140* The set operation has the memory semantics of setRelease.5141*5142* @param obj object into which to XOR the value5143* @param offset location to XOR value in obj5144* @param value to XOR to existing value in field5145* @return value of field in obj at offset before update5146*/5147public final short getAndBitwiseXorShortRelease(Object obj, long offset, short value) {5148for (;;) {5149short shortAtOffset = getShort(obj, offset);5150if (weakCompareAndSetShortRelease(obj, offset, shortAtOffset, (short) (shortAtOffset ^ value))) {5151return shortAtOffset;5152}5153}5154}51555156/**5157* Atomically XOR's the given value to the current value of the5158* field at offset in obj and returns the value of the field prior5159* to the update.5160* The get operation has the memory semantics of getAcquire.5161* The set operation has the memory semantics of set.5162*5163* @param obj object into which to XOR the value5164* @param offset location to XOR value in obj5165* @param value to XOR to existing value in field5166* @return value of field in obj at offset before update5167*/5168public final short getAndBitwiseXorShortAcquire(Object obj, long offset, short value) {5169for (;;) {5170short shortAtOffset = getShort(obj, offset);5171if (weakCompareAndSetShortAcquire(obj, offset, shortAtOffset, (short) (shortAtOffset ^ value))) {5172return shortAtOffset;5173}5174}5175}51765177/**5178* Atomically OR's the given value to the current value of the5179* field at offset in obj and returns the value of the field prior5180* to the update.5181* The get operation has the memory semantics of getVolatile.5182* The set operation has the memory semantics of setVolatile.5183*5184* @param obj object into which to OR the value5185* @param offset location to OR value in obj5186* @param value to OR to existing value in field5187* @return value of field in obj at offset before update5188*/5189public final char getAndBitwiseOrChar(Object obj, long offset, char value) {5190for (;;) {5191char charAtOffset = getCharVolatile(obj, offset);5192if (weakCompareAndSetChar(obj, offset, charAtOffset, (char) (charAtOffset | value))) {5193return charAtOffset;5194}5195}5196}51975198/**5199* Atomically OR's the given value to the current value of the5200* field at offset in obj and returns the value of the field prior5201* to the update.5202* The get operation has the memory semantics of get.5203* The set operation has the memory semantics of setRelease.5204*5205* @param obj object into which to OR the value5206* @param offset location to OR value in obj5207* @param value to OR to existing value in field5208* @return value of field in obj at offset before update5209*/5210public final char getAndBitwiseOrCharRelease(Object obj, long offset, char value) {5211for (;;) {5212char charAtOffset = getChar(obj, offset);5213if (weakCompareAndSetCharRelease(obj, offset, charAtOffset, (char) (charAtOffset | value))) {5214return charAtOffset;5215}5216}5217}52185219/**5220* Atomically OR's the given value to the current value of the5221* field at offset in obj and returns the value of the field prior5222* to the update.5223* The get operation has the memory semantics of getAcquire.5224* The set operation has the memory semantics of set.5225*5226* @param obj object into which to OR the value5227* @param offset location to OR value in obj5228* @param value to OR to existing value in field5229* @return value of field in obj at offset before update5230*/5231public final char getAndBitwiseOrCharAcquire(Object obj, long offset, char value) {5232for (;;) {5233char charAtOffset = getChar(obj, offset);5234if (weakCompareAndSetCharAcquire(obj, offset, charAtOffset, (char) (charAtOffset | value))) {5235return charAtOffset;5236}5237}5238}52395240/**5241* Atomically AND's the given value to the current value of the5242* field at offset in obj and returns the value of the field prior5243* to the update.5244* The get operation has the memory semantics of getVolatile.5245* The set operation has the memory semantics of setVolatile.5246*5247* @param obj object into which to AND the value5248* @param offset location to AND value in obj5249* @param value to AND to existing value in field5250* @return value of field in obj at offset before update5251*/5252public final char getAndBitwiseAndChar(Object obj, long offset, char value) {5253for (;;) {5254char charAtOffset = getCharVolatile(obj, offset);5255if (weakCompareAndSetChar(obj, offset, charAtOffset, (char) (charAtOffset & value))) {5256return charAtOffset;5257}5258}5259}52605261/**5262* Atomically AND's the given value to the current value of the5263* field at offset in obj and returns the value of the field prior5264* to the update.5265* The get operation has the memory semantics of get.5266* The set operation has the memory semantics of setRelease.5267*5268* @param obj object into which to AND the value5269* @param offset location to AND value in obj5270* @param value to AND to existing value in field5271* @return value of field in obj at offset before update5272*/5273public final char getAndBitwiseAndCharRelease(Object obj, long offset, char value) {5274for (;;) {5275char charAtOffset = getChar(obj, offset);5276if (weakCompareAndSetCharRelease(obj, offset, charAtOffset, (char) (charAtOffset & value))) {5277return charAtOffset;5278}5279}5280}52815282/**5283* Atomically AND's the given value to the current value of the5284* field at offset in obj and returns the value of the field prior5285* to the update.5286* The get operation has the memory semantics of getAcquire.5287* The set operation has the memory semantics of set.5288*5289* @param obj object into which to AND the value5290* @param offset location to AND value in obj5291* @param value to AND to existing value in field5292* @return value of field in obj at offset before update5293*/5294public final char getAndBitwiseAndCharAcquire(Object obj, long offset, char value) {5295for (;;) {5296char charAtOffset = getChar(obj, offset);5297if (weakCompareAndSetCharAcquire(obj, offset, charAtOffset, (char) (charAtOffset & value))) {5298return charAtOffset;5299}5300}5301}53025303/**5304* Atomically XOR's the given value to the current value of the5305* field at offset in obj and returns the value of the field prior5306* to the update.5307* The get operation has the memory semantics of getVolatile.5308* The set operation has the memory semantics of setVolatile.5309*5310* @param obj object into which to XOR the value5311* @param offset location to XOR value in obj5312* @param value to XOR to existing value in field5313* @return value of field in obj at offset before update5314*/5315public final char getAndBitwiseXorChar(Object obj, long offset, char value) {5316for (;;) {5317char charAtOffset = getCharVolatile(obj, offset);5318if (weakCompareAndSetChar(obj, offset, charAtOffset, (char) (charAtOffset ^ value))) {5319return charAtOffset;5320}5321}5322}53235324/**5325* Atomically XOR's the given value to the current value of the5326* field at offset in obj and returns the value of the field prior5327* to the update.5328* The get operation has the memory semantics of get.5329* The set operation has the memory semantics of setRelease.5330*5331* @param obj object into which to XOR the value5332* @param offset location to XOR value in obj5333* @param value to XOR to existing value in field5334* @return value of field in obj at offset before update5335*/5336public final char getAndBitwiseXorCharRelease(Object obj, long offset, char value) {5337for (;;) {5338char charAtOffset = getChar(obj, offset);5339if (weakCompareAndSetCharRelease(obj, offset, charAtOffset, (char) (charAtOffset ^ value))) {5340return charAtOffset;5341}5342}5343}53445345/**5346* Atomically XOR's the given value to the current value of the5347* field at offset in obj and returns the value of the field prior5348* to the update.5349* The get operation has the memory semantics of getAcquire.5350* The set operation has the memory semantics of set.5351*5352* @param obj object into which to XOR the value5353* @param offset location to XOR value in obj5354* @param value to XOR to existing value in field5355* @return value of field in obj at offset before update5356*/5357public final char getAndBitwiseXorCharAcquire(Object obj, long offset, char value) {5358for (;;) {5359char charAtOffset = getChar(obj, offset);5360if (weakCompareAndSetCharAcquire(obj, offset, charAtOffset, (char) (charAtOffset ^ value))) {5361return charAtOffset;5362}5363}5364}53655366/**5367* Atomically OR's the given value to the current value of the5368* field at offset in obj and returns the value of the field prior5369* to the update.5370* The get operation has the memory semantics of getVolatile.5371* The set operation has the memory semantics of setVolatile.5372*5373* @param obj object into which to OR the value5374* @param offset location to OR value in obj5375* @param value to OR to existing value in field5376* @return value of field in obj at offset before update5377*/5378public final boolean getAndBitwiseOrBoolean(Object obj, long offset, boolean value) {5379byte result = getAndBitwiseOrByte(obj, offset, bool2byte(value));5380return byte2bool(result);5381}53825383/**5384* Atomically OR's the given value to the current value of the5385* field at offset in obj and returns the value of the field prior5386* to the update.5387* The get operation has the memory semantics of get.5388* The set operation has the memory semantics of setRelease.5389*5390* @param obj object into which to OR the value5391* @param offset location to OR value in obj5392* @param value to OR to existing value in field5393* @return value of field in obj at offset before update5394*/5395public final boolean getAndBitwiseOrBooleanRelease(Object obj, long offset, boolean value) {5396byte result = getAndBitwiseOrByteRelease(obj, offset, bool2byte(value));5397return byte2bool(result);5398}53995400/**5401* Atomically OR's the given value to the current value of the5402* field at offset in obj and returns the value of the field prior5403* to the update.5404* The get operation has the memory semantics of getAcquire.5405* The set operation has the memory semantics of set.5406*5407* @param obj object into which to OR the value5408* @param offset location to OR value in obj5409* @param value to OR to existing value in field5410* @return value of field in obj at offset before update5411*/5412public final boolean getAndBitwiseOrBooleanAcquire(Object obj, long offset, boolean value) {5413byte result = getAndBitwiseOrByteAcquire(obj, offset, bool2byte(value));5414return byte2bool(result);5415}54165417/**5418* Atomically AND's the given value to the current value of the5419* field at offset in obj and returns the value of the field prior5420* to the update.5421* The get operation has the memory semantics of getVolatile.5422* The set operation has the memory semantics of setVolatile.5423*5424* @param obj object into which to AND the value5425* @param offset location to AND value in obj5426* @param value to AND to existing value in field5427* @return value of field in obj at offset before update5428*/5429public final boolean getAndBitwiseAndBoolean(Object obj, long offset, boolean value) {5430byte result = getAndBitwiseAndByte(obj, offset, bool2byte(value));5431return byte2bool(result);5432}54335434/**5435* Atomically AND's the given value to the current value of the5436* field at offset in obj and returns the value of the field prior5437* to the update.5438* The get operation has the memory semantics of get.5439* The set operation has the memory semantics of setRelease.5440*5441* @param obj object into which to AND the value5442* @param offset location to AND value in obj5443* @param value to AND to existing value in field5444* @return value of field in obj at offset before update5445*/5446public final boolean getAndBitwiseAndBooleanRelease(Object obj, long offset, boolean value) {5447byte result = getAndBitwiseAndByteRelease(obj, offset, bool2byte(value));5448return byte2bool(result);5449}54505451/**5452* Atomically AND's the given value to the current value of the5453* field at offset in obj and returns the value of the field prior5454* to the update.5455* The get operation has the memory semantics of getAcquire.5456* The set operation has the memory semantics of set.5457*5458* @param obj object into which to AND the value5459* @param offset location to AND value in obj5460* @param value to AND to existing value in field5461* @return value of field in obj at offset before update5462*/5463public final boolean getAndBitwiseAndBooleanAcquire(Object obj, long offset, boolean value) {5464byte result = getAndBitwiseAndByteAcquire(obj, offset, bool2byte(value));5465return byte2bool(result);5466}54675468/**5469* Atomically XOR's the given value to the current value of the5470* field at offset in obj and returns the value of the field prior5471* to the update.5472* The get operation has the memory semantics of getVolatile.5473* The set operation has the memory semantics of setVolatile.5474*5475* @param obj object into which to XOR the value5476* @param offset location to XOR value in obj5477* @param value to XOR to existing value in field5478* @return value of field in obj at offset before update5479*/5480public final boolean getAndBitwiseXorBoolean(Object obj, long offset, boolean value) {5481byte result = getAndBitwiseXorByte(obj, offset, bool2byte(value));5482return byte2bool(result);5483}54845485/**5486* Atomically XOR's the given value to the current value of the5487* field at offset in obj and returns the value of the field prior5488* to the update.5489* The get operation has the memory semantics of get.5490* The set operation has the memory semantics of setRelease.5491*5492* @param obj object into which to XOR the value5493* @param offset location to XOR value in obj5494* @param value to XOR to existing value in field5495* @return value of field in obj at offset before update5496*/5497public final boolean getAndBitwiseXorBooleanRelease(Object obj, long offset, boolean value) {5498byte result = getAndBitwiseXorByteRelease(obj, offset, bool2byte(value));5499return byte2bool(result);5500}55015502/**5503* Atomically XOR's the given value to the current value of the5504* field at offset in obj and returns the value of the field prior5505* to the update.5506* The get operation has the memory semantics of getAcquire.5507* The set operation has the memory semantics of set.5508*5509* @param obj object into which to XOR the value5510* @param offset location to XOR value in obj5511* @param value to XOR to existing value in field5512* @return value of field in obj at offset before update5513*/5514public final boolean getAndBitwiseXorBooleanAcquire(Object obj, long offset, boolean value) {5515byte result = getAndBitwiseXorByteAcquire(obj, offset, bool2byte(value));5516return byte2bool(result);5517}55185519/**5520* Inserts an acquire memory fence, ensuring that no loads before this fence5521* are reordered with any loads/stores after the fence.5522*/5523public final void loadLoadFence() {5524loadFence();5525}55265527/**5528* Inserts a release memory fence, ensuring that no stores before this fence5529* are reordered with any loads/stores after the fence.5530*/5531public final void storeStoreFence() {5532storeFence();5533}55345535/**5536* @return true if machine is big endian, false otherwise5537*/5538public final boolean isBigEndian() {5539return IS_BIG_ENDIAN;5540}55415542/**5543* @return true if addresses are aligned in memory, false otherwise5544*/5545public final boolean unalignedAccess() {5546return UNALIGNED_ACCESS;5547}55485549/**5550* Gets the value of the int in the obj parameter referenced by offset5551* that may be unaligned in memory.5552* This is a non-volatile operation.5553*5554* @param obj object from which to retrieve the value5555* @param offset position of the value in obj5556* @return int value stored in obj5557*/5558public final int getIntUnaligned(Object obj, long offset) {5559int result = 0;55605561if (isOffsetIntAligned(offset)) {5562result = getInt(obj, offset);5563} else if (isOffsetShortAligned(offset)) {5564short first = getShort(obj, offset);5565short second = getShort(obj, 2L + offset);5566result = makeInt(first, second);5567} else {5568byte first = getByte(obj, offset);5569byte second = getByte(obj, 1L + offset);5570byte third = getByte(obj, 2L + offset);5571byte fourth = getByte(obj, 3L + offset);5572result = makeInt(first, second, third, fourth);5573}55745575return result;5576}55775578/**5579* Gets the value of the int in the obj parameter referenced by offset5580* that may be unaligned in memory. Value may be reversed according to5581* the endianness parameter.5582* This is a non-volatile operation.5583*5584* @param obj object from which to retrieve the value5585* @param offset position of the value in obj5586* @param bigEndian in what endianness value should be returned5587* @return int value stored in obj5588*/5589public final int getIntUnaligned(Object obj, long offset, boolean bigEndian) {5590int result = getIntUnaligned(obj, offset);5591return convEndian(bigEndian, result);5592}55935594/**5595* Gets the value of the long in the obj parameter referenced by offset5596* that may be unaligned in memory.5597* This is a non-volatile operation.5598*5599* @param obj object from which to retrieve the value5600* @param offset position of the value in obj5601* @return long value stored in obj5602*/5603public final long getLongUnaligned(Object obj, long offset) {5604long result = 0;56055606if (isOffsetLongAligned(offset)) {5607result = getLong(obj, offset);5608} else if (isOffsetIntAligned(offset)) {5609int first = getInt(obj, offset);5610int second = getInt(obj, 4L + offset);5611result = makeLong(first, second);5612} else if (isOffsetShortAligned(offset)) {5613short first = getShort(obj, offset);5614short second = getShort(obj, 2L + offset);5615short third = getShort(obj, 4L + offset);5616short fourth = getShort(obj, 6L + offset);5617result = makeLong(first, second, third, fourth);5618} else {5619byte first = getByte(obj, offset);5620byte second = getByte(obj, 1L + offset);5621byte third = getByte(obj, 2L + offset);5622byte fourth = getByte(obj, 3L + offset);5623byte fifth = getByte(obj, 4L + offset);5624byte sixth = getByte(obj, 5L + offset);5625byte seventh = getByte(obj, 6L + offset);5626byte eighth = getByte(obj, 7L + offset);5627result = makeLong(first, second, third, fourth, fifth, sixth, seventh, eighth);5628}56295630return result;5631}56325633/**5634* Gets the value of the long in the obj parameter referenced by offset5635* that may be unaligned in memory. Value may be reversed according to5636* the endianness parameter.5637* This is a non-volatile operation.5638*5639* @param obj object from which to retrieve the value5640* @param offset position of the value in obj5641* @param bigEndian in what endianness value should be returned5642* @return long value stored in obj5643*/5644public final long getLongUnaligned(Object obj, long offset, boolean bigEndian) {5645long result = getLongUnaligned(obj, offset);5646return convEndian(bigEndian, result);5647}56485649/**5650* Gets the value of the short in the obj parameter referenced by offset5651* that may be unaligned in memory.5652* This is a non-volatile operation.5653*5654* @param obj object from which to retrieve the value5655* @param offset position of the value in obj5656* @return short value stored in obj5657*/5658public final short getShortUnaligned(Object obj, long offset) {5659short result = 0;56605661if (isOffsetShortAligned(offset)) {5662result = getShort(obj, offset);5663} else {5664byte first = getByte(obj, offset);5665byte second = getByte(obj, 1L + offset);5666result = makeShort(first, second);5667}56685669return result;5670}56715672/**5673* Gets the value of the short in the obj parameter referenced by offset5674* that may be unaligned in memory. Value may be reversed according to5675* the endianness parameter.5676* This is a non-volatile operation.5677*5678* @param obj object from which to retrieve the value5679* @param offset position of the value in obj5680* @param bigEndian in what endianness value should be returned5681* @return short value stored in obj5682*/5683public final short getShortUnaligned(Object obj, long offset, boolean bigEndian) {5684short result = getShortUnaligned(obj, offset);5685return convEndian(bigEndian, result);5686}56875688/**5689* Gets the value of the char in the obj parameter referenced by offset5690* that may be unaligned in memory.5691* This is a non-volatile operation.5692*5693* @param obj object from which to retrieve the value5694* @param offset position of the value in obj5695* @return char value stored in obj5696*/5697public final char getCharUnaligned(Object obj, long offset) {5698char result = 0;56995700if (isOffsetCharAligned(offset)) {5701result = getChar(obj, offset);5702} else {5703byte first = getByte(obj, offset);5704byte second = getByte(obj, 1L + offset);5705result = s2c(makeShort(first, second));5706}57075708return result;5709}57105711/**5712* Gets the value of the char in the obj parameter referenced by offset5713* that may be unaligned in memory. Value may be reversed according to5714* the endianness parameter.5715* This is a non-volatile operation.5716*5717* @param obj object into which to retrieve the value5718* @param offset position of the value in obj5719* @param bigEndian in what endianness value should be returned5720* @return char value stored in obj5721*/5722public final char getCharUnaligned(Object obj, long offset, boolean bigEndian) {5723char result = getCharUnaligned(obj, offset);5724return convEndian(bigEndian, result);5725}57265727/**5728* Sets the value of the int in the obj parameter at memory offset5729* that may be unaligned in memory.5730* This is a non-volatile operation.5731*5732* @param obj object into which to store the value5733* @param offset position of the value in obj5734* @param value int to store in obj5735*/5736public final void putIntUnaligned(Object obj, long offset, int value) {5737if (isOffsetIntAligned(offset)) {5738putInt(obj, offset, value);5739} else if (isOffsetShortAligned(offset)) {5740putIntParts(obj, offset, (short) (value >> 0), (short) (value >>> 16));5741} else {5742putIntParts(obj, offset, (byte) (value >>> 0), (byte) (value >>> 8), (byte) (value >>> 16),5743(byte) (value >>> 24));5744}5745}57465747/**5748* Sets the value of the int in the obj parameter at memory offset5749* that may be unaligned in memory. Value may be reversed according to5750* the endianness parameter.5751* This is a non-volatile operation.5752*5753* @param obj object into which to store the value5754* @param offset position of the value in obj5755* @param value int to store in obj5756* @param bigEndian in what endianness value should be set5757*/5758public final void putIntUnaligned(Object obj, long offset, int value, boolean bigEndian) {5759int endianValue = convEndian(bigEndian, value);5760putIntUnaligned(obj, offset, endianValue);5761}57625763/**5764* Sets the value of the long in the obj parameter at memory offset5765* that may be unaligned in memory.5766* This is a non-volatile operation.5767*5768* @param obj object into which to store the value5769* @param offset position of the value in obj5770* @param value long to store in obj5771*/5772public final void putLongUnaligned(Object obj, long offset, long value) {5773if (isOffsetLongAligned(offset)) {5774putLong(obj, offset, value);5775} else if (isOffsetIntAligned(offset)) {5776putLongParts(obj, offset, (int) (value >> 0), (int) (value >>> 32));5777} else if (isOffsetShortAligned(offset)) {5778putLongParts(obj, offset, (short) (value >>> 0), (short) (value >>> 16), (short) (value >>> 32),5779(short) (value >>> 48));5780} else {5781putLongParts(obj, offset, (byte) (value >>> 0), (byte) (value >>> 8), (byte) (value >>> 16),5782(byte) (value >>> 24), (byte) (value >>> 32), (byte) (value >>> 40), (byte) (value >>> 48),5783(byte) (value >>> 56));5784}5785}57865787/**5788* Sets the value of the long in the obj parameter at memory offset5789* that may be unaligned in memory. Value may be reversed according to5790* the endianness parameter.5791* This is a non-volatile operation.5792*5793* @param obj object into which to store the value5794* @param offset position of the value in obj5795* @param value long to store in obj5796* @param bigEndian in what endianness value should be set5797*/5798public final void putLongUnaligned(Object obj, long offset, long value, boolean bigEndian) {5799long endianValue = convEndian(bigEndian, value);5800putLongUnaligned(obj, offset, endianValue);5801}58025803/**5804* Sets the value of the short in the obj parameter at memory offset5805* that may be unaligned in memory.5806* This is a non-volatile operation.5807*5808* @param obj object into which to store the value5809* @param offset position of the value in obj5810* @param value short to store in obj5811*/5812public final void putShortUnaligned(Object obj, long offset, short value) {5813if (isOffsetShortAligned(offset)) {5814putShort(obj, offset, value);5815} else {5816putShortParts(obj, offset, (byte) (value >>> 0), (byte) (value >>> 8));5817}5818}58195820/**5821* Sets the value of the short in the obj parameter at memory offset5822* that may be unaligned in memory. Value may be reversed according to5823* the endianness parameter.5824* This is a non-volatile operation.5825*5826* @param obj object into which to store the value5827* @param offset position of the value in obj5828* @param value short to store in obj5829* @param bigEndian in what endianness value should be set5830*/5831public final void putShortUnaligned(Object obj, long offset, short value, boolean bigEndian) {5832short endianValue = convEndian(bigEndian, value);5833putShortUnaligned(obj, offset, endianValue);5834}58355836/**5837* Sets the value of the char in the obj parameter at memory offset5838* that may be unaligned in memory.5839* This is a non-volatile operation.5840*5841* @param obj object into which to store the value5842* @param offset position of the value in obj5843* @param value char to store in obj5844*/5845public final void putCharUnaligned(Object obj, long offset, char value) {5846putShortUnaligned(obj, offset, c2s(value));5847}58485849/**5850* Sets the value of the char in the obj parameter at memory offset5851* that may be unaligned in memory. Value may be reversed according to5852* the endianness parameter.5853* This is a non-volatile operation.5854*5855* @param obj object into which to store the value5856* @param offset position of the value in obj5857* @param value char to store in obj5858* @param bigEndian in what endianness value should be set5859*/5860public final void putCharUnaligned(Object obj, long offset, char value, boolean bigEndian) {5861char endianValue = convEndian(bigEndian, value);5862putCharUnaligned(obj, offset, endianValue);5863}58645865/*[IF JAVA_SPEC_VERSION >= 12]*/5866/**5867* If incoming ByteBuffer is an instance of sun.nio.ch.DirectBuffer,5868* and it is direct, and not a slice or duplicate,5869* if it has a cleaner, it is invoked,5870* otherwise an IllegalArgumentException is thrown5871*5872* @param bbo a ByteBuffer object5873* @throws IllegalArgumentException as per description above5874*/5875public void invokeCleaner(ByteBuffer bbo) {5876if (bbo instanceof DirectBuffer) {5877if (bbo.isDirect()) {5878DirectBuffer db = (DirectBuffer)bbo;5879if (db.attachment() == null) {5880Cleaner cleaner = db.cleaner();5881if (cleaner != null) {5882cleaner.clean();5883}5884} else {5885/*[MSG "K0706", "This DirectBuffer object is a slice or duplicate"]*/5886throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0706")); //$NON-NLS-1$5887}5888} else {5889/*[MSG "K0705", "This DirectBuffer object is not direct"]*/5890throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0705")); //$NON-NLS-1$5891}5892} else {5893/*[MSG "K0704", "A sun.nio.ch.DirectBuffer object is expected"]*/5894throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0704")); //$NON-NLS-1$5895}5896}5897/*[ENDIF] JAVA_SPEC_VERSION >= 12 */58985899/*5900* Private methods5901*/5902/* @return true if offset accesses an int that is aligned in memory, else false */5903private boolean isOffsetIntAligned(long offset) {5904/* Masks bits that must be 0 to be int aligned. */5905final long OFFSET_ALIGNED_INT = 0b11L;5906return (0L == (OFFSET_ALIGNED_INT & offset));5907}59085909/* @return true if offset accesses a long that is aligned in memory, else false */5910private boolean isOffsetLongAligned(long offset) {5911/* Masks bits that must be 0 to be long aligned. */5912final long OFFSET_ALIGNED_LONG = 0b111L;5913return (0L == (OFFSET_ALIGNED_LONG & offset));5914}59155916/* @return true if offset accesses a short that is aligned in memory, else false */5917private boolean isOffsetShortAligned(long offset) {5918/* Masks bits that must be 0 to be short aligned. */5919final long OFFSET_ALIGNED_SHORT = 0b1L;5920return (0L == (OFFSET_ALIGNED_SHORT & offset));5921}59225923/* @return true if offset accesses a char that is aligned in memory, else false */5924private boolean isOffsetCharAligned(long offset) {5925return isOffsetShortAligned(offset);5926}59275928/* @return new instance of IllegalArgumentException. */5929private RuntimeException invalidInput() {5930return new IllegalArgumentException();5931}59325933/*5934* Generic compareAndExchange for 8 bit primitives (byte and boolean).5935*5936* @param obj object into which to store the value5937* @param offset location to compare and store value in obj5938* @param compareValue value extended to the size of an int that is5939* expected to be in obj at offset5940* @param exchangeValue value extended to the size of an int that will5941* be set in obj at offset if compare is successful5942* @return value in obj at offset before this operation. This will be compareValue5943* if the exchange was successful5944*/5945private final byte compareAndExchange8bits(Object obj, long offset, int compareValue, int exchangeValue) {5946byte result;59475948if ((obj == null) || obj.getClass().isArray()) {5949/* mask extended 8 bit type to remove any sign extension for negative values */5950compareValue = BYTE_MASK_INT & compareValue;5951exchangeValue = BYTE_MASK_INT & exchangeValue;59525953int byteOffset = pickPos(3, (int) (BYTE_OFFSET_MASK & offset));5954int bitOffset = BITS_IN_BYTE * byteOffset;5955int primitiveMask = BYTE_MASK_INT << (BC_SHIFT_INT_MASK & bitOffset);59565957result = (byte) compareAndExchangeForSmallTypesArraysHelper(obj, offset, compareValue, exchangeValue,5958bitOffset, primitiveMask);5959} else {5960/* object is non-null primitive type */5961result = (byte) compareAndExchangeForSmallTypesPrimitivesHelper(obj, offset, compareValue, exchangeValue);5962}59635964return result;5965}59665967/*5968* Verify that parameters are valid.5969*5970* @throws IllegalArgumentException if 16 bit primitive would span multiple5971* memory blocks5972*/5973private void compareAndExchange16BitsOffsetChecks(long offset) {5974if ((IS_BIG_ENDIAN) && (BYTE_OFFSET_MASK == (BYTE_OFFSET_MASK & offset))) {5975/*[MSG "K0700", "Update spans the word, not supported"]*/5976throw new IllegalArgumentException(com.ibm.oti.util.Msg.getString("K0700")); //$NON-NLS-1$5977}5978}59795980/*5981* Generic compareAndExchange for 16 bit primitives (short and char).5982*5983* @param obj object into which to store the value5984* @param offset location to compare and store value in obj5985* @param compareValue value extended to the size of an int that is5986* expected to be in obj at offset5987* @param exchangeValue value extended to the size of an int that will5988* be set in obj at offset if compare is successful5989* @return value in obj at offset before this operation. This will be compareValue5990* if the exchange was successful5991*5992* @throws IllegalArgumentException if 16 bit type is unaligned in memory5993*/5994private final short compareAndExchange16bits(Object obj, long offset, int compareValue, int exchangeValue) {5995short result;59965997compareAndExchange16BitsOffsetChecks(offset);59985999if ((obj == null) || obj.getClass().isArray()) {6000/* mask extended 16 bit type to remove any sign extension for negative values */6001compareValue = SHORT_MASK_INT & compareValue;6002exchangeValue = SHORT_MASK_INT & exchangeValue;60036004int byteOffset = pickPos(2, (int) (BYTE_OFFSET_MASK & offset));6005int bitOffset = BITS_IN_BYTE * byteOffset;6006int primitiveMask = SHORT_MASK_INT << (BC_SHIFT_INT_MASK & bitOffset);60076008result = (short) compareAndExchangeForSmallTypesArraysHelper(obj, offset, compareValue, exchangeValue,6009bitOffset, primitiveMask);6010} else {6011/* object is non-null primitive type */6012result = (short) compareAndExchangeForSmallTypesPrimitivesHelper(obj, offset, compareValue, exchangeValue);6013}60146015return result;6016}60176018/*6019* Compare and exchange for a primitive and not an array. Method is for6020* primitives smaller than an int such as byte, boolean, char, short.6021*6022* @param obj object into which to store the value6023* @param offset location to compare and store value in obj6024* @param compareValue value extended to the size of an int that is6025* expected to be in obj at offset6026* @param exchangeValue value extended to the size of an int that will6027* be set in obj at offset if compare is successful6028* @return value of the field before this operation extended to the size of6029* an int. This will be compareValue if the exchange was successful6030*/6031private final int compareAndExchangeForSmallTypesPrimitivesHelper(Object obj, long offset, int compareValue,6032int exchangeValue) {6033return compareAndExchangeInt(obj, offset, compareValue, exchangeValue);6034}60356036/*6037* Compare and exchange for an array of primitives. Method is for primitives6038* smaller than an int such as byte, boolean, char, short.6039*6040* @param obj object into which to store the value6041* @param offset location to compare and store value in obj6042* @param compareValue value extended to the size of an int that is6043* expected to be in obj at offset6044* @param exchangeValue value extended to the size of an int that will6045* be set in obj at offset if compare is successful6046* @param bitOffset offset within aligned int to exchanged primitive6047* @param primitiveMask masks bits of exchange value in int6048* @return value of the field before this operation extended to the size of an int.6049* This will be compareValue if the exchange was successful6050*/6051private final int compareAndExchangeForSmallTypesArraysHelper(Object obj, long offset, int compareValue,6052int exchangeValue, int bitOffset, int primitiveMask) {6053for (;;) {6054int compareCopy = getIntVolatile(obj, offset & INT_OFFSET_ALIGN_MASK);60556056/* If object's compare value does not match compareValue argument, fail. */6057if ((compareValue << (BC_SHIFT_INT_MASK & bitOffset)) != (primitiveMask & compareCopy)) {6058return (primitiveMask & compareCopy) >> bitOffset; /* failure */6059}60606061/*6062* Insert exchange value in appropriate position to perform int compare and6063* exchange.6064*/6065int exchangeCopy = (~primitiveMask) & compareCopy;6066exchangeCopy |= exchangeValue << (BC_SHIFT_INT_MASK & bitOffset);60676068int result = compareAndExchangeInt(obj, offset & INT_OFFSET_ALIGN_MASK, compareCopy, exchangeCopy);60696070if (result == compareCopy) {6071return compareValue; /* success */6072} else {6073/*6074* An array value has changed so this operation is no longer atomic. If the6075* index that changed is the one we are trying to exchange, fail. Otherwise try6076* again.6077*/6078result &= primitiveMask;6079if ((primitiveMask & compareCopy) != result) {6080return result >>> (BC_SHIFT_INT_MASK & bitOffset); /* failure */6081}6082}6083}6084}60856086/*6087* Verify that no bits are set in long past the least6088* significant 32.6089*6090* @return true if no bits past 32 are set, false otherwise6091*/6092private boolean is32BitClean(long value) {6093long shiftedValue = value >>> 32;6094return (0L == shiftedValue);6095}60966097/*6098* Verify that parameter is a valid size.6099*6100* @throws IllegalArgumentException if parameter is not valid6101*/6102private void checkSize(long value) {6103if (BYTES_IN_INT == ADDRESS_SIZE) {6104if (!is32BitClean(value)) {6105throw invalidInput();6106}6107} else {6108if (value < 0) {6109throw invalidInput();6110}6111}6112}61136114/*6115* Verify that the address parameter does not exceed the6116* maximum possible value of a native address. Address may6117* be negative to support sign extended pointers.6118*6119* @throws IllegalArgumentException if address is invalid6120*/6121private void checkNativeAddress(long address) {6122if (BYTES_IN_INT == ADDRESS_SIZE) {6123long shiftedValue = address >> 32;61246125/* shiftedValue at this point will be either -1 if address6126* is at most 32 bits and negative, or 0 if the address is6127* 32 bits and positive. The following calculation will only6128* equate to zero and pass the check in these two cases.6129*/6130shiftedValue = (shiftedValue + 1) & -2L;61316132if (0 != shiftedValue) {6133throw invalidInput();6134}6135}6136}61376138/*6139* Verify that parameter is a valid offset in obj.6140*6141* @throws IllegalArgumentException if offset is invalid6142*/6143private void checkOffset(Object obj, long offset) {6144if (BYTES_IN_INT == ADDRESS_SIZE) {6145boolean isClean = is32BitClean(offset);6146if (!isClean) {6147throw invalidInput();6148}6149} else {6150if (offset < 0) {6151throw invalidInput();6152}6153}6154}61556156/*6157* Verify that parameter is a valid offset in obj.6158*6159* @throws IllegalArgumentException if offset is invalid6160*/6161private void checkPointer(Object obj, long offset) {6162if (null == obj) {6163checkNativeAddress(offset);6164} else {6165checkOffset(obj, offset);6166}6167}61686169/*6170* Verify that parameter is a valid array.6171*6172* @throws IllegalArgumentException if verification fails6173*/6174private void checkPrimitiveArray(Class<?> c) {6175Class<?> cType = c.getComponentType();61766177if (null == cType || !cType.isPrimitive()) {6178throw invalidInput();6179}6180}61816182/*6183* Verify that parameter is a valid offset in obj,6184* and obj is a valid array.6185*6186* @throws IllegalArgumentException if verification fails6187*/6188private void checkPrimitivePointer(Object obj, long offset) {6189checkPointer(obj, offset);61906191if (null != obj) {6192checkPrimitiveArray(obj.getClass());6193}6194}61956196/*6197* Verify that parameters is a valid size.6198*6199* @throws IllegalArgumentException if parameter is not valid6200*/6201private void allocateMemoryChecks(long size) {6202checkSize(size);6203}62046205/*6206* Verify that parameters are valid.6207*6208* @throws IllegalArgumentException if parameters are not valid6209*/6210private void reallocateMemoryChecks(long address, long size) {6211checkPointer(null, address);6212checkSize(size);6213}62146215/*6216* Verify that parameters are valid.6217*6218* @throws IllegalArgumentException if startIndex is illegal in obj, or6219* if size is invalid6220*/6221private void setMemoryChecks(Object obj, long startIndex, long size, byte replace) {6222checkPrimitivePointer(obj, startIndex);6223checkSize(size);6224}62256226/*6227* Verify that parameters are valid.6228*6229* @throws IllegalArgumentException if srcOffset is illegal in srcObj,6230* if destOffset is illegal in destObj, or if size is invalid6231*/6232private void copyMemoryChecks(Object srcObj, long srcOffset, Object destObj, long destOffset, long size) {6233checkSize(size);6234checkPrimitivePointer(srcObj, srcOffset);6235checkPrimitivePointer(destObj, destOffset);6236}62376238/*6239* Verify that parameters are valid.6240*6241* @throws IllegalArgumentException if srcOffset is illegal in srcObj,6242* if destOffset is illegal in destObj, if copySize is invalid or copySize is not6243* a multiple of elementSize6244*/6245private void copySwapMemoryChecks(Object srcObj, long srcOffset, Object destObj, long destOffset, long copySize,6246long elementSize) {6247checkSize(copySize);6248if ((2 == elementSize) || (4 == elementSize) || (8 == elementSize)) {6249if (0 == (copySize % elementSize)) {6250checkPrimitivePointer(srcObj, srcOffset);6251checkPrimitivePointer(destObj, destOffset);6252} else {6253throw invalidInput();6254}6255} else {6256throw invalidInput();6257}6258}62596260/*6261* Verify that parameter is valid.6262*6263* @throws IllegalArgumentException if parameter is not valid6264*/6265private void freeMemoryChecks(long startIndex) {6266checkPointer(null, startIndex);6267}62686269/*6270* Allocate new array of same type as class parameter and6271* length of int parameter.6272*6273* @param c class of same type as desired array6274* @param length desired length of array6275* @return allocated array of desired length and type, or null6276* if class type is not a primitive wrapper6277*/6278private Object allocateUninitializedArray0(Class<?> c, int length) {6279Object result = null;62806281if (c == Byte.TYPE) {6282result = new byte[length];6283} else if (c == Boolean.TYPE) {6284result = new boolean[length];6285} else if (c == Short.TYPE) {6286result = new short[length];6287} else if (c == Character.TYPE) {6288result = new char[length];6289} else if (c == Integer.TYPE) {6290result = new int[length];6291} else if (c == Float.TYPE) {6292result = new float[length];6293} else if (c == Long.TYPE) {6294result = new long[length];6295} else if (c == Double.TYPE) {6296result = new double[length];6297}62986299return result;6300}63016302/* Convert short primitive to char. */6303private char s2c(short value) {6304return (char) value;6305}63066307/* Convert char primitive to short. */6308private short c2s(char value) {6309return (short) value;6310}63116312/* Convert byte primitive to boolean. */6313private boolean byte2bool(byte value) {6314return (value != 0);6315}63166317/* Convert boolean primitive to byte. */6318private byte bool2byte(boolean value) {6319return (value) ? (byte) 1 : (byte) 0;6320}63216322/* Throws new instance of IllegalAccessError. */6323private static void throwIllegalAccessError() {6324throw new IllegalAccessError();6325}63266327/*6328* Picks position based on endianness.6329*6330* @param value total length of object6331* @param position little endian position of object6332* @return position based on endianness of machine6333*/6334private static int pickPos(int value, int position) {6335return (IS_BIG_ENDIAN) ? (value - position) : (position);6336}63376338/*6339* Creates an int by concatenating two shorts where the first parameter is the6340* least significant. Ordering is based on endianness of the machine.6341*/6342private static int makeInt(short arg0, short arg1) {6343int result;6344result = toUnsignedInt(arg0) << (BC_SHIFT_INT_MASK & pickPos(16, 0));6345result |= toUnsignedInt(arg1) << (BC_SHIFT_INT_MASK & pickPos(16, 16));6346return result;6347}63486349/*6350* Creates an int by concatenating four bytes where the first parameter is the6351* least significant. Ordering is based on endianness of the machine.6352*/6353private static int makeInt(byte arg0, byte arg1, byte arg2, byte arg3) {6354int result;6355result = toUnsignedInt(arg0) << (BC_SHIFT_INT_MASK & pickPos(24, 0));6356result |= toUnsignedInt(arg1) << (BC_SHIFT_INT_MASK & pickPos(24, 8));6357result |= toUnsignedInt(arg2) << (BC_SHIFT_INT_MASK & pickPos(24, 16));6358result |= toUnsignedInt(arg3) << (BC_SHIFT_INT_MASK & pickPos(24, 24));6359return result;6360}63616362/*6363* Creates a long by concatenating eight bytes where the first parameter is the least significant.6364* Ordering is based on endianness of the machine.6365*/6366private static long makeLong(byte arg0, byte arg1, byte arg2, byte arg3, byte arg4, byte arg5, byte arg6,6367byte arg7) {6368long result;6369result = toUnsignedLong(arg0) << (BC_SHIFT_LONG_MASK & pickPos(56, 0));6370result |= toUnsignedLong(arg1) << (BC_SHIFT_LONG_MASK & pickPos(56, 8));6371result |= toUnsignedLong(arg2) << (BC_SHIFT_LONG_MASK & pickPos(56, 16));6372result |= toUnsignedLong(arg3) << (BC_SHIFT_LONG_MASK & pickPos(56, 24));6373result |= toUnsignedLong(arg4) << (BC_SHIFT_LONG_MASK & pickPos(56, 32));6374result |= toUnsignedLong(arg5) << (BC_SHIFT_LONG_MASK & pickPos(56, 40));6375result |= toUnsignedLong(arg6) << (BC_SHIFT_LONG_MASK & pickPos(56, 48));6376result |= toUnsignedLong(arg7) << (BC_SHIFT_LONG_MASK & pickPos(56, 56));6377return result;6378}63796380/*6381* Creates a long by concatenating four shorts where the first parameter is the least6382* significant. Ordering is based on endianness of the machine.6383*/6384private static long makeLong(short arg0, short arg1, short arg2, short arg3) {6385long result;6386result = toUnsignedLong(arg0) << (BC_SHIFT_LONG_MASK & pickPos(48, 0));6387result |= toUnsignedLong(arg1) << (BC_SHIFT_LONG_MASK & pickPos(48, 16));6388result |= toUnsignedLong(arg2) << (BC_SHIFT_LONG_MASK & pickPos(48, 32));6389result |= toUnsignedLong(arg3) << (BC_SHIFT_LONG_MASK & pickPos(48, 48));6390return result;6391}63926393/*6394* Creates a long by concatenating two integers where the first parameter is the6395* least significant. Ordering is based on endianness of the machine.6396*/6397private static long makeLong(int arg0, int arg1) {6398long result;6399result = toUnsignedLong(arg0) << (BC_SHIFT_LONG_MASK & pickPos(32, 0));6400result |= toUnsignedLong(arg1) << (BC_SHIFT_LONG_MASK & pickPos(32, 32));6401return result;6402}64036404/*6405* Creates a short by concatenating two bytes where the first parameter is the6406* least significant. Ordering is based on endianness of the machine.6407*/6408private static short makeShort(byte arg0, byte arg1) {6409int result;6410result = toUnsignedInt(arg0) << (BC_SHIFT_INT_MASK & pickPos(8, 0));6411result |= toUnsignedInt(arg1) << (BC_SHIFT_INT_MASK & pickPos(8, 8));6412return (short) result;6413}64146415/*6416* Pick first parameter if machine is little endian,6417* otherwise pick second.6418*/6419private static byte pick(byte arg0, byte arg1) {6420return (IS_BIG_ENDIAN) ? arg1 : arg0;6421}64226423/*6424* Pick first parameter if machine is little endian,6425* otherwise pick second.6426*/6427private static short pick(short arg0, short arg1) {6428return (IS_BIG_ENDIAN) ? arg1 : arg0;6429}64306431/*6432* Pick first parameter if machine is little endian,6433* otherwise pick second.6434*/6435private static int pick(int arg0, int arg1) {6436return (IS_BIG_ENDIAN) ? arg1 : arg0;6437}64386439/*6440* Insert int value inserted per short into obj at offset. The first short parameter is the6441* least significant and will be inserted according to machine endianness.6442*/6443private void putIntParts(Object obj, long offset, short part1, short part2) {6444putShort(obj, 0L + offset, pick(part1, part2));6445putShort(obj, 2L + offset, pick(part2, part1));6446}64476448/*6449* Insert int value inserted per byte into obj at offset. The first byte parameter is the6450* least significant and will be inserted according to machine endianness.6451*/6452private void putIntParts(Object obj, long offset, byte part1, byte part2, byte part3, byte part4) {6453putByte(obj, 0L + offset, pick(part1, part4));6454putByte(obj, 1L + offset, pick(part2, part3));6455putByte(obj, 2L + offset, pick(part3, part2));6456putByte(obj, 3L + offset, pick(part4, part1));6457}64586459/*6460* Insert long value inserted per byte into obj at offset. The first byte parameter is the6461* least significant and will be inserted according to machine endianness.6462*/6463private void putLongParts(Object obj, long offset, byte part1, byte part2, byte part3, byte part4, byte part5,6464byte part6, byte part7, byte part8) {6465putByte(obj, 0L + offset, pick(part1, part8));6466putByte(obj, 1L + offset, pick(part2, part7));6467putByte(obj, 2L + offset, pick(part3, part6));6468putByte(obj, 3L + offset, pick(part4, part5));6469putByte(obj, 4L + offset, pick(part5, part4));6470putByte(obj, 5L + offset, pick(part6, part3));6471putByte(obj, 6L + offset, pick(part7, part2));6472putByte(obj, 7L + offset, pick(part8, part1));6473}64746475/*6476* Insert long value inserted per short into obj at offset. The first short parameter is the6477* least significant and will be inserted according to machine endianness.6478*/6479private void putLongParts(Object obj, long offset, short part1, short part2, short part3, short part4) {6480putShort(obj, 0L + offset, pick(part1, part4));6481putShort(obj, 2L + offset, pick(part2, part3));6482putShort(obj, 4L + offset, pick(part3, part2));6483putShort(obj, 6L + offset, pick(part4, part1));6484}64856486/*6487* Insert long value inserted per int into obj at offset. The first int parameter is the6488* least significant and will be inserted according to machine endianness.6489*/6490private void putLongParts(Object obj, long offset, int part1, int part2) {6491putInt(obj, 0L + offset, pick(part1, part2));6492putInt(obj, 4L + offset, pick(part2, part1));6493}64946495/*6496* Insert short value inserted per byte into obj at offset. The first byte parameter is the6497* least significant and will be inserted according to machine endianness.6498*/6499private void putShortParts(Object obj, long offset, byte part1, byte part2) {6500putByte(obj, 0L + offset, pick(part1, part2));6501putByte(obj, 1L + offset, pick(part2, part1));6502}65036504/* Converts byte to unsigned int. */6505private static int toUnsignedInt(byte value) {6506int ivalue = value;6507return BYTE_MASK_INT & ivalue;6508}65096510/* Converts short to unsigned int. */6511private static int toUnsignedInt(short value) {6512int ivalue = value;6513return SHORT_MASK_INT & ivalue;6514}65156516/* Converts byte to unsigned long. */6517private static long toUnsignedLong(byte value) {6518long lvalue = value;6519return BYTE_MASK & lvalue;6520}65216522/* Converts short to unsigned long. */6523private static long toUnsignedLong(short value) {6524long lvalue = value;6525return SHORT_MASK & lvalue;6526}65276528/* Converts int to unsigned long. */6529private static long toUnsignedLong(int value) {6530long lvalue = value;6531return INT_MASK & lvalue;6532}65336534/* Convert int value according to users endianness preference. Bytes may be reversed. */6535private static int convEndian(boolean isBigEndian, int value) {6536return (IS_BIG_ENDIAN == isBigEndian) ? value : Integer.reverseBytes(value);6537}65386539/* Convert long value according to users endianness preference. Bytes may be reversed. */6540private static long convEndian(boolean isBigEndian, long value) {6541return (IS_BIG_ENDIAN == isBigEndian) ? value : Long.reverseBytes(value);6542}65436544/* Convert short value according to users endianness preference. Bytes may be reversed. */6545private static short convEndian(boolean isBigEndian, short value) {6546return (IS_BIG_ENDIAN == isBigEndian) ? value : Short.reverseBytes(value);6547}65486549/* Converts char value according to users endianness preference. Bytes may be reversed. */6550private static char convEndian(boolean isBigEndian, char value) {6551return (IS_BIG_ENDIAN == isBigEndian) ? value : Character.reverseBytes(value);6552}65536554/*[IF INLINE-TYPES]*/6555/**6556* Retrieves the value of the primitive type in the obj parameter referenced by offset.6557* The primitive type in obj at the given offset must be flattened.6558* This is a non-volatile operation.6559*6560* @param obj object from which to retrieve the primitive type6561* @param offset position of the primitive type in obj6562* @param clz the class of primitive type to return6563* @return the value of the primitive type stored in obj at the given offset6564*/6565public native <V> V getValue(Object obj, long offset, Class<?> clz);65666567/**6568* Sets the value of the primitive type in the obj parameter at memory offset.6569* Both the new value and the primitive type in obj at the given offset must be flattened.6570* This is a non-volatile operation.6571*6572* @param obj object into which to store the primitive type6573* @param offset position of the primitive type in obj6574* @param clz the class of the primitive type to store in obj6575* @param value primitive type to store in obj6576*/6577public native <V> void putValue(Object obj, long offset, Class<?> clz, V value);65786579/**6580* Returns the uninitialized default instance of the specified primitive class6581*6582* @param clz the specificed primitive class6583* @return the uninitialized default instance of clz6584*/6585public native <V> V uninitializedDefaultValue(Class<?> clz);65866587/**6588* Determines the size of the header for a specified primitive class6589*6590* @param clz the specified primitive class6591* @return the size of the header for clz6592*/6593public native <V> long valueHeaderSize(Class<V> clz);65946595/**6596* Determines whether a class is a flattened array6597*6598* @param clz the class to check6599* @return boolean value indicating whether the class is a flattened array6600*/6601public native boolean isFlattenedArray(Class<?> clz);66026603/**6604* Determines whether a field is flattened6605*6606* @param field the field to check6607* @return boolean value indicating whether the field is flattened6608*/6609public native boolean isFlattened(Field field);66106611/**6612* Determines the size of an object in bytes6613*6614* @param o the object to determine the size of6615*/6616public native long getObjectSize(Object o);66176618public final <V> boolean compareAndSetValue(Object obj, long offset, Class<?> clz, V v1, V v2) {6619throw OpenJDKCompileStubThrowError();6620}66216622public final <V> Object compareAndExchangeValue(Object obj, long offset, Class<?> clz, V v1, V v2) {6623throw OpenJDKCompileStubThrowError();6624}66256626public final <V> Object compareAndExchangeValueAcquire(Object obj, long offset, Class<?> clz, V v1, V v2) {6627throw OpenJDKCompileStubThrowError();6628}66296630public final <V> Object compareAndExchangeValueRelease(Object obj, long offset, Class<?> clz, V v1, V v2) {6631throw OpenJDKCompileStubThrowError();6632}66336634public final <V> boolean weakCompareAndSetValuePlain(Object obj, long offset, Class<?> clz, V v1, V v2) {6635throw OpenJDKCompileStubThrowError();6636}66376638public final <V> boolean weakCompareAndSetValueAcquire(Object obj, long offset, Class<?> clz, V v1, V v2) {6639throw OpenJDKCompileStubThrowError();6640}66416642public final <V> boolean weakCompareAndSetValueRelease(Object obj, long offset, Class<?> clz, V v1, V v2) {6643throw OpenJDKCompileStubThrowError();6644}66456646public final <V> boolean weakCompareAndSetValue(Object obj, long offset, Class<?> clz, V v1, V v2) {6647throw OpenJDKCompileStubThrowError();6648}66496650/**6651* Atomically retrieves the primitive type in the obj parameter referenced by offset.6652*6653* @param obj object from which to retrieve the primitive type6654* @param offset position of the primitive type in obj6655* @param clz the class of primitive type to return6656* @return primitive type stored in obj6657*/6658public final <V> Object getValueVolatile(Object obj, long offset, Class<?> clz) {6659return getValue(obj, offset, clz);6660}66616662/**6663* Atomically sets the value of the primitive type in the obj parameter at memory offset.6664* This is a non-volatile operation.6665*6666* @param obj object into which to store the primitive type6667* @param offset position of the primitive type in obj6668* @param clz the class of the primitive type to store in obj6669* @param value primitive type to store in obj6670*/6671public final <V> void putValueVolatile(Object obj, long offset, Class<?> clz, V v) {6672putValue(obj, offset, clz, v);6673}66746675public final <V> Object getValueAcquire(Object obj, long offset, Class<?> clz) {6676throw OpenJDKCompileStubThrowError();6677}66786679public final <V> void putValueRelease(Object obj, long offset, Class<?> clz, V v) {6680throw OpenJDKCompileStubThrowError();6681}66826683public final <V> Object getValueOpaque(Object obj, long offset, Class<?> clz) {6684throw OpenJDKCompileStubThrowError();6685}66866687public final <V> void putValueOpaque(Object obj, long offset, Class<?> clz, V v) {6688throw OpenJDKCompileStubThrowError();6689}66906691public final <V> Object getAndSetValue(Object obj, long offset, Class<?> clz, V v) {6692throw OpenJDKCompileStubThrowError();6693}66946695public final <V> Object getAndSetValueRelease(Object obj, long offset, Class<?> clz, V v) {6696throw OpenJDKCompileStubThrowError();6697}66986699public final <V> Object getAndSetValueAcquire(Object obj, long offset, Class<?> clz, V v) {6700throw OpenJDKCompileStubThrowError();6701}67026703/**6704* Atomically sets the reference at offset in obj if the compare value6705* matches the existing value in the object.6706* The get operation has memory semantics of get.6707* The set operation has the memory semantics of setRelease.6708*6709* @param obj object into which to store the value6710* @param offset location to compare and store value in obj6711* @param clz Class of the obj6712* @param compareValue value that is expected to be in obj at offset6713* @param setValue value that will be set in obj at offset if compare is successful6714* @return boolean value indicating whether the field was updated6715*/6716public final <V> boolean compareAndSetReference(Object obj, long offset, Class<?> clz, V compareValue, V setValue) {6717return compareAndSetReference(obj, offset, compareValue, setValue);6718}67196720/**6721* Atomically sets the reference at offset in obj if the compare value6722* matches the existing value in the object.6723* The get operation has memory semantics of getAcquire.6724* The set operation has the memory semantics of set.6725*6726* @param obj object into which to store the value6727* @param offset location to compare and store value in obj6728* @param clz Class of the obj6729* @param compareValue value that is expected to be in obj at offset6730* @param setValue value that will be set in obj at offset if compare is successful6731* @return boolean value indicating whether the field was updated6732*/6733public final <V> boolean weakCompareAndSetReferenceAcquire(Object obj, long offset, Class<?> clz, V compareValue, V setValue) {6734return weakCompareAndSetReferenceAcquire(obj, offset, compareValue, setValue);6735}67366737/**6738* Sets the reference at offset in obj if the compare value6739* matches the existing value in the object.6740* The get operation has memory semantics of get.6741* The set operation has the memory semantics of setRelease.6742*6743* @param obj object into which to store the value6744* @param offset location to compare and store value in obj6745* @param clz Class of the obj6746* @param compareValue value that is expected to be in obj at offset6747* @param setValue value that will be set in obj at offset if compare is successful6748* @return boolean value indicating whether the field was updated6749*/6750public final <V> boolean weakCompareAndSetReferenceRelease(Object obj, long offset, Class<?> clz, V compareValue, V setValue) {6751return weakCompareAndSetReferenceRelease(obj, offset, compareValue, setValue);6752}67536754/**6755* Atomically sets the reference at offset in obj if the compare value6756* matches the existing value in the object.6757* The get operation has memory semantics of getVolatile.6758* The set operation has the memory semantics of setVolatile.6759*6760* @param obj object into which to store the value6761* @param offset location to compare and store value in obj6762* @param clz Class of the obj6763* @param compareValue value that is expected to be in obj at offset6764* @param exchangeValue value that will be set in obj at offset if compare is successful6765* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful6766*/6767public final <V> Object compareAndExchangeReference(Object obj, long offset, Class<?> clz, V compareValue, V exchangeValue) {6768return compareAndExchangeReference(obj, offset, compareValue, exchangeValue);6769}67706771/**6772* Atomically sets the reference at offset in obj if the compare value6773* matches the existing value in the object.6774* The get operation has memory semantics of getAcquire.6775* The set operation has the memory semantics of set.6776*6777* @param obj object into which to store the value6778* @param offset location to compare and store value in obj6779* @param clz Class of the obj6780* @param compareValue value that is expected to be in obj at offset6781* @param exchangeValue value that will be set in obj at offset if compare is successful6782* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful6783*/6784public final <V> Object compareAndExchangeReferenceAcquire(Object obj, long offset, Class<?> clz, V compareValue, V exchangeValue) {6785return compareAndExchangeReferenceAcquire(obj, offset, compareValue, exchangeValue);6786}67876788/**6789* Atomically sets the reference at offset in obj if the compare value6790* matches the existing value in the object.6791* The get operation has memory semantics of get.6792* The set operation has the memory semantics of setRelease.6793*6794* @param obj object into which to store the value6795* @param offset location to compare and store value in obj6796* @param clz Class of the obj6797* @param compareValue value that is expected to be in obj at offset6798* @param exchangeValue value that will be set in obj at offset if compare is successful6799* @return value in obj at offset before this operation. This will be compareValue if the exchange was successful6800*/6801public final <V> Object compareAndExchangeReferenceRelease(Object obj, long offset, Class<?> clz, V compareValue, V exchangeValue) {6802return compareAndExchangeReferenceRelease(obj, offset, compareValue, exchangeValue);6803}68046805/**6806* Sets the reference at offset in obj if the compare value6807* matches the existing value in the object.6808* The get operation has memory semantics of get.6809* The set operation has the memory semantics of set.6810*6811* @param obj object into which to store the value6812* @param offset location to compare and store value in obj6813* @param clz Class of the obj6814* @param compareValue value that is expected to be in obj at offset6815* @param setValue value that will be set in obj at offset if compare is successful6816* @return boolean value indicating whether the field was updated6817*/6818public final <V> boolean weakCompareAndSetReferencePlain(Object obj, long offset, Class<?> clz, V compareValue, V setValue) {6819return weakCompareAndSetReferencePlain(obj, offset, compareValue, setValue);6820}68216822/**6823* Sets the reference at offset in obj if the compare value6824* matches the existing value in the object.6825* The get operation has memory semantics of get.6826* The set operation has the memory semantics of set.6827*6828* @param obj object into which to store the value6829* @param offset location to compare and store value in obj6830* @param clz Class of the obj6831* @param compareValue value that is expected to be in obj at offset6832* @param setValue value that will be set in obj at offset if compare is successful6833* @return boolean value indicating whether the field was updated6834*/6835public final <V> boolean weakCompareAndSetReference(Object obj, long offset, Class<?> clz, V compareValue, V setValue) {6836return weakCompareAndSetReference(obj, offset, compareValue, setValue);6837}68386839public Object getReferenceVolatile(Object obj, long offset, Class<?> clz) {6840// ToDo: this is a temporary implementation - https://github.com/eclipse-openj9/openj9/issues/136146841return getReferenceVolatile(obj, offset);6842}68436844public Object getReference(Object obj, long offset, Class<?> clz) {6845// ToDo: this is a temporary implementation - https://github.com/eclipse-openj9/openj9/issues/136146846return getReference(obj, offset);6847}68486849private static InternalError OpenJDKCompileStubThrowError() {6850// ToDo: https://github.com/eclipse-openj9/openj9/issues/136146851throw new InternalError("Compile stub invoked! Apart from deliberate reflective access, this should not happen. Please report this to the project so it can be addressed"); //$NON-NLS-1$6852}6853/*[ENDIF] INLINE-TYPES */6854}685568566857