[Ikvm-commit] ikvm/openjdk/sun/misc Unsafe.java,1.31,1.32
Brought to you by:
jfrijters
|
From: Jeroen F. <jfr...@us...> - 2014-11-14 15:27:49
|
Update of /cvsroot/ikvm/ikvm/openjdk/sun/misc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10151/openjdk/sun/misc Modified Files: Unsafe.java Log Message: Made Unsafe interlocked operations truly atomic (except for unaligned array access and 'wrong' array type access). Index: Unsafe.java =================================================================== RCS file: /cvsroot/ikvm/ikvm/openjdk/sun/misc/Unsafe.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Unsafe.java 6 Nov 2014 12:29:25 -0000 1.31 --- Unsafe.java 14 Nov 2014 15:27:44 -0000 1.32 *************** *** 119,123 **** } ! private static Field getField(long offset) { synchronized(fields) --- 119,123 ---- } ! static Field getField(long offset) { synchronized(fields) *************** *** 127,167 **** } ! public boolean compareAndSwapObject(Object obj, long offset, Object expect, Object update) ! { ! if(obj instanceof Object[]) ! { ! Object[] arr = (Object[])obj; ! int index = (int)offset; ! synchronized(this) ! { ! if(arr[index] == expect) ! { ! arr[index] = update; ! return true; ! } ! return false; ! } ! } ! else ! { ! Field field = getField(offset); ! synchronized(field) ! { ! try ! { ! if(field.get(obj) == expect) ! { ! field.set(obj, update); ! return true; ! } ! return false; ! } ! catch(IllegalAccessException x) ! { ! throw (InternalError)new InternalError().initCause(x); ! } ! } ! } ! } public void putObjectVolatile(Object obj, long offset, Object newValue) --- 127,131 ---- } ! public final native boolean compareAndSwapObject(Object obj, long offset, Object expect, Object update); public void putObjectVolatile(Object obj, long offset, Object newValue) *************** *** 229,267 **** private static native void WriteInt64(Object obj, long offset, long value); ! public boolean compareAndSwapInt(Object obj, long offset, int expect, int update) ! { ! if (obj instanceof cli.System.Array) ! { ! synchronized(this) ! { ! if(ReadInt32(obj, offset) == expect) ! { ! WriteInt32(obj, offset, update); ! return true; ! } ! return false; ! } ! } ! else ! { ! Field field = getField(offset); ! synchronized(field) ! { ! try ! { ! if(field.getInt(obj) == expect) ! { ! field.setInt(obj, update); ! return true; ! } ! return false; ! } ! catch(IllegalAccessException x) ! { ! throw (InternalError)new InternalError().initCause(x); ! } ! } ! } ! } public void putIntVolatile(Object obj, long offset, int newValue) --- 193,197 ---- private static native void WriteInt64(Object obj, long offset, long value); ! public final native boolean compareAndSwapInt(Object obj, long offset, int expect, int update); public void putIntVolatile(Object obj, long offset, int newValue) *************** *** 322,360 **** } ! public boolean compareAndSwapLong(Object obj, long offset, long expect, long update) ! { ! if (obj instanceof cli.System.Array) ! { ! synchronized(this) ! { ! if(ReadInt64(obj, offset) == expect) ! { ! WriteInt64(obj, offset, update); ! return true; ! } ! return false; ! } ! } ! else ! { ! Field field = getField(offset); ! synchronized(field) ! { ! try ! { ! if(field.getLong(obj) == expect) ! { ! field.setLong(obj, update); ! return true; ! } ! return false; ! } ! catch(IllegalAccessException x) ! { ! throw (InternalError)new InternalError().initCause(x); ! } ! } ! } ! } public void putLongVolatile(Object obj, long offset, long newValue) --- 252,256 ---- } ! public final native boolean compareAndSwapLong(Object obj, long offset, long expect, long update); public void putLongVolatile(Object obj, long offset, long newValue) |