harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r527227 - in /harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti: jvmti_pop_frame.cpp jvmti_stack.cpp
Date Tue, 10 Apr 2007 18:03:30 GMT
Author: gshimansky
Date: Tue Apr 10 11:03:29 2007
New Revision: 527227

URL: http://svn.apache.org/viewvc?view=rev&rev=527227
Log:
Applied HARMONY-2749 [drlvm][jvmti] PopFrame does not contain check of JVMTI_ERROR_NO_MORE_FRAMES
(31)


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp?view=diff&rev=527227&r1=527226&r2=527227
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp Tue Apr 10 11:03:29
2007
@@ -255,11 +255,7 @@
     // create stack iterator from native
     StackIterator* si = si_create_from_native();
     si_transfer_all_preserved_registers(si);
-    TRACE(("PopFrame prepare for method %s.%s%s, IP: %p",
-        class_get_name(method_get_class(si_get_code_chunk_info(si)->get_method())),
-        method_get_name(si_get_code_chunk_info(si)->get_method()),
-        method_get_descriptor(si_get_code_chunk_info(si)->get_method()),
-        si_get_ip(si) ));
+    TRACE(("PopFrame prepare for method IP: %p", si_get_ip(si) ));
 
     // prepare pop frame - find regs values
     uint32 buf = 0;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?view=diff&rev=527227&r1=527226&r2=527227
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Tue Apr 10 11:03:29 2007
@@ -72,10 +72,12 @@
             Class *clss = method_get_class(method);
             assert(clss);
 
-            if (strcmp(method_get_name(method), "runImpl") == 0 &&
-                strcmp(class_get_name(clss), "java/lang/VMStart$MainThread") == 0)
-            {
-                skip = 3;
+            if (!strcmp(method_get_name(method), "runImpl")) {
+                if(!strcmp(class_get_name(clss), "java/lang/VMStart$MainThread")) {
+                    skip = 3;
+                } else if(!strcmp(class_get_name(clss), "java/lang/Thread")) {
+                    skip = 1;
+                }
             }
         }
 
@@ -583,36 +585,54 @@
     CHECK_EVERYTHING();
     CHECK_CAPABILITY(can_pop_frame);
 
-    if (thread == 0) {
-        return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
+    if (NULL == thread) {
+        return JVMTI_ERROR_INVALID_THREAD;
     }
 
-    if (NULL == thread)
-        return JVMTI_ERROR_INVALID_THREAD;
+    JNIEnv *jni_env = p_TLS_vmthread->jni_env;
 
-    // check error condition: JVMTI_ERROR_INVALID_THREAD
-    err = env->GetThreadState(thread, &state);
+    jthread curr_thread = getCurrentThread();
+    if (jni_env->IsSameObject(thread,curr_thread) ) {
+        // cannot pop frame yourself
+        return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
+    }
 
+    // get thread state
+    err = env->GetThreadState(thread, &state);
     if (err != JVMTI_ERROR_NONE) {
         return err;
     }
 
-    // check error condition: JVMTI_ERROR_THREAD_NOT_ALIVE
+    // check thread state
     if ((state & JVMTI_THREAD_STATE_ALIVE) == 0) {
         return JVMTI_ERROR_THREAD_NOT_ALIVE;
     }
-
-    // check error condition: JVMTI_ERROR_THREAD_NOT_SUSPENDED
-    JNIEnv *jni_env = p_TLS_vmthread->jni_env;
-    jthread curr_thread = getCurrentThread();
-    if (jni_env->IsSameObject(thread,curr_thread)
-            || ((state & JVMTI_THREAD_STATE_SUSPENDED) == 0)) {
+    if( (state & JVMTI_THREAD_STATE_SUSPENDED) == 0) {
         return JVMTI_ERROR_THREAD_NOT_SUSPENDED;
     }
 
+    // check stack depth
+    hythread_t hy_thread = jthread_get_native_thread(thread);
+    VM_thread* vm_thread = get_vm_thread(hy_thread);
+
+    jint depth;
+    if (interpreter_enabled()) {
+        err = interpreter.interpreter_ti_get_frame_count(env,
+            vm_thread, &depth);
+    } else {
+        depth = get_thread_stack_depth(vm_thread);
+        err = JVMTI_ERROR_NONE;
+    }
+    if (err != JVMTI_ERROR_NONE) {
+        return err;
+    }
+
+    if(depth <= 1) {
+        return JVMTI_ERROR_NO_MORE_FRAMES;
+    }
+
     if (interpreter_enabled()) {
-        return interpreter.interpreter_ti_pop_frame(env,
-            get_vm_thread_ptr_safe(jvmti_test_jenv, thread));
+        return interpreter.interpreter_ti_pop_frame(env, vm_thread);
     } else {
         return jvmti_jit_pop_frame(thread);
     }



Mime
View raw message