319 // So far, only Solaris has real implementation of initialize_thread(). |
319 // So far, only Solaris has real implementation of initialize_thread(). |
320 // |
320 // |
321 // set up any platform-specific state. |
321 // set up any platform-specific state. |
322 os::initialize_thread(this); |
322 os::initialize_thread(this); |
323 |
323 |
|
324 #if INCLUDE_NMT |
324 // record thread's native stack, stack grows downward |
325 // record thread's native stack, stack grows downward |
325 if (MemTracker::is_on()) { |
326 if (MemTracker::is_on()) { |
326 address stack_low_addr = stack_base() - stack_size(); |
327 address stack_low_addr = stack_base() - stack_size(); |
327 MemTracker::record_thread_stack(stack_low_addr, stack_size(), this, |
328 MemTracker::record_thread_stack(stack_low_addr, stack_size(), this, |
328 CURRENT_PC); |
329 CURRENT_PC); |
329 } |
330 } |
|
331 #endif // INCLUDE_NMT |
330 } |
332 } |
331 |
333 |
332 |
334 |
333 Thread::~Thread() { |
335 Thread::~Thread() { |
334 // Reclaim the objectmonitors from the omFreeList of the moribund thread. |
336 // Reclaim the objectmonitors from the omFreeList of the moribund thread. |
336 |
338 |
337 // stack_base can be NULL if the thread is never started or exited before |
339 // stack_base can be NULL if the thread is never started or exited before |
338 // record_stack_base_and_size called. Although, we would like to ensure |
340 // record_stack_base_and_size called. Although, we would like to ensure |
339 // that all started threads do call record_stack_base_and_size(), there is |
341 // that all started threads do call record_stack_base_and_size(), there is |
340 // not proper way to enforce that. |
342 // not proper way to enforce that. |
|
343 #if INCLUDE_NMT |
341 if (_stack_base != NULL) { |
344 if (_stack_base != NULL) { |
342 address low_stack_addr = stack_base() - stack_size(); |
345 address low_stack_addr = stack_base() - stack_size(); |
343 MemTracker::release_thread_stack(low_stack_addr, stack_size(), this); |
346 MemTracker::release_thread_stack(low_stack_addr, stack_size(), this); |
344 } |
347 } |
|
348 #endif // INCLUDE_NMT |
345 |
349 |
346 // deallocate data structures |
350 // deallocate data structures |
347 delete resource_area(); |
351 delete resource_area(); |
348 // since the handle marks are using the handle area, we have to deallocated the root |
352 // since the handle marks are using the handle area, we have to deallocated the root |
349 // handle mark before deallocating the thread's handle area, |
353 // handle mark before deallocating the thread's handle area, |
1355 set_deopt_nmethod(NULL); |
1359 set_deopt_nmethod(NULL); |
1356 clear_must_deopt_id(); |
1360 clear_must_deopt_id(); |
1357 set_monitor_chunks(NULL); |
1361 set_monitor_chunks(NULL); |
1358 set_next(NULL); |
1362 set_next(NULL); |
1359 set_thread_state(_thread_new); |
1363 set_thread_state(_thread_new); |
|
1364 #if INCLUDE_NMT |
1360 set_recorder(NULL); |
1365 set_recorder(NULL); |
|
1366 #endif |
1361 _terminated = _not_terminated; |
1367 _terminated = _not_terminated; |
1362 _privileged_stack_top = NULL; |
1368 _privileged_stack_top = NULL; |
1363 _array_for_gc = NULL; |
1369 _array_for_gc = NULL; |
1364 _suspend_equivalent = false; |
1370 _suspend_equivalent = false; |
1365 _in_deopt_handler = 0; |
1371 _in_deopt_handler = 0; |
3521 #else /* USDT2 */ |
3527 #else /* USDT2 */ |
3522 HOTSPOT_VM_INIT_END(); |
3528 HOTSPOT_VM_INIT_END(); |
3523 #endif /* USDT2 */ |
3529 #endif /* USDT2 */ |
3524 |
3530 |
3525 // record VM initialization completion time |
3531 // record VM initialization completion time |
|
3532 #if INCLUDE_MANAGEMENT |
3526 Management::record_vm_init_completed(); |
3533 Management::record_vm_init_completed(); |
|
3534 #endif // INCLUDE_MANAGEMENT |
3527 |
3535 |
3528 // Compute system loader. Note that this has to occur after set_init_completed, since |
3536 // Compute system loader. Note that this has to occur after set_init_completed, since |
3529 // valid exceptions may be thrown in the process. |
3537 // valid exceptions may be thrown in the process. |
3530 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and |
3538 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and |
3531 // set_init_completed has just been called, causing exceptions not to be shortcut |
3539 // set_init_completed has just been called, causing exceptions not to be shortcut |
3582 if (CleanChunkPoolAsync) { |
3590 if (CleanChunkPoolAsync) { |
3583 Chunk::start_chunk_pool_cleaner_task(); |
3591 Chunk::start_chunk_pool_cleaner_task(); |
3584 } |
3592 } |
3585 |
3593 |
3586 // initialize compiler(s) |
3594 // initialize compiler(s) |
|
3595 #if defined(COMPILER1) || defined(COMPILER2) |
3587 CompileBroker::compilation_init(); |
3596 CompileBroker::compilation_init(); |
3588 |
3597 #endif |
|
3598 |
|
3599 #if INCLUDE_MANAGEMENT |
3589 Management::initialize(THREAD); |
3600 Management::initialize(THREAD); |
|
3601 #endif // INCLUDE_MANAGEMENT |
|
3602 |
3590 if (HAS_PENDING_EXCEPTION) { |
3603 if (HAS_PENDING_EXCEPTION) { |
3591 // management agent fails to start possibly due to |
3604 // management agent fails to start possibly due to |
3592 // configuration problem and is responsible for printing |
3605 // configuration problem and is responsible for printing |
3593 // stack trace if appropriate. Simply exit VM. |
3606 // stack trace if appropriate. Simply exit VM. |
3594 vm_exit(1); |
3607 vm_exit(1); |
3754 void Threads::create_vm_init_agents() { |
3767 void Threads::create_vm_init_agents() { |
3755 extern struct JavaVM_ main_vm; |
3768 extern struct JavaVM_ main_vm; |
3756 AgentLibrary* agent; |
3769 AgentLibrary* agent; |
3757 |
3770 |
3758 JvmtiExport::enter_onload_phase(); |
3771 JvmtiExport::enter_onload_phase(); |
|
3772 |
3759 for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) { |
3773 for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) { |
3760 OnLoadEntry_t on_load_entry = lookup_agent_on_load(agent); |
3774 OnLoadEntry_t on_load_entry = lookup_agent_on_load(agent); |
3761 |
3775 |
3762 if (on_load_entry != NULL) { |
3776 if (on_load_entry != NULL) { |
3763 // Invoke the Agent_OnLoad function |
3777 // Invoke the Agent_OnLoad function |