/* * Copyright (c) 1998, 2021, 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. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Returns true if owner field == DEFLATER_MARKER and false otherwise. // This accessor is called when we really need to know if the owner // field == DEFLATER_MARKER and any non-NULL value won't do the trick. inlinebool ObjectMonitor::owner_is_DEFLATER_MARKER() const { return owner_raw() == DEFLATER_MARKER;
}
// Returns true if 'this' is being async deflated and false otherwise. inlinebool ObjectMonitor::is_being_async_deflated() { return contentions() < 0;
}
// Return number of threads contending for this monitor. inlineint ObjectMonitor::contentions() const { return Atomic::load(&_contentions);
}
// Add value to the contentions field. inlinevoid ObjectMonitor::add_to_contentions(int value) {
Atomic::add(&_contentions, value);
}
// Simply set _owner field to new_value; current value must match old_value. // (Simple means no memory sync needed.) inlinevoid ObjectMonitor::set_owner_from(void* old_value, void* new_value) { #ifdef ASSERT void* prev = Atomic::load(&_owner);
assert(prev == old_value, "unexpected prev owner=" INTPTR_FORMAT ", expected=" INTPTR_FORMAT, p2i(prev), p2i(old_value)); #endif
Atomic::store(&_owner, new_value);
log_trace(monitorinflation, owner)("set_owner_from(): mid="
INTPTR_FORMAT ", old_value=" INTPTR_FORMAT ", new_value=" INTPTR_FORMAT, p2i(this),
p2i(old_value), p2i(new_value));
}
// Simply set _owner field to self; current value must match basic_lock_p. inlinevoid ObjectMonitor::set_owner_from_BasicLock(void* basic_lock_p, JavaThread* current) { #ifdef ASSERT void* prev = Atomic::load(&_owner);
assert(prev == basic_lock_p, "unexpected prev owner=" INTPTR_FORMAT ", expected=" INTPTR_FORMAT, p2i(prev), p2i(basic_lock_p)); #endif // Non-null owner field to non-null owner field is safe without // cmpxchg() as long as all readers can tolerate either flavor.
Atomic::store(&_owner, current);
log_trace(monitorinflation, owner)("set_owner_from_BasicLock(): mid="
INTPTR_FORMAT ", basic_lock_p="
INTPTR_FORMAT ", new_value=" INTPTR_FORMAT,
p2i(this), p2i(basic_lock_p), p2i(current));
}
// Try to set _owner field to new_value if the current value matches // old_value. Otherwise, does not change the _owner field. Returns // the prior value of the _owner field. inlinevoid* ObjectMonitor::try_set_owner_from(void* old_value, void* new_value) { void* prev = Atomic::cmpxchg(&_owner, old_value, new_value); if (prev == old_value) {
log_trace(monitorinflation, owner)("try_set_owner_from(): mid="
INTPTR_FORMAT ", prev=" INTPTR_FORMAT ", new=" INTPTR_FORMAT, p2i(this),
p2i(prev), p2i(new_value));
} return prev;
}
// The _next_om field can be concurrently read and modified so we // use Atomic operations to disable compiler optimizations that // might try to elide loading and/or storing this field.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.