harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r454411 [5/5] - in /incubator/harmony/enhanced/drlvm/trunk: build/make/ build/make/targets/ vm/gcv4/src/ vm/include/ vm/include/open/ vm/interpreter/src/ vm/jitrino/src/vm/drl/ vm/port/src/encoder/ia32_em64t/ vm/port/src/lil/ vm/port/src/li...
Date Mon, 09 Oct 2006 16:02:02 GMT
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMClassRegistry.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMClassRegistry.java?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMClassRegistry.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMClassRegistry.java Mon Oct  9 09:01:52 2006
@@ -41,7 +41,8 @@
  * 
  * @api2vm
  */
-final class VMClassRegistry {
+final class VMClassRegistry 
+{
     /**
      * This method satisfies the requirements of the specification for the
      * {@link Class#getSimpleName() Class.getSimpleName()}
@@ -86,7 +87,8 @@
     /**
      * This class is not supposed to be instantiated.
      */
-    private VMClassRegistry() {
+    private VMClassRegistry() 
+    {
     }
 
     /**
@@ -108,7 +110,7 @@
      * @api2vm
      */
     static native Class<?> defineClass(String name, ClassLoader classLoader,
-        byte[] data, int off, int len) throws ClassFormatError;
+    byte[] data, int off, int len) throws ClassFormatError;
 
     /**
      * This method satisfies the requirements of the specification for the
@@ -138,10 +140,24 @@
 
     /**
      * This method satisfies the requirements of the specification for the
+     * {@link Class#getClassLoader() Class.getClassLoader()} method except
+     * the clazz parameter may be null. In this case context class loader
+     * of the current thread is returned.
+     * 
+     * @api2vm
+     */
+    static ClassLoader getClassLoader(Class<?> clazz) {
+        return clazz != null ? getClassLoader0(clazz)
+            : Thread.currentThread().getContextClassLoader();
+    }
+
+    /**
+     * This method satisfies the requirements of the specification for the
      * {@link Class#getClassLoader() Class.getClassLoader()} method.
+     * 
      * @api2vm
      */
-    static native ClassLoader getClassLoader(Class<?> clazz);
+    static native ClassLoader getClassLoader0(Class<?> clazz);
 
     /**
      * This method satisfies the requirements of the specification for the

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMStart.java Mon Oct  9 09:01:52 2006
@@ -37,7 +37,7 @@
  * </ul> 
  */
 class VMStart {
-	static int exitCode = 0;
+
     public static void initialize() {
         //start helper threads such as Finalizer
         startHelperThreads();
@@ -47,30 +47,6 @@
         parseSystemProperties();
     }
 
-    public static void start (String mainClassName, String args[]) {
-        try {
-            // create main thread in new thread group
-            MainThread mainThread = new MainThread(mainClassName, args);
-            mainThread.start();
-            //startHelperThreads();
-            //System.out.println("Join Group " + Thread.currentThread().getThreadGroup());
-        } catch (Throwable e) {
-            e.printStackTrace(System.err);
-            System.exit(-1);
-        } 
-    }
-
-    public static void shutdown() {
-        try {
-            joinAllNonDaemonThreads();
-            //System.out.println("Joined all ");
-            System.exit(exitCode);
-        } catch (Throwable e) {
-            e.printStackTrace(System.err);
-            System.exit(-1);
-        } 
-    }
-    
     public static void parseSystemProperties() {
     }
     
@@ -87,75 +63,14 @@
     }
     // should shutdown helper threads
     static class DefaultShutDownHook extends Thread {
-        public void run() {
-            FinalizerThread.shutdown();
-            EMThreadSupport.shutdown();
-        }
-    }
-    
-    // main thread
-    static class MainThread extends Thread {
-        String mainClass; 
-        String args[];
-        public boolean started = false;
         
-        MainThread (String mainClass, String args[]) {
-            super(new ThreadGroup("main"), "main");
-            this.mainClass = mainClass;
-            this.args = args;
-            
+        public DefaultShutDownHook() {
+            super("Thread-shutdown");
         }
+
         public void run() {
+            FinalizerThread.shutdown();
+            EMThreadSupport.shutdown();
         }
-
-        void runImpl() {
-            // prevent access from user classes to run() method
-            if(started) {
-                return;
-            }
-            started = true;
-            
-            try {
-                // load and start main class
-                ClassLoader loader = ClassLoader.getSystemClassLoader();
-                Class cl = Class.forName(mainClass, true, loader);
-                final Method mainMethod = cl.getMethod("main", 
-                        new Class[]{String[].class});
-                int expectedModifiers = (Modifier.PUBLIC | Modifier.STATIC);
-                if ((mainMethod.getModifiers() & expectedModifiers) != expectedModifiers 
-                    || mainMethod.getReturnType() != Void.TYPE) {
-                    throw new NoSuchMethodError(
-                        "The method main must be declared public, static, and void.");
-                }
-                // the class itself may be non-public
-                AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                    public Object run() {
-                        mainMethod.setAccessible(true);
-                        return null;
-                    }
-                });
-
-                mainMethod.invoke(null, new Object[] {args});
-            } catch (InvocationTargetException userException) {
-            	exitCode = 1;
-                userException.getCause().printStackTrace();
-            } catch (Throwable e) {
-            	exitCode = 1;
-                e.printStackTrace(System.err);
-            }  finally {
-                group.remove(this);
-                synchronized(lock) {
-                    this.isAlive = false;
-                    lock.notifyAll();
-                }
-           }
-       }
-    }
-    
-    static void mainThreadInit() {
-        Thread theFirstThread = new Thread(true);
     }
-    
-    
-    native static void joinAllNonDaemonThreads();
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/VMThreadManager.java Mon Oct  9 09:01:52 2006
@@ -234,18 +234,12 @@
      */
     static native int yield();
 
-     /**
-      * This method initialize native thread structure as well as inter dependencies
-      * between java thread and native thread.
-      * @api2vm
-      */
-     static native long init(Thread thread, ThreadWeakRef ref, long oldAddr);
-
-     /**
-      * This method attches current thread to vm. Required for main thread construction.
-      * @api2vm
-      */
-     static native int attach(java.lang.Thread thread);
+    /**
+     * This method initialize native thread structure as well as inter dependencies
+     * between java thread and native thread.
+     * @api2vm
+     */
+    static native long init(Thread thread, ThreadWeakRef ref, long oldAddr);
 
     /**
      * Returns the state of the given thread as described by JVMTI spec

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/kernel/vm/VM.java Mon Oct  9 09:01:52 2006
@@ -70,7 +70,7 @@
      * @deprecated
      */
     public static ClassLoader callerClassLoader() {
-        return getClassLoader(VMStack.getCallerClass(1));
+        return getStackClassLoader(2);
     }
 
     private static native ClassLoader getClassLoader(Class clazz);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/VMStack.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/VMStack.java?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/VMStack.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/VMStack.java Mon Oct  9 09:01:52 2006
@@ -114,12 +114,24 @@
      * VMClassRegistry.getClassLoader(Class clazz)} method. It has package
      * visibility only. So it can be used by other classes in this package to
      * to get class loader with out security checks.
