< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page
rev 52211 : [mq]: tinit


 403   if (time_struct_ptr != NULL) {
 404     *res = *time_struct_ptr;
 405     return res;
 406   }
 407   return NULL;
 408 }
 409 
 410 struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
 411   const struct tm* time_struct_ptr = gmtime(clock);
 412   if (time_struct_ptr != NULL) {
 413     *res = *time_struct_ptr;
 414     return res;
 415   }
 416   return NULL;
 417 }
 418 
 419 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
 420 
 421 // Thread start routine for all newly created threads
 422 static unsigned __stdcall thread_native_entry(Thread* thread) {



 423   // Try to randomize the cache line index of hot stack frames.
 424   // This helps when threads of the same stack traces evict each other's
 425   // cache lines. The threads can be either from the same JVM instance, or
 426   // from different JVM instances. The benefit is especially true for
 427   // processors with hyperthreading technology.
 428   static int counter = 0;
 429   int pid = os::current_process_id();
 430   _alloca(((pid ^ counter++) & 7) * 128);
 431 
 432   thread->initialize_thread_current();
 433 
 434   OSThread* osthr = thread->osthread();
 435   assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
 436 
 437   if (UseNUMA) {
 438     int lgrp_id = os::numa_get_group_id();
 439     if (lgrp_id != -1) {
 440       thread->set_lgrp_id(lgrp_id);
 441     }
 442   }
 443 
 444   // Diagnostic code to investigate JDK-6573254
 445   int res = 30115;  // non-java thread
 446   if (thread->is_Java_thread()) {
 447     res = 20115;    // java thread
 448   }
 449 
 450   log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").", os::current_thread_id());
 451 
 452   // Install a win32 structured exception handler around every thread created
 453   // by VM, so VM can generate error dump when an exception occurred in non-
 454   // Java thread (e.g. VM thread).
 455   __try {
 456     thread->run();
 457   } __except(topLevelExceptionFilter(
 458                                      (_EXCEPTION_POINTERS*)_exception_info())) {
 459     // Nothing to do.
 460   }
 461 



 462   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
 463 
 464   // One less thread is executing
 465   // When the VMThread gets here, the main thread may have already exited
 466   // which frees the CodeHeap containing the Atomic::add code
 467   if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
 468     Atomic::dec(&os::win32::_os_thread_count);
 469   }
 470 
 471   // If a thread has not deleted itself ("delete this") as part of its
 472   // termination sequence, we have to ensure thread-local-storage is
 473   // cleared before we actually terminate. No threads should ever be
 474   // deleted asynchronously with respect to their termination.
 475   if (Thread::current_or_null_safe() != NULL) {
 476     assert(Thread::current_or_null_safe() == thread, "current thread is wrong");
 477     thread->clear_thread_current();
 478   }
 479 
 480   // Thread must not return from exit_process_or_thread(), but if it does,
 481   // let it proceed to exit normally
 482   return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res);
 483 }
 484 
 485 static OSThread* create_os_thread(Thread* thread, HANDLE thread_handle,
 486                                   int thread_id) {
 487   // Allocate the OSThread object
 488   OSThread* osthread = new OSThread(NULL, NULL);
 489   if (osthread == NULL) return NULL;
 490 
 491   // Initialize support for Java interrupts
 492   HANDLE interrupt_event = CreateEvent(NULL, true, false, NULL);
 493   if (interrupt_event == NULL) {
 494     delete osthread;
 495     return NULL;
 496   }
 497   osthread->set_interrupt_event(interrupt_event);




 403   if (time_struct_ptr != NULL) {
 404     *res = *time_struct_ptr;
 405     return res;
 406   }
 407   return NULL;
 408 }
 409 
 410 struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) {
 411   const struct tm* time_struct_ptr = gmtime(clock);
 412   if (time_struct_ptr != NULL) {
 413     *res = *time_struct_ptr;
 414     return res;
 415   }
 416   return NULL;
 417 }
 418 
 419 LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
 420 
 421 // Thread start routine for all newly created threads
 422 static unsigned __stdcall thread_native_entry(Thread* thread) {
 423 
 424   thread->record_stack_base_and_size();
 425 
 426   // Try to randomize the cache line index of hot stack frames.
 427   // This helps when threads of the same stack traces evict each other's
 428   // cache lines. The threads can be either from the same JVM instance, or
 429   // from different JVM instances. The benefit is especially true for
 430   // processors with hyperthreading technology.
 431   static int counter = 0;
 432   int pid = os::current_process_id();
 433   _alloca(((pid ^ counter++) & 7) * 128);
 434 
 435   thread->initialize_thread_current();
 436 
 437   OSThread* osthr = thread->osthread();
 438   assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
 439 
 440   if (UseNUMA) {
 441     int lgrp_id = os::numa_get_group_id();
 442     if (lgrp_id != -1) {
 443       thread->set_lgrp_id(lgrp_id);
 444     }
 445   }
 446 
 447   // Diagnostic code to investigate JDK-6573254
 448   int res = 30115;  // non-java thread
 449   if (thread->is_Java_thread()) {
 450     res = 20115;    // java thread
 451   }
 452 
 453   log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").", os::current_thread_id());
 454 
 455   // Install a win32 structured exception handler around every thread created
 456   // by VM, so VM can generate error dump when an exception occurred in non-
 457   // Java thread (e.g. VM thread).
 458   __try {
 459     thread->call_run();
 460   } __except(topLevelExceptionFilter(
 461                                      (_EXCEPTION_POINTERS*)_exception_info())) {
 462     // Nothing to do.
 463   }
 464 
 465   // Note: at this point the thread object may already have deleted itself.
 466   // Do not dereference it from here on out.
 467 
 468   log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id());
 469 
 470   // One less thread is executing
 471   // When the VMThread gets here, the main thread may have already exited
 472   // which frees the CodeHeap containing the Atomic::add code
 473   if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
 474     Atomic::dec(&os::win32::_os_thread_count);









 475   }
 476 
 477   // Thread must not return from exit_process_or_thread(), but if it does,
 478   // let it proceed to exit normally
 479   return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res);
 480 }
 481 
 482 static OSThread* create_os_thread(Thread* thread, HANDLE thread_handle,
 483                                   int thread_id) {
 484   // Allocate the OSThread object
 485   OSThread* osthread = new OSThread(NULL, NULL);
 486   if (osthread == NULL) return NULL;
 487 
 488   // Initialize support for Java interrupts
 489   HANDLE interrupt_event = CreateEvent(NULL, true, false, NULL);
 490   if (interrupt_event == NULL) {
 491     delete osthread;
 492     return NULL;
 493   }
 494   osthread->set_interrupt_event(interrupt_event);


< prev index next >