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 |
1326 #ifndef SERIALGC |
1347 #ifndef SERIALGC |
1327 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1348 SATBMarkQueueSet JavaThread::_satb_mark_queue_set; |
1328 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1349 DirtyCardQueueSet JavaThread::_dirty_card_queue_set; |
1329 #endif // !SERIALGC |
1350 #endif // !SERIALGC |
1330 |
1351 |
1331 JavaThread::JavaThread(bool is_attaching) : |
1352 JavaThread::JavaThread(bool is_attaching_via_jni) : |
1332 Thread() |
1353 Thread() |
1333 #ifndef SERIALGC |
1354 #ifndef SERIALGC |
1334 , _satb_mark_queue(&_satb_mark_queue_set), |
1355 , _satb_mark_queue(&_satb_mark_queue_set), |
1335 _dirty_card_queue(&_dirty_card_queue_set) |
1356 _dirty_card_queue(&_dirty_card_queue_set) |
1336 #endif // !SERIALGC |
1357 #endif // !SERIALGC |
1337 { |
1358 { |
1338 initialize(); |
1359 initialize(); |
1339 _is_attaching = is_attaching; |
1360 if (is_attaching_via_jni) { |
|
1361 _jni_attach_state = _attaching_via_jni; |
|
1362 } else { |
|
1363 _jni_attach_state = _not_attaching_via_jni; |
|
1364 } |
1340 assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); |
1365 assert(_deferred_card_mark.is_empty(), "Default MemRegion ctor"); |
1341 } |
1366 } |
1342 |
1367 |
1343 bool JavaThread::reguard_stack(address cur_sp) { |
1368 bool JavaThread::reguard_stack(address cur_sp) { |
1344 if (_stack_guard_state != stack_guard_yellow_disabled) { |
1369 if (_stack_guard_state != stack_guard_yellow_disabled) { |
1390 { |
1415 { |
1391 if (TraceThreadEvents) { |
1416 if (TraceThreadEvents) { |
1392 tty->print_cr("creating thread %p", this); |
1417 tty->print_cr("creating thread %p", this); |
1393 } |
1418 } |
1394 initialize(); |
1419 initialize(); |
1395 _is_attaching = false; |
1420 _jni_attach_state = _not_attaching_via_jni; |
1396 set_entry_point(entry_point); |
1421 set_entry_point(entry_point); |
1397 // Create the native thread itself. |
1422 // Create the native thread itself. |
1398 // %note runtime_23 |
1423 // %note runtime_23 |
1399 os::ThreadType thr_type = os::java_thread; |
1424 os::ThreadType thr_type = os::java_thread; |
1400 thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : |
1425 thr_type = entry_point == &compiler_thread_entry ? os::compiler_thread : |
1502 // Execute thread entry point unless this thread has a pending exception |
1527 // Execute thread entry point unless this thread has a pending exception |
1503 // or has been stopped before starting. |
1528 // or has been stopped before starting. |
1504 // Note: Due to JVM_StopThread we can have pending exceptions already! |
1529 // Note: Due to JVM_StopThread we can have pending exceptions already! |
1505 if (!this->has_pending_exception() && |
1530 if (!this->has_pending_exception() && |
1506 !java_lang_Thread::is_stillborn(this->threadObj())) { |
1531 !java_lang_Thread::is_stillborn(this->threadObj())) { |
|
1532 { |
|
1533 ResourceMark rm(this); |
|
1534 this->set_native_thread_name(this->get_thread_name()); |
|
1535 } |
1507 HandleMark hm(this); |
1536 HandleMark hm(this); |
1508 this->entry_point()(this, this); |
1537 this->entry_point()(this, this); |
1509 } |
1538 } |
1510 |
1539 |
1511 DTRACE_THREAD_PROBE(stop, this); |
1540 DTRACE_THREAD_PROBE(stop, this); |
2681 } |
2710 } |
2682 else { |
2711 else { |
2683 name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen); |
2712 name_str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length(), buf, buflen); |
2684 } |
2713 } |
2685 } |
2714 } |
2686 else if (is_attaching()) { // workaround for 6412693 - see 6404306 |
2715 else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306 |
2687 name_str = "<no-name - thread is attaching>"; |
2716 name_str = "<no-name - thread is attaching>"; |
2688 } |
2717 } |
2689 else { |
2718 else { |
2690 name_str = Thread::name(); |
2719 name_str = Thread::name(); |
2691 } |
2720 } |
3077 |
3106 |
3078 if (PauseAtStartup) { |
3107 if (PauseAtStartup) { |
3079 os::pause(); |
3108 os::pause(); |
3080 } |
3109 } |
3081 |
3110 |
|
3111 #ifndef USDT2 |
3082 HS_DTRACE_PROBE(hotspot, vm__init__begin); |
3112 HS_DTRACE_PROBE(hotspot, vm__init__begin); |
|
3113 #else /* USDT2 */ |
|
3114 HOTSPOT_VM_INIT_BEGIN(); |
|
3115 #endif /* USDT2 */ |
3083 |
3116 |
3084 // Record VM creation timing statistics |
3117 // Record VM creation timing statistics |
3085 TraceVmCreationTime create_vm_timer; |
3118 TraceVmCreationTime create_vm_timer; |
3086 create_vm_timer.start(); |
3119 create_vm_timer.start(); |
3087 |
3120 |
3332 |
3365 |
3333 // Set flag that basic initialization has completed. Used by exceptions and various |
3366 // Set flag that basic initialization has completed. Used by exceptions and various |
3334 // debug stuff, that does not work until all basic classes have been initialized. |
3367 // debug stuff, that does not work until all basic classes have been initialized. |
3335 set_init_completed(); |
3368 set_init_completed(); |
3336 |
3369 |
|
3370 #ifndef USDT2 |
3337 HS_DTRACE_PROBE(hotspot, vm__init__end); |
3371 HS_DTRACE_PROBE(hotspot, vm__init__end); |
|
3372 #else /* USDT2 */ |
|
3373 HOTSPOT_VM_INIT_END(); |
|
3374 #endif /* USDT2 */ |
3338 |
3375 |
3339 // record VM initialization completion time |
3376 // record VM initialization completion time |
3340 Management::record_vm_init_completed(); |
3377 Management::record_vm_init_completed(); |
3341 |
3378 |
3342 // Compute system loader. Note that this has to occur after set_init_completed, since |
3379 // Compute system loader. Note that this has to occur after set_init_completed, since |