harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r448657 - in /incubator/harmony/enhanced/drlvm/trunk/vm: thread/src/ vmcore/include/ vmcore/src/jit/ vmcore/src/jvmti/ vmcore/src/util/ia32/base/
Date Thu, 21 Sep 2006 20:08:14 GMT
Author: geirm
Date: Thu Sep 21 13:08:13 2006
New Revision: 448657

URL: http://svn.apache.org/viewvc?view=rev&rev=448657
Log:
HARMONY-1523

Frame unwinding requested by jvmtiPopFrame() function is established by suspended thread itself
during it's staying 
in safe point. For this purpose safe point callback can be used.
See HARMONY-1420 for brief top-level pop frame implementation design.

Proposed patch:
    1. Exports hythread_set_safepoint_callback() from thead manager.
    2. Implements the callback function to perform frame unwinding.
    3. Adds poppable attribute to those m2n frames that can be popped.

Committed and tested on Ubuntu 6


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ia32/base/jit_runtime_support_ia32.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Thu Sep 21 13:08:13 2006
@@ -58,6 +58,7 @@
 hythread_suspend_disable
 hythread_safe_point
 hythread_suspend_other
+hythread_set_safepoint_callback
 hythread_get_safepoint_callback
 hythread_suspend_all
 hythread_resume_all
@@ -115,7 +116,6 @@
 hythread_init
 countdown_nondaemon_threads
 increase_nondaemon_threads_count
-set_safepoint_callback
 
 release_start_lock
 acquire_start_lock

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Thu Sep 21 13:08:13 2006
@@ -58,6 +58,7 @@
 hythread_safe_point;
 hythread_suspend_other;
 hythread_get_safepoint_callback;
+hythread_set_safepoint_callback;
 hythread_suspend_all;
 hythread_resume_all;
 hythread_iterator_create;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c Thu Sep 21 13:08:13
2006
@@ -466,7 +466,7 @@
     env = tm_java_thread->jenv;
     tm_java_thread->stop_exception = (*env)->NewGlobalRef(env,excn);
     
-    return set_safepoint_callback(tm_native_thread, stop_callback);
+    return hythread_set_safepoint_callback(tm_native_thread, stop_callback);
 }
 
 /**

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Thu Sep 21
13:08:13 2006
@@ -332,7 +332,7 @@
  * @param[in] thread thread where callback needs to be executed
  * @param[in] callback callback function
  */
-IDATA set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback) {
+IDATA hythread_set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback)
{
     while (apr_atomic_casptr((volatile void **)&thread->safepoint_callback, (void
*)callback, (void *)NULL) != NULL);
     if(tm_self_tls == thread) {
         int old_status = thread->suspend_disable_count;

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Thu Sep 21 13:08:13
2006
@@ -79,7 +79,7 @@
 void jvmti_get_compilation_flags(OpenMethodExecutionParams *flags);
 
 // Marks topmost frame of the specified thead to be popped
-jvmtiError jvmti_jit_pop_frame(VM_thread *thread);
+jvmtiError jvmti_jit_pop_frame(jthread thread);
 // On current thread perform popping of topmost frame
 void jvmti_jit_do_pop_frame();
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/compile.cpp Thu Sep 21 13:08:13
2006
@@ -874,13 +874,13 @@
     assert(callee_addr);
     LilCodeStub *cs = lil_parse_code_stub(
         "entry 0:managed:arbitrary;"
-        "push_m2n 0, 0;"
+        "push_m2n 0, %0I;"
         "out platform:pint:void;"
-        "o0=%0i;"
-        "call %1i;"       // call instrumentation procedure
+        "o0=%1i;"
+        "call %2i;"       // call instrumentation procedure
         "pop_m2n;"
-        "tailcall %2i;",  // call original entry point
-        callee, instr_proc, lil_npc_to_fp(callee_addr));
+        "tailcall %3i;",  // call original entry point
+        FRAME_POPABLE, callee, instr_proc, lil_npc_to_fp(callee_addr));
     assert(cs && lil_is_valid(cs));
     // TODO: 2 & 3 parameters should be removed from the method signature
     // since it makes sense for debugging only

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Thu Sep
21 13:08:13 2006
@@ -131,11 +131,12 @@
             assert(cs);
         }
         cs = lil_parse_onto_end(cs,
-            "push_m2n 0, 0;"
+            "push_m2n 0, %0i;"
             "out platform::ref;"
-            "call %0i;"
+            "call %1i;"
             "pop_m2n;"
             "ret;",
+            FRAME_POPABLE,
             rth_multianewarrayhelper);
         assert(cs && lil_is_valid(cs));
         
@@ -199,13 +200,14 @@
             assert(cs);
         }
         cs = lil_parse_onto_end(cs,
-            "push_m2n 0, 0;"
+            "push_m2n 0, %0i;"
             "out platform:pint,g4:ref;"
             "o0=i1;"
             "o1=i0;"
-            "call %0i;"
+            "call %1i;"
             "pop_m2n;"
             "ret;",
+            FRAME_POPABLE,
             p_instantiate_ref);
         assert(cs && lil_is_valid(cs));
         addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -778,7 +780,7 @@
             ":_exn_raised;"
             "out platform::void;"
             "call.noret %5i;",
