src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/thread.cpp

Print this page




 310   // set up any platform-specific state.
 311   os::initialize_thread();
 312 }
 313 
 314 void Thread::record_stack_base_and_size() {
 315   set_stack_base(os::current_stack_base());
 316   set_stack_size(os::current_stack_size());
 317 
 318   // record thread's native stack, stack grows downward
 319   address vm_base = _stack_base - _stack_size;
 320   MemTracker::record_virtual_memory_reserve(vm_base, _stack_size,
 321     CURRENT_PC, this);
 322   MemTracker::record_virtual_memory_type(vm_base, mtThreadStack);
 323 }
 324 
 325 
 326 Thread::~Thread() {
 327   // Reclaim the objectmonitors from the omFreeList of the moribund thread.
 328   ObjectSynchronizer::omFlush (this) ;
 329 
 330   MemTracker::record_virtual_memory_release((_stack_base - _stack_size),
 331     _stack_size, this);






 332 





 333   // deallocate data structures
 334   delete resource_area();
 335   // since the handle marks are using the handle area, we have to deallocated the root
 336   // handle mark before deallocating the thread's handle area,
 337   assert(last_handle_mark() != NULL, "check we have an element");
 338   delete last_handle_mark();
 339   assert(last_handle_mark() == NULL, "check we have reached the end");
 340 
 341   // It's possible we can encounter a null _ParkEvent, etc., in stillborn threads.
 342   // We NULL out the fields for good hygiene.
 343   ParkEvent::Release (_ParkEvent)   ; _ParkEvent   = NULL ;
 344   ParkEvent::Release (_SleepEvent)  ; _SleepEvent  = NULL ;
 345   ParkEvent::Release (_MutexEvent)  ; _MutexEvent  = NULL ;
 346   ParkEvent::Release (_MuxEvent)    ; _MuxEvent    = NULL ;
 347 
 348   delete handle_area();
 349 
 350   // osthread() can be NULL, if creation of thread failed.
 351   if (osthread() != NULL) os::free_thread(osthread());
 352 




 310   // set up any platform-specific state.
 311   os::initialize_thread();
 312 }
 313 
 314 void Thread::record_stack_base_and_size() {
 315   set_stack_base(os::current_stack_base());
 316   set_stack_size(os::current_stack_size());
 317 
 318   // record thread's native stack, stack grows downward
 319   address vm_base = _stack_base - _stack_size;
 320   MemTracker::record_virtual_memory_reserve(vm_base, _stack_size,
 321     CURRENT_PC, this);
 322   MemTracker::record_virtual_memory_type(vm_base, mtThreadStack);
 323 }
 324 
 325 
 326 Thread::~Thread() {
 327   // Reclaim the objectmonitors from the omFreeList of the moribund thread.
 328   ObjectSynchronizer::omFlush (this) ;
 329 
 330   // stack_base() asserts stack base address, that ensures all threads call
 331   // Thread::record_stack_base_and_size() method, which will create
 332   // thread native stack records.
 333   // With exception that "Thread" objects are created, but failed
 334   // to start. In this case, the stack information is not recorded.
 335   OSThread* os_thr = osthread();
 336   if (os_thr != NULL && os_thr->get_state() != ALLOCATED &&
 337       os_thr->get_state() != INITIALIZED) {
 338     
 339     address stack_base_addr = stack_base();
 340     MemTracker::record_virtual_memory_release((stack_base_addr - stack_size()),
 341        stack_size(), this);
 342   }
 343 
 344   // deallocate data structures
 345   delete resource_area();
 346   // since the handle marks are using the handle area, we have to deallocated the root
 347   // handle mark before deallocating the thread's handle area,
 348   assert(last_handle_mark() != NULL, "check we have an element");
 349   delete last_handle_mark();
 350   assert(last_handle_mark() == NULL, "check we have reached the end");
 351 
 352   // It's possible we can encounter a null _ParkEvent, etc., in stillborn threads.
 353   // We NULL out the fields for good hygiene.
 354   ParkEvent::Release (_ParkEvent)   ; _ParkEvent   = NULL ;
 355   ParkEvent::Release (_SleepEvent)  ; _SleepEvent  = NULL ;
 356   ParkEvent::Release (_MutexEvent)  ; _MutexEvent  = NULL ;
 357   ParkEvent::Release (_MuxEvent)    ; _MuxEvent    = NULL ;
 358 
 359   delete handle_area();
 360 
 361   // osthread() can be NULL, if creation of thread failed.
 362   if (osthread() != NULL) os::free_thread(osthread());
 363 


src/share/vm/runtime/thread.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File