1879N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1798N/A// ObjectWaiter serves as a "proxy" or surrogate thread. 1798N/A// TODO-FIXME: Eliminate ObjectWaiter and use the thread-specific 1798N/A// ParkEvent instead. Beware, however, that the JVMTI code 1798N/A// knows about ObjectWaiters, so we'll have to reconcile that code. 1798N/A// See next_waiter(), first_waiter(), etc. 0N/A// This is a very sensitive and fragile class. DO NOT make any 0N/A// change unless you are fully aware of the underlying semantics. 0N/A// This class can not inherit from any other class, because I have 0N/A// to let the displaced header be the very first word. Otherwise I 0N/A// have to let markOop include this file, which would export the 0N/A// monitor data structure to everywhere. 0N/A// The ObjectMonitor class is used to implement JavaMonitors which have 0N/A// transformed from the lightweight structure of the thread stack to a 0N/A// heavy weight lock due to contention 0N/A// It is also used as RawMonitor by the JVMTI 0N/A // TODO-FIXME: the "offset" routines should return a type of off_t instead of int ... 0N/A // ByteSize would also be an appropriate type. 0N/A // Eventaully we'll make provisions for multiple callbacks, but 0N/A // now one will suffice. 1798N/A // TODO-FIXME: merge _count and _waiters. 1798N/A // TODO-FIXME: assert _owner == null implies _recursions = 0 1798N/A // TODO-FIXME: assert _WaitSet != null implies _count > 0 1798N/A // initialize the monitor, exception the semaphore, all other fields 1798N/A // are simple integers or pointers 1798N/A // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0 1798N/A // _count == 0 _EntryList == NULL etc 1798N/A // TODO: add stronger asserts ... 1798N/A // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0 1798N/A // _count == 0 EntryList == NULL 1798N/A // _recursions == 0 _WaitSet == NULL 1798N/A // TODO: assert (is_busy()|_recursions) == 0 0N/A// Use the following at your own risk 0N/A // WARNING: this must be the very first word of ObjectMonitor 0N/A // This means this class can't use any virtual member functions. 0N/A // TODO-FIXME: assert that offsetof(_header) is 0 or get rid of the 0N/A // implicit 0 offset in emitted code. 0N/A void*
volatile _object;
// backward object pointer - strong root 0N/A // All the following fields must be machine word aligned 0N/A // The VM assumes write ordering wrt these fields, which can be 0N/A // read from other threads. 1798N/A protected:
// protected for jvmtiRawMonitor 0N/A void *
volatile _owner;
// pointer to owning thread OR BasicLock 0N/A // The list is actually composed of WaitNodes, acting 0N/A // as proxies for Threads. 0N/A Thread *
volatile _succ ;
// Heir presumptive thread - used for futile wakeup throttling 0N/A volatile int _Spinner ;
// for exit->spinner handoff optimization 0N/A volatile int _SpinFreq ;
// Spin 1-out-of-N attempts: success rate 0N/A // TODO-FIXME: _count, _waiters and _recursions should be of 0N/A // type int, or int32_t but not intptr_t. There's no reason 0N/A // to use 64-bit fields for these variables on a 64-bit JVM. 0N/A // at stop-the-world time. See deflate_idle_monitors(). 0N/A // _count is approximately |_WaitSet| + |_EntryList| 0N/A int _QMix ;
// Mixed prepend queue discipline 1879N/A#
endif // SHARE_VM_RUNTIME_OBJECTMONITOR_HPP