Package com.aparapi.internal.util
Class UnsafeWrapper
- java.lang.Object
-
- com.aparapi.internal.util.UnsafeWrapper
-
public class UnsafeWrapper extends java.lang.ObjectA wrapper around sun.misc.Unsafe for handling atomic operations, copies from fields to arrays and vice versa. We avoid usingsun.misc.Unsafedirectly using reflection, mostly just to avoid getting 'unsafe' compiler errors. This might need to be changed if we start to see performance issues.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.reflect.MethodarrayBaseOffsetMethodprivate static java.lang.reflect.MethodarrayIndexScaleMethodprivate static java.lang.reflect.MethodcompareAndSwapIntMethodprivate static java.lang.reflect.MethodgetBooleanMethodprivate static java.lang.reflect.MethodgetByteMethodprivate static java.lang.reflect.MethodgetFloatMethodprivate static java.lang.reflect.MethodgetIntMethodprivate static java.lang.reflect.MethodgetIntVolatileMethodprivate static java.lang.reflect.MethodgetLongMethodprivate static java.lang.reflect.MethodgetObjectMethodprivate static intintArrayBaseprivate static intintArrayScaleprivate static java.lang.reflect.MethodobjectFieldOffsetMethodprivate static java.lang.reflect.MethodputBooleanMethodprivate static java.lang.reflect.MethodputByteMethodprivate static java.lang.reflect.MethodputDoubleMethodprivate static java.lang.reflect.MethodputFloatMethodprivate static java.lang.reflect.MethodputIntMethodprivate static java.lang.reflect.MethodputLongMethodprivate static java.lang.Objectunsafe
-
Constructor Summary
Constructors Constructor Description UnsafeWrapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intarrayBaseOffset(java.lang.Class<?> _arrayClass)static intarrayIndexScale(java.lang.Class<?> _arrayClass)static intatomicAdd(int[] _arr, int _index, int _delta)static booleangetBoolean(java.lang.Object _object, long _offset)static bytegetByte(java.lang.Object _object, long _offset)static floatgetFloat(java.lang.Object _object, long _offset)static intgetInt(java.lang.Object _object, long _offset)static longgetLong(java.lang.Object _object, long _offset)static java.lang.ObjectgetObject(java.lang.Object _object, long _offset)static longobjectFieldOffset(java.lang.reflect.Field _field)static voidputBoolean(java.lang.Object _object, long _offset, boolean _boolean)static voidputByte(java.lang.Object _object, long _offset, byte _byte)static voidputDouble(java.lang.Object _object, long _offset, double _double)static voidputFloat(java.lang.Object _object, long _offset, float _float)static voidputInt(java.lang.Object _object, long _offset, int _int)static voidputLong(java.lang.Object _object, long _offset, long _long)
-
-
-
Field Detail
-
unsafe
private static java.lang.Object unsafe
-
getIntVolatileMethod
private static java.lang.reflect.Method getIntVolatileMethod
-
arrayBaseOffsetMethod
private static java.lang.reflect.Method arrayBaseOffsetMethod
-
arrayIndexScaleMethod
private static java.lang.reflect.Method arrayIndexScaleMethod
-
getObjectMethod
private static java.lang.reflect.Method getObjectMethod
-
getIntMethod
private static java.lang.reflect.Method getIntMethod
-
getFloatMethod
private static java.lang.reflect.Method getFloatMethod
-
getByteMethod
private static java.lang.reflect.Method getByteMethod
-
getBooleanMethod
private static java.lang.reflect.Method getBooleanMethod
-
getLongMethod
private static java.lang.reflect.Method getLongMethod
-
objectFieldOffsetMethod
private static java.lang.reflect.Method objectFieldOffsetMethod
-
putBooleanMethod
private static java.lang.reflect.Method putBooleanMethod
-
putIntMethod
private static java.lang.reflect.Method putIntMethod
-
putFloatMethod
private static java.lang.reflect.Method putFloatMethod
-
putDoubleMethod
private static java.lang.reflect.Method putDoubleMethod
-
putByteMethod
private static java.lang.reflect.Method putByteMethod
-
putLongMethod
private static java.lang.reflect.Method putLongMethod
-
compareAndSwapIntMethod
private static java.lang.reflect.Method compareAndSwapIntMethod
-
intArrayBase
private static int intArrayBase
-
intArrayScale
private static int intArrayScale
-
-
Method Detail
-
atomicAdd
public static int atomicAdd(int[] _arr, int _index, int _delta)
-
arrayBaseOffset
public static int arrayBaseOffset(java.lang.Class<?> _arrayClass)
-
arrayIndexScale
public static int arrayIndexScale(java.lang.Class<?> _arrayClass)
-
getObject
public static java.lang.Object getObject(java.lang.Object _object, long _offset)
-
getInt
public static int getInt(java.lang.Object _object, long _offset)
-
getFloat
public static float getFloat(java.lang.Object _object, long _offset)
-
getByte
public static byte getByte(java.lang.Object _object, long _offset)
-
getBoolean
public static boolean getBoolean(java.lang.Object _object, long _offset)
-
getLong
public static long getLong(java.lang.Object _object, long _offset)
-
putBoolean
public static void putBoolean(java.lang.Object _object, long _offset, boolean _boolean)
-
putFloat
public static void putFloat(java.lang.Object _object, long _offset, float _float)
-
putInt
public static void putInt(java.lang.Object _object, long _offset, int _int)
-
putDouble
public static void putDouble(java.lang.Object _object, long _offset, double _double)
-
putByte
public static void putByte(java.lang.Object _object, long _offset, byte _byte)
-
putLong
public static void putLong(java.lang.Object _object, long _offset, long _long)
-
objectFieldOffset
public static long objectFieldOffset(java.lang.reflect.Field _field)
-
-