harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r489694 - in /harmony/enhanced/drlvm/trunk/vm: interpreter/src/ tests/smoke/shutdown/ vmcore/src/exception/ vmcore/src/init/ vmcore/src/jni/ vmcore/src/thread/
Date Fri, 22 Dec 2006 17:12:59 GMT
Author: gshimansky
Date: Fri Dec 22 09:12:58 2006
New Revision: 489694

URL: http://svn.apache.org/viewvc?view=rev&rev=489694
Log:
Applied HARMONY-2817 [drlvm][interpreter] Exception propogation changed when VM is in shutdwon stage.

Tests passed on Ubuntu8 x86, WindowsXP x86 and SuSE9 x86_64


Modified:
    harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
    harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c
    harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/interpreter/src/interpreter.cpp Fri Dec 22 09:12:58 2006
@@ -2322,6 +2322,20 @@
     uint32 ip = frame.ip - (uint8*)m->get_byte_code_addr();
     DEBUG_BYTECODE("ip = " << dec << (int)ip << endl);
 
+    // When VM is in shutdown stage we need to execute final block to
+    // release monitors and propogate an exception to the upper frames.
+    if (VM_Global_State::loader_env->IsVmShutdowning()) {
+        for(uint32 i = 0; i < m->num_bc_exception_handlers(); i++) {
+            Handler *h = m->get_bc_exception_handler_info(i);
+            if (h->get_catch_type_index() == 0 &&
+                h->get_start_pc() <= ip && ip < h->get_end_pc()) {
+                *hh = h;
+                return true;
+            }
+        }
+        return false;
+    }
+
     Class *clazz = m->get_class();
 
     for(uint32 i = 0; i < m->num_bc_exception_handlers(); i++) {
@@ -2341,6 +2355,7 @@
 
             DEBUG_BYTECODE("catch type index = " << (int)catch_type_index << endl);
 
+            // WARNING: GC may occur here !!!
             Class *obj = interp_resolve_class(clazz, catch_type_index);
 
             if (!obj) {
@@ -2807,12 +2822,15 @@
                                     frame.locked_monitors = new_ml;
                                     Opcode_MONITORENTER(frame);
                                     frame.exc = get_current_thread_exception();
+                                    goto check_exception;
+                                    /*
                                     if (frame.exc != 0) {
                                         frame.locked_monitors = new_ml->next;
                                         new_ml->next = frame.free_monitors;
                                         frame.free_monitors = new_ml;
                                         goto got_exception;
                                     }
+                                    */
                                 }
                                 break;
             case OPCODE_MONITOREXIT:
@@ -2975,19 +2993,6 @@
         if (frame.exc == 0) continue;
 got_exception:
         assert(&frame == getLastStackFrame());
-
-        if (VM_Global_State::loader_env->IsVmShutdowning()) {
-            assert(!hythread_is_suspend_enabled());
-            assert(exn_raised());
-            if (frame.locked_monitors) {
-                M2N_ALLOC_MACRO;
-                vm_monitor_exit_wrapper(frame.locked_monitors->monitor);
-                M2N_FREE_MACRO;
-                assert(!frame.locked_monitors->next);
-            }
-            M2N_FREE_MACRO;
-            return;
-        }
 
         clear_current_thread_exception();
 

Modified: harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.c Fri Dec 22 09:12:58 2006
@@ -19,7 +19,7 @@
     if (methID == NULL) {
         --allocated;
         if (allocated == 0) {
-            printf("PASSED");
+            printf("SED");
         }
         return;
     }
@@ -28,9 +28,9 @@
     if ((*jni_env)->ExceptionOccurred(jni_env)) {
         --allocated;
         if (allocated == 0) {
-            printf("PASSED");
+            printf("SED");
         }
         return;
     }
-    printf("FAILED");
+    printf(" FAILED ");
 }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/smoke/shutdown/TestNativeAllocation.java Fri Dec 22 09:12:58 2006
