< prev index next > src/hotspot/share/runtime/objectMonitor.inline.hpp
Print this page
/*
- * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
#include "runtime/objectMonitor.hpp"
#include "logging/log.hpp"
#include "oops/access.inline.hpp"
#include "runtime/atomic.hpp"
+ #include "runtime/lockStack.inline.hpp"
#include "runtime/synchronizer.hpp"
- inline intptr_t ObjectMonitor::is_entered(JavaThread* current) const {
- void* owner = owner_raw();
- if (current == owner || current->is_lock_owned((address)owner)) {
- return 1;
+ inline bool ObjectMonitor::is_entered(JavaThread* current) const {
+ if (LockingMode == LM_LIGHTWEIGHT) {
+ if (is_owner_anonymous()) {
+ return current->lock_stack().contains(object());
+ } else {
+ return current == owner_raw();
+ }
+ } else {
+ void* owner = owner_raw();
+ if (current == owner || current->is_lock_owned((address)owner)) {
+ return true;
+ }
}
- return 0;
+ return false;
}
inline markWord ObjectMonitor::header() const {
return Atomic::load(&_header);
}
inline jint ObjectMonitor::waiters() const {
return _waiters;
}
+ inline bool ObjectMonitor::has_owner() const {
+ void* owner = owner_raw();
+ return owner != NULL && owner != DEFLATER_MARKER;
+ }
+
// Returns NULL if DEFLATER_MARKER is observed.
inline void* ObjectMonitor::owner() const {
void* owner = owner_raw();
return owner != DEFLATER_MARKER ? owner : NULL;
}
// Add value to the contentions field.
inline void ObjectMonitor::add_to_contentions(jint value) {
Atomic::add(&_contentions, value);
}
+ inline void ObjectMonitor::set_recursions(size_t recursions) {
+ assert(_recursions == 0, "must be");
+ assert(has_owner(), "must be owned");
+ _recursions = checked_cast<intx>(recursions);
+ }
+
// Clear _owner field; current value must match old_value.
inline void ObjectMonitor::release_clear_owner(void* old_value) {
#ifdef ASSERT
void* prev = Atomic::load(&_owner);
assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT
< prev index next >