author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57906 | e17f768b3b71 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
54609
04857e2cd509
8222295: more baseline cleanups from Async Monitor Deflation project
dcubed
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.runtime; |
|
26 |
||
27 |
import java.util.*; |
|
28 |
||
29 |
import sun.jvm.hotspot.debugger.*; |
|
30 |
import sun.jvm.hotspot.oops.*; |
|
31 |
import sun.jvm.hotspot.types.*; |
|
32 |
||
33 |
public class ObjectMonitor extends VMObject { |
|
34 |
static { |
|
35 |
VM.registerVMInitializedObserver(new Observer() { |
|
36 |
public void update(Observable o, Object data) { |
|
37 |
initialize(VM.getVM().getTypeDataBase()); |
|
38 |
} |
|
39 |
}); |
|
40 |
} |
|
41 |
||
42 |
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { |
|
43 |
heap = VM.getVM().getObjectHeap(); |
|
44 |
Type type = db.lookupType("ObjectMonitor"); |
|
45 |
sun.jvm.hotspot.types.Field f = type.getField("_header"); |
|
46 |
headerFieldOffset = f.getOffset(); |
|
47 |
f = type.getField("_object"); |
|
48 |
objectFieldOffset = f.getOffset(); |
|
49 |
f = type.getField("_owner"); |
|
50 |
ownerFieldOffset = f.getOffset(); |
|
57906
e17f768b3b71
8230184: rename, whitespace, indent and comments changes in preparation for lock free Monitor lists
dcubed
parents:
57777
diff
changeset
|
51 |
f = type.getField("_next_om"); |
e17f768b3b71
8230184: rename, whitespace, indent and comments changes in preparation for lock free Monitor lists
dcubed
parents:
57777
diff
changeset
|
52 |
nextOMFieldOffset = f.getOffset(); |
54609
04857e2cd509
8222295: more baseline cleanups from Async Monitor Deflation project
dcubed
parents:
47216
diff
changeset
|
53 |
contentionsField = type.getJIntField("_contentions"); |
27165
785a8d56024c
8049737: Contended Locking reorder and cache line bucket
dcubed
parents:
5547
diff
changeset
|
54 |
waitersField = type.getJIntField("_waiters"); |
1 | 55 |
recursionsField = type.getCIntegerField("_recursions"); |
56 |
} |
|
57 |
||
58 |
public ObjectMonitor(Address addr) { |
|
59 |
super(addr); |
|
60 |
} |
|
61 |
||
62 |
public Mark header() { |
|
63 |
return new Mark(addr.addOffsetTo(headerFieldOffset)); |
|
64 |
} |
|
65 |
||
66 |
// FIXME |
|
57777
90ead0febf56
8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents:
54609
diff
changeset
|
67 |
// void set_header(markWord hdr); |
1 | 68 |
|
69 |
// FIXME: must implement and delegate to platform-dependent implementation |
|
70 |
// public boolean isBusy(); |
|
71 |
public boolean isEntered(sun.jvm.hotspot.runtime.Thread current) { |
|
72 |
Address o = owner(); |
|
73 |
if (current.threadObjectAddress().equals(o) || |
|
74 |
current.isLockOwned(o)) { |
|
75 |
return true; |
|
76 |
} |
|
77 |
return false; |
|
78 |
} |
|
79 |
||
80 |
public Address owner() { return addr.getAddressAt(ownerFieldOffset); } |
|
81 |
// FIXME |
|
82 |
// void set_owner(void* owner); |
|
83 |
||
27165
785a8d56024c
8049737: Contended Locking reorder and cache line bucket
dcubed
parents:
5547
diff
changeset
|
84 |
public int waiters() { return waitersField.getValue(addr); } |
1 | 85 |
|
57906
e17f768b3b71
8230184: rename, whitespace, indent and comments changes in preparation for lock free Monitor lists
dcubed
parents:
57777
diff
changeset
|
86 |
public Address nextOM() { return addr.getAddressAt(nextOMFieldOffset); } |
1 | 87 |
// FIXME |
88 |
// void set_queue(void* owner); |
|
89 |
||
90 |
public long recursions() { return recursionsField.getValue(addr); } |
|
91 |
||
92 |
public OopHandle object() { |
|
93 |
return addr.getOopHandleAt(objectFieldOffset); |
|
94 |
} |
|
95 |
||
27165
785a8d56024c
8049737: Contended Locking reorder and cache line bucket
dcubed
parents:
5547
diff
changeset
|
96 |
public int contentions() { |
54609
04857e2cd509
8222295: more baseline cleanups from Async Monitor Deflation project
dcubed
parents:
47216
diff
changeset
|
97 |
return contentionsField.getValue(addr); |
1 | 98 |
} |
99 |
||
100 |
// FIXME |
|
101 |
// void* object_addr(); |
|
102 |
// void set_object(void* obj); |
|
103 |
||
104 |
// The following four either aren't expressed as typed fields in |
|
105 |
// vmStructs.cpp because they aren't strongly typed in the VM, or |
|
106 |
// would confuse the SA's type system. |
|
107 |
private static ObjectHeap heap; |
|
108 |
private static long headerFieldOffset; |
|
109 |
private static long objectFieldOffset; |
|
110 |
private static long ownerFieldOffset; |
|
57906
e17f768b3b71
8230184: rename, whitespace, indent and comments changes in preparation for lock free Monitor lists
dcubed
parents:
57777
diff
changeset
|
111 |
private static long nextOMFieldOffset; |
54609
04857e2cd509
8222295: more baseline cleanups from Async Monitor Deflation project
dcubed
parents:
47216
diff
changeset
|
112 |
private static JIntField contentionsField; |
27165
785a8d56024c
8049737: Contended Locking reorder and cache line bucket
dcubed
parents:
5547
diff
changeset
|
113 |
private static JIntField waitersField; |
1 | 114 |
private static CIntegerField recursionsField; |
115 |
// FIXME: expose platform-dependent stuff |
|
116 |
} |