< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page




 224 
 225 
 226 Thread::Thread() {
 227   // stack and get_thread
 228   set_stack_base(NULL);
 229   set_stack_size(0);
 230   set_self_raw_id(0);
 231   set_lgrp_id(-1);
 232   DEBUG_ONLY(clear_suspendible_thread();)
 233 
 234   // allocated data structures
 235   set_osthread(NULL);
 236   set_resource_area(new (mtThread)ResourceArea());
 237   DEBUG_ONLY(_current_resource_mark = NULL;)
 238   set_handle_area(new (mtThread) HandleArea(NULL));
 239   set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
 240   set_active_handles(NULL);
 241   set_free_handle_block(NULL);
 242   set_last_handle_mark(NULL);
 243 



 244   // This initial value ==> never claimed.
 245   _oops_do_parity = 0;
 246   _threads_hazard_ptr = NULL;
 247   _nested_threads_hazard_ptr = NULL;
 248   _nested_threads_hazard_ptr_cnt = 0;
 249   _rcu_counter = 0;
 250 
 251   // the handle mark links itself to last_handle_mark
 252   new HandleMark(this);
 253 
 254   // plain initialization
 255   debug_only(_owned_locks = NULL;)
 256   debug_only(_allow_allocation_count = 0;)
 257   NOT_PRODUCT(_allow_safepoint_count = 0;)
 258   NOT_PRODUCT(_skip_gcalot = false;)
 259   _jvmti_env_iteration_count = 0;
 260   set_allocated_bytes(0);
 261   _vm_operation_started_count = 0;
 262   _vm_operation_completed_count = 0;
 263   _current_pending_monitor = NULL;


 862     ObjectSynchronizer::thread_local_used_oops_do(this, f);
 863   }
 864 }
 865 
 866 void Thread::metadata_handles_do(void f(Metadata*)) {
 867   // Only walk the Handles in Thread.
 868   if (metadata_handles() != NULL) {
 869     for (int i = 0; i< metadata_handles()->length(); i++) {
 870       f(metadata_handles()->at(i));
 871     }
 872   }
 873 }
 874 
 875 void Thread::print_on(outputStream* st) const {
 876   // get_priority assumes osthread initialized
 877   if (osthread() != NULL) {
 878     int os_prio;
 879     if (os::get_native_priority(this, &os_prio) == OS_OK) {
 880       st->print("os_prio=%d ", os_prio);
 881     }















 882     st->print("tid=" INTPTR_FORMAT " ", p2i(this));
 883     osthread()->print_on(st);
 884   }
 885   if (_threads_hazard_ptr != NULL) {
 886     st->print("_threads_hazard_ptr=" INTPTR_FORMAT, p2i(_threads_hazard_ptr));
 887   }
 888   if (_nested_threads_hazard_ptr != NULL) {
 889     print_nested_threads_hazard_ptrs_on(st);
 890   }
 891   st->print(" ");
 892   debug_only(if (WizardMode) print_owned_locks_on(st);)
 893 }
 894 
 895 void Thread::print_nested_threads_hazard_ptrs_on(outputStream* st) const {
 896   assert(_nested_threads_hazard_ptr != NULL, "must be set to print");
 897 
 898   if (EnableThreadSMRStatistics) {
 899     st->print(", _nested_threads_hazard_ptr_cnt=%u", _nested_threads_hazard_ptr_cnt);
 900   }
 901   st->print(", _nested_threads_hazard_ptrs=");




 224 
 225 
 226 Thread::Thread() {
 227   // stack and get_thread
 228   set_stack_base(NULL);
 229   set_stack_size(0);
 230   set_self_raw_id(0);
 231   set_lgrp_id(-1);
 232   DEBUG_ONLY(clear_suspendible_thread();)
 233 
 234   // allocated data structures
 235   set_osthread(NULL);
 236   set_resource_area(new (mtThread)ResourceArea());
 237   DEBUG_ONLY(_current_resource_mark = NULL;)
 238   set_handle_area(new (mtThread) HandleArea(NULL));
 239   set_metadata_handles(new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(30, true));
 240   set_active_handles(NULL);
 241   set_free_handle_block(NULL);
 242   set_last_handle_mark(NULL);
 243 
 244   _statistic_info.setStartTime(os::javaTimeMillis());
 245   _statistic_info.setDefineClassCount(0);
 246 
 247   // This initial value ==> never claimed.
 248   _oops_do_parity = 0;
 249   _threads_hazard_ptr = NULL;
 250   _nested_threads_hazard_ptr = NULL;
 251   _nested_threads_hazard_ptr_cnt = 0;
 252   _rcu_counter = 0;
 253 
 254   // the handle mark links itself to last_handle_mark
 255   new HandleMark(this);
 256 
 257   // plain initialization
 258   debug_only(_owned_locks = NULL;)
 259   debug_only(_allow_allocation_count = 0;)
 260   NOT_PRODUCT(_allow_safepoint_count = 0;)
 261   NOT_PRODUCT(_skip_gcalot = false;)
 262   _jvmti_env_iteration_count = 0;
 263   set_allocated_bytes(0);
 264   _vm_operation_started_count = 0;
 265   _vm_operation_completed_count = 0;
 266   _current_pending_monitor = NULL;


 865     ObjectSynchronizer::thread_local_used_oops_do(this, f);
 866   }
 867 }
 868 
 869 void Thread::metadata_handles_do(void f(Metadata*)) {
 870   // Only walk the Handles in Thread.
 871   if (metadata_handles() != NULL) {
 872     for (int i = 0; i< metadata_handles()->length(); i++) {
 873       f(metadata_handles()->at(i));
 874     }
 875   }
 876 }
 877 
 878 void Thread::print_on(outputStream* st) const {
 879   // get_priority assumes osthread initialized
 880   if (osthread() != NULL) {
 881     int os_prio;
 882     if (os::get_native_priority(this, &os_prio) == OS_OK) {
 883       st->print("os_prio=%d ", os_prio);
 884     }
 885 
 886     if (os::is_thread_cpu_time_supported()) {
 887       st->print("cpu=%.2fms ",
 888                 os::thread_cpu_time(const_cast<Thread*>(this), true) / 1000000.0
 889         );
 890       st->print("elapsed=%.2fs ",
 891                 _statistic_info.getElepsedTime() / 1000.0);
 892     }
 893 
 894     if (is_Java_thread()) {
 895       jlong allocated_bytes = const_cast<Thread*>(this)->cooked_allocated_bytes();
 896       st->print("allocated=" JLONG_FORMAT "B ", allocated_bytes);
 897       st->print("defined_classes=" INT64_FORMAT " ", _statistic_info.getDefineClassCount());
 898     }
 899 
 900     st->print("tid=" INTPTR_FORMAT " ", p2i(this));
 901     osthread()->print_on(st);
 902   }
 903   if (_threads_hazard_ptr != NULL) {
 904     st->print("_threads_hazard_ptr=" INTPTR_FORMAT, p2i(_threads_hazard_ptr));
 905   }
 906   if (_nested_threads_hazard_ptr != NULL) {
 907     print_nested_threads_hazard_ptrs_on(st);
 908   }
 909   st->print(" ");
 910   debug_only(if (WizardMode) print_owned_locks_on(st);)
 911 }
 912 
 913 void Thread::print_nested_threads_hazard_ptrs_on(outputStream* st) const {
 914   assert(_nested_threads_hazard_ptr != NULL, "must be set to print");
 915 
 916   if (EnableThreadSMRStatistics) {
 917     st->print(", _nested_threads_hazard_ptr_cnt=%u", _nested_threads_hazard_ptr_cnt);
 918   }
 919   st->print(", _nested_threads_hazard_ptrs=");


< prev index next >