src/share/vm/runtime/objectMonitor.inline.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/objectMonitor.inline.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,110 @@
     1.4 +/*
     1.5 + * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +inline intptr_t ObjectMonitor::is_entered(TRAPS) const {
    1.29 +  if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) {
    1.30 +    return 1;
    1.31 +  }
    1.32 +  return 0;
    1.33 +}
    1.34 +
    1.35 +inline markOop ObjectMonitor::header() const {
    1.36 +  return _header;
    1.37 +}
    1.38 +
    1.39 +inline void ObjectMonitor::set_header(markOop hdr) {
    1.40 +  _header = hdr;
    1.41 +}
    1.42 +
    1.43 +inline intptr_t ObjectMonitor::count() const {
    1.44 +  return _count;
    1.45 +}
    1.46 +
    1.47 +inline void ObjectMonitor::set_count(intptr_t count) {
    1.48 +  _count= count;
    1.49 +}
    1.50 +
    1.51 +inline intptr_t ObjectMonitor::waiters() const {
    1.52 +  return _waiters;
    1.53 +}
    1.54 +
    1.55 +inline void* ObjectMonitor::owner() const {
    1.56 +  return _owner;
    1.57 +}
    1.58 +
    1.59 +inline void ObjectMonitor::clear() {
    1.60 +  assert(_header, "Fatal logic error in ObjectMonitor header!");
    1.61 +  assert(_count == 0, "Fatal logic error in ObjectMonitor count!");
    1.62 +  assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!");
    1.63 +  assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!");
    1.64 +  assert(_object, "Fatal logic error in ObjectMonitor object!");
    1.65 +  assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!");
    1.66 +
    1.67 +  _header = NULL;
    1.68 +  _object = NULL;
    1.69 +}
    1.70 +
    1.71 +
    1.72 +inline void* ObjectMonitor::object() const {
    1.73 +  return _object;
    1.74 +}
    1.75 +
    1.76 +inline void* ObjectMonitor::object_addr() {
    1.77 +  return (void *)(&_object);
    1.78 +}
    1.79 +
    1.80 +inline void ObjectMonitor::set_object(void* obj) {
    1.81 +  _object = obj;
    1.82 +}
    1.83 +
    1.84 +inline bool ObjectMonitor::check(TRAPS) {
    1.85 +  if (THREAD != _owner) {
    1.86 +    if (THREAD->is_lock_owned((address) _owner)) {
    1.87 +      _owner = THREAD;  // regain ownership of inflated monitor
    1.88 +      OwnerIsThread = 1 ;
    1.89 +      assert (_recursions == 0, "invariant") ;
    1.90 +    } else {
    1.91 +      check_slow(THREAD);
    1.92 +      return false;
    1.93 +    }
    1.94 +  }
    1.95 +  return true;
    1.96 +}
    1.97 +
    1.98 +
    1.99 +// return number of threads contending for this monitor
   1.100 +inline intptr_t ObjectMonitor::contentions() const {
   1.101 +  return _count;
   1.102 +}
   1.103 +
   1.104 +inline void ObjectMonitor::set_owner(void* owner) {
   1.105 +  _owner = owner;
   1.106 +  _recursions = 0;
   1.107 +  _count = 0;
   1.108 +}
   1.109 +
   1.110 +
   1.111 +// here are the platform-dependent bodies:
   1.112 +
   1.113 +# include "incls/_objectMonitor_pd.inline.hpp.incl"

mercurial