comparison src/share/vm/runtime/thread.cpp @ 10405:f2110083203d

8005849: JEP 167: Event-Based JVM Tracing Reviewed-by: acorn, coleenp, sla Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>
author sla
date Mon, 10 Jun 2013 11:30:51 +0200
parents caac22686b17
children 836a62f43af9 b9f4c4ec0f50 58be756e7595
comparison
equal deleted inserted replaced
10404:d0add7016434 10405:f2110083203d
75 #include "runtime/vm_operations.hpp" 75 #include "runtime/vm_operations.hpp"
76 #include "services/attachListener.hpp" 76 #include "services/attachListener.hpp"
77 #include "services/management.hpp" 77 #include "services/management.hpp"
78 #include "services/memTracker.hpp" 78 #include "services/memTracker.hpp"
79 #include "services/threadService.hpp" 79 #include "services/threadService.hpp"
80 #include "trace/traceEventTypes.hpp" 80 #include "trace/tracing.hpp"
81 #include "trace/traceMacros.hpp"
81 #include "utilities/defaultStream.hpp" 82 #include "utilities/defaultStream.hpp"
82 #include "utilities/dtrace.hpp" 83 #include "utilities/dtrace.hpp"
83 #include "utilities/events.hpp" 84 #include "utilities/events.hpp"
84 #include "utilities/preserveException.hpp" 85 #include "utilities/preserveException.hpp"
85 #include "utilities/macros.hpp" 86 #include "utilities/macros.hpp"
236 NOT_PRODUCT(_allow_safepoint_count = 0;) 237 NOT_PRODUCT(_allow_safepoint_count = 0;)
237 NOT_PRODUCT(_skip_gcalot = false;) 238 NOT_PRODUCT(_skip_gcalot = false;)
238 CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;) 239 CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;)
239 _jvmti_env_iteration_count = 0; 240 _jvmti_env_iteration_count = 0;
240 set_allocated_bytes(0); 241 set_allocated_bytes(0);
241 set_trace_buffer(NULL);
242 _vm_operation_started_count = 0; 242 _vm_operation_started_count = 0;
243 _vm_operation_completed_count = 0; 243 _vm_operation_completed_count = 0;
244 _current_pending_monitor = NULL; 244 _current_pending_monitor = NULL;
245 _current_pending_monitor_is_from_java = true; 245 _current_pending_monitor_is_from_java = true;
246 _current_waiting_monitor = NULL; 246 _current_waiting_monitor = NULL;
1657 1657
1658 if (JvmtiExport::should_post_thread_life()) { 1658 if (JvmtiExport::should_post_thread_life()) {
1659 JvmtiExport::post_thread_start(this); 1659 JvmtiExport::post_thread_start(this);
1660 } 1660 }
1661 1661
1662 EVENT_BEGIN(TraceEventThreadStart, event); 1662 EventThreadStart event;
1663 EVENT_COMMIT(event, 1663 if (event.should_commit()) {
1664 EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj()))); 1664 event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
1665 event.commit();
1666 }
1665 1667
1666 // We call another function to do the rest so we are sure that the stack addresses used 1668 // We call another function to do the rest so we are sure that the stack addresses used
1667 // from there will be lower than the stack base just computed 1669 // from there will be lower than the stack base just computed
1668 thread_main_inner(); 1670 thread_main_inner();
1669 1671
1789 } 1791 }
1790 } 1792 }
1791 1793
1792 // Called before the java thread exit since we want to read info 1794 // Called before the java thread exit since we want to read info
1793 // from java_lang_Thread object 1795 // from java_lang_Thread object
1794 EVENT_BEGIN(TraceEventThreadEnd, event); 1796 EventThreadEnd event;
1795 EVENT_COMMIT(event, 1797 if (event.should_commit()) {
1796 EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj()))); 1798 event.set_javalangthread(java_lang_Thread::thread_id(this->threadObj()));
1799 event.commit();
1800 }
1797 1801
1798 // Call after last event on thread 1802 // Call after last event on thread
1799 EVENT_THREAD_EXIT(this); 1803 EVENT_THREAD_EXIT(this);
1800 1804
1801 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during 1805 // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
3646 } 3650 }
3647 3651
3648 // Notify JVMTI agents that VM initialization is complete - nop if no agents. 3652 // Notify JVMTI agents that VM initialization is complete - nop if no agents.
3649 JvmtiExport::post_vm_initialized(); 3653 JvmtiExport::post_vm_initialized();
3650 3654
3651 if (!TRACE_START()) { 3655 if (TRACE_START() != JNI_OK) {
3652 vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION)); 3656 vm_exit_during_initialization("Failed to start tracing backend.");
3653 } 3657 }
3654 3658
3655 if (CleanChunkPoolAsync) { 3659 if (CleanChunkPoolAsync) {
3656 Chunk::start_chunk_pool_cleaner_task(); 3660 Chunk::start_chunk_pool_cleaner_task();
3657 } 3661 }