-            p_is_inited, FRAME_JNI, p_init,
+            p_is_inited, (FRAME_JNI | FRAME_POPABLE), p_init,
             OFFSET(VM_thread, thread_exception.exc_object),
             OFFSET(VM_thread, thread_exception.exc_class),
             p_rethrow);
@@ -1749,11 +1751,12 @@
     }
     
     cs = lil_parse_onto_end(cs,
-        "push_m2n 0, 0;"
+        "push_m2n 0, %0i;"
         "in2out platform:pint;"
-        "call %0i;"
+        "call %1i;"
         "pop_m2n;"
         "ret;",
+        FRAME_POPABLE,
         (void*)&rth_resolve);
     assert(cs && lil_is_valid(cs));
     addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -1777,11 +1780,12 @@
             assert(cs);
         }
     cs = lil_parse_onto_end(cs,
-        "push_m2n 0, 0;"
+        "push_m2n 0, %0i;"
         "in2out platform:void;"
-        "call %0i;"
+        "call %1i;"
         "pop_m2n;"
         "ret;",
+        FRAME_POPABLE,
         jvmti_method_enter_callback_ptr);
     assert(cs && lil_is_valid(cs));
     addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -1805,13 +1809,14 @@
         assert(cs);
     }
     cs = lil_parse_onto_end(cs,
-        "push_m2n 0, 0;"
+        "push_m2n 0, %0i;"
         "out platform:pint,pint:void;"
         "o0=i1;"
         "o1=i0;"
-        "call %0i;"
+        "call %1i;"
         "pop_m2n;"
         "ret;",
+        FRAME_POPABLE,
         jvmti_method_exit_callback_ptr);
     assert(cs && lil_is_valid(cs));
     addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -1837,12 +1842,13 @@
         assert(cs);
     }
     cs = lil_parse_onto_end(cs,
-            "push_m2n 0, 0;"
+            "push_m2n 0, %0i;"
             "in2out platform:void;"
-            "call %0i;"
+            "call %1i;"
             "pop_m2n;"
             "ret;",
-             jvmti_field_access_callback_ptr);
+            FRAME_POPABLE,
+            jvmti_field_access_callback_ptr);
     assert(cs && lil_is_valid(cs));
     addr = LilCodeGenerator::get_platform()->compile(cs);
 
@@ -1883,11 +1889,12 @@
         assert(cs);
         }
     cs = lil_parse_onto_end(cs,
-            "push_m2n 0, 0;"
+            "push_m2n 0, %0i;"
             "in2out platform:void;"
-            "call %0i;"
+            "call %1i;"
             "pop_m2n;"
             "ret;",
+            FRAME_POPABLE,
             jvmti_field_modification_callback_ptr);
     assert(cs && lil_is_valid(cs));
     addr = LilCodeGenerator::get_platform()->compile(cs);