@@ -42,7 +42,7 @@
                 } catch (Throwable e) {
                     System.out.println("FAILED");
                 } finally {
-                    System.out.println("FAILED");
+                    System.out.print("PAS");
                 }
             }
             System.out.println("FAILED");

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Fri Dec 22 09:12:58 2006
@@ -231,12 +231,10 @@
         ti->vm_brpt->unlock();
     }
 
-    // When VM is in shutdown stage we need to execute final block to
+    // When VM is in shutdown stage we need to execute "finally" clause to
     // release monitors and propogate an exception to the upper frames.
-    if (VM_Global_State::loader_env->IsVmShutdowning()) {
-        exn_class = VM_Global_State::loader_env->JavaLangObject_Class;
-        *exn_obj = NULL;
-    }
+    Class_Handle search_exn_class = !VM_Global_State::loader_env->IsVmShutdowning()
+        ? exn_class : VM_Global_State::loader_env->JavaLangObject_Class;
 
     bool same_frame = true;
     while (!si_is_past_end(si) && !si_is_native(si)) {
@@ -260,7 +258,7 @@
             if (!handler)
                 continue;
             if (handler->is_in_range(ip, is_ip_past)
-                && handler->is_assignable(exn_class)) {
+                && handler->is_assignable(search_exn_class)) {
                 // Found a handler that catches the exception.
 #ifdef VM_STATS
                 cci->num_catches++;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Fri Dec 22 09:12:58 2006
@@ -113,75 +113,97 @@
     //hythread_suspend_enable();
 }
 
-/*
-void vm_shutdown_stop_java_threads(int exit_code)
-{
-    jthread current_java_thread;
-    JNIEnv_Internal * jni_env;
-    Global_Env * vm_env;
-    
-    // Current thread should be in suspend enabled state to prevent
-    // possible dead-locks.
-    assert(hythread_is_suspend_enabled());
-    
-    current_java_thread = jthread_self();
-    // Current thread should be attached to ThreadManager.
-    assert(current_java_thread);
-    jni_env = (JNIEnv_Internal *) jthread_get_JNI_env(current_java_thread);
-    vm_env = jni_env->vm->vm_env;
-    
-    // 2) Acquire VM state lock.
-    apr_thread_mutex_lock(vm_env->vm_state_mutex);
-    assert(vm_env->vm_state != Global_Env::VM_INITIALIZING);
-    
-    // 3) Check VM state.
-    if (vm_env->vm_state == Global_Env::VM_SHUTDOWNING) {
-        apr_thread_mutex_unlock(vm_env->vm_state_mutex);
-        return;
+/**
+ * Stops running java threads by throwing an exception
+ * up to the first native frame.
+ *
+ * @param[in] vm_env a global VM environment
+ */
+static void vm_shutdown_stop_java_threads(Global_Env * vm_env) {
+    hythread_t self;
+    hythread_t * running_threads;
+    hythread_t native_thread;
+    hythread_iterator_t it;
+    VM_thread * vm_thread;
+    int size;
+    bool changed;
+    int left;
+    int prev;
+   
+    self = hythread_self();
+
+    // Collect running java threads.
+    size = 0;
+    it = hythread_iterator_create(NULL);
+    running_threads = (hythread_t *)apr_palloc(vm_env->mem_pool,
+        hythread_iterator_size(it) * sizeof(hythread_t));
+    while(native_thread = hythread_iterator_next(&it)) {
+        vm_thread = get_vm_thread(native_thread);
+        if (vm_thread != NULL && native_thread != self) {
+            running_threads[size] = native_thread;
+            ++size;
+        }
     }
+    hythread_iterator_release(&it);
 
-    assert(vm_env->vm_state == Global_Env::VM_RUNNING);
+    // Interrupt running threads.
+    for (int i = 0; i < size; i++) {
+        hythread_interrupt(running_threads[i]);
+    }
 
-    // 4) Change VM state. Exception propagation mechanism should be changed
-    // upon setting up this flag.
-    vm_env->vm_state = Global_Env::VM_SHUTDOWNING;
-    
-    // 5) Block thread creation.
-    // TODO: investigate how to achive that with ThreadManager
-    
-    // 6) Execute shutdown callback for the current thread.
-    vm_shutdown_callback(NULL);
-    
-    // 7) Setup shutdown callback to all java threads but current.
-    // It causes an exception to be raised and all java monitors to
-    // be released upon reaching a safepoint.
-    hythread_group_set_suspend_disabled_callback(hythread_group_get_java(), vm_shutdown_callback, NULL);
-    
-    // 8) Unlock VM state mutex.
-    apr_thread_mutex_unlock(vm_env->vm_state_mutex);
+    left = size;
+    prev = -1;
+    // Spin until there is no running threads.
+    while (left > 0) {
+        do {
+            left = 0;
+            changed = false;
+            // Join or Interrupt.
+            for (int i = 0; i < size; i++) {
+                if (running_threads[i] == NULL) continue;
+                if (hythread_join_timed(running_threads[i], 100, 0) == TM_ERROR_NONE) {
+                    changed = true;
+                    running_threads[i] = NULL;
+                } else {
+                    hythread_interrupt(running_threads[i]);
+                    ++left;
+                }
+            }
+        } while(left > 0 && changed);
+
+        // We are stuck :-( Need to throw asynchronous exception.
+        if (left > 0) {
+            for (int i = 0; i < size; i++) {
+                if (running_threads[i] == NULL) continue;
+                if (left > 1 && i == prev) { 
+                    continue;
+                } else {
+                    prev = i;
+                    hythread_set_safepoint_callback(running_threads[i], vm_shutdown_callback);
+                }
+            }
+        }
+    }               
 }
-*/
 
 /**
- * TODO:
+ * Waits until all non-daemon threads finish their execution,
+ * initiates VM shutdown sequence and stops running threads if any.
+ *
+ * @param[in] java_vm JVM that should be destroyed
+ * @param[in] java_thread current java thread
  */
 jint vm_destroy(JavaVM_Internal * java_vm, jthread java_thread)
 {
     jint status;
     JNIEnv * jni_env;
     jobject uncaught_exception;
-    VM_thread * vm_thread;
-    hythread_t native_thread;
-    hythread_t self;
-    hythread_iterator_t it;
-    hythread_t * running_threads;
-    int size;
 
     assert(hythread_is_suspend_enabled());
 
     jni_env = jthread_get_JNI_env(java_thread);
-    self = hythread_self();
 
+    // Wait until all non-daemon threads finish their execution.
     status = jthread_wait_for_all_nondaemon_threads();
     if (status != TM_ERROR_NONE) {
         TRACE("Failed to wait for all non-daemon threads completion.");
@@ -233,29 +255,7 @@
     // before destroying VM-wide data.
 
     // Stop java threads
-    size = 0;
-    it = hythread_iterator_create(NULL);
-    running_threads = (hythread_t *)apr_palloc(
-        java_vm->vm_env->mem_pool, hythread_iterator_size(it) * sizeof(hythread_t));
-    while(native_thread = hythread_iterator_next(&it)) {
-        vm_thread = get_vm_thread(native_thread);
-        if (vm_thread != NULL && native_thread != self) {
-            running_threads[size] = native_thread;
-            ++size;
-            hythread_set_safepoint_callback(native_thread, vm_shutdown_callback);
-        }
-    }
-    hythread_iterator_release(&it);
-
-    // Interrupt running threads.
-    for (int i = 0; i < size; i++) {
-        hythread_interrupt(running_threads[i]);
-    }
-
-    // Wait for threads completion.
-    for (int i = 0; i < size; i++) {
-        hythread_join(running_threads[i]);
-    }
+    vm_shutdown_stop_java_threads(java_vm->vm_env);
 
     // TODO: ups we don't stop native threads as well :-((
     // We are lucky! Currently, there are no such threads.

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Fri Dec 22 09:12:58 2006
@@ -656,13 +656,12 @@
     TRACE2("jni", "FindClass called, name = " << name);
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (exn_raised() || vm_env->IsVmShutdowning()) return NULL;
+
+    if (exn_raised()) return NULL;
     char *ch = strchr(name, '.');
     if (NULL != ch)
     {
-        ThrowNew_Quick(jni_env,
-            VM_Global_State::loader_env->JavaLangNoClassDefFoundError_String->bytes,
-            name);
+        ThrowNew_Quick(jni_env, vm_env->JavaLangNoClassDefFoundError_String->bytes, name);
         return NULL;
     }
 
@@ -676,8 +675,8 @@
     TRACE2("jni", "GetSuperclass called");
     assert(hythread_is_suspend_enabled());
     
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
+
     Class* clss = jclass_to_struct_Class(clazz);
     if(clss) {
         if(clss->is_interface()) {
@@ -774,21 +773,12 @@
 // chacks usage of this function and replace by lazy
 jthrowable JNICALL ExceptionOccurred(JNIEnv * jni_env)
 {
+    jthrowable result;
+
     TRACE2("jni", "ExceptionOccurred called");
     assert(hythread_is_suspend_enabled());
-    
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) {
-        // Wait until shutdown exception is raised by callback.
-        while (!exn_raised()) {
-            // Switch enable/disable status to give a chance for
-            // callback execution.
-            hythread_suspend_disable();
-            hythread_suspend_enable();
-            hythread_yield();
-        }
-    }
-    jthrowable result = exn_get();
+        
+    result = exn_get();
 
 #ifdef _DEBUG
     hythread_suspend_disable();
@@ -797,9 +787,6 @@
     } else {
         TRACE2("jni", "Exception occured, no exception");        
     }
-    if (vm_env->IsVmShutdowning() && !result) {
-        TRACE2("vm.core.shutdown", "ExceptionOccured: shutdown exception hasn't been raised");
-    }
     hythread_suspend_enable();
 #endif
     
@@ -810,9 +797,11 @@
 {
     TRACE2("jni", "ExceptionDescribe called");
     assert(hythread_is_suspend_enabled());
+    
     // we should not report vm shutdown exception to the user
     Global_Env * vm_env = jni_get_vm_env(jni_env);
     if (vm_env->IsVmShutdowning()) return;
+
     if (exn_raised()) {
         exn_print_stack_trace(stderr, exn_get());
     }
@@ -862,8 +851,8 @@
     TRACE2("jni", "NewGlobalRef called");
     assert(hythread_is_suspend_enabled());
     
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning() || !obj) return NULL;
+    if (exn_raised() || !obj) return NULL;
+
     if(!obj) {
         return 0;
     }
@@ -905,7 +894,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning() || ref == NULL) return NULL;
+    if (exn_raised() || ref == NULL) return NULL;
 
     jobject new_ref = oh_copy_to_local_handle(ref);
 
@@ -999,8 +988,7 @@
     TRACE2("jni", "AllocObject called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning() || clazz == NULL) return NULL;
+    if (exn_raised() || clazz == NULL) return NULL;
 
     Class* clss = jclass_to_struct_Class(clazz);
 
@@ -1140,8 +1128,7 @@
     TRACE2("jni", "NewString called, length = " << length);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     return (jstring)string_create_from_unicode_h(unicodeChars, length);
 } //NewString
@@ -1164,8 +1151,7 @@
     TRACE2("jni", "GetStringChars called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (!string || vm_env->IsVmShutdowning()) return NULL;
+    if (!string || exn_raised()) return NULL;
 
     assert(check_is_jstring_class(string));
 
@@ -1195,8 +1181,7 @@
     TRACE2("jni", "NewStringUTF called, bytes = " << bytes);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     return (jstring)string_create_from_utf8_h(bytes, (unsigned)strlen(bytes));
 } //NewStringUTF
@@ -1219,8 +1204,8 @@
     TRACE2("jni", "GetStringUTFChars called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning() || !string) return NULL;
+    if (exn_raised() || !string) return NULL;
+
     assert(check_is_jstring_class(string));
     const char* res = string_get_utf8_chars_h((ObjectHandle)string);
     if (isCopy) *isCopy = JNI_TRUE;
@@ -1247,8 +1232,7 @@
     TRACE2("jni", "RegisterNatives called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return -1;
+    if (exn_raised()) return -1;
 
     Class_Handle clss = jclass_to_struct_Class(clazz);
     return class_register_methods(clss, methods, nMethods) ? -1 : 0;
@@ -1267,8 +1251,7 @@
     TRACE2("jni", "MonitorEnter called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return -1;
+    if (exn_raised()) return -1;
 
     jthread_monitor_enter(obj);
     return exn_raised() ? -1 : 0;
@@ -1302,8 +1285,7 @@
     TRACE2("jni", "GetStringRegion called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     assert(s);
 
@@ -1400,9 +1382,7 @@
     TRACE2("jni", "ExceptionCheck called, exception status = " << exn_raised());
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    
-    if (exn_raised() || vm_env->IsVmShutdowning())
+    if (exn_raised())
         return JNI_TRUE;
     else
         return JNI_FALSE;
@@ -1432,6 +1412,7 @@
 {
     TRACE2("jni", "FromReflectedField called");
     Class* clss = jobject_to_struct_Class(field);
+
     Global_Env * vm_env = jni_get_vm_env(jni_env);
 
     if (clss == vm_env->java_lang_reflect_Field_Class) 
@@ -1447,10 +1428,9 @@
 {
     TRACE2("jni", "ToReflectedMethod called");
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
     Method *m = (Method*)methodID;
     // True if flags are different
-    if ((bool)m->is_static() != (bool)isStatic || vm_env->IsVmShutdowning())
+    if ((bool)m->is_static() != (bool)isStatic || exn_raised())
         return NULL;
 
     if (m->is_init())
@@ -1464,9 +1444,8 @@
 {
     TRACE2("jni", "ToReflectedField called");
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
     Field *f = (Field*)fieldID;
-    if ((bool)f->is_static() != (bool)isStatic || vm_env->IsVmShutdowning()) // True if flags are different
+    if ((bool)f->is_static() != (bool)isStatic || exn_raised()) // True if flags are different
         return NULL;
 
     return reflection_reflect_field(jni_env, fieldID);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_array.cpp Fri Dec 22 09:12:58 2006
@@ -63,7 +63,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     ObjectHandle elem_handle = (ObjectHandle)initialElement;
 
@@ -89,7 +89,7 @@
 
         return NULL;
     }
-  tmn_suspend_disable();       //---------------------------------v
+    tmn_suspend_disable();       //---------------------------------v
  
     Vector_Handle vector = vm_new_vector(arr_clss, length);
 
@@ -109,7 +109,6 @@
     // only if the elem is non-null.
     if (elem != NULL) {
         ManagedObject **elems = (ManagedObject **)get_vector_element_address_ref(vector, 0);
-        Global_Env * vm_env = VM_Global_State::loader_env;
         if (vm_env->compress_references) {
             COMPRESSED_REFERENCE elem_offset = compress_reference((ManagedObject *)elem);
             COMPRESSED_REFERENCE *compressed_elems = (COMPRESSED_REFERENCE *)elems;
@@ -138,8 +137,7 @@
     assert(hythread_is_suspend_enabled());
     assert(array);
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     jsize length = GetArrayLength(jni_env, array);
     if ((index < 0) || (index >= length)) {
@@ -177,8 +175,7 @@
     assert(hythread_is_suspend_enabled());
     assert(array);
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     if ((index < 0) || (index >= length)) {
@@ -235,7 +232,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfBoolean_Class;    
     unsigned sz = clss->calculate_array_size(length);
@@ -270,9 +267,9 @@
 {
     TRACE2("jni", "NewByteArray called");
     assert(hythread_is_suspend_enabled());
-    
+        
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfByte_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -309,7 +306,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     Class *clss = vm_env->ArrayOfChar_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -346,7 +343,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfShort_Class; 
     unsigned sz = clss->calculate_array_size(length);
@@ -382,9 +379,9 @@
 {
     TRACE2("jni", "NewIntArray called");
     assert(hythread_is_suspend_enabled());
-    
+        
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfInt_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -421,7 +418,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     Class *clss = vm_env->ArrayOfLong_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -458,7 +455,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfFloat_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -495,7 +492,7 @@
     assert(hythread_is_suspend_enabled());
     
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
     
     Class *clss = vm_env->ArrayOfDouble_Class;
     unsigned sz = clss->calculate_array_size(length);
@@ -539,10 +536,9 @@
                                           jboolean *isCopy)
 {
     TRACE2("jni", "GetBooleanArrayElements called");
-    assert(hythread_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());    
     
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -584,9 +580,8 @@
 {
     TRACE2("jni", "GetByteArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -629,8 +624,7 @@
     TRACE2("jni", "GetCharArrayElements called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -672,9 +666,8 @@
 {
     TRACE2("jni", "GetShortArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -716,9 +709,8 @@
 {
     TRACE2("jni", "GetIntArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -761,9 +753,8 @@
 {
     TRACE2("jni", "GetLongArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -805,9 +796,8 @@
 {
     TRACE2("jni", "GetFloatArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -850,9 +840,8 @@
 {
     TRACE2("jni", "GetDoubleArrayElements called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     ObjectHandle h = (ObjectHandle)array;
 
@@ -1345,10 +1334,9 @@
                                     jboolean *buf)
 {
     TRACE2("jni", "GetBooleanArrayRegion called");
-    assert(hythread_is_suspend_enabled());
+    assert(hythread_is_suspend_enabled());    
     
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1379,9 +1367,8 @@
 {
     TRACE2("jni", "GetByteArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1412,9 +1399,8 @@
 {
     TRACE2("jni", "GetCharArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1445,9 +1431,8 @@
 {
     TRACE2("jni", "GetShortArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1478,9 +1463,8 @@
 {
     TRACE2("jni", "GetIntArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1511,9 +1495,8 @@
 {
     TRACE2("jni", "GetLongArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1544,9 +1527,8 @@
 {
     TRACE2("jni", "GetFloatArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1577,9 +1559,8 @@
 {
     TRACE2("jni", "GetDoubleArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1618,9 +1599,8 @@
 {
     TRACE2("jni", "SetBooleanArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1653,9 +1633,8 @@
 {
     TRACE2("jni", "SetByteArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1688,9 +1667,8 @@
 {
     TRACE2("jni", "SetCharArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1723,9 +1701,8 @@
 {
     TRACE2("jni", "SetShortArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1758,9 +1735,8 @@
 {
     TRACE2("jni", "SetIntArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1793,9 +1769,8 @@
 {
     TRACE2("jni", "SetLongArrayRegion called");
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1829,8 +1804,7 @@
     TRACE2("jni", "SetFloatArrayRegion called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;
@@ -1864,8 +1838,7 @@
     TRACE2("jni", "SetDoubleArrayRegion called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     jsize length = GetArrayLength(jni_env, array);
     jsize end = start + len;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_field.cpp Fri Dec 22 09:12:58 2006
@@ -45,8 +45,7 @@
     TRACE2("jni", "GetFieldID called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Class* clss = jclass_to_struct_Class(clazz);
     Field *field = class_lookup_field_recursive(clss, name, sig);
@@ -73,12 +72,12 @@
     assert(hythread_is_suspend_enabled());
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
-    String *class_string = VM_Global_State::loader_env->string_pool.lookup(class_name);
+    String *class_string = vm_env->string_pool.lookup(class_name);
     assert(hythread_is_suspend_enabled());
     Class *clss =
-        class_load_verify_prepare_from_jni(VM_Global_State::loader_env, class_string);
+        class_load_verify_prepare_from_jni(vm_env, class_string);
     if(!clss) {
         return 0;
     }
@@ -94,8 +93,7 @@
     TRACE2("jni", "GetStaticFieldID called");
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Class* clss = jclass_to_struct_Class(clazz);
     Field *field = class_lookup_field_recursive(clss, name, sig);
@@ -120,8 +118,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -161,8 +158,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -194,8 +190,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -229,8 +224,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();     //---------------------------------v
 
@@ -264,8 +258,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -299,8 +292,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -334,8 +326,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -369,8 +360,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -404,8 +394,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
     
     tmn_suspend_disable();       //---------------------------------v
 
@@ -450,8 +439,7 @@
     ObjectHandle h = (ObjectHandle)obj;
     ObjectHandle v = (ObjectHandle)value;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -493,8 +481,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -526,7 +513,7 @@
     ObjectHandle h = (ObjectHandle)obj;
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -562,8 +549,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -597,7 +583,7 @@
     ObjectHandle h = (ObjectHandle)obj;
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -633,8 +619,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -667,8 +652,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -700,8 +684,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -734,8 +717,7 @@
     assert(hythread_is_suspend_enabled());
     ObjectHandle h = (ObjectHandle)obj;
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     tmn_suspend_disable();       //---------------------------------v
 
@@ -783,8 +765,7 @@
     TRACE2("jni", "GetStaticObjectField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    if (exn_raised()) return NULL;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -815,8 +796,7 @@
     TRACE2("jni", "GetStaticBooleanField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -833,8 +813,7 @@
     TRACE2("jni", "GetStaticByteField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -851,8 +830,7 @@
     TRACE2("jni", "GetStaticCharField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -869,8 +847,7 @@
     TRACE2("jni", "GetStaticShortField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -887,8 +864,7 @@
     TRACE2("jni", "GetStaticIntField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -905,8 +881,7 @@
     TRACE2("jni", "GetStaticLongField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -923,8 +898,7 @@
     TRACE2("jni", "GetStaticFloatField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -941,8 +915,7 @@
     TRACE2("jni", "GetStaticDoubleField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    if (exn_raised()) return 0;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -972,8 +945,7 @@
     TRACE2("jni", "SetStaticObjectField called, id = " << fieldID);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1002,8 +974,7 @@
     TRACE2("jni", "SetStaticBooleanField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1023,7 +994,7 @@
     assert(hythread_is_suspend_enabled());
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1046,8 +1017,7 @@
     TRACE2("jni", "SetStaticCharField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1067,7 +1037,7 @@
     assert(hythread_is_suspend_enabled());
 
     Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1090,8 +1060,7 @@
     TRACE2("jni", "SetStaticIntField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1111,8 +1080,7 @@
     TRACE2("jni", "SetStaticLongField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1131,8 +1099,7 @@
     TRACE2("jni", "SetStaticFloatField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);
@@ -1151,8 +1118,7 @@
     TRACE2("jni", "SetStaticDoubleField called, id = " << fieldID << " value = " << value);
     assert(hythread_is_suspend_enabled());
 
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    if (exn_raised()) return;
 
     Field *f = (Field *)fieldID;
     assert(f);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni_method.cpp Fri Dec 22 09:12:58 2006
@@ -65,9 +65,8 @@
     TRACE2("jni", "GetMethodID called: " << name << descr);
     assert(hythread_is_suspend_enabled());
     assert(clazz);
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     Class* clss = jclass_to_struct_Class(clazz);
     Method *method;
@@ -102,9 +101,8 @@
     TRACE2("jni", "GetStaticMethodID called: " << name << descr);
     assert(hythread_is_suspend_enabled());
     Class* clss = jclass_to_struct_Class(clazz);
-    
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+        
+    if (exn_raised()) return NULL;
 
     Method *method;
     if ('<' == *name) {
@@ -222,9 +220,8 @@
 {
     TRACE2("jni", "CallVoidMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     call_method_no_ref_result(jni_env, obj, methodID, args, 0, FALSE);
 } //CallVoidMethodA
@@ -261,9 +258,8 @@
 {
     TRACE2("jni", "CallObjectMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     jvalue result;
     Method *method = (Method *)methodID; // resolve to actual vtable entry below
@@ -331,9 +327,8 @@
 {
     TRACE2("jni", "CallBooleanMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-    
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+        
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -372,9 +367,8 @@
 {
     TRACE2("jni", "CallByteMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -414,9 +408,8 @@
 {
     TRACE2("jni", "CallCharMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -456,9 +449,8 @@
 {
     TRACE2("jni", "CallShortMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -498,9 +490,8 @@
 {
     TRACE2("jni", "CallIntMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -540,9 +531,8 @@
 {
     TRACE2("jni", "CallLongMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -582,9 +572,8 @@
 {
     TRACE2("jni", "CallFloatMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -624,9 +613,8 @@
 {
     TRACE2("jni", "CallDoubleMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, FALSE);
@@ -683,9 +671,8 @@
 {
     TRACE2("jni", "CallNonvirtualVoidMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     call_method_no_ref_result(jni_env, obj, methodID, args, 0, TRUE);
 } //CallNonvirtualVoidMethodA
@@ -731,9 +718,8 @@
 {
     TRACE2("jni", "CallNonvirtualObjectMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     jvalue result;
     Method *method = (Method *)methodID;
@@ -793,9 +779,8 @@
 {
     TRACE2("jni", "CallNonvirtualBooleanMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -843,9 +828,8 @@
 {
     TRACE2("jni", "CallNonvirtualByteMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -893,9 +877,8 @@
 {
     TRACE2("jni", "CallNonvirtualCharMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -943,9 +926,8 @@
 {
     TRACE2("jni", "CallNonvirtualShortMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -993,9 +975,8 @@
 {
     TRACE2("jni", "CallNonvirtualIntMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result,  TRUE);
@@ -1043,9 +1024,8 @@
 {
     TRACE2("jni", "CallNonvirtualLongMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -1093,9 +1073,8 @@
 {
     TRACE2("jni", "CallNonvirtualFloatMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -1143,9 +1122,8 @@
 {
     TRACE2("jni", "CallNonvirtualDoubleMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_method_no_ref_result(jni_env, obj, methodID, args, &result, TRUE);
@@ -1210,9 +1188,8 @@
 {
     TRACE2("jni", "CallStaticObjectMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return NULL;
+    
+    if (exn_raised()) return NULL;
 
     jvalue result;
     Method *method = (Method *)methodID;
@@ -1261,9 +1238,8 @@
 {
     TRACE2("jni", "CallStaticBooleanMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1302,9 +1278,8 @@
 {
     TRACE2("jni", "CallStaticByteMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1343,9 +1318,8 @@
 {
     TRACE2("jni", "CallStaticCharMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1384,9 +1358,8 @@
 {
     TRACE2("jni", "CallStaticShortMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1425,9 +1398,8 @@
 {
     TRACE2("jni", "CallStaticIntMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1466,9 +1438,8 @@
 {
     TRACE2("jni", "CallStaticLongMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1507,9 +1478,8 @@
 {
     TRACE2("jni", "CallStaticFloatMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1548,9 +1518,8 @@
 {
     TRACE2("jni", "CallStaticDoubleMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return 0;
+    
+    if (exn_raised()) return 0;
 
     jvalue result;
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, &result);
@@ -1588,9 +1557,8 @@
 {
     TRACE2("jni", "CallStaticVoidMethodA called, id = " << methodID);
     assert(hythread_is_suspend_enabled());
-
-    Global_Env * vm_env = jni_get_vm_env(jni_env);
-    if (vm_env->IsVmShutdowning()) return;
+    
+    if (exn_raised()) return;
 
     call_static_method_no_ref_result(jni_env, clazz, methodID, args, 0);
 } //CallStaticVoidMethodA

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp?view=diff&rev=489694&r1=489693&r2=489694
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp Fri Dec 22 09:12:58 2006
@@ -126,7 +126,11 @@
 
     // Initialize arguments.
     args[0].l = java_thread;
-    args[1].l = exn_get();
+    if (vm_env->IsVmShutdowning()) {
+        args[1].l = NULL;
+    } else {
+        args[1].l = exn_get();
+    }    
     exn_clear();
 
     hythread_suspend_disable();



Mime
View raw message