0N/A/*
4278N/A * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP
1879N/A#define SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP
1879N/A
0N/Ainline intptr_t ObjectMonitor::is_entered(TRAPS) const {
0N/A if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
0N/A return 1;
0N/A }
0N/A return 0;
0N/A}
0N/A
0N/Ainline markOop ObjectMonitor::header() const {
0N/A return _header;
0N/A}
0N/A
0N/Ainline void ObjectMonitor::set_header(markOop hdr) {
0N/A _header = hdr;
0N/A}
0N/A
0N/Ainline intptr_t ObjectMonitor::count() const {
0N/A return _count;
0N/A}
0N/A
0N/Ainline void ObjectMonitor::set_count(intptr_t count) {
0N/A _count= count;
0N/A}
0N/A
0N/Ainline intptr_t ObjectMonitor::waiters() const {
0N/A return _waiters;
0N/A}
0N/A
0N/Ainline void* ObjectMonitor::owner() const {
0N/A return _owner;
0N/A}
0N/A
0N/Ainline void ObjectMonitor::clear() {
0N/A assert(_header, "Fatal logic error in ObjectMonitor header!");
0N/A assert(_count == 0, "Fatal logic error in ObjectMonitor count!");
0N/A assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!");
0N/A assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!");
0N/A assert(_object, "Fatal logic error in ObjectMonitor object!");
0N/A assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!");
0N/A
0N/A _header = NULL;
0N/A _object = NULL;
0N/A}
0N/A
0N/A
0N/Ainline void* ObjectMonitor::object() const {
0N/A return _object;
0N/A}
0N/A
0N/Ainline void* ObjectMonitor::object_addr() {
0N/A return (void *)(&_object);
0N/A}
0N/A
0N/Ainline void ObjectMonitor::set_object(void* obj) {
0N/A _object = obj;
0N/A}
0N/A
0N/Ainline bool ObjectMonitor::check(TRAPS) {
0N/A if (THREAD != _owner) {
0N/A if (THREAD->is_lock_owned((address) _owner)) {
0N/A _owner = THREAD; // regain ownership of inflated monitor
0N/A OwnerIsThread = 1 ;
0N/A assert (_recursions == 0, "invariant") ;
0N/A } else {
0N/A check_slow(THREAD);
0N/A return false;
0N/A }
0N/A }
0N/A return true;
0N/A}
0N/A
0N/A
0N/A// return number of threads contending for this monitor
0N/Ainline intptr_t ObjectMonitor::contentions() const {
0N/A return _count;
0N/A}
0N/A
4278N/A// Do NOT set _count = 0. There is a race such that _count could
4278N/A// be set while inflating prior to setting _owner
4278N/A// Just use Atomic::inc/dec and assert 0 when monitor put on free list
0N/Ainline void ObjectMonitor::set_owner(void* owner) {
0N/A _owner = owner;
0N/A _recursions = 0;
0N/A}
0N/A
1879N/A
1879N/A#endif // SHARE_VM_RUNTIME_OBJECTMONITOR_INLINE_HPP