annotate src/share/vm/runtime/vm_operations.hpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents c0492d52d55b
children 1ee8caae33af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 139
diff changeset
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // The following classes are used for operations
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // initiated by a Java thread but that must
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // take place in the VMThread.
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 #define VM_OP_ENUM(type) VMOp_##type,
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Note: When new VM_XXX comes up, add 'XXX' to the template table.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 #define VM_OPS_DO(template) \
a61af66fc99e Initial load
duke
parents:
diff changeset
33 template(Dummy) \
a61af66fc99e Initial load
duke
parents:
diff changeset
34 template(ThreadStop) \
a61af66fc99e Initial load
duke
parents:
diff changeset
35 template(ThreadDump) \
a61af66fc99e Initial load
duke
parents:
diff changeset
36 template(PrintThreads) \
a61af66fc99e Initial load
duke
parents:
diff changeset
37 template(FindDeadlocks) \
a61af66fc99e Initial load
duke
parents:
diff changeset
38 template(ForceSafepoint) \
a61af66fc99e Initial load
duke
parents:
diff changeset
39 template(ForceAsyncSafepoint) \
a61af66fc99e Initial load
duke
parents:
diff changeset
40 template(Deoptimize) \
a61af66fc99e Initial load
duke
parents:
diff changeset
41 template(DeoptimizeFrame) \
a61af66fc99e Initial load
duke
parents:
diff changeset
42 template(DeoptimizeAll) \
a61af66fc99e Initial load
duke
parents:
diff changeset
43 template(ZombieAll) \
a61af66fc99e Initial load
duke
parents:
diff changeset
44 template(Verify) \
a61af66fc99e Initial load
duke
parents:
diff changeset
45 template(PrintJNI) \
a61af66fc99e Initial load
duke
parents:
diff changeset
46 template(HeapDumper) \
a61af66fc99e Initial load
duke
parents:
diff changeset
47 template(DeoptimizeTheWorld) \
a61af66fc99e Initial load
duke
parents:
diff changeset
48 template(GC_HeapInspection) \
a61af66fc99e Initial load
duke
parents:
diff changeset
49 template(GenCollectFull) \
a61af66fc99e Initial load
duke
parents:
diff changeset
50 template(GenCollectFullConcurrent) \
a61af66fc99e Initial load
duke
parents:
diff changeset
51 template(GenCollectForAllocation) \
139
c0492d52d55b 6539517: CR 6186200 should be extended to perm gen allocation to prevent spurious OOM's from perm gen
apetrusenko
parents: 0
diff changeset
52 template(GenCollectForPermanentAllocation) \
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 template(ParallelGCFailedAllocation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
54 template(ParallelGCFailedPermanentAllocation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
55 template(ParallelGCSystemGC) \
a61af66fc99e Initial load
duke
parents:
diff changeset
56 template(CMS_Initial_Mark) \
a61af66fc99e Initial load
duke
parents:
diff changeset
57 template(CMS_Final_Remark) \
a61af66fc99e Initial load
duke
parents:
diff changeset
58 template(EnableBiasedLocking) \
a61af66fc99e Initial load
duke
parents:
diff changeset
59 template(RevokeBias) \
a61af66fc99e Initial load
duke
parents:
diff changeset
60 template(BulkRevokeBias) \
a61af66fc99e Initial load
duke
parents:
diff changeset
61 template(PopulateDumpSharedSpace) \
a61af66fc99e Initial load
duke
parents:
diff changeset
62 template(JNIFunctionTableCopier) \
a61af66fc99e Initial load
duke
parents:
diff changeset
63 template(RedefineClasses) \
a61af66fc99e Initial load
duke
parents:
diff changeset
64 template(GetOwnedMonitorInfo) \
a61af66fc99e Initial load
duke
parents:
diff changeset
65 template(GetObjectMonitorUsage) \
a61af66fc99e Initial load
duke
parents:
diff changeset
66 template(GetCurrentContendedMonitor) \
a61af66fc99e Initial load
duke
parents:
diff changeset
67 template(GetStackTrace) \
a61af66fc99e Initial load
duke
parents:
diff changeset
68 template(GetMultipleStackTraces) \
a61af66fc99e Initial load
duke
parents:
diff changeset
69 template(GetAllStackTraces) \
a61af66fc99e Initial load
duke
parents:
diff changeset
70 template(GetThreadListStackTraces) \
a61af66fc99e Initial load
duke
parents:
diff changeset
71 template(GetFrameCount) \
a61af66fc99e Initial load
duke
parents:
diff changeset
72 template(GetFrameLocation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
73 template(ChangeBreakpoints) \
a61af66fc99e Initial load
duke
parents:
diff changeset
74 template(GetOrSetLocal) \
a61af66fc99e Initial load
duke
parents:
diff changeset
75 template(GetCurrentLocation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
76 template(EnterInterpOnlyMode) \
a61af66fc99e Initial load
duke
parents:
diff changeset
77 template(ChangeSingleStep) \
a61af66fc99e Initial load
duke
parents:
diff changeset
78 template(HeapWalkOperation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
79 template(HeapIterateOperation) \
a61af66fc99e Initial load
duke
parents:
diff changeset
80 template(ReportJavaOutOfMemory) \
a61af66fc99e Initial load
duke
parents:
diff changeset
81 template(Exit) \
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 class VM_Operation: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 enum Mode {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 _safepoint, // blocking, safepoint, vm_op C-heap allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
87 _no_safepoint, // blocking, no safepoint, vm_op C-Heap allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
88 _concurrent, // non-blocking, no safepoint, vm_op C-Heap allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _async_safepoint // non-blocking, safepoint, vm_op C-Heap allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
90 };
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 enum VMOp_Type {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 VM_OPS_DO(VM_OP_ENUM)
a61af66fc99e Initial load
duke
parents:
diff changeset
94 VMOp_Terminating
a61af66fc99e Initial load
duke
parents:
diff changeset
95 };
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Thread* _calling_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 ThreadPriority _priority;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 long _timestamp;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 VM_Operation* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 VM_Operation* _prev;
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // The VM operation name array
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static const char* _names[];
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
108 VM_Operation() { _calling_thread = NULL; _next = NULL; _prev = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 virtual ~VM_Operation() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // VM operation support (used by VM thread)
a61af66fc99e Initial load
duke
parents:
diff changeset
112 Thread* calling_thread() const { return _calling_thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 ThreadPriority priority() { return _priority; }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void set_calling_thread(Thread* thread, ThreadPriority priority);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 long timestamp() const { return _timestamp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 void set_timestamp(long timestamp) { _timestamp = timestamp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Called by VM thread - does in turn invoke doit(). Do not override this
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void evaluate();
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // evaluate() is called by the VMThread and in turn calls doit().
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // If the thread invoking VMThread::execute((VM_Operation*) is a JavaThread,
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // doit_prologue() is called in that thread before transferring control to
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // the VMThread.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // If doit_prologue() returns true the VM operation will proceed, and
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // doit_epilogue() will be called by the JavaThread once the VM operation
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // completes. If doit_prologue() returns false the VM operation is cancelled.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 virtual void doit() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 virtual bool doit_prologue() { return true; };
a61af66fc99e Initial load
duke
parents:
diff changeset
131 virtual void doit_epilogue() {}; // Note: Not called if mode is: _concurrent
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Type test
a61af66fc99e Initial load
duke
parents:
diff changeset
134 virtual bool is_methodCompiler() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Linking
a61af66fc99e Initial load
duke
parents:
diff changeset
137 VM_Operation *next() const { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 VM_Operation *prev() const { return _prev; }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 void set_next(VM_Operation *next) { _next = next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void set_prev(VM_Operation *prev) { _prev = prev; }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Configuration. Override these appropriatly in subclasses.
a61af66fc99e Initial load
duke
parents:
diff changeset
143 virtual VMOp_Type type() const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 virtual Mode evaluation_mode() const { return _safepoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 virtual bool allow_nested_vm_operations() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 virtual bool is_cheap_allocated() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 virtual void oops_do(OopClosure* f) { /* do nothing */ };
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // CAUTION: <don't hang yourself with following rope>
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // If you override these methods, make sure that the evaluation
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // of these methods is race-free and non-blocking, since these
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // methods may be evaluated either by the mutators or by the
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // vm thread, either concurrently with mutators or with the mutators
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // stopped. In other words, taking locks is verboten, and if there
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // are any races in evaluating the conditions, they'd better be benign.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 virtual bool evaluate_at_safepoint() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return evaluation_mode() == _safepoint ||
a61af66fc99e Initial load
duke
parents:
diff changeset
158 evaluation_mode() == _async_safepoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 virtual bool evaluate_concurrently() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return evaluation_mode() == _concurrent ||
a61af66fc99e Initial load
duke
parents:
diff changeset
162 evaluation_mode() == _async_safepoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
166 void print_on_error(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 const char* name() const { return _names[type()]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 static const char* name(int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return _names[type];
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
173 void print_on(outputStream* st) const { print_on_error(st); }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
175 };
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 class VM_ThreadStop: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
179 oop _thread; // The Thread that the Throwable is thrown against
a61af66fc99e Initial load
duke
parents:
diff changeset
180 oop _throwable; // The Throwable thrown at the target Thread
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // All oops are passed as JNI handles, since there is no guarantee that a GC might happen before the
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // VM operation is executed.
a61af66fc99e Initial load
duke
parents:
diff changeset
184 VM_ThreadStop(oop thread, oop throwable) {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 _thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 _throwable = throwable;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 VMOp_Type type() const { return VMOp_ThreadStop; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 oop target_thread() const { return _thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 oop throwable() const { return _throwable;}
a61af66fc99e Initial load
duke
parents:
diff changeset
191 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // We deoptimize if top-most frame is compiled - this might require a C2I adapter to be generated
a61af66fc99e Initial load
duke
parents:
diff changeset
193 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 Mode evaluation_mode() const { return _async_safepoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 bool is_cheap_allocated() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // GC support
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void oops_do(OopClosure* f) {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 f->do_oop(&_thread); f->do_oop(&_throwable);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 };
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // dummy vm op, evaluated just to force a safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
204 class VM_ForceSafepoint: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
206 VM_ForceSafepoint() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
207 void doit() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
208 VMOp_Type type() const { return VMOp_ForceSafepoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
209 };
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // dummy vm op, evaluated just to force a safepoint
a61af66fc99e Initial load
duke
parents:
diff changeset
212 class VM_ForceAsyncSafepoint: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
214 VM_ForceAsyncSafepoint() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void doit() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
216 VMOp_Type type() const { return VMOp_ForceAsyncSafepoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 Mode evaluation_mode() const { return _async_safepoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 bool is_cheap_allocated() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 };
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 class VM_Deoptimize: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
223 VM_Deoptimize() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
224 VMOp_Type type() const { return VMOp_Deoptimize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
226 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
227 };
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 class VM_DeoptimizeFrame: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
231 JavaThread* _thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 intptr_t* _id;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
234 VM_DeoptimizeFrame(JavaThread* thread, intptr_t* id);
a61af66fc99e Initial load
duke
parents:
diff changeset
235 VMOp_Type type() const { return VMOp_DeoptimizeFrame; }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
237 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
238 };
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
241 class VM_DeoptimizeAll: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
243 KlassHandle _dependee;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
245 VM_DeoptimizeAll() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
246 VMOp_Type type() const { return VMOp_DeoptimizeAll; }
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
248 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
249 };
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 class VM_ZombieAll: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
254 VM_ZombieAll() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
255 VMOp_Type type() const { return VMOp_ZombieAll; }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
257 bool allow_nested_vm_operations() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 };
a61af66fc99e Initial load
duke
parents:
diff changeset
259 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 class VM_Verify: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
263 KlassHandle _dependee;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
265 VM_Verify() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
266 VMOp_Type type() const { return VMOp_Verify; }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
268 };
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 class VM_PrintThreads: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
273 outputStream* _out;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 bool _print_concurrent_locks;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
276 VM_PrintThreads() { _out = tty; _print_concurrent_locks = PrintConcurrentLocks; }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 VM_PrintThreads(outputStream* out, bool print_concurrent_locks) { _out = out; _print_concurrent_locks = print_concurrent_locks; }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 VMOp_Type type() const { return VMOp_PrintThreads; }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 bool doit_prologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
281 void doit_epilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
282 };
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 class VM_PrintJNI: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 outputStream* _out;
a61af66fc99e Initial load
duke
parents:
diff changeset
287 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
288 VM_PrintJNI() { _out = tty; }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 VM_PrintJNI(outputStream* out) { _out = out; }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 VMOp_Type type() const { return VMOp_PrintJNI; }
a61af66fc99e Initial load
duke
parents:
diff changeset
291 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
292 };
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 class DeadlockCycle;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 class VM_FindDeadlocks: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
297 bool _concurrent_locks;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 DeadlockCycle* _deadlocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 outputStream* _out;
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
302 VM_FindDeadlocks(bool concurrent_locks) : _concurrent_locks(concurrent_locks), _out(NULL), _deadlocks(NULL) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
303 VM_FindDeadlocks(outputStream* st) : _concurrent_locks(true), _out(st), _deadlocks(NULL) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
304 ~VM_FindDeadlocks();
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 DeadlockCycle* result() { return _deadlocks; };
a61af66fc99e Initial load
duke
parents:
diff changeset
307 VMOp_Type type() const { return VMOp_FindDeadlocks; }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 bool doit_prologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 };
a61af66fc99e Initial load
duke
parents:
diff changeset
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 class ThreadDumpResult;
a61af66fc99e Initial load
duke
parents:
diff changeset
313 class ThreadSnapshot;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 class ThreadConcurrentLocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 class VM_ThreadDump : public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
317 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
318 ThreadDumpResult* _result;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 int _num_threads;
a61af66fc99e Initial load
duke
parents:
diff changeset
320 GrowableArray<instanceHandle>* _threads;
a61af66fc99e Initial load
duke
parents:
diff changeset
321 int _max_depth;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 bool _with_locked_monitors;
a61af66fc99e Initial load
duke
parents:
diff changeset
323 bool _with_locked_synchronizers;
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 ThreadSnapshot* snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl);
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
328 VM_ThreadDump(ThreadDumpResult* result,
a61af66fc99e Initial load
duke
parents:
diff changeset
329 int max_depth, // -1 indicates entire stack
a61af66fc99e Initial load
duke
parents:
diff changeset
330 bool with_locked_monitors,
a61af66fc99e Initial load
duke
parents:
diff changeset
331 bool with_locked_synchronizers);
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 VM_ThreadDump(ThreadDumpResult* result,
a61af66fc99e Initial load
duke
parents:
diff changeset
334 GrowableArray<instanceHandle>* threads,
a61af66fc99e Initial load
duke
parents:
diff changeset
335 int num_threads, // -1 indicates entire stack
a61af66fc99e Initial load
duke
parents:
diff changeset
336 int max_depth,
a61af66fc99e Initial load
duke
parents:
diff changeset
337 bool with_locked_monitors,
a61af66fc99e Initial load
duke
parents:
diff changeset
338 bool with_locked_synchronizers);
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 VMOp_Type type() const { return VMOp_ThreadDump; }
a61af66fc99e Initial load
duke
parents:
diff changeset
341 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
342 bool doit_prologue();
a61af66fc99e Initial load
duke
parents:
diff changeset
343 void doit_epilogue();
a61af66fc99e Initial load
duke
parents:
diff changeset
344 };
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 class VM_Exit: public VM_Operation {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
349 int _exit_code;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 static volatile bool _vm_exited;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 static Thread * _shutdown_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 static void wait_if_vm_exited();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
354 VM_Exit(int exit_code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
355 _exit_code = exit_code;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
357 static int wait_for_threads_in_native_to_block();
a61af66fc99e Initial load
duke
parents:
diff changeset
358 static int set_vm_exited();
a61af66fc99e Initial load
duke
parents:
diff changeset
359 static bool vm_exited() { return _vm_exited; }
a61af66fc99e Initial load
duke
parents:
diff changeset
360 static void block_if_vm_exited() {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 if (_vm_exited) {
a61af66fc99e Initial load
duke
parents:
diff changeset
362 wait_if_vm_exited();
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 VMOp_Type type() const { return VMOp_Exit; }
a61af66fc99e Initial load
duke
parents:
diff changeset
366 void doit();
a61af66fc99e Initial load
duke
parents:
diff changeset
367 };