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