harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r619000 - in /harmony/enhanced/drlvm/trunk/vm/vmcore: build/ src/kernel_classes/javasrc/java/lang/ src/kernel_classes/javasrc/org/apache/harmony/drlvm/ src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ src/kernel_classes/native/ s...
Date Wed, 06 Feb 2008 14:32:39 GMT
Author: gshimansky
Date: Wed Feb  6 06:32:37 2008
New Revision: 619000

URL: http://svn.apache.org/viewvc?rev=619000&view=rev
Log:
Applied patch from HARMONY-4555
[drlvm][thread][perf]Thread.currentThread() works slowly


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/build/vmcore.exp Wed Feb  6 06:32:37 2008
@@ -246,7 +246,7 @@
     Java_java_lang_VMMemoryManager_getMaxMemory;
     Java_java_lang_VMMemoryManager_getTotalMemory;
     Java_java_lang_VMMemoryManager_runGC;
-    Java_java_lang_VMThreadManager_currentThread;
+    Java_java_lang_VMThreadManager_currentThreadNative;
     Java_java_lang_VMThreadManager_getState;
     Java_java_lang_VMThreadManager_holdsLock;
     Java_java_lang_VMThreadManager_init;
@@ -273,6 +273,7 @@
     Java_java_util_concurrent_locks_LockSupport_unpark;
     Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset;
     Java_org_apache_harmony_drlvm_thread_ThreadHelper_getLockWordOffset;
+    Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadJavaObjectOffset;
     Java_org_apache_harmony_drlvm_VMHelperFastPath_getVtableIntfTableOffset;
     Java_org_apache_harmony_drlvm_VMHelperFastPath_getVtableIntfTypeOffset;
     Java_org_apache_harmony_drlvm_VMHelperFastPath_getVtableSuperclassesOffset;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java
Wed Feb  6 06:32:37 2008
@@ -20,6 +20,9 @@
  */
 package java.lang;
 
+import org.apache.harmony.drlvm.VMHelper;
+import org.apache.harmony.drlvm.thread.ThreadHelper;
+
 /**
  * Provides the methods to interact with VM Thread Manager that are used by
  * {@link java.lang.Thread Thread} class and {@link java.lang.Object Object}
@@ -86,7 +89,14 @@
      * thread and hasn't been initialized yet.
      * @api2vm
      */
-    static native Thread currentThread();
+    public static native Thread currentThreadNative();
+
+    static Thread currentThread() {
+        if (VMHelper.isVMMagicPackageSupported()) {
+            return ThreadHelper.getCurrentThread();
+        }
+        return currentThreadNative();
+    }
 
     /**
      * This method satisfies the requirements of the specification for the

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/VMHelper.java
Wed Feb  6 06:32:37 2008
@@ -56,11 +56,11 @@
     public static final int OBJ_INFO_OFFSET = 4;
 
     public static final int CLASS_JLC_HANDLE_OFFSET = getClassJLCHanldeOffset();
-
-
+    
     // preload @Inline vmmagic class
     static final Class pragmaInline = org.vmmagic.pragma.Inline.class;
-
+    static final Class threadHelper = org.apache.harmony.drlvm.thread.ThreadHelper.class;
+    static final Class vmFastPathes = org.apache.harmony.drlvm.VMHelperFastPath.class;
 
     //Slow path versions of helpers
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/drlvm/thread/ThreadHelper.java
Wed Feb  6 06:32:37 2008
@@ -31,6 +31,7 @@
 
     public static final int LOCK_WORD_OFFSET    = getLockWordOffset();
     public static final int TLS_THREAD_ID_OFFSET= getThreadIdOffset();
+    public static final int THREAD_JAVA_OBJECT_OFFSET = getThreadJavaObjectOffset();
 
     @Inline
     static int getThreadId() {
@@ -40,6 +41,17 @@
     }
 
     @Inline
+    public static Thread getCurrentThread() {
+        Address tlsThread = VMHelper.getTlsBaseAddress();
+        Address javaObjectPtr = tlsThread.plus(THREAD_JAVA_OBJECT_OFFSET).loadAddress();
+        if (javaObjectPtr.isZero()) {
+            return null;
+        } else {
+            return (Thread)javaObjectPtr.loadAddress().toObjectReference().toObject();
+        }
+    }
+
+    @Inline
     static void monitorEnterUseReservation(Object obj) {
         Address lockWordPtr = ObjectReference.fromObject(obj).toAddress().plus(LOCK_WORD_OFFSET);
         int threadId = getThreadId();
@@ -107,6 +119,7 @@
 
     private static native int getThreadIdOffset();
     private static native int getLockWordOffset();
+    private static native int getThreadJavaObjectOffset();
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
Wed Feb  6 06:32:37 2008
@@ -33,10 +33,10 @@
 
 /*
  * Class:     java_lang_VMThreadManager
- * Method:    currentThread
+ * Method:    currentThreadNative
  * Signature: ()Ljava/lang/Thread;
  */
-JNIEXPORT jobject JNICALL Java_java_lang_VMThreadManager_currentThread
+JNIEXPORT jobject JNICALL Java_java_lang_VMThreadManager_currentThreadNative
   (JNIEnv * UNREF jenv, jclass clazz)
 {
     return jthread_self();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.h?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.h
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.h
Wed Feb  6 06:32:37 2008
@@ -37,9 +37,9 @@
 /* Native methods */
 
 /*
- * Method: java.lang.VMThreadManager.currentThread()Ljava/lang/Thread;
+ * Method: java.lang.VMThreadManager.currentThreadNative()Ljava/lang/Thread;
  */
-JNIEXPORT jobject JNICALL Java_java_lang_VMThreadManager_currentThread
+JNIEXPORT jobject JNICALL Java_java_lang_VMThreadManager_currentThreadNative
     (JNIEnv *, jclass);
 
 /*

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp?rev=619000&r1=618999&r2=619000&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp Wed Feb  6 06:32:37
2008
@@ -311,6 +311,18 @@
 	return (jint)offset;
 }
 
+/*
+ * Class:     org_apache_harmony_drlvm_thread_ThreadHelper
+ * Method:    getThreadJavaObjectOffset
+ * Signature: ()I
+ */
+VMEXPORT jint JNICALL
+Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadJavaObjectOffset(JNIEnv *env,
jclass klass)
+{
+    vm_thread_t vm_thread = NULL;
+    return (jint)(POINTER_SIZE_INT)&vm_thread->java_thread;
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */



Mime
View raw message