You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/08/27 23:54:21 UTC

svn commit: r437465 - in /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes: javasrc/org/apache/harmony/util/concurrent/ javasrc/sun/misc/ native/

Author: ndbeyer
Date: Sun Aug 27 14:54:20 2006
New Revision: 437465

URL: http://svn.apache.org/viewvc?rev=437465&view=rev
Log:
Apply patch for HARMONY-1191: [j.u.c integration with DRLVM - step#2]: implement get/set<*>Volatile methods

Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/util/concurrent/Atomics.java
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/sun/misc/Unsafe.java
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.h

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/util/concurrent/Atomics.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/util/concurrent/Atomics.java?rev=437465&r1=437464&r2=437465&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/util/concurrent/Atomics.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/util/concurrent/Atomics.java Sun Aug 27 14:54:20 2006
@@ -32,6 +32,54 @@
 
     private Atomics() {};
 
+     /*
+      * Writes new value to the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be set
+      * @param offset the field offset within the given object
+      * @param value value to set
+      */
+    public static native void setIntVolatile(Object obj, long offset, int value);
+
+     /*
+      * Reads value from the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be read
+      * @param offset the field offset within the given object
+      * @return the field's value
+      */
+    public static native int getIntVolatile(Object obj, long offset);
+
+     /*
+      * Writes new value to the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be set
+      * @param offset the field offset within the given object
+      * @param value value to set
+      */
+    public static native void setLongVolatile(Object obj, long offset, long value);
+
+     /*
+      * Reads value from the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be read
+      * @param offset the field offset within the given object
+      * @return the field's value
+      */
+    public static native long getLongVolatile(Object obj, long offset);
+
+         /*
+      * Writes new value to the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be set
+      * @param offset the field offset within the given object
+      * @param value value to set
+      */
+    public static native void setObjectVolatile(Object obj, long offset, Object value);
+
+     /*
+      * Reads value from the object's field (by given offset) in volatile manner
+      * @param obj object which field needs to be read
+      * @param offset the field offset within the given object
+      * @return the field's value
+      */
+    public static native Object getObjectVolatile(Object obj, long offset);
+
      /**
       * Returns offset of the given field.
       * @param field the field for which offset is returned

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/sun/misc/Unsafe.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/sun/misc/Unsafe.java?rev=437465&r1=437464&r2=437465&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/sun/misc/Unsafe.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/sun/misc/Unsafe.java Sun Aug 27 14:54:20 2006
@@ -163,7 +163,7 @@
      * @param newValue The value to write.
      */
     public void putIntVolatile(Object object, long fieldOffset, int newValue) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        Atomics.setIntVolatile(object, fieldOffset, newValue);
     }
 
     /**
@@ -177,7 +177,7 @@
      * @return The value that was read.
      */
     public int getIntVolatile(Object object, long fieldOffset) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        return Atomics.getIntVolatile(object, fieldOffset);
     }
 
     /**
@@ -191,7 +191,7 @@
      * @param newValue The value to write.
      */
     public void putLongVolatile(Object object, long fieldOffset, long newValue) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        Atomics.setLongVolatile(object, fieldOffset, newValue);
     }
 
     /**
@@ -205,7 +205,7 @@
      * @return The value that was read.
      */
     public long getLongVolatile(Object object, long fieldOffset) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        return Atomics.getLongVolatile(object, fieldOffset);
     }
 
     /**
@@ -219,7 +219,7 @@
      * @param newValue The value to write.
      */
     public void putObjectVolatile(Object object, long fieldOffset, Object newValue) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        Atomics.setObjectVolatile(object, fieldOffset, newValue);
     }
 
     /**
@@ -233,7 +233,7 @@
      * @param newValue The value to write.
      */
     public Object getObjectVolatile(Object object, long fieldOffset) {
-        throw new UnsupportedOperationException("Not Yet Implemented");
+        return Atomics.getObjectVolatile(object, fieldOffset);
     }
 
     /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.cpp?rev=437465&r1=437464&r2=437465&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.cpp Sun Aug 27 14:54:20 2006
