comparison src/os/bsd/vm/os_bsd.cpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 6b0fd0964b87 40136aa2cdb1
children 096c224171c4
comparison
equal deleted inserted replaced
12058:ccb4f2af2319 12355:cefad50507d8
640 extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction; 640 extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction;
641 objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL; 641 objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL;
642 #endif 642 #endif
643 643
644 #ifdef __APPLE__ 644 #ifdef __APPLE__
645 static uint64_t locate_unique_thread_id() { 645 static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) {
646 // Additional thread_id used to correlate threads in SA 646 // Additional thread_id used to correlate threads in SA
647 thread_identifier_info_data_t m_ident_info; 647 thread_identifier_info_data_t m_ident_info;
648 mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT; 648 mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
649 649
650 thread_info(::mach_thread_self(), THREAD_IDENTIFIER_INFO, 650 thread_info(mach_thread_port, THREAD_IDENTIFIER_INFO,
651 (thread_info_t) &m_ident_info, &count); 651 (thread_info_t) &m_ident_info, &count);
652
652 return m_ident_info.thread_id; 653 return m_ident_info.thread_id;
653 } 654 }
654 #endif 655 #endif
655 656
656 // Thread start routine for all newly created threads 657 // Thread start routine for all newly created threads
677 sync->notify_all(); 678 sync->notify_all();
678 return NULL; 679 return NULL;
679 } 680 }
680 681
681 #ifdef __APPLE__ 682 #ifdef __APPLE__
682 // thread_id is mach thread on macos 683 // thread_id is mach thread on macos, which pthreads graciously caches and provides for us
683 osthread->set_thread_id(::mach_thread_self()); 684 mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
684 osthread->set_unique_thread_id(locate_unique_thread_id()); 685 guarantee(thread_id != 0, "thread id missing from pthreads");
686 osthread->set_thread_id(thread_id);
687
688 uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
689 guarantee(unique_thread_id != 0, "unique thread id was not found");
690 osthread->set_unique_thread_id(unique_thread_id);
685 #else 691 #else
686 // thread_id is pthread_id on BSD 692 // thread_id is pthread_id on BSD
687 osthread->set_thread_id(::pthread_self()); 693 osthread->set_thread_id(::pthread_self());
688 #endif 694 #endif
689 // initialize signal mask for this thread 695 // initialize signal mask for this thread
841 return false; 847 return false;
842 } 848 }
843 849
844 // Store pthread info into the OSThread 850 // Store pthread info into the OSThread
845 #ifdef __APPLE__ 851 #ifdef __APPLE__
846 osthread->set_thread_id(::mach_thread_self()); 852 // thread_id is mach thread on macos, which pthreads graciously caches and provides for us
847 osthread->set_unique_thread_id(locate_unique_thread_id()); 853 mach_port_t thread_id = ::pthread_mach_thread_np(::pthread_self());
854 guarantee(thread_id != 0, "just checking");
855 osthread->set_thread_id(thread_id);
856
857 uint64_t unique_thread_id = locate_unique_thread_id(thread_id);
858 guarantee(unique_thread_id != 0, "just checking");
859 osthread->set_unique_thread_id(unique_thread_id);
848 #else 860 #else
849 osthread->set_thread_id(::pthread_self()); 861 osthread->set_thread_id(::pthread_self());
850 #endif 862 #endif
851 osthread->set_pthread_id(::pthread_self()); 863 osthread->set_pthread_id(::pthread_self());
852 864
1113 return n; 1125 return n;
1114 } 1126 }
1115 1127
1116 intx os::current_thread_id() { 1128 intx os::current_thread_id() {
1117 #ifdef __APPLE__ 1129 #ifdef __APPLE__
1118 return (intx)::mach_thread_self(); 1130 return (intx)::pthread_mach_thread_np(::pthread_self());
1119 #else 1131 #else
1120 return (intx)::pthread_self(); 1132 return (intx)::pthread_self();
1121 #endif 1133 #endif
1122 } 1134 }
1123 int os::current_process_id() { 1135 int os::current_process_id() {
2311 2323
2312 void os::large_page_init() { 2324 void os::large_page_init() {
2313 } 2325 }
2314 2326
2315 2327
2316 char* os::reserve_memory_special(size_t bytes, char* req_addr, bool exec) { 2328 char* os::reserve_memory_special(size_t bytes, size_t alignment, char* req_addr, bool exec) {
2329 fatal("This code is not used or maintained.");
2330
2317 // "exec" is passed in but not used. Creating the shared image for 2331 // "exec" is passed in but not used. Creating the shared image for
2318 // the code cache doesn't have an SHM_X executable permission to check. 2332 // the code cache doesn't have an SHM_X executable permission to check.
2319 assert(UseLargePages && UseSHM, "only for SHM large pages"); 2333 assert(UseLargePages && UseSHM, "only for SHM large pages");
2320 2334
2321 key_t key = IPC_PRIVATE; 2335 key_t key = IPC_PRIVATE;
3273 3287
3274 // We don't activate signal checker if libjsig is in place, we trust ourselves 3288 // We don't activate signal checker if libjsig is in place, we trust ourselves
3275 // and if UserSignalHandler is installed all bets are off 3289 // and if UserSignalHandler is installed all bets are off
3276 if (CheckJNICalls) { 3290 if (CheckJNICalls) {
3277 if (libjsig_is_loaded) { 3291 if (libjsig_is_loaded) {
3278 tty->print_cr("Info: libjsig is activated, all active signal checking is disabled"); 3292 if (PrintJNIResolving) {
3293 tty->print_cr("Info: libjsig is activated, all active signal checking is disabled");
3294 }
3279 check_signals = false; 3295 check_signals = false;
3280 } 3296 }
3281 if (AllowUserSignalHandlers) { 3297 if (AllowUserSignalHandlers) {
3282 tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled"); 3298 if (PrintJNIResolving) {
3299 tty->print_cr("Info: AllowUserSignalHandlers is activated, all active signal checking is disabled");
3300 }
3283 check_signals = false; 3301 check_signals = false;
3284 } 3302 }
3285 } 3303 }
3286 } 3304 }
3287 } 3305 }
3568 #ifndef PRODUCT 3586 #ifndef PRODUCT
3569 if(Verbose && PrintMiscellaneous) 3587 if(Verbose && PrintMiscellaneous)
3570 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); 3588 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page);
3571 #endif 3589 #endif
3572 } 3590 }
3573
3574 os::large_page_init();
3575 3591
3576 // initialize suspend/resume support - must do this before signal_sets_init() 3592 // initialize suspend/resume support - must do this before signal_sets_init()
3577 if (SR_initialize() != 0) { 3593 if (SR_initialize() != 0) {
3578 perror("SR_initialize failed"); 3594 perror("SR_initialize failed");
3579 return JNI_ERR; 3595 return JNI_ERR;
4734 n = MIN2(n, (int)bufferSize); 4750 n = MIN2(n, (int)bufferSize);
4735 4751
4736 return n; 4752 return n;
4737 } 4753 }
4738 4754
4755 #ifndef PRODUCT
4756 void TestReserveMemorySpecial_test() {
4757 // No tests available for this platform
4758 }
4759 #endif