29 #include "jvmtifiles/jvmtiEnv.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/instanceKlass.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/jvmtiAgentThread.hpp"
36 #include "prims/jvmtiEventController.inline.hpp"
37 #include "prims/jvmtiImpl.hpp"
38 #include "prims/jvmtiRedefineClasses.hpp"
39 #include "runtime/atomic.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "runtime/handles.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "runtime/interfaceSupport.hpp"
44 #include "runtime/javaCalls.hpp"
45 #include "runtime/os.hpp"
46 #include "runtime/serviceThread.hpp"
47 #include "runtime/signature.hpp"
48 #include "runtime/thread.inline.hpp"
49 #include "runtime/vframe.hpp"
50 #include "runtime/vframe_hp.hpp"
51 #include "runtime/vm_operations.hpp"
52 #include "utilities/exceptions.hpp"
53
54 //
55 // class JvmtiAgentThread
56 //
57 // JavaThread used to wrap a thread started by an agent
58 // using the JVMTI method RunAgentThread.
59 //
60
61 JvmtiAgentThread::JvmtiAgentThread(JvmtiEnv* env, jvmtiStartFunction start_fn, const void *start_arg)
62 : JavaThread(start_function_wrapper) {
63 _env = env;
64 _start_fn = start_fn;
65 _start_arg = start_arg;
66 }
67
68 void
861 return true;
862 }
863
864 bool JvmtiSuspendControl::resume(JavaThread *java_thread) {
865 // external suspend should have caught resuming a thread twice
866 assert(java_thread->is_being_ext_suspended(), "thread should be suspended");
867
868 // resume thread
869 {
870 // must always grab Threads_lock, see JVM_SuspendThread
871 MutexLocker ml(Threads_lock);
872 java_thread->java_resume();
873 }
874
875 return true;
876 }
877
878
879 void JvmtiSuspendControl::print() {
880 #ifndef PRODUCT
881 MutexLocker mu(Threads_lock);
882 LogStreamHandle(Trace, jvmti) log_stream;
883 log_stream.print("Suspended Threads: [");
884 for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) {
885 #ifdef JVMTI_TRACE
886 const char *name = JvmtiTrace::safe_get_thread_name(thread);
887 #else
888 const char *name = "";
889 #endif /*JVMTI_TRACE */
890 log_stream.print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
891 if (!thread->has_last_Java_frame()) {
892 log_stream.print("no stack");
893 }
894 log_stream.print(") ");
895 }
896 log_stream.print_cr("]");
897 #endif
898 }
899
900 JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event(
901 nmethod* nm) {
902 JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD);
903 event._event_data.compiled_method_load = nm;
904 // Keep the nmethod alive until the ServiceThread can process
|
29 #include "jvmtifiles/jvmtiEnv.hpp"
30 #include "logging/log.hpp"
31 #include "logging/logStream.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "oops/instanceKlass.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "prims/jvmtiAgentThread.hpp"
36 #include "prims/jvmtiEventController.inline.hpp"
37 #include "prims/jvmtiImpl.hpp"
38 #include "prims/jvmtiRedefineClasses.hpp"
39 #include "runtime/atomic.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "runtime/handles.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "runtime/interfaceSupport.hpp"
44 #include "runtime/javaCalls.hpp"
45 #include "runtime/os.hpp"
46 #include "runtime/serviceThread.hpp"
47 #include "runtime/signature.hpp"
48 #include "runtime/thread.inline.hpp"
49 #include "runtime/threadSMR.hpp"
50 #include "runtime/vframe.hpp"
51 #include "runtime/vframe_hp.hpp"
52 #include "runtime/vm_operations.hpp"
53 #include "utilities/exceptions.hpp"
54
55 //
56 // class JvmtiAgentThread
57 //
58 // JavaThread used to wrap a thread started by an agent
59 // using the JVMTI method RunAgentThread.
60 //
61
62 JvmtiAgentThread::JvmtiAgentThread(JvmtiEnv* env, jvmtiStartFunction start_fn, const void *start_arg)
63 : JavaThread(start_function_wrapper) {
64 _env = env;
65 _start_fn = start_fn;
66 _start_arg = start_arg;
67 }
68
69 void
862 return true;
863 }
864
865 bool JvmtiSuspendControl::resume(JavaThread *java_thread) {
866 // external suspend should have caught resuming a thread twice
867 assert(java_thread->is_being_ext_suspended(), "thread should be suspended");
868
869 // resume thread
870 {
871 // must always grab Threads_lock, see JVM_SuspendThread
872 MutexLocker ml(Threads_lock);
873 java_thread->java_resume();
874 }
875
876 return true;
877 }
878
879
880 void JvmtiSuspendControl::print() {
881 #ifndef PRODUCT
882 LogStreamHandle(Trace, jvmti) log_stream;
883 log_stream.print("Suspended Threads: [");
884 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) {
885 #ifdef JVMTI_TRACE
886 const char *name = JvmtiTrace::safe_get_thread_name(thread);
887 #else
888 const char *name = "";
889 #endif /*JVMTI_TRACE */
890 log_stream.print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_');
891 if (!thread->has_last_Java_frame()) {
892 log_stream.print("no stack");
893 }
894 log_stream.print(") ");
895 }
896 log_stream.print_cr("]");
897 #endif
898 }
899
900 JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event(
901 nmethod* nm) {
902 JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD);
903 event._event_data.compiled_method_load = nm;
904 // Keep the nmethod alive until the ServiceThread can process
|