@@ -19,9 +19,61 @@
  */  
 
 #include "jni.h"
+#include "jni_direct.h"
 #include "atomics.h"
 #include "org_apache_harmony_util_concurrent_Atomics.h"
 
+
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setIntVolatile__Ljava_lang_Object_2JI(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset, jint value)
+{
+    SetIntFieldOffset(env, obj, (jint)offset, value);
+    MemoryReadWriteBarrier();
+}
+
+
+JNIEXPORT jint JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getIntVolatile__Ljava_lang_Object_2J(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset)
+{
+    MemoryReadWriteBarrier();
+    return GetIntFieldOffset(env, obj, (jint)offset);
+}
+
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setLongVolatile__Ljava_lang_Object_2JJ(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset, jlong value)
+{
+    SetLongFieldOffset(env, obj, (jint)offset, value);
+    MemoryReadWriteBarrier();
+}
+
+
+JNIEXPORT jlong JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getLongVolatile__Ljava_lang_Object_2J(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset)
+{
+    MemoryReadWriteBarrier();
+    return GetLongFieldOffset(env, obj, (jint)offset);
+}
+
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setObjectVolatile__Ljava_lang_Object_2JLjava_lang_Object_2(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset, jobject value)
+{
+    SetObjectFieldOffset(env, obj, (jint)offset, value);
+    MemoryReadWriteBarrier();
+}
+
+
+JNIEXPORT jobject JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getObjectVolatile__Ljava_lang_Object_2J(JNIEnv * env, jclass self, 
+    jobject obj, jlong offset)
+{
+    MemoryReadWriteBarrier();
+    return GetObjectFieldOffset(env, obj, (jint)offset);
+}
 
 JNIEXPORT jlong JNICALL
 Java_org_apache_harmony_util_concurrent_Atomics_getFieldOffset(JNIEnv * env, jclass self, 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.h?rev=437465&r1=437464&r2=437465&view=diff
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_util_concurrent_Atomics.h Sun Aug 27 14:54:20 2006
@@ -41,6 +41,51 @@
 /* Native methods */
 
 /*
+ * Method: org.apache.harmony.util.concurrent.Atomics.setIntVolatile(Ljava/lang/Object;JI)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setIntVolatile__Ljava_lang_Object_2JI(JNIEnv *, jclass, 
+    jobject, jlong, jint);
+
+
+/*
+ * Method: org.apache.harmony.util.concurrent.Atomics.getIntVolatile(Ljava/lang/Object;J)I
+ */
+JNIEXPORT jint JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getIntVolatile__Ljava_lang_Object_2J(JNIEnv *, jclass, 
+    jobject, jlong);
+
+/*
+ * Method: org.apache.harmony.util.concurrent.Atomics.setLongVolatile(Ljava/lang/Object;JJ)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setLongVolatile__Ljava_lang_Object_2JJ(JNIEnv *, jclass, 
+    jobject, jlong, jlong);
+
+
+/*
+ * Method: org.apache.harmony.util.concurrent.Atomics.getLongVolatile(Ljava/lang/Object;J)J
+ */
+JNIEXPORT jlong JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getLongVolatile__Ljava_lang_Object_2J(JNIEnv *, jclass, 
+    jobject, jlong);
+
+/*
+ * Method: org.apache.harmony.util.concurrent.Atomics.setObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_setObjectVolatile__Ljava_lang_Object_2JLjava_lang_Object_2(JNIEnv *, jclass, 
+    jobject, jlong, jobject);
+
+
+/*
+ * Method: org.apache.harmony.util.concurrent.Atomics.getObjectVolatile(Ljava/lang/Object;J)Ljava/lang/Object;
+ */
+JNIEXPORT jobject JNICALL 
+Java_org_apache_harmony_util_concurrent_Atomics_getObjectVolatile__Ljava_lang_Object_2J(JNIEnv *, jclass, 
+    jobject, jlong);
+
+/*
  * Method: org.apache.harmony.util.concurrent.Atomics.getFieldOffset(Ljava/lang/reflect/Field;)J
  */
 JNIEXPORT jlong JNICALL