< prev index next > src/hotspot/share/runtime/lockStack.inline.hpp
Print this page
#define SHARE_RUNTIME_LOCKSTACK_INLINE_HPP
#include "runtime/lockStack.hpp"
#include "memory/iterator.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "runtime/globals.hpp"
#include "runtime/javaThread.hpp"
+ #include "runtime/lightweightSynchronizer.hpp"
+ #include "runtime/objectMonitor.inline.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/stackWatermark.hpp"
#include "runtime/stackWatermarkSet.inline.hpp"
+ #include "runtime/synchronizer.hpp"
#include "utilities/align.hpp"
#include "utilities/globalDefinitions.hpp"
inline int LockStack::to_index(uint32_t offset) {
assert(is_aligned(offset, oopSize), "Bad alignment: %u", offset);
inline bool LockStack::is_full() const {
return to_index(_top) == CAPACITY;
}
+ inline bool LockStack::can_push(int n) const {
+ return (CAPACITY - to_index(_top)) >= n;
+ }
+
inline bool LockStack::is_owning_thread() const {
Thread* current = Thread::current();
if (current->is_Java_thread()) {
JavaThread* thread = JavaThread::cast(current);
bool is_owning = &thread->lock_stack() == this;
inline oop LockStack::bottom() const {
assert(to_index(_top) > 0, "must contain an oop");
return _base[0];
}
+ inline oop LockStack::top() {
+ assert(to_index(_top) > 0, "may only call with at least one element in the stack");
+ return _base[to_index(_top) - 1];
+ }
+
inline bool LockStack::is_empty() const {
return to_index(_top) == 0;
}
inline bool LockStack::is_recursive(oop o) const {
cl->do_oop(&_base[i]);
}
verify("post-oops-do");
}
+ inline void OMCache::set_monitor(ObjectMonitor *monitor) {
+ const int end = OMCacheSize - 1;
+ if (end < 0) {
+ return;
+ }
+
+ oop obj = monitor->object_peek();
+ assert(obj != nullptr, "must be alive");
+ assert(monitor == LightweightSynchronizer::read_monitor(JavaThread::current(), obj), "must be exist in table");
+
+ OMCacheEntry to_insert = {obj, monitor};
+
+ for (int i = 0; i < end; ++i) {
+ if (_entries[i]._oop == obj ||
+ _entries[i]._monitor == nullptr ||
+ _entries[i]._monitor->is_being_async_deflated()) {
+ // Use stale slot.
+ _entries[i] = to_insert;
+ return;
+ }
+ // Swap with the most recent value.
+ ::swap(to_insert, _entries[i]);
+ }
+ _entries[end] = to_insert;
+ }
+
+ inline ObjectMonitor* OMCache::get_monitor(oop o) {
+ for (int i = 0; i < OMCacheSize; ++i) {
+ if (_entries[i]._oop == o) {
+ assert(_entries[i]._monitor != nullptr, "monitor must exist");
+ if (_entries[i]._monitor->is_being_async_deflated()) {
+ // Bad monitor
+ // Shift down rest
+ for (; i < OMCacheSize - 1; ++i) {
+ _entries[i] = _entries[i + 1];
+ }
+ // Clear end
+ _entries[i] = {};
+ return nullptr;
+ }
+ return _entries[i]._monitor;
+ }
+ }
+ return nullptr;
+ }
+
+ inline void OMCache::clear() {
+ for (size_t i = 0 , r = 0; i < CAPACITY; ++i) {
+ // Clear
+ _entries[i] = {};
+ }
+ }
+
#endif // SHARE_RUNTIME_LOCKSTACK_INLINE_HPP
< prev index next >