Fri, 12 Feb 2010 15:27:36 -0800
Merge
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | inline intptr_t ObjectMonitor::is_entered(TRAPS) const { |
duke@435 | 26 | if (THREAD == _owner || THREAD->is_lock_owned((address) _owner)) { |
duke@435 | 27 | return 1; |
duke@435 | 28 | } |
duke@435 | 29 | return 0; |
duke@435 | 30 | } |
duke@435 | 31 | |
duke@435 | 32 | inline markOop ObjectMonitor::header() const { |
duke@435 | 33 | return _header; |
duke@435 | 34 | } |
duke@435 | 35 | |
duke@435 | 36 | inline void ObjectMonitor::set_header(markOop hdr) { |
duke@435 | 37 | _header = hdr; |
duke@435 | 38 | } |
duke@435 | 39 | |
duke@435 | 40 | inline intptr_t ObjectMonitor::count() const { |
duke@435 | 41 | return _count; |
duke@435 | 42 | } |
duke@435 | 43 | |
duke@435 | 44 | inline void ObjectMonitor::set_count(intptr_t count) { |
duke@435 | 45 | _count= count; |
duke@435 | 46 | } |
duke@435 | 47 | |
duke@435 | 48 | inline intptr_t ObjectMonitor::waiters() const { |
duke@435 | 49 | return _waiters; |
duke@435 | 50 | } |
duke@435 | 51 | |
duke@435 | 52 | inline void* ObjectMonitor::owner() const { |
duke@435 | 53 | return _owner; |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | inline void ObjectMonitor::clear() { |
duke@435 | 57 | assert(_header, "Fatal logic error in ObjectMonitor header!"); |
duke@435 | 58 | assert(_count == 0, "Fatal logic error in ObjectMonitor count!"); |
duke@435 | 59 | assert(_waiters == 0, "Fatal logic error in ObjectMonitor waiters!"); |
duke@435 | 60 | assert(_recursions == 0, "Fatal logic error in ObjectMonitor recursions!"); |
duke@435 | 61 | assert(_object, "Fatal logic error in ObjectMonitor object!"); |
duke@435 | 62 | assert(_owner == 0, "Fatal logic error in ObjectMonitor owner!"); |
duke@435 | 63 | |
duke@435 | 64 | _header = NULL; |
duke@435 | 65 | _object = NULL; |
duke@435 | 66 | } |
duke@435 | 67 | |
duke@435 | 68 | |
duke@435 | 69 | inline void* ObjectMonitor::object() const { |
duke@435 | 70 | return _object; |
duke@435 | 71 | } |
duke@435 | 72 | |
duke@435 | 73 | inline void* ObjectMonitor::object_addr() { |
duke@435 | 74 | return (void *)(&_object); |
duke@435 | 75 | } |
duke@435 | 76 | |
duke@435 | 77 | inline void ObjectMonitor::set_object(void* obj) { |
duke@435 | 78 | _object = obj; |
duke@435 | 79 | } |
duke@435 | 80 | |
duke@435 | 81 | inline bool ObjectMonitor::check(TRAPS) { |
duke@435 | 82 | if (THREAD != _owner) { |
duke@435 | 83 | if (THREAD->is_lock_owned((address) _owner)) { |
duke@435 | 84 | _owner = THREAD; // regain ownership of inflated monitor |
duke@435 | 85 | OwnerIsThread = 1 ; |
duke@435 | 86 | assert (_recursions == 0, "invariant") ; |
duke@435 | 87 | } else { |
duke@435 | 88 | check_slow(THREAD); |
duke@435 | 89 | return false; |
duke@435 | 90 | } |
duke@435 | 91 | } |
duke@435 | 92 | return true; |
duke@435 | 93 | } |
duke@435 | 94 | |
duke@435 | 95 | |
duke@435 | 96 | // return number of threads contending for this monitor |
duke@435 | 97 | inline intptr_t ObjectMonitor::contentions() const { |
duke@435 | 98 | return _count; |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | inline void ObjectMonitor::set_owner(void* owner) { |
duke@435 | 102 | _owner = owner; |
duke@435 | 103 | _recursions = 0; |
duke@435 | 104 | _count = 0; |
duke@435 | 105 | } |
duke@435 | 106 | |
duke@435 | 107 | |
duke@435 | 108 | // here are the platform-dependent bodies: |
duke@435 | 109 | |
duke@435 | 110 | # include "incls/_objectMonitor_pd.inline.hpp.incl" |