Mercurial > hg > graal-compiler
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java @ 2426:1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair
author | trims |
---|---|
date | Tue, 05 Apr 2011 14:12:31 -0700 |
parents | bf8517f4e4d0 |
children |
rev | line source |
---|---|
0 | 1 /* |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
1552
diff
changeset
|
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.runtime; | |
26 | |
27 import java.util.*; | |
28 import sun.jvm.hotspot.debugger.*; | |
29 import sun.jvm.hotspot.types.*; | |
30 | |
31 public class Thread extends VMObject { | |
32 private static long tlabFieldOffset; | |
33 | |
34 private static CIntegerField suspendFlagsField; | |
35 // Thread::SuspendFlags enum constants | |
36 private static int EXTERNAL_SUSPEND; | |
37 private static int EXT_SUSPENDED; | |
38 private static int HAS_ASYNC_EXCEPTION; | |
39 | |
40 private static AddressField activeHandlesField; | |
41 private static AddressField currentPendingMonitorField; | |
42 private static AddressField currentWaitingMonitorField; | |
43 | |
44 static { | |
45 VM.registerVMInitializedObserver(new Observer() { | |
46 public void update(Observable o, Object data) { | |
47 initialize(VM.getVM().getTypeDataBase()); | |
48 } | |
49 }); | |
50 } | |
51 | |
52 private static synchronized void initialize(TypeDataBase db) { | |
53 Type type = db.lookupType("Thread"); | |
54 | |
55 suspendFlagsField = type.getCIntegerField("_suspend_flags"); | |
56 EXTERNAL_SUSPEND = db.lookupIntConstant("Thread::_external_suspend").intValue(); | |
57 EXT_SUSPENDED = db.lookupIntConstant("Thread::_ext_suspended").intValue(); | |
58 HAS_ASYNC_EXCEPTION = db.lookupIntConstant("Thread::_has_async_exception").intValue(); | |
59 | |
60 tlabFieldOffset = type.getField("_tlab").getOffset(); | |
61 activeHandlesField = type.getAddressField("_active_handles"); | |
62 currentPendingMonitorField = type.getAddressField("_current_pending_monitor"); | |
63 currentWaitingMonitorField = type.getAddressField("_current_waiting_monitor"); | |
64 } | |
65 | |
66 public Thread(Address addr) { | |
67 super(addr); | |
68 } | |
69 | |
70 public int suspendFlags() { | |
71 return (int) suspendFlagsField.getValue(addr); | |
72 } | |
73 | |
74 public boolean isExternalSuspend() { | |
75 return (suspendFlags() & EXTERNAL_SUSPEND) != 0; | |
76 } | |
77 | |
78 public boolean isExtSuspended() { | |
79 return (suspendFlags() & EXT_SUSPENDED) != 0; | |
80 } | |
81 | |
82 public boolean isBeingExtSuspended() { | |
83 return isExtSuspended() || isExternalSuspend(); | |
84 } | |
85 | |
86 // historical usage: checked for VM or external suspension | |
87 public boolean isAnySuspended() { | |
88 return isExtSuspended(); | |
89 } | |
90 | |
91 public boolean hasAsyncException() { | |
92 return (suspendFlags() & HAS_ASYNC_EXCEPTION) != 0; | |
93 } | |
94 | |
95 public ThreadLocalAllocBuffer tlab() { | |
96 return new ThreadLocalAllocBuffer(addr.addOffsetTo(tlabFieldOffset)); | |
97 } | |
98 | |
99 public JNIHandleBlock activeHandles() { | |
100 Address a = activeHandlesField.getAddress(addr); | |
101 if (a == null) { | |
102 return null; | |
103 } | |
104 return new JNIHandleBlock(a); | |
105 } | |
106 | |
107 public boolean isVMThread() { return false; } | |
108 public boolean isJavaThread() { return false; } | |
109 public boolean isCompilerThread() { return false; } | |
110 public boolean isHiddenFromExternalView() { return false; } | |
111 public boolean isJvmtiAgentThread() { return false; } | |
112 public boolean isWatcherThread() { return false; } | |
113 public boolean isConcurrentMarkSweepThread() { return false; } | |
2195
bf8517f4e4d0
6766644: Redefinition of compiled method fails with assertion "Can not load classes with the Compiler thread"
kamg
parents:
1552
diff
changeset
|
114 public boolean isServiceThread() { return false; } |
0 | 115 |
116 /** Memory operations */ | |
117 public void oopsDo(AddressVisitor oopVisitor) { | |
118 // FIXME: Empty for now; will later traverse JNI handles and | |
119 // pending exception | |
120 } | |
121 | |
122 public ObjectMonitor getCurrentPendingMonitor() { | |
123 Address monitorAddr = currentPendingMonitorField.getValue(addr); | |
124 if (monitorAddr == null) { | |
125 return null; | |
126 } | |
127 return new ObjectMonitor(monitorAddr); | |
128 } | |
129 | |
130 public ObjectMonitor getCurrentWaitingMonitor() { | |
131 Address monitorAddr = currentWaitingMonitorField.getValue(addr); | |
132 if (monitorAddr == null) { | |
133 return null; | |
134 } | |
135 return new ObjectMonitor(monitorAddr); | |
136 } | |
137 | |
138 public boolean isLockOwned(Address lock) { | |
139 if (isInStack(lock)) return true; | |
140 return false; | |
141 } | |
142 | |
143 public boolean isInStack(Address a) { | |
144 // In the Serviceability Agent we need access to the thread's | |
145 // stack pointer to be able to answer this question. Since it is | |
146 // only a debugging system at the moment we need access to the | |
147 // underlying thread, which is only present for Java threads; see | |
148 // JavaThread.java. | |
149 return false; | |
150 } | |
151 | |
152 /** Assistance for ObjectMonitor implementation */ | |
153 Address threadObjectAddress() { return addr; } | |
154 } |