954 955 st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]", 956 p2i(stack_end()), p2i(stack_base())); 957 958 if (osthread()) { 959 st->print(" [id=%d]", osthread()->thread_id()); 960 } 961 962 ThreadsSMRSupport::print_info_on(this, st); 963 } 964 965 void Thread::print_value_on(outputStream* st) const { 966 if (is_Named_thread()) { 967 st->print(" \"%s\" ", name()); 968 } 969 st->print(INTPTR_FORMAT, p2i(this)); // print address 970 } 971 972 #ifdef ASSERT 973 void Thread::print_owned_locks_on(outputStream* st) const { 974 Monitor *cur = _owned_locks; 975 if (cur == NULL) { 976 st->print(" (no locks) "); 977 } else { 978 st->print_cr(" Locks owned:"); 979 while (cur) { 980 cur->print_on(st); 981 cur = cur->next(); 982 } 983 } 984 } 985 986 // Checks safepoint allowed and clears unhandled oops at potential safepoints. 987 void Thread::check_possible_safepoint() { 988 if (!is_Java_thread()) return; 989 990 if (_no_safepoint_count > 0) { 991 fatal("Possible safepoint reached by thread that does not allow it"); 992 } 993 #ifdef CHECK_UNHANDLED_OOPS 994 // Clear unhandled oops in JavaThreads so we get a crash right away. 995 clear_unhandled_oops(); 996 #endif // CHECK_UNHANDLED_OOPS 997 } 998 999 // The flag: potential_vm_operation notifies if this particular safepoint state could potentially 1000 // invoke the vm-thread (e.g., an oop allocation). In that case, we also have to make sure that 1001 // no locks which allow_vm_block's are held 1002 void Thread::check_for_valid_safepoint_state(bool potential_vm_operation) { 1003 if (!is_Java_thread()) return; 1004 1005 check_possible_safepoint(); 1006 1007 if (((JavaThread*)this)->thread_state() != _thread_in_vm) { 1008 fatal("LEAF method calling lock?"); 1009 } 1010 1011 if (potential_vm_operation && !Universe::is_bootstrapping()) { 1012 // Make sure we do not hold any locks that the VM thread also uses. 1013 // This could potentially lead to deadlocks 1014 for (Monitor *cur = _owned_locks; cur; cur = cur->next()) { 1015 // Threads_lock is special, since the safepoint synchronization will not start before this is 1016 // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock, 1017 // since it is used to transfer control between JavaThreads and the VMThread 1018 // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first! 1019 if ((cur->allow_vm_block() && 1020 cur != Threads_lock && 1021 cur != Compile_lock && // Temporary: should not be necessary when we get separate compilation 1022 cur != VMOperationRequest_lock && 1023 cur != VMOperationQueue_lock) || 1024 cur->rank() == Mutex::special) { 1025 fatal("Thread holding lock at safepoint that vm can block on: %s", cur->name()); 1026 } 1027 } 1028 } 1029 1030 if (GCALotAtAllSafepoints) { 1031 // We could enter a safepoint here and thus have a gc 1032 InterfaceSupport::check_gc_alot(); 1033 } 1034 } | 954 955 st->print(" [stack: " PTR_FORMAT "," PTR_FORMAT "]", 956 p2i(stack_end()), p2i(stack_base())); 957 958 if (osthread()) { 959 st->print(" [id=%d]", osthread()->thread_id()); 960 } 961 962 ThreadsSMRSupport::print_info_on(this, st); 963 } 964 965 void Thread::print_value_on(outputStream* st) const { 966 if (is_Named_thread()) { 967 st->print(" \"%s\" ", name()); 968 } 969 st->print(INTPTR_FORMAT, p2i(this)); // print address 970 } 971 972 #ifdef ASSERT 973 void Thread::print_owned_locks_on(outputStream* st) const { 974 Mutex* cur = _owned_locks; 975 if (cur == NULL) { 976 st->print(" (no locks) "); 977 } else { 978 st->print_cr(" Locks owned:"); 979 while (cur) { 980 cur->print_on(st); 981 cur = cur->next(); 982 } 983 } 984 } 985 986 // Checks safepoint allowed and clears unhandled oops at potential safepoints. 987 void Thread::check_possible_safepoint() { 988 if (!is_Java_thread()) return; 989 990 if (_no_safepoint_count > 0) { 991 fatal("Possible safepoint reached by thread that does not allow it"); 992 } 993 #ifdef CHECK_UNHANDLED_OOPS 994 // Clear unhandled oops in JavaThreads so we get a crash right away. 995 clear_unhandled_oops(); 996 #endif // CHECK_UNHANDLED_OOPS 997 } 998 999 // The flag: potential_vm_operation notifies if this particular safepoint state could potentially 1000 // invoke the vm-thread (e.g., an oop allocation). In that case, we also have to make sure that 1001 // no locks which allow_vm_block's are held 1002 void Thread::check_for_valid_safepoint_state(bool potential_vm_operation) { 1003 if (!is_Java_thread()) return; 1004 1005 check_possible_safepoint(); 1006 1007 if (((JavaThread*)this)->thread_state() != _thread_in_vm) { 1008 fatal("LEAF method calling lock?"); 1009 } 1010 1011 if (potential_vm_operation && !Universe::is_bootstrapping()) { 1012 // Make sure we do not hold any locks that the VM thread also uses. 1013 // This could potentially lead to deadlocks 1014 for (Mutex* cur = _owned_locks; cur; cur = cur->next()) { 1015 // Threads_lock is special, since the safepoint synchronization will not start before this is 1016 // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock, 1017 // since it is used to transfer control between JavaThreads and the VMThread 1018 // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first! 1019 if ((cur->allow_vm_block() && 1020 cur != Threads_lock && 1021 cur != Compile_lock && // Temporary: should not be necessary when we get separate compilation 1022 cur != VMOperationRequest_lock && 1023 cur != VMOperationQueue_lock) || 1024 cur->rank() == Mutex::special) { 1025 fatal("Thread holding lock at safepoint that vm can block on: %s", cur->name()); 1026 } 1027 } 1028 } 1029 1030 if (GCALotAtAllSafepoints) { 1031 // We could enter a safepoint here and thus have a gc 1032 InterfaceSupport::check_gc_alot(); 1033 } 1034 } |