< prev index next > src/hotspot/share/runtime/threads.cpp
Print this page
vmSymbols::threadgroup_string_void_signature(),
thread_group,
string,
CHECK);
+ assert(thread->lock_id() == ThreadIdentifier::initial(), "invariant");
+
// Set thread status to running since main thread has
// been started and running.
java_lang_Thread::set_thread_status(thread_oop(),
JavaThreadStatus::RUNNABLE);
}
main_thread->record_stack_base_and_size();
main_thread->register_thread_stack_with_NMT();
main_thread->set_active_handles(JNIHandleBlock::allocate_block());
MACOS_AARCH64_ONLY(main_thread->init_wx());
+ // Set the lock_id now since we will run Java code before the Thread instance
+ // is even created. The same value will be assigned to the Thread instance on init.
+ main_thread->set_lock_id(ThreadIdentifier::next());
+ assert(main_thread->lock_id() == ThreadIdentifier::initial(), "invariant");
+
if (!main_thread->set_as_starting_thread()) {
vm_shutdown_during_initialization(
"Failed necessary internal allocation. Out of swap space");
main_thread->smr_delete();
*canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
}
*canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
return status;
}
+ ObjectMonitor::Initialize2();
+
JFR_ONLY(Jfr::on_create_vm_1();)
// Should be done after the heap is fully created
main_thread->cache_global_variables();
return result;
}
#endif // INCLUDE_JVMTI
! JavaThread *Threads::owning_thread_from_monitor_owner(ThreadsList * t_list,
! address owner) {
- assert(LockingMode != LM_LIGHTWEIGHT, "Not with new lightweight locking");
- // null owner means not locked so we can skip the search
- if (owner == nullptr) return nullptr;
-
- for (JavaThread* p : *t_list) {
- // first, see if owner is the address of a Java thread
- if (owner == (address)p) return p;
- }
-
- // Cannot assert on lack of success here since this function may be
- // used by code that is trying to report useful problem information
- // like deadlock detection.
- if (LockingMode == LM_MONITOR) return nullptr;
- // If we didn't find a matching Java thread and we didn't force use of
- // heavyweight monitors, then the owner is the stack address of the
- // Lock Word in the owning Java thread's stack.
- //
JavaThread* the_owner = nullptr;
for (JavaThread* q : *t_list) {
! if (q->is_lock_owned(owner)) {
the_owner = q;
break;
}
}
-
- // cannot assert on lack of success here; see above comment
return the_owner;
}
JavaThread* Threads::owning_thread_from_object(ThreadsList * t_list, oop obj) {
assert(LockingMode == LM_LIGHTWEIGHT, "Only with new lightweight locking");
return result;
}
#endif // INCLUDE_JVMTI
! JavaThread *Threads::owning_thread_from_stacklock(ThreadsList * t_list, address basicLock) {
! assert(LockingMode == LM_LEGACY, "Not with new lightweight locking");
JavaThread* the_owner = nullptr;
for (JavaThread* q : *t_list) {
! if (q->is_lock_owned(basicLock)) {
the_owner = q;
break;
}
}
return the_owner;
}
JavaThread* Threads::owning_thread_from_object(ThreadsList * t_list, oop obj) {
assert(LockingMode == LM_LIGHTWEIGHT, "Only with new lightweight locking");
}
return nullptr;
}
JavaThread* Threads::owning_thread_from_monitor(ThreadsList* t_list, ObjectMonitor* monitor) {
! if (LockingMode == LM_LIGHTWEIGHT) {
! if (monitor->is_owner_anonymous()) {
return owning_thread_from_object(t_list, monitor->object());
} else {
! Thread* owner = reinterpret_cast<Thread*>(monitor->owner());
! assert(owner == nullptr || owner->is_Java_thread(), "only JavaThreads own monitors");
- return reinterpret_cast<JavaThread*>(owner);
}
} else {
! address owner = (address)monitor->owner();
! return owning_thread_from_monitor_owner(t_list, owner);
}
}
class PrintOnClosure : public ThreadClosure {
private:
}
return nullptr;
}
JavaThread* Threads::owning_thread_from_monitor(ThreadsList* t_list, ObjectMonitor* monitor) {
! if (monitor->is_owner_anonymous()) {
! if (LockingMode == LM_LIGHTWEIGHT) {
return owning_thread_from_object(t_list, monitor->object());
} else {
! assert(LockingMode == LM_LEGACY, "invariant");
! return owning_thread_from_stacklock(t_list, (address)monitor->stack_locker());
}
} else {
! JavaThread* the_owner = nullptr;
! int64_t owner_tid = (int64_t)monitor->owner();
+ for (JavaThread* q : *t_list) {
+ if (monitor->is_owner(q)) {
+ the_owner = q;
+ break;
+ }
+ }
+ return the_owner;
}
}
class PrintOnClosure : public ThreadClosure {
private:
< prev index next >