108 |
108 |
109 #ifdef DTRACE_ENABLED |
109 #ifdef DTRACE_ENABLED |
110 |
110 |
111 // Only bother with this argument setup if dtrace is available |
111 // Only bother with this argument setup if dtrace is available |
112 |
112 |
|
113 #ifndef USDT2 |
113 HS_DTRACE_PROBE_DECL(hotspot, vm__init__begin); |
114 HS_DTRACE_PROBE_DECL(hotspot, vm__init__begin); |
114 HS_DTRACE_PROBE_DECL(hotspot, vm__init__end); |
115 HS_DTRACE_PROBE_DECL(hotspot, vm__init__end); |
115 HS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t, |
116 HS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t, |
116 intptr_t, intptr_t, bool); |
117 intptr_t, intptr_t, bool); |
117 HS_DTRACE_PROBE_DECL5(hotspot, thread__stop, char*, intptr_t, |
118 HS_DTRACE_PROBE_DECL5(hotspot, thread__stop, char*, intptr_t, |
127 name, len, \ |
128 name, len, \ |
128 java_lang_Thread::thread_id((javathread)->threadObj()), \ |
129 java_lang_Thread::thread_id((javathread)->threadObj()), \ |
129 (javathread)->osthread()->thread_id(), \ |
130 (javathread)->osthread()->thread_id(), \ |
130 java_lang_Thread::is_daemon((javathread)->threadObj())); \ |
131 java_lang_Thread::is_daemon((javathread)->threadObj())); \ |
131 } |
132 } |
|
133 |
|
134 #else /* USDT2 */ |
|
135 |
|
136 #define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_PROBE_START |
|
137 #define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_PROBE_STOP |
|
138 |
|
139 #define DTRACE_THREAD_PROBE(probe, javathread) \ |
|
140 { \ |
|
141 ResourceMark rm(this); \ |
|
142 int len = 0; \ |
|
143 const char* name = (javathread)->get_thread_name(); \ |
|
144 len = strlen(name); \ |
|
145 HOTSPOT_THREAD_PROBE_##probe( /* probe = start, stop */ \ |
|
146 (char *) name, len, \ |
|
147 java_lang_Thread::thread_id((javathread)->threadObj()), \ |
|
148 (uintptr_t) (javathread)->osthread()->thread_id(), \ |
|
149 java_lang_Thread::is_daemon((javathread)->threadObj())); \ |
|
150 } |
|
151 |
|
152 #endif /* USDT2 */ |
132 |
153 |
133 #else // ndef DTRACE_ENABLED |
154 #else // ndef DTRACE_ENABLED |
134 |
155 |
135 #define DTRACE_THREAD_PROBE(probe, javathread) |
156 #define DTRACE_THREAD_PROBE(probe, javathread) |
136 |
157 |
1325 #ifndef SERIALGC |
1346 #ifndef SERIALGC |
1326 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1347 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1327 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1348 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1328 #endif // !SERIALGC |
1349 #endif // !SERIALGC |
1329 |
1350 |
1330 JavaThread::JavaThread(bool is_attaching) : |
1351 JavaThread::JavaThread(bool is_attaching_via_jni) : |
1331 Thread() |
1352 Thread() |
1332 #ifndef SERIALGC |
1353 #ifndef SERIALGC |
1333 , _satb_mark_queue(&_satb_mark_queue_set), |
1354 , _satb_mark_queue(&_satb_mark_queue_set), |
1334 _dirty_card_queue(&_dirty_card_queue_set) |
1355 _dirty_card_queue(&_dirty_card_queue_set) |
1335 #endif // !SERIALGC |
1356 #endif // !SERIALGC |
1336 { |
1357 { |
1337 initialize(); |
1358 initialize(); |
1338 _is_attaching = is_attaching; |
1359 if (is_attaching_via_jni) { |
|
1360 _jni_attach_state = _attaching_via_jni; |
|
1361 } else { |
|
1362 _jni_attach_state = _not_attaching_via_jni; |
|
1363 } |
1339 assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); |
1364 assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); |
1340 } |
1365 } |
1341 |
1366 |
1342 bool JavaThread::reguard_stack(address cur_sp) { |
1367 bool JavaThread::reguard_stack(address cur_sp) { |
1343 if (_stack_guard_state != stack_guard_yellow_disabled) { |
1368 if (_stack_guard_state != stack_guard_yellow_disabled) { |
1389 { |
1414 { |
1390 if (TraceThreadEvents) { |
1415 if (TraceThreadEvents) { |
1391 tty->print_cr("creating thread %p", this); |
1416 tty->print_cr("creating thread %p", this); |
1392 } |
1417 } |
1393 initialize(); |
1418 initialize(); |
1394 _is_attaching = false; |
1419 _jni_attach_state = _not_attaching_via_jni; |
1395 set_entry_point(entry_point); |
1420 set_entry_point(entry_point); |
1396 // Create the native thread itself. |
1421 // Create the native thread itself. |
1397 // %note runtime_23 |
1422 // %note runtime_23 |
1398 os::ThreadType thr_type = os::java_thread; |
1423 os::ThreadType thr_type = os::java_thread; |
1399 thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : |
1424 thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : |
1501 // Execute thread entry point unless this thread has a pending exception |
1526 // Execute thread entry point unless this thread has a pending exception |
1502 // or has been stopped before starting. |
1527 // or has been stopped before starting. |
1503 // Note: Due to JVM_StopThread we can have pending exceptions already! |
1528 // Note: Due to JVM_StopThread we can have pending exceptions already! |
1504 if (!this->has_pending_exception() && |
1529 if (!this->has_pending_exception() && |
1505 !java_lang_Thread::is_stillborn(this->threadObj())) { |
1530 !java_lang_Thread::is_stillborn(this->threadObj())) { |
|
1531 { |
|
1532 ResourceMark rm(this); |
|
1533 this->set_native_thread_name(this->get_thread_name()); |
|
1534 } |
1506 HandleMark hm(this); |
1535 HandleMark hm(this); |
1507 this->entry_point()(this, this); |
1536 this->entry_point()(this, this); |
1508 } |
1537 } |
1509 |
1538 |
1510 DTRACE_THREAD_PROBE(stop, this); |
1539 DTRACE_THREAD_PROBE(stop, this); |
2680 } |
2709 } |
2681 else { |
2710 else { |
2682 name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen); |
2711 name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen); |
2683 } |
2712 } |
2684 } |
2713 } |
2685 else if (is_attaching()) { // workaround for 6412693 - see 6404306 |
2714 else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306 |
2686 name_str = "<no-name - thread is attaching>"; |
2715 name_str = "<no-name - thread is attaching>"; |
2687 } |
2716 } |
2688 else { |
2717 else { |
2689 name_str = Thread::name(); |
2718 name_str = Thread::name(); |
2690 } |
2719 } |
3076 |
3105 |
3077 if (PauseAtStartup) { |
3106 if (PauseAtStartup) { |
3078 os::pause(); |
3107 os::pause(); |
3079 } |
3108 } |
3080 |
3109 |
|
3110 #ifndef USDT2 |
3081 HS_DTRACE_PROBE(hotspot, vm__init__begin); |
3111 HS_DTRACE_PROBE(hotspot, vm__init__begin); |
|
3112 #else /* USDT2 */ |
|
3113 HOTSPOT_VM_INIT_BEGIN(); |
|
3114 #endif /* USDT2 */ |
3082 |
3115 |
3083 // Record VM creation timing statistics |
3116 // Record VM creation timing statistics |
3084 TraceVmCreationTime create_vm_timer; |
3117 TraceVmCreationTime create_vm_timer; |
3085 create_vm_timer.start(); |
3118 create_vm_timer.start(); |
3086 |
3119 |
3331 |
3364 |
3332 // Set flag that basic initialization has completed. Used by exceptions and various |
3365 // Set flag that basic initialization has completed. Used by exceptions and various |
3333 // debug stuff, that does not work until all basic classes have been initialized. |
3366 // debug stuff, that does not work until all basic classes have been initialized. |
3334 set_init_completed(); |
3367 set_init_completed(); |
3335 |
3368 |
|
3369 #ifndef USDT2 |
3336 HS_DTRACE_PROBE(hotspot, vm__init__end); |
3370 HS_DTRACE_PROBE(hotspot, vm__init__end); |
|
3371 #else /* USDT2 */ |
|
3372 HOTSPOT_VM_INIT_END(); |
|
3373 #endif /* USDT2 */ |
3337 |
3374 |
3338 // record VM initialization completion time |
3375 // record VM initialization completion time |
3339 Management::record_vm_init_completed(); |
3376 Management::record_vm_init_completed(); |
3340 |
3377 |
3341 // Compute system loader. Note that this has to occur after set_init_completed, since |
3378 // Compute system loader. Note that this has to occur after set_init_completed, since |