@@ -2911,7 +2918,7 @@
     void * fptr_suspend_disable = (void*)&hythread_suspend_disable;
 
     LilCodeStub* cs = lil_parse_code_stub(
-        lil_stub, FRAME_COMPILATION,
+        lil_stub, (FRAME_COMPILATION | FRAME_POPABLE),
         fptr_suspend_enable, (void*)fptr, fptr_suspend_disable,
         OFFSET(VM_thread, thread_exception.exc_object),
         OFFSET(VM_thread, thread_exception.exc_class),

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break.cpp Thu Sep 21
13:08:13 2006
@@ -204,6 +204,11 @@
     M2nFrame *m2nf = m2n_push_suspended_frame(regs);
     BEGIN_RAISE_AREA;
 
+    // need to be able to pop the frame
+    frame_type m2nf_type = m2n_get_frame_type(m2nf);
+    m2nf_type = (frame_type) (m2nf_type | FRAME_POPABLE);
+    m2n_set_frame_type(m2nf, m2nf_type);
+
     hythread_t h_thread = hythread_self();
     jthread j_thread = jthread_get_java_thread(h_thread);
     ObjectHandle hThread = oh_allocate_local_handle();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_pop_frame.cpp Thu Sep
21 13:08:13 2006
@@ -24,25 +24,53 @@
 #include "jvmti_interface.h"
 #include "exceptions.h"
 #include "environment.h"
+#include "open/jthread.h"
 #include "vm_threads.h"
 #include "jit_intf_cpp.h"
 #include "m2n.h"
 #include "mon_enter_exit.h"
 #include "stack_iterator.h"
-//#include "cxxlog.h"
 #include "clog.h"
 
-jvmtiError jvmti_jit_pop_frame(VM_thread *thread)
+static void jvmti_pop_frame_callback()
+{
+    TRACE(("--->>>  JVMTI pop frame callback..."));
+    frame_type type = m2n_get_frame_type(p_TLS_vmthread->last_m2n_frame);
+
+    // frame wasn't requested to be popped
+    if (FRAME_POP_NOW != (FRAME_POP_NOW & type))
+        return;
+
+    // if we are in hythread_safe_point() or frame is unwindable
+    if (FRAME_SAFE_POINT == (FRAME_SAFE_POINT & type) || is_unwindable()) {
+        // wait for resume
+        TRACE(("entering safe_point"));
+        hythread_safe_point();
+        TRACE(("left safe_point"));
+
+        // switch execution to the previous frame
+        jvmti_jit_do_pop_frame();
+        assert(0 /* mustn't get here */);
+    } else {
+        // raise special exception object
+        exn_raise_object(VM_Global_State::loader_env->popFrameException);
+    }
+} //jvmti_pop_frame_callback
+
+jvmtiError jvmti_jit_pop_frame(jthread java_thread)
 {
     assert(hythread_is_suspend_enabled());
 
-    M2nFrame* top_frame = thread->last_m2n_frame;
+    hythread_t hy_thread = jthread_get_native_thread(java_thread);
+    VM_thread* vm_thread = get_vm_thread(hy_thread);
+
+    M2nFrame* top_frame = m2n_get_last_frame(vm_thread);
     frame_type type = m2n_get_frame_type(top_frame);
 
     if (FRAME_POPABLE != (FRAME_POPABLE & type))
         return JVMTI_ERROR_OPAQUE_FRAME;
 
-    StackIterator *si = si_create_from_native(thread);
+    StackIterator *si = si_create_from_native(vm_thread);
 
     // check that topmost frame is M2n
     assert(si_is_native(si));
@@ -55,19 +83,20 @@
     si_goto_previous(si);
 
     if (si_is_native(si)) {
-        M2nFrame* third_frame = m2n_get_previous_frame(top_frame);
-        
-        if (FRAME_POPABLE != (FRAME_POPABLE & m2n_get_frame_type(top_frame)))
-            return JVMTI_ERROR_OPAQUE_FRAME;
+        si_free(si);
+        return JVMTI_ERROR_OPAQUE_FRAME;
     }
 
+    si_free(si);
+
     type = (frame_type) (type | FRAME_POP_NOW);
     m2n_set_frame_type(top_frame, type);
 
-    si_free(si);
+    // Install safepoint callback that would perform popping job
+    hythread_set_safepoint_callback(hy_thread, &jvmti_pop_frame_callback);
 
     return JVMTI_ERROR_NONE;
-}
+} //jvmti_jit_pop_frame
 
 void jvmti_jit_do_pop_frame()
 {
@@ -166,32 +195,16 @@
 
     // transfer cdontrol
     si_transfer_control(si);
-}
+} // jvmti_jit_do_pop_frame
 
 void jvmti_safe_point()
 {
-//    __asm int 3;
-    TRACE(("entering safe_point"));
+//    TRACE(("entering safe_point"));
     hythread_safe_point();
 
-    TRACE(("left safe_point"));
-    frame_type type = m2n_get_frame_type(m2n_get_last_frame());
-
-    if (FRAME_POP_NOW == (FRAME_POP_NOW & type))
-        jvmti_jit_do_pop_frame();
-}
-
-void jvmti_pop_frame_callback()
-{
-    TRACE(("suspend_disable post callback..."));
-    frame_type type = m2n_get_frame_type(p_TLS_vmthread->last_m2n_frame);
-
-    if (FRAME_POP_NOW != (FRAME_POP_NOW & type))
-        return;
+    //TRACE(("left safe_point"));
+    //frame_type type = m2n_get_frame_type(m2n_get_last_frame());
 
-    if (is_unwindable()) {
-        jvmti_jit_do_pop_frame();
-    } else {
-        exn_raise_object(VM_Global_State::loader_env->popFrameException);
-    }
+    //if (FRAME_POP_NOW == (FRAME_POP_NOW & type))
+    //    jvmti_jit_do_pop_frame();
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp?view=diff&rev=448657&r1=448656&r2=448657
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_stack.cpp Thu Sep 21
13:08:13 2006
@@ -598,8 +598,7 @@
         return interpreter.interpreter_ti_pop_frame(env,
             get_vm_thread_ptr_safe(jvmti_test_jenv, thread));
     } else {
-        return jvmti_jit_pop_frame(
-            get_vm_thread_ptr_safe(jvmti_test_jenv, thread));
+        return jvmti_jit_pop_frame(thread);
     }
 }
 

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=448657&r1=448656&r2=448657
==============================================================================
--- 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
Thu Sep 21 13:08:13 2006
@@ -249,7 +249,7 @@
              out platform::void; \
              call.noret %5i;",
              (void *)is_class_initialized,
-             FRAME_JNI,
+             (FRAME_JNI | FRAME_POPABLE),
              (void *)class_initialize,
              APR_OFFSETOF(VM_thread, thread_exception.exc_object),
              APR_OFFSETOF(VM_thread, thread_exception.exc_class),



Mime
View raw message