-     * @param clazz class to get class loader for. The clazz argument should
-     *        never be null. 
-     * @return class loader of the specified class.
+     * 
+     * @param clazz class to get class loader for.
+     * @return class loader for the specified class.
      * @api2vm
      */
-    static native ClassLoader getClassLoader(Class<?> clazz);
+    static ClassLoader getClassLoader(Class<?> clazz) {
+        return clazz != null ? getClassLoader0(clazz)
+           : Thread.currentThread().getContextClassLoader();
+    }
+
+
+    /**
+     * This method satisfies the requirements of the specification for the
+     * {@link Class#getClassLoader() Class.getClassLoader()} method.
+     * 
+     * @api2vm
+     */
+    static native ClassLoader getClassLoader0(Class<?> clazz);
 
     public static native StackTraceElement[] getThreadStackTrace(Thread t);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.cpp Mon Oct  9 09:01:52 2006
@@ -91,18 +91,17 @@
  * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/lang/Class;
  */
 JNIEXPORT jclass JNICALL Java_java_lang_VMClassRegistry_findLoadedClass
-    (JNIEnv *jenv_ext, jclass, jstring name, jobject cl)
+    (JNIEnv *jenv, jclass, jstring name, jobject cl)
 {
     ASSERT_RAISE_AREA;
 
     // check the name is provided
     if (name == NULL) {
-        ThrowNew_Quick(jenv_ext, "java/lang/NullPointerException", "null class name value.");
+        ThrowNew_Quick(jenv, "java/lang/NullPointerException", "null class name value.");
         return NULL;
     }
 
     // obtain char* for the name
-    JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
     unsigned length = GetStringUTFLength(jenv, name);
     char* buf = (char*)STD_MALLOC(length+1);
     assert(buf);
@@ -116,7 +115,7 @@
 
     // filter out primitive types
 
-    Global_Env *ge = jenv->vm->vm_env;
+    Global_Env *ge = jni_get_vm_env(jenv);
     Class* primitives[] = {
         ge->Boolean_Class,
         ge->Char_Class,
@@ -185,7 +184,7 @@
  * Method:    getClassLoader
  * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader;
  */
-JNIEXPORT jobject JNICALL Java_java_lang_VMClassRegistry_getClassLoader
+JNIEXPORT jobject JNICALL Java_java_lang_VMClassRegistry_getClassLoader0
   (JNIEnv *jenv, jclass, jclass clazz)
 {
     Class_Handle clss = jni_get_class_handle(jenv, clazz);
@@ -556,13 +555,13 @@
     // load native library
     ClassLoaderHandle loader;
     if( classLoader ) {
-        loader = class_loader_lookup( classLoader );
+        loader = class_loader_lookup(classLoader);
     } else {
         // bootstrap class loader
         loader = (ClassLoaderHandle)
-            ((JNIEnv_Internal*)jenv)->vm->vm_env->bootstrap_class_loader;
+            jni_get_vm_env(jenv)->bootstrap_class_loader;
     }
-    class_loader_load_native_lib( str_filename, loader );
+    class_loader_load_native_lib(str_filename, loader);
 
     // release char string
     ReleaseStringUTFChars(jenv, filename, str_filename);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.h?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMClassRegistry.h Mon Oct  9 09:01:52 2006
@@ -67,7 +67,7 @@
  * Method: java.lang.VMClassRegistry.getClassLoader(Ljava/lang/Class;)Ljava/lang/ClassLoader;
  */
 JNIEXPORT jobject JNICALL
-Java_java_lang_VMClassRegistry_getClassLoader(JNIEnv *, jclass, 
+Java_java_lang_VMClassRegistry_getClassLoader0(JNIEnv *, jclass, 
     jclass);
 
 /*

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMExecutionEngine.cpp Mon Oct  9 09:01:52 2006
@@ -45,6 +45,7 @@
 #include "exceptions.h"
 #include "java_lang_VMExecutionEngine.h"
 #include "assertion_registry.h"
+#include "init.h"
 
 /*
  * Class:     java_lang_VMExecutionEngine
@@ -84,7 +85,7 @@
   (JNIEnv * jenv, jclass, jclass jclss, jboolean recursive, jint defaultStatus)
 {
     Assertion_Status status = ASRT_UNSPECIFIED;
-    Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+    Global_Env* genv = jni_get_vm_env(jenv);
     Assertion_Registry* reg = genv->assert_reg;
     if (!reg) {
         return status;
@@ -173,7 +174,7 @@
     PropPut(jenv, pProperties, "java.tmpdir", tmp);
     PropPut(jenv, pProperties, "java.class.path",
         properties_get_string_property( 
-            reinterpret_cast<PropertiesHandle>(&((JNIEnv_Internal*)jenv)->vm->vm_env->properties),
+            reinterpret_cast<PropertiesHandle>(jni_get_vm_env(jenv)->properties),
             "java.class.path") );
 
     // TODO : fix this - it should come from Class.h
@@ -199,7 +200,7 @@
     }
 
     // Next, add runtime specified properties.
-    Properties::Iterator *iterator = VM_Global_State::loader_env->properties.getIterator();
+    Properties::Iterator *iterator = VM_Global_State::loader_env->properties->getIterator();
     const Prop_entry *next = NULL;
     while((next = iterator->next())){
         if (!PropPut(jenv, pProperties, next->key, ((Prop_String*)next->value)->value)){

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMStart.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMStart.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMStart.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMStart.cpp Mon Oct  9 09:01:52 2006
@@ -1,36 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/** 
- * @author Artem Aliev
- * @version $Revision: 1.1.2.1.4.4 $
- */  
-#include "thread_generic.h"
-#include "open/hythread_ext.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT void JNICALL Java_java_lang_VMStart_joinAllNonDaemonThreads (JNIEnv * UNREF jenv, jclass UNREF starter)
-{
-    hythread_wait_for_all_nondaemon_threads();
-}
-
-#ifdef __cplusplus
-}
-#endif

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp Mon Oct  9 09:01:52 2006
@@ -28,6 +28,7 @@
 #include "open/jthread.h"
 #include "open/ti_thread.h"
 #include "open/thread_externals.h"
+#include "jni_utils.h"
 
 /*
  * Class:     java_lang_VMThreadManager
@@ -159,7 +160,7 @@
   (JNIEnv *jenv, jclass clazz, jobject thread, jlong stackSize, jboolean daemon, jint priority)
 {
     jthread_threadattr_t attrs;
-    
+
     attrs.daemon = daemon;
     attrs.priority = priority;
     attrs.stacksize = stackSize > 40000000? 0:(jint)stackSize;
@@ -197,6 +198,7 @@
 JNIEXPORT jint JNICALL Java_java_lang_VMThreadManager_wait
   (JNIEnv *env, jclass clazz, jobject monitor, jlong millis, jint UNREF nanos)
 {
+    // TODO: need to evaluate return code properly
     return jthread_monitor_timed_wait(monitor, millis, nanos);
 }
 
@@ -209,17 +211,6 @@
   (JNIEnv * UNREF jenv, jclass clazz)
 {
     return jthread_yield();
-}
-
-/*
- * Class:     java_lang_VMThreadManager
- * Method:    attach
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_java_lang_VMThreadManager_attach
-  (JNIEnv * UNREF jenv, jclass clazz, jobject java_thread)
-{
-    jthread_attach(jenv, java_thread);
 }
 
 /*

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_kernel_vm_VM.cpp Mon Oct  9 09:01:52 2006
@@ -39,7 +39,7 @@
 (JNIEnv *jenv, jclass, jclass clazz)
 {
     // reuse similar method in VMClassRegistry
-    return Java_java_lang_VMClassRegistry_getClassLoader(jenv, NULL, clazz);
+    return Java_java_lang_VMClassRegistry_getClassLoader0(jenv, NULL, clazz);
 }
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMGenericsAndAnnotations.cpp Mon Oct  9 09:01:52 2006
@@ -76,7 +76,7 @@
 JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_vm_VMGenericsAndAnnotations_getParameterAnnotations
 (JNIEnv *jenv, jclass, jlong jmethod) 
 {
-    static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+    static Global_Env* genv = jni_get_vm_env(jenv);
     Method* method = (Method*) ((POINTER_SIZE_INT) jmethod);
     Class* declaring_class = method->get_class();
 
@@ -91,7 +91,7 @@
     if (num == 0) {
         unsigned nparams = (method->get_num_args() - (method->is_static() ? 0 : 1));
         if (nparams > 0) {
-            static Class* antn_class = ((JNIEnv_Internal*)jenv)->vm->vm_env->LoadCoreClass(
+            static Class* antn_class = jni_get_vm_env(jenv)->LoadCoreClass(
                 "java/lang/annotation/Annotation");
             array = NewObjectArray(jenv, nparams, 
                 struct_Class_to_java_lang_Class_Handle(array_class), NewObjectArray(jenv, 0, 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.cpp Mon Oct  9 09:01:52 2006
@@ -106,9 +106,8 @@
  * Signature: (IZ)[Ljava/lang/Class;
  */
 JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_vm_VMStack_getClasses
-  (JNIEnv *jenv_ext, jclass, jint signedMaxSize, jboolean considerPrivileged)
+  (JNIEnv *jenv, jclass, jint signedMaxSize, jboolean considerPrivileged)
 {
-    JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
     
     // if signedMaxSize is negative, maxSize will be > MAX_INT_VALUE
     unsigned maxSize = signedMaxSize;
@@ -123,7 +122,7 @@
     // For details look at the org/apache/harmony/vm/VMStack.java file. Thus skipping 2 frames.
     unsigned skip = 2;
 
-    Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+    Global_Env* genv = jni_get_vm_env(jenv);
 
     // count target array length ignoring reflection frames
     unsigned length = 0, s;
@@ -214,15 +213,14 @@
  * Signature: (Ljava/lang/Object;)[Ljava/lang/StackTraceElement;
  */
 JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_vm_VMStack_getStackTrace
-  (JNIEnv * jenv_ext, jclass, jobject state)
+  (JNIEnv * jenv, jclass, jobject state)
 {
     ASSERT_RAISE_AREA;
     if (NULL == state)
         return NULL;
 
-    Global_Env* genv = VM_Global_State::loader_env;
+    Global_Env* genv = jni_get_vm_env(jenv);
 
-    JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
      // state object contains raw data as long array
     jlongArray array = (jlongArray)state;
     assert(array);
@@ -255,7 +253,7 @@
         Method *method = frames[skip].method;
         // skip Throwable constructor
         if (method->is_init() && method->get_class() ==
-                VM_Global_State::loader_env->java_lang_Throwable_Class) {
+                genv->java_lang_Throwable_Class) {
             void *old_this = frames[skip].outdated_this;
             skip++;
 
@@ -272,25 +270,6 @@
         }
     }
 
-
-    // skip the VMStart$MainThread.runImpl() if it exists from the bottom
-    // of the stack along with 2 reflection frames used to invoke method main
-    static String* starter_String = genv->string_pool.lookup("java/lang/VMStart$MainThread");
-    Method_Handle method = frames[size - 1].method;
-    assert(method);
-
-    if (!strcmp(method_get_name(method), "runImpl")
-          && method->get_class()->name == starter_String) {
-        for (; --size;) {
-            method = frames[size - 1].method;
-            assert(method);
-            if ((strstr(method->get_class()->name->bytes, "java/lang/reflect"))
-                == NULL) {
-                break;
-            }
-        }
-    }
-
     ASSERT(size >= skip, "Trying to skip " << skip 
         << " frames but there are only "
         << size << " frames in stack");
@@ -335,8 +314,7 @@
      
         tmn_suspend_disable();
         // class name
-        String* className = class_get_java_name(method->get_class(), 
-            VM_Global_State::loader_env);
+        String* className = class_get_java_name(method->get_class(), genv);
         strClassName->object = vm_instantiate_cp_string_resolved(className);
         if (!strClassName->object) {
             tmn_suspend_enable();
@@ -376,7 +354,7 @@
   (JNIEnv *jenv, jclass, jclass clazz)
 {
     // reuse similar method in VMClassRegistry
-    return Java_java_lang_VMClassRegistry_getClassLoader(jenv, NULL, clazz);
+    return Java_java_lang_VMClassRegistry_getClassLoader0(jenv, NULL, clazz);
 }
 
 /*

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.h?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_vm_VMStack.h Mon Oct  9 09:01:52 2006
@@ -72,7 +72,7 @@
  * Method: org.apache.harmony.vm.VMStack.getClassLoader(Ljava/lang/Class;)Ljava/lang/ClassLoader;
  */
 JNIEXPORT jobject JNICALL
-Java_org_apache_harmony_vm_VMStack_getClassLoader(JNIEnv *, jclass, 
+Java_org_apache_harmony_vm_VMStack_getClassLoader0(JNIEnv *, jclass, 
     jclass);
 
 /*

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/object/object_handles.cpp Mon Oct  9 09:01:52 2006
@@ -206,7 +206,7 @@
     h->handle.object = NULL;
     h->allocated_on_the_stack = false;
     
-    tmn_suspend_disable(); // ----------------vvv
+    hythread_suspend_disable(); // ----------------vvv
     p_handle_lock->_lock(); 
     // Insert at beginning of globals list
     h->prev = NULL;
@@ -215,7 +215,7 @@
     if(h->next)
         h->next->prev = h;
     p_handle_lock->_unlock();
-    tmn_suspend_enable(); //--------------------------------------------^^^
+    hythread_suspend_enable(); //--------------------------------------------^^^
     return &h->handle;
 } //vm_create_global_object_handle
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/reflection/annotations.cpp Mon Oct  9 09:01:52 2006
@@ -40,7 +40,7 @@
     unsigned num = table ? table->length : 0;
     TRACE("annotations table size = " << num);
 
-    static Class* antn_class = ((JNIEnv_Internal*)jenv)->vm->vm_env->LoadCoreClass(
+    static Class* antn_class = jni_get_vm_env(jenv)->LoadCoreClass(
         "java/lang/annotation/Annotation");
 
     jobjectArray array = NewObjectArray(jenv, num, 
@@ -122,7 +122,7 @@
     }
     TRACE("Annotation type " << antn_type);
 
-    static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+    static Global_Env* genv = jni_get_vm_env(jenv);
     static Class* factory_class = genv->LoadCoreClass(
         "org/apache/harmony/lang/annotation/AnnotationFactory");
     static jmethodID factory_method = (jmethodID)class_lookup_method(factory_class, "createAnnotation", 
@@ -184,7 +184,7 @@
             if (enum_value) {
                 return enum_value;
             } else {
-                static Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+                static Global_Env* genv = jni_get_vm_env(jenv);
                 static Class* ECNPE_class = genv->LoadCoreClass(
                     "java/lang/EnumConstantNotPresentException");
                 static jmethodID ECNPE_ctor = (jmethodID)class_lookup_method(ECNPE_class, "<init>", 
@@ -210,7 +210,7 @@
                                   String* name, jthrowable* cause, 
                                   jarray array, unsigned idx, Class* type) 
 {
-    Global_Env* genv = ((JNIEnv_Internal*)jenv)->vm->vm_env;
+    Global_Env* genv = jni_get_vm_env(jenv);
     switch (value.tag) {
     case AVT_INT:
         {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/stack/stack_trace.cpp Mon Oct  9 09:01:52 2006
@@ -25,7 +25,7 @@
 #include "stack_trace.h"
 #include "interpreter.h"
 #include "jit_intf_cpp.h"
-
+#include "environment.h"
 #include "method_lookup.h"
 
 void get_file_and_line(Method_Handle mh, void *ip, bool is_ip_past, const char **file, int *line) {
@@ -55,7 +55,8 @@
     uint16 bcOffset;
     POINTER_SIZE_INT callLength = 5;
 
-    CodeChunkInfo* jit_info = vm_methods->find((unsigned char*)ip - callLength);
+    Global_Env * vm_env = VM_Global_State::loader_env;
+    CodeChunkInfo* jit_info = vm_env->vm_methods->find((unsigned char*)ip - callLength);
     if (jit_info->get_jit()->get_bc_location_for_native(
         method,
         (NativeCodePtr) ((POINTER_SIZE_INT) ip - callLength),

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/lock_manager.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/lock_manager.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/lock_manager.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/lock_manager.cpp Mon Oct  9 09:01:52 2006
@@ -46,8 +46,7 @@
 }
 
 Lock_Manager::Lock_Manager()
-{   // init thread menager if needed
-    hythread_init(hythread_lib);
+{
     UNREF IDATA stat = hymutex_create (&lock, TM_MUTEX_NESTED);
     assert(stat==TM_ERROR_NONE);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp Mon Oct  9 09:01:52 2006
@@ -42,15 +42,20 @@
 #include <unistd.h>
 #endif
 
+#include <apr_pools.h>
+
+#include "open/hythread.h"
+#include "open/jthread.h"
 #include "open/thread_externals.h"
-#include "environment.h"
-#include "vm_strings.h"
 #include "open/types.h"
 #include "open/vm_util.h"
+#include "open/gc.h"
+
+#include "environment.h"
+#include "vm_strings.h"
 #include "object_layout.h"
 #include "Class.h"
 #include "classloader.h"
-#include "open/gc.h"
 #include "vm_threads.h"
 #include "nogc.h"
 #include "ini.h"
@@ -62,14 +67,19 @@
 #include "vm_threads.h"
 #include "jni_utils.h"
 #include "object.h"
-
 #include "platform_core_natives.h"
 #include "heap.h"
 #include "verify_stack_enumeration.h"
-
 #include "sync_bits.h"
 #include "vm_stats.h"
 #include "native_utils.h"
+#include "thread_manager.h"
+#include "object_generic.h"
+#include "thread_generic.h"
+#include "mon_enter_exit.h"
+#include "jni_direct.h"
+#include "port_malloc.h"
+
 
 #ifdef PLATFORM_NT
 // wjw -- following lines needs to be generic for all OSs
@@ -78,66 +88,105 @@
 
 #ifdef _IPF_
 #include "java_lang_thread_ipf.h"
+#include "../m2n_ipf_internal.h"
 #elif defined _EM64T_
 #include "java_lang_thread_em64t.h"
+#include "../m2n_em64t_internal.h"
 #else
 #include "java_lang_thread_ia32.h"
+#include "../m2n_ia32_internal.h"
 #endif
 
-#include "thread_manager.h"
-#include "object_generic.h"
-#include "thread_generic.h"
-
-#include "mon_enter_exit.h"
-
-#include "jni_direct.h"
+extern struct JNINativeInterface_ jni_vtable;
 
-#ifdef _IPF_
-#include "../m2n_ipf_internal.h"
-#elif defined _EM64T_
-#include "../m2n_em64t_internal.h"
-#else
-#include "../m2n_ia32_internal.h"
-#endif
+/**
+ * Runs java.lang.Thread.detach() method.
+ */
+static IDATA run_java_detach(jthread java_thread) {
+    static Method * detach = NULL;
+    const char * method_name = "detach";
+    const char * descriptor = "(Ljava/lang/Throwable;)V";
+    jvalue args[2];
+    JNIEnv * jni_env;
+    Global_Env * vm_env;
+    Class * thread_class;
+
+    assert(hythread_is_suspend_enabled());
+
+    jni_env = jthread_get_JNI_env(java_thread);
+    vm_env = jni_get_vm_env(jni_env);
+    thread_class = vm_env->java_lang_Thread_Class;
+
+    if (detach == NULL) {
+        detach = class_lookup_method(thread_class, method_name, descriptor);
+        if (detach == NULL) {
+            TRACE("Failed to find thread's detach method " << descriptor << " , exception = " << exn_get());
+            return TM_ERROR_INTERNAL;
+        }
+    }
 
-#include "port_malloc.h"
+    // Initialize arguments.
+    args[0].l = java_thread;
+    args[1].l = exn_get();
+    exn_clear();
 
-#include "open/jthread.h"
+    hythread_suspend_disable();
+    vm_execute_java_method_array((jmethodID) detach, 0, args);
+    hythread_suspend_enable();
 
-/////////////////////////////////////////////////////////////////////
-// Native lib stuff
+    if (exn_raised()) {
+        TRACE("java.lang.Thread.detach(Throwable) method completed with an exception: " << exn_get_name());
+        return TM_ERROR_INTERNAL;
+    }
+    return TM_ERROR_NONE;
+}
 
+/**
+ * Attaches thread current thread to VM.
+ */
+jint vm_attach(JavaVM * java_vm, JNIEnv ** p_jni_env) {
+    M2nFrame * p_m2n;
+    VM_thread * p_vm_thread;
+    ObjectHandles * p_handles;
+    
+    // It seems to be reasonable to have suspend enabled state here.
+    // It is unsafe to perform operations which require suspend disabled
+    // mode until current thread is not attaced to VM.
+    assert(hythread_is_suspend_enabled());
+
+    p_vm_thread = p_TLS_vmthread;
+    if (p_vm_thread != NULL) {
+        if (java_vm != p_vm_thread->jni_env->vm) {
+            return TM_ERROR_INTERNAL;
+        }
+        *p_jni_env = p_vm_thread->jni_env;
+        return JNI_OK;
+    }
 
-IDATA vm_attach() {
-	//hythread_suspend_disable();
-	IDATA status;
-	status = hythread_global_lock();
-    if(status != TM_ERROR_NONE)
-        return status;
-    VM_thread * p_vm_thread = get_a_thread_block();
-    if (NULL == p_vm_thread) {
+    p_vm_thread = get_a_thread_block((JavaVM_Internal *)java_vm);
+    if (p_vm_thread == NULL) {
         TRACE2("thread", "can't get a thread block for a new thread");
-		status =hythread_global_unlock();
-		assert (status == TM_ERROR_NONE);
-        return TM_ERROR_OUT_OF_MEMORY;
+        return JNI_ENOMEM;
     }
-
-    set_TLS_data(p_vm_thread);
-    M2nFrame* p_m2n = (M2nFrame*) STD_MALLOC(sizeof(M2nFrame));
-    ObjectHandles* p_handles = (ObjectHandles*) STD_MALLOC (sizeof(ObjectHandlesNew));
-    if ((p_m2n==NULL)||(p_handles==NULL))
-	{
+    
+    // Create JNI environment for current thread.
+    p_vm_thread->jni_env = (JNIEnv_Internal *) apr_palloc(p_vm_thread->pool, sizeof(JNIEnv_Internal));
+    
+    // Initialize JNI environment.
+    p_vm_thread->jni_env->functions = &jni_vtable;
+    p_vm_thread->jni_env->vm = (JavaVM_Internal *)java_vm;
+    p_vm_thread->jni_env->reserved0 = (void *)0x1234abcd;
+    *p_jni_env = p_vm_thread->jni_env;
+    
+    // Create top level M2N frame.
+    p_m2n = (M2nFrame*) apr_palloc(p_vm_thread->pool, sizeof(M2nFrame));
+    // Create local handles.
+    p_handles = (ObjectHandles*) apr_palloc(p_vm_thread->pool, sizeof(ObjectHandlesNew));
+    if (p_vm_thread->jni_env == NULL || p_m2n == NULL ||p_handles == NULL) {
         TRACE2("thread", "can't get a thread block for a new thread");
-		status =hythread_global_unlock();
-		assert (status == TM_ERROR_NONE);
-        return TM_ERROR_OUT_OF_MEMORY;
-    }
-    status =hythread_global_unlock();
-    if(status != TM_ERROR_NONE)
-        return status;
-
-	hythread_suspend_disable();
-
+        return JNI_ENOMEM;
+    }
+    
     init_stack_info();
 
     m2n_null_init(p_m2n);
@@ -149,31 +198,57 @@
     m2n_set_frame_type(p_m2n, FRAME_NON_UNWINDABLE);
     gc_thread_init(&p_vm_thread->_gc_private_information);
 
-    assert(!hythread_is_suspend_enabled());
-    hythread_suspend_enable();
-	return TM_ERROR_NONE;
-    }
+    assert(hythread_is_suspend_enabled());
+    return JNI_OK;
+}
+
+/**
+ * Detaches current thread from VM.
+ */
+jint vm_detach(jthread java_thread) {
+    VM_thread * p_vm_thread;
+    jint status;
+    
+    assert(hythread_is_suspend_enabled());
 
-IDATA vm_detach() {
-	IDATA status;
-    VM_thread *p_vm_thread=get_thread_ptr();
+    status = run_java_detach(java_thread);
+    if (status != JNI_OK) return status;
 
     hythread_suspend_disable();
-//  assert(p_vm_thread->app_status == thread_is_running);
+
+    p_vm_thread = get_thread_ptr();
+
+    // Notify GC about thread detaching.
     gc_thread_kill(&p_vm_thread->_gc_private_information);
+    assert(p_vm_thread->gc_frames == 0);
+    // Remove current VM_thread from TLS.
+    set_TLS_data(NULL);
+    // Destroy current VM_thread structure.
+    apr_pool_destroy(p_vm_thread->pool);
+    
     hythread_suspend_enable();
- 
-	status = hythread_global_lock();
-	if(status != TM_ERROR_NONE)
-        return status;
-    assert(p_vm_thread->gc_frames == 0);  
 
-    free_this_thread_block( p_vm_thread );
-    set_TLS_data(NULL);
-	status =hythread_global_unlock();
-	return status;
-    }
+    return JNI_OK;
+
+/** TODO: Check if we need these actions!!!
+    jint monitor_count;
+    jobject * monitor_objects;
     
+#ifndef NDEBUG
+    hythread_t tm_native_thread = jthread_get_native_thread();
+    assert(tm_native_thread);
+    assert(tm_native_thread == hythread_self());
+#endif
 
-////////////////////////////////////////////////////////////////////////////////////////////
-//////// CALLED by vm_init() to initialialize thread groups and create the main thread ////
+    // 2) release all owned monitors if any.
+    status = jthread_get_owned_monitors(java_thread, &monitor_count, &monitor_objects);
+    // TODO: how to deal with OutOfMemoryError?
+    assert(status != TM_ERROR_NONE);
+    for (int i = 0; i < monitor_count; i++) {
+        jthread_monitor_notify_all(monitor_objects[i]);
+        jthread_monitor_exit(monitor_objects[i]);
+    }
+    // 3) Remove tm_thread_t pointer from java.lang.Thread object.
+    vm_jthread_set_tm_data(jthread java_thread, NULL);
+*/
+}

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp Mon Oct  9 09:01:52 2006
@@ -54,11 +54,14 @@
 #include "open/jthread.h"
 
 #include "vm_threads.h"
-#define LOG_DOMAIN "thread"
-#include "cxxlog.h"
 #include "tl/memory_pool.h"
 #include "open/vm_util.h"
 #include "suspend_checker.h"
+#include "jni_utils.h"
+#include "heap.h"
+#include "vm_strings.h"
+#include "interpreter.h"
+#include "exceptions_int.h"
 
 #ifdef PLATFORM_NT
 // wjw -- following lines needs to be generic for all OSs
@@ -71,12 +74,8 @@
 #include "java_lang_thread_ia32.h"
 #endif
 
-#include "interpreter.h"
-#include "exceptions_int.h"
-
-static StaticInitializer thread_runtime_initializer;
-
-static tl::MemoryPool thr_pool;
+#define LOG_DOMAIN "vmcore.thread"
+#include "cxxlog.h"
 
 hythread_tls_key_t TLS_key_pvmthread;
 
@@ -91,52 +90,33 @@
 }
 #endif
 
-void init_TLS_data();
-
-void vm_thread_init(Global_Env * UNREF p_env___not_used)
-{
-   init_TLS_data();
-}
-
-
-void vm_thread_shutdown()
-{
-} //vm_thread_shutdown
-
 
+void init_TLS_data();
 
-VM_thread * get_a_thread_block()
-{
-    VM_thread *p_vmthread;
+VM_thread * get_a_thread_block(JavaVM_Internal * java_vm) {
+    VM_thread * p_vmthread;
+    apr_pool_t * thread_pool;
 
-    p_vmthread = p_TLS_vmthread;   
+    p_vmthread = p_TLS_vmthread;
     if (!p_vmthread) {
-        p_vmthread = (VM_thread *)thr_pool.alloc(sizeof(VM_thread));
-        memset(p_vmthread, 0, sizeof(VM_thread) );
-    }
-    return p_vmthread;
-    } 
-    
-void free_this_thread_block(VM_thread *p_vmthread)
-{
-     }
-        
-void vm_thread_attach()
-{
-    VM_thread *p_vmthread;
-   
-    p_vmthread = p_TLS_vmthread;   
-    if (!p_vmthread) {
-        p_vmthread = (VM_thread *)thr_pool.alloc(sizeof(VM_thread));
-        memset(p_vmthread, 0, sizeof(VM_thread) );
+        if (apr_pool_create(&thread_pool, java_vm->vm_env->mem_pool) != APR_SUCCESS) {
+            return NULL;
+        }
+        p_vmthread = (VM_thread *) apr_pcalloc(thread_pool, sizeof(VM_thread));
+        if (!p_vmthread) return NULL;
+
+        p_vmthread->pool = thread_pool;
         set_TLS_data(p_vmthread);
+    } else {
+        memset(p_vmthread, 0, sizeof(VM_thread));
     }
-} //init_thread_block
-
+    return p_vmthread;
+} 
+            
 VM_thread *get_vm_thread(hythread_t thr) {
     if (thr == NULL) {
         return NULL;
-}
+    }
     return (VM_thread *)hythread_tls_get(thr, TLS_key_pvmthread);
 }
 
@@ -166,7 +146,7 @@
   
 void set_TLS_data(VM_thread *thread) {
     hythread_tls_set(hythread_self(), TLS_key_pvmthread, thread);
-        //printf ("sett ls call %p %p\n", get_thread_ptr(), get_vm_thread(hythread_self()));
+    //printf ("sett ls call %p %p\n", get_thread_ptr(), get_vm_thread(hythread_self()));
 }
 
 IDATA jthread_throw_exception(char* name, char* message) {
@@ -204,7 +184,7 @@
 
 void* vm_jthread_get_tm_data(jthread thread)
 {
-    JNIEnv *jenv = (JNIEnv*)jni_native_intf;    
+    JNIEnv *jenv = jni_native_intf;    
     jclass jThreadClass = jenv->GetObjectClass(thread);
     jfieldID field_id = jenv->GetFieldID(jThreadClass, "vm_thread", "J");
     POINTER_SIZE_INT data = (POINTER_SIZE_INT)jenv->GetLongField(thread, field_id);
@@ -213,17 +193,12 @@
 }
 
 void vm_jthread_set_tm_data(jthread jt, void* nt) {
-    JNIEnv *jenv = (JNIEnv*)jni_native_intf;    
+    JNIEnv *jenv = jni_native_intf;    
     jclass jthreadclass = jenv->GetObjectClass(jt);
     jfieldID field_id = jenv->GetFieldID(jthreadclass, "vm_thread", "J");
     jenv->SetLongField(jt, field_id, (jlong)(POINTER_SIZE_INT)nt);
 }
 
-JNIEnv * get_jnienv(void)
-{
-    return (JNIEnv*)jni_native_intf;
-}
-
 int vm_objects_are_equal(jobject obj1, jobject obj2){
     //ObjectHandle h1 = (ObjectHandle)obj1;
     //ObjectHandle h2 = (ObjectHandle)obj2;
@@ -239,4 +214,3 @@
 int ti_is_enabled(){
     return VM_Global_State::loader_env->TI->isEnabled();
 }
-

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/ini_iA32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/ini_iA32.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/ini_iA32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/ini_iA32.cpp Mon Oct  9 09:01:52 2006
@@ -240,6 +240,7 @@
     }
 
     if (exn_raised()) {
+        TRACE("Exception occured: " << exn_get_name());
         if ((resultPtr != NULL) && (ret_type != JAVA_TYPE_VOID)) {   
             resultPtr->l = 0; //clear result
         }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp Mon Oct  9 09:01:52 2006
@@ -1261,60 +1261,6 @@
  */
 
 
-// a structure used in memoizing already created stubs
-struct TypecheckStubMemoizer {
-    Class *clss;  // the class for which this stub is for
-    void *fast_checkcast_stub, *fast_instanceof_stub;
-    TypecheckStubMemoizer *next;
-
-    static TypecheckStubMemoizer* head;  // head of the list
-    static  tl::MemoryPool mem;  // we'll alocate structures from here
-
-    static void* find_stub(Class *c, bool is_checkcast) {
-        // search for an existing struct for this class
-        for (TypecheckStubMemoizer *t = head;  t != NULL;  t = t->next) {
-            if (t->clss == c) {
-                return (is_checkcast) ?
-                    t->fast_checkcast_stub : t->fast_instanceof_stub;
-            }
-        }
-
-        return NULL;
-    }
-
-    static void add_stub(Class *c, void *stub, bool is_checkcast) {
-        // search for an existing struct for this class
-      
-      TypecheckStubMemoizer *t;
-      for (t = head;  t != NULL;  t = t->next) {
-            if (t->clss == c)
-                break;
-        }
-
-        if (t == NULL) {
-            // create new structure
-            t = (TypecheckStubMemoizer*) mem.alloc(sizeof(TypecheckStubMemoizer));
-            t->clss = c;
-            t->fast_checkcast_stub = NULL;
-            t->fast_instanceof_stub = NULL;
-            t->next = head;
-            head = t;
-        }
-
-        if (is_checkcast) {
-            assert(t->fast_checkcast_stub == NULL);
-            t->fast_checkcast_stub = stub;
-        }
-        else {
-            assert(t->fast_instanceof_stub == NULL);
-            t->fast_instanceof_stub = stub;
-        }
-    }
-};
-
-static StaticInitializer jit_runtime_initializer;
-TypecheckStubMemoizer* TypecheckStubMemoizer::head = NULL;
-tl::MemoryPool TypecheckStubMemoizer::mem;  // we'll alocate structures from here
 
 /* ? 03/07/30: temporary interface change!!! */
 void *vm_get_rt_support_addr_optimized(VM_RT_SUPPORT f, Class_Handle c) {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp Mon Oct  9 09:01:52 2006
@@ -306,12 +306,11 @@
         break;
     default:
 #ifdef _DEBUG
-        printf("Return type %c is not implemented\n", ret_type);
         printf("Returned to C from %s.%s%s\n",
                meth->get_class()->name->bytes, meth->get_name()->bytes,
                meth->get_descriptor()->bytes);
 #endif
-        vm_exit(1);
+        DIE("Return type " << ret_type << " is not implemented\n");
     }
 
 } //vm_execute_java_method_array

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp Mon Oct  9 09:01:52 2006
@@ -126,8 +126,7 @@
 
 static void unimplemented_rt_support_func1(int f, const char *name)
 {
-    printf("This runtime support function is not implemented: f=%d, '%s'\n", f, name);
-    vm_exit(1);
+    DIE("This runtime support function is not implemented: f=" << f << ", " << name);
 } //unimplemented_rt_support_func1
 
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/mem_alloc.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/mem_alloc.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/mem_alloc.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/mem_alloc.cpp Mon Oct  9 09:01:52 2006
@@ -51,7 +51,7 @@
 static apr_thread_mutex_t* jit_code_mutex;
 
 
-// this vector is used to store ptrs of allocated memory to free it in vm_exit
+// this vector is used to store ptrs of allocated memory to free it on exit
 static std::vector<port_vmem_t *> m_allocated_memory_ptrs;
 
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/natives_support.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/natives_support.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/natives_support.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/natives_support.cpp Mon Oct  9 09:01:52 2006
@@ -36,6 +36,7 @@
 #include "open/vm_util.h"
 
 #include "jni_types.h"
+#include "jni_utils.h"
 
 #define LOG_DOMAIN "natives"
 #include "cxxlog.h"
@@ -57,17 +58,17 @@
 
 
 // Initializes natives_support module. Caller must provide thread safety.
-bool natives_init()
+jint natives_init()
 {
     apr_status_t apr_status = apr_pool_create(&jni_libs.ppool, NULL);
 
     if (APR_SUCCESS != apr_status)
     {
         assert(jni_libs.ppool == NULL);
-        return false;
+        return JNI_ENOMEM;
     }
 
-    return true;
+    return JNI_OK;
 }
 
 // Searches for given name trough the list of loaded libraries
@@ -112,7 +113,7 @@
 
         assert(onload_func);
 
-        JavaVM* vm = jni_native_intf->vm; // FIXME ???? Can we use it here ????
+        JavaVM* vm = jni_get_java_vm(jni_native_intf); // FIXME ???? Can we use it here ????
 
         assert(hythread_is_suspend_enabled());
         jint res = onload_func(vm, NULL);
@@ -149,7 +150,7 @@
 
         assert(onunload_func);
 
-        JavaVM* vm = jni_native_intf->vm; // FIXME ???? Can we use it here ????
+        JavaVM* vm = jni_get_java_vm(jni_native_intf); // FIXME ???? Can we use it here ????
 
         assert(hythread_is_suspend_enabled());
         onunload_func(vm, NULL);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/vm_stats.cpp Mon Oct  9 09:01:52 2006
@@ -320,7 +320,6 @@
 }
 
 VM_Statistics & VM_Statistics::get_vm_stats() {
-    static StaticInitializer initializer = StaticInitializer();
     static VM_Statistics vm_stats = VM_Statistics();
     return vm_stats;
 }
@@ -657,6 +656,7 @@
 
 void VM_Statistics::print()
 {
+    Global_Env *env = VM_Global_State::loader_env;
     if(!vm_print_total_stats)
         return;
 
@@ -668,9 +668,7 @@
         print_methods();
     }
 
-    if (vm_methods != NULL) {
-        vm_methods->print_stats();
-    }
+    env->vm_methods->print_stats();
 
     printf("%11" FMT64 "u ::::Number of native methods\n", num_native_methods);
     printf("%11" FMT64 "u ::::Number of Java methods\n",   num_java_methods);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp Mon Oct  9 09:01:52 2006
@@ -114,8 +114,7 @@
 
     case STATUS_PRIVILEGED_INSTRUCTION:
         {
-            ABORT("Unexpected exception code");
-            vm_exit(99553);
+            DIE("Unexpected exception code");
         }
         break;
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmi/src/vmi.cpp Mon Oct  9 09:01:52 2006
@@ -20,6 +20,7 @@
  */  
 #include <assert.h>
 
+
 #include "platform_lowlevel.h"
 #include "vm_trace.h"
 
@@ -147,7 +148,7 @@
 {
     *valuePtr = const_cast<char *>(
         properties_get_string_property(
-            (PropertiesHandle)&VM_Global_State::loader_env->properties, key));
+            (PropertiesHandle)VM_Global_State::loader_env->properties, key));
     return VMI_ERROR_NONE;
 }
 
@@ -158,14 +159,14 @@
     /*
      * The possible implemenation might be:
      */
-    add_pair_to_properties(VM_Global_State::loader_env->properties, key, value);
+    add_pair_to_properties(*VM_Global_State::loader_env->properties, key, value);
     return VMI_ERROR_NONE;
 }
 
 vmiError JNICALL CountSystemProperties(VMInterface *vmi, int *countPtr)
 {
-    Properties &p = VM_Global_State::loader_env->properties;
-    Properties::Iterator *iter = p.getIterator();
+    Properties *p = VM_Global_State::loader_env->properties;
+    Properties::Iterator *iter = p->getIterator();
     int count = 0;
     const Prop_entry *next = NULL;
 
@@ -179,8 +180,8 @@
 vmiError JNICALL IterateSystemProperties(VMInterface *vmi,
         vmiSystemPropertyIterator iterator, void *userData)
 {
-    Properties &p = VM_Global_State::loader_env->properties;
-    Properties::Iterator *iter = p.getIterator();
+    Properties *p = VM_Global_State::loader_env->properties;
+    Properties::Iterator *iter = p->getIterator();
     const Prop_entry *next = NULL;
 
     while((next = iter->next()))

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmstart/src/main.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmstart/src/main.cpp?view=diff&rev=454411&r1=454410&r2=454411
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmstart/src/main.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmstart/src/main.cpp Mon Oct  9 09:01:52 2006
@@ -1,32 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-/** 
- * @author Intel, Alexei Fedotov
- * @version $Revision: 1.1.2.1.4.3 $
- */
-
-int vm_main(int argc, char *argv[]);
-
-int main(int argc, char *argv[])
-{
-    /*
-     * delegate control to vm-provided initialization function
-     * currently found in vmcore/src/init/vm_main.cpp
-     */
-     
-    return vm_main(argc, argv);
-}



Mime
View raw message