src/share/vm/runtime/thread.cpp

changeset 3427
94ec88ca68e2
parent 3294
bca17e38de00
child 3499
aa3d708d67c4
     1.1 --- a/src/share/vm/runtime/thread.cpp	Mon Jan 09 10:27:24 2012 +0100
     1.2 +++ b/src/share/vm/runtime/thread.cpp	Wed Jan 11 17:34:02 2012 -0500
     1.3 @@ -73,6 +73,7 @@
     1.4  #include "services/attachListener.hpp"
     1.5  #include "services/management.hpp"
     1.6  #include "services/threadService.hpp"
     1.7 +#include "trace/traceEventTypes.hpp"
     1.8  #include "utilities/defaultStream.hpp"
     1.9  #include "utilities/dtrace.hpp"
    1.10  #include "utilities/events.hpp"
    1.11 @@ -232,6 +233,7 @@
    1.12    CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;)
    1.13    _jvmti_env_iteration_count = 0;
    1.14    set_allocated_bytes(0);
    1.15 +  set_trace_buffer(NULL);
    1.16    _vm_operation_started_count = 0;
    1.17    _vm_operation_completed_count = 0;
    1.18    _current_pending_monitor = NULL;
    1.19 @@ -1512,6 +1514,10 @@
    1.20      JvmtiExport::post_thread_start(this);
    1.21    }
    1.22  
    1.23 +  EVENT_BEGIN(TraceEventThreadStart, event);
    1.24 +  EVENT_COMMIT(event,
    1.25 +     EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj())));
    1.26 +
    1.27    // We call another function to do the rest so we are sure that the stack addresses used
    1.28    // from there will be lower than the stack base just computed
    1.29    thread_main_inner();
    1.30 @@ -1641,6 +1647,15 @@
    1.31        }
    1.32      }
    1.33  
    1.34 +    // Called before the java thread exit since we want to read info
    1.35 +    // from java_lang_Thread object
    1.36 +    EVENT_BEGIN(TraceEventThreadEnd, event);
    1.37 +    EVENT_COMMIT(event,
    1.38 +        EVENT_SET(event, javalangthread, java_lang_Thread::thread_id(this->threadObj())));
    1.39 +
    1.40 +    // Call after last event on thread
    1.41 +    EVENT_THREAD_EXIT(this);
    1.42 +
    1.43      // Call Thread.exit(). We try 3 times in case we got another Thread.stop during
    1.44      // the execution of the method. If that is not enough, then we don't really care. Thread.stop
    1.45      // is deprecated anyhow.
    1.46 @@ -3186,6 +3201,11 @@
    1.47      return status;
    1.48    }
    1.49  
    1.50 +  // Must be run after init_ft which initializes ft_enabled
    1.51 +  if (TRACE_INITIALIZE() != JNI_OK) {
    1.52 +    vm_exit_during_initialization("Failed to initialize tracing backend");
    1.53 +  }
    1.54 +
    1.55    // Should be done after the heap is fully created
    1.56    main_thread->cache_global_variables();
    1.57  
    1.58 @@ -3423,6 +3443,10 @@
    1.59      create_vm_init_libraries();
    1.60    }
    1.61  
    1.62 +  if (!TRACE_START()) {
    1.63 +    vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
    1.64 +  }
    1.65 +
    1.66    // Notify JVMTI agents that VM initialization is complete - nop if no agents.
    1.67    JvmtiExport::post_vm_initialized();
    1.68  

mercurial