Mercurial > hg > graal-jvmci-8
annotate src/share/vm/runtime/vm_operations.hpp @ 1936:8d88c9ac9247
Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Thu, 23 Dec 2010 18:13:28 +0100 |
parents | ce6848d0666d |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1202
diff
changeset
|
2 * Copyright (c) 1997, 2009, 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:
1202
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1202
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:
1202
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // The following classes are used for operations | |
26 // initiated by a Java thread but that must | |
27 // take place in the VMThread. | |
28 | |
29 #define VM_OP_ENUM(type) VMOp_##type, | |
30 | |
31 // Note: When new VM_XXX comes up, add 'XXX' to the template table. | |
32 #define VM_OPS_DO(template) \ | |
33 template(Dummy) \ | |
34 template(ThreadStop) \ | |
35 template(ThreadDump) \ | |
36 template(PrintThreads) \ | |
37 template(FindDeadlocks) \ | |
38 template(ForceSafepoint) \ | |
39 template(ForceAsyncSafepoint) \ | |
40 template(Deoptimize) \ | |
41 template(DeoptimizeFrame) \ | |
42 template(DeoptimizeAll) \ | |
43 template(ZombieAll) \ | |
1202 | 44 template(HandleFullCodeCache) \ |
0 | 45 template(Verify) \ |
46 template(PrintJNI) \ | |
47 template(HeapDumper) \ | |
48 template(DeoptimizeTheWorld) \ | |
49 template(GC_HeapInspection) \ | |
50 template(GenCollectFull) \ | |
51 template(GenCollectFullConcurrent) \ | |
52 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
|
53 template(GenCollectForPermanentAllocation) \ |
0 | 54 template(ParallelGCFailedAllocation) \ |
55 template(ParallelGCFailedPermanentAllocation) \ | |
56 template(ParallelGCSystemGC) \ | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
139
diff
changeset
|
57 template(CGC_Operation) \ |
0 | 58 template(CMS_Initial_Mark) \ |
59 template(CMS_Final_Remark) \ | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
139
diff
changeset
|
60 template(G1CollectFull) \ |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
139
diff
changeset
|
61 template(G1CollectForAllocation) \ |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
139
diff
changeset
|
62 template(G1IncCollectionPause) \ |
0 | 63 template(EnableBiasedLocking) \ |
64 template(RevokeBias) \ | |
65 template(BulkRevokeBias) \ | |
66 template(PopulateDumpSharedSpace) \ | |
67 template(JNIFunctionTableCopier) \ | |
68 template(RedefineClasses) \ | |
69 template(GetOwnedMonitorInfo) \ | |
70 template(GetObjectMonitorUsage) \ | |
71 template(GetCurrentContendedMonitor) \ | |
72 template(GetStackTrace) \ | |
73 template(GetMultipleStackTraces) \ | |
74 template(GetAllStackTraces) \ | |
75 template(GetThreadListStackTraces) \ | |
76 template(GetFrameCount) \ | |
77 template(GetFrameLocation) \ | |
78 template(ChangeBreakpoints) \ | |
79 template(GetOrSetLocal) \ | |
80 template(GetCurrentLocation) \ | |
81 template(EnterInterpOnlyMode) \ | |
82 template(ChangeSingleStep) \ | |
83 template(HeapWalkOperation) \ | |
84 template(HeapIterateOperation) \ | |
85 template(ReportJavaOutOfMemory) \ | |
86 template(Exit) \ | |
87 | |
88 class VM_Operation: public CHeapObj { | |
89 public: | |
90 enum Mode { | |
91 _safepoint, // blocking, safepoint, vm_op C-heap allocated | |
92 _no_safepoint, // blocking, no safepoint, vm_op C-Heap allocated | |
93 _concurrent, // non-blocking, no safepoint, vm_op C-Heap allocated | |
94 _async_safepoint // non-blocking, safepoint, vm_op C-Heap allocated | |
95 }; | |
96 | |
97 enum VMOp_Type { | |
98 VM_OPS_DO(VM_OP_ENUM) | |
99 VMOp_Terminating | |
100 }; | |
101 | |
102 private: | |
103 Thread* _calling_thread; | |
104 ThreadPriority _priority; | |
105 long _timestamp; | |
106 VM_Operation* _next; | |
107 VM_Operation* _prev; | |
108 | |
109 // The VM operation name array | |
110 static const char* _names[]; | |
111 | |
112 public: | |
113 VM_Operation() { _calling_thread = NULL; _next = NULL; _prev = NULL; } | |
114 virtual ~VM_Operation() {} | |
115 | |
116 // VM operation support (used by VM thread) | |
117 Thread* calling_thread() const { return _calling_thread; } | |
118 ThreadPriority priority() { return _priority; } | |
119 void set_calling_thread(Thread* thread, ThreadPriority priority); | |
120 | |
121 long timestamp() const { return _timestamp; } | |
122 void set_timestamp(long timestamp) { _timestamp = timestamp; } | |
123 | |
124 // Called by VM thread - does in turn invoke doit(). Do not override this | |
125 void evaluate(); | |
126 | |
127 // evaluate() is called by the VMThread and in turn calls doit(). | |
128 // If the thread invoking VMThread::execute((VM_Operation*) is a JavaThread, | |
129 // doit_prologue() is called in that thread before transferring control to | |
130 // the VMThread. | |
131 // If doit_prologue() returns true the VM operation will proceed, and | |
132 // doit_epilogue() will be called by the JavaThread once the VM operation | |
133 // completes. If doit_prologue() returns false the VM operation is cancelled. | |
134 virtual void doit() = 0; | |
135 virtual bool doit_prologue() { return true; }; | |
136 virtual void doit_epilogue() {}; // Note: Not called if mode is: _concurrent | |
137 | |
138 // Type test | |
139 virtual bool is_methodCompiler() const { return false; } | |
140 | |
141 // Linking | |
142 VM_Operation *next() const { return _next; } | |
143 VM_Operation *prev() const { return _prev; } | |
144 void set_next(VM_Operation *next) { _next = next; } | |
145 void set_prev(VM_Operation *prev) { _prev = prev; } | |
146 | |
147 // Configuration. Override these appropriatly in subclasses. | |
148 virtual VMOp_Type type() const = 0; | |
149 virtual Mode evaluation_mode() const { return _safepoint; } | |
150 virtual bool allow_nested_vm_operations() const { return false; } | |
151 virtual bool is_cheap_allocated() const { return false; } | |
152 virtual void oops_do(OopClosure* f) { /* do nothing */ }; | |
153 | |
154 // CAUTION: <don't hang yourself with following rope> | |
155 // If you override these methods, make sure that the evaluation | |
156 // of these methods is race-free and non-blocking, since these | |
157 // methods may be evaluated either by the mutators or by the | |
158 // vm thread, either concurrently with mutators or with the mutators | |
159 // stopped. In other words, taking locks is verboten, and if there | |
160 // are any races in evaluating the conditions, they'd better be benign. | |
161 virtual bool evaluate_at_safepoint() const { | |
162 return evaluation_mode() == _safepoint || | |
163 evaluation_mode() == _async_safepoint; | |
164 } | |
165 virtual bool evaluate_concurrently() const { | |
166 return evaluation_mode() == _concurrent || | |
167 evaluation_mode() == _async_safepoint; | |
168 } | |
169 | |
170 // Debugging | |
171 void print_on_error(outputStream* st) const; | |
172 const char* name() const { return _names[type()]; } | |
173 static const char* name(int type) { | |
174 assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); | |
175 return _names[type]; | |
176 } | |
177 #ifndef PRODUCT | |
178 void print_on(outputStream* st) const { print_on_error(st); } | |
179 #endif | |
180 }; | |
181 | |
182 class VM_ThreadStop: public VM_Operation { | |
183 private: | |
184 oop _thread; // The Thread that the Throwable is thrown against | |
185 oop _throwable; // The Throwable thrown at the target Thread | |
186 public: | |
187 // All oops are passed as JNI handles, since there is no guarantee that a GC might happen before the | |
188 // VM operation is executed. | |
189 VM_ThreadStop(oop thread, oop throwable) { | |
190 _thread = thread; | |
191 _throwable = throwable; | |
192 } | |
193 VMOp_Type type() const { return VMOp_ThreadStop; } | |
194 oop target_thread() const { return _thread; } | |
195 oop throwable() const { return _throwable;} | |
196 void doit(); | |
197 // We deoptimize if top-most frame is compiled - this might require a C2I adapter to be generated | |
198 bool allow_nested_vm_operations() const { return true; } | |
199 Mode evaluation_mode() const { return _async_safepoint; } | |
200 bool is_cheap_allocated() const { return true; } | |
201 | |
202 // GC support | |
203 void oops_do(OopClosure* f) { | |
204 f->do_oop(&_thread); f->do_oop(&_throwable); | |
205 } | |
206 }; | |
207 | |
208 // dummy vm op, evaluated just to force a safepoint | |
209 class VM_ForceSafepoint: public VM_Operation { | |
210 public: | |
211 VM_ForceSafepoint() {} | |
212 void doit() {} | |
213 VMOp_Type type() const { return VMOp_ForceSafepoint; } | |
214 }; | |
215 | |
216 // dummy vm op, evaluated just to force a safepoint | |
217 class VM_ForceAsyncSafepoint: public VM_Operation { | |
218 public: | |
219 VM_ForceAsyncSafepoint() {} | |
220 void doit() {} | |
221 VMOp_Type type() const { return VMOp_ForceAsyncSafepoint; } | |
222 Mode evaluation_mode() const { return _async_safepoint; } | |
223 bool is_cheap_allocated() const { return true; } | |
224 }; | |
225 | |
226 class VM_Deoptimize: public VM_Operation { | |
227 public: | |
228 VM_Deoptimize() {} | |
229 VMOp_Type type() const { return VMOp_Deoptimize; } | |
230 void doit(); | |
231 bool allow_nested_vm_operations() const { return true; } | |
232 }; | |
233 | |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
234 |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
235 // Deopt helper that can deoptimize frames in threads other than the |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
236 // current thread. Only used through Deoptimization::deoptimize_frame. |
0 | 237 class VM_DeoptimizeFrame: public VM_Operation { |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
238 friend class Deoptimization; |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
239 |
0 | 240 private: |
241 JavaThread* _thread; | |
242 intptr_t* _id; | |
1905
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
243 VM_DeoptimizeFrame(JavaThread* thread, intptr_t* id); |
ce6848d0666d
6968367: can_post_on_exceptions is still using VM_DeoptimizeFrame in some places
never
parents:
1552
diff
changeset
|
244 |
0 | 245 public: |
246 VMOp_Type type() const { return VMOp_DeoptimizeFrame; } | |
247 void doit(); | |
248 bool allow_nested_vm_operations() const { return true; } | |
249 }; | |
250 | |
1202 | 251 class VM_HandleFullCodeCache: public VM_Operation { |
252 private: | |
253 bool _is_full; | |
254 public: | |
255 VM_HandleFullCodeCache(bool is_full) { _is_full = is_full; } | |
256 VMOp_Type type() const { return VMOp_HandleFullCodeCache; } | |
257 void doit(); | |
258 bool allow_nested_vm_operations() const { return true; } | |
259 }; | |
260 | |
0 | 261 #ifndef PRODUCT |
262 class VM_DeoptimizeAll: public VM_Operation { | |
263 private: | |
264 KlassHandle _dependee; | |
265 public: | |
266 VM_DeoptimizeAll() {} | |
267 VMOp_Type type() const { return VMOp_DeoptimizeAll; } | |
268 void doit(); | |
269 bool allow_nested_vm_operations() const { return true; } | |
270 }; | |
271 | |
272 | |
273 class VM_ZombieAll: public VM_Operation { | |
274 public: | |
275 VM_ZombieAll() {} | |
276 VMOp_Type type() const { return VMOp_ZombieAll; } | |
277 void doit(); | |
278 bool allow_nested_vm_operations() const { return true; } | |
279 }; | |
280 #endif // PRODUCT | |
281 | |
282 class VM_Verify: public VM_Operation { | |
283 private: | |
284 KlassHandle _dependee; | |
285 public: | |
286 VM_Verify() {} | |
287 VMOp_Type type() const { return VMOp_Verify; } | |
288 void doit(); | |
289 }; | |
290 | |
291 | |
292 class VM_PrintThreads: public VM_Operation { | |
293 private: | |
294 outputStream* _out; | |
295 bool _print_concurrent_locks; | |
296 public: | |
297 VM_PrintThreads() { _out = tty; _print_concurrent_locks = PrintConcurrentLocks; } | |
298 VM_PrintThreads(outputStream* out, bool print_concurrent_locks) { _out = out; _print_concurrent_locks = print_concurrent_locks; } | |
299 VMOp_Type type() const { return VMOp_PrintThreads; } | |
300 void doit(); | |
301 bool doit_prologue(); | |
302 void doit_epilogue(); | |
303 }; | |
304 | |
305 class VM_PrintJNI: public VM_Operation { | |
306 private: | |
307 outputStream* _out; | |
308 public: | |
309 VM_PrintJNI() { _out = tty; } | |
310 VM_PrintJNI(outputStream* out) { _out = out; } | |
311 VMOp_Type type() const { return VMOp_PrintJNI; } | |
312 void doit(); | |
313 }; | |
314 | |
315 class DeadlockCycle; | |
316 class VM_FindDeadlocks: public VM_Operation { | |
317 private: | |
318 bool _concurrent_locks; | |
319 DeadlockCycle* _deadlocks; | |
320 outputStream* _out; | |
321 | |
322 public: | |
323 VM_FindDeadlocks(bool concurrent_locks) : _concurrent_locks(concurrent_locks), _out(NULL), _deadlocks(NULL) {}; | |
324 VM_FindDeadlocks(outputStream* st) : _concurrent_locks(true), _out(st), _deadlocks(NULL) {}; | |
325 ~VM_FindDeadlocks(); | |
326 | |
327 DeadlockCycle* result() { return _deadlocks; }; | |
328 VMOp_Type type() const { return VMOp_FindDeadlocks; } | |
329 void doit(); | |
330 bool doit_prologue(); | |
331 }; | |
332 | |
333 class ThreadDumpResult; | |
334 class ThreadSnapshot; | |
335 class ThreadConcurrentLocks; | |
336 | |
337 class VM_ThreadDump : public VM_Operation { | |
338 private: | |
339 ThreadDumpResult* _result; | |
340 int _num_threads; | |
341 GrowableArray<instanceHandle>* _threads; | |
342 int _max_depth; | |
343 bool _with_locked_monitors; | |
344 bool _with_locked_synchronizers; | |
345 | |
346 ThreadSnapshot* snapshot_thread(JavaThread* java_thread, ThreadConcurrentLocks* tcl); | |
347 | |
348 public: | |
349 VM_ThreadDump(ThreadDumpResult* result, | |
350 int max_depth, // -1 indicates entire stack | |
351 bool with_locked_monitors, | |
352 bool with_locked_synchronizers); | |
353 | |
354 VM_ThreadDump(ThreadDumpResult* result, | |
355 GrowableArray<instanceHandle>* threads, | |
356 int num_threads, // -1 indicates entire stack | |
357 int max_depth, | |
358 bool with_locked_monitors, | |
359 bool with_locked_synchronizers); | |
360 | |
361 VMOp_Type type() const { return VMOp_ThreadDump; } | |
362 void doit(); | |
363 bool doit_prologue(); | |
364 void doit_epilogue(); | |
365 }; | |
366 | |
367 | |
368 class VM_Exit: public VM_Operation { | |
369 private: | |
370 int _exit_code; | |
371 static volatile bool _vm_exited; | |
372 static Thread * _shutdown_thread; | |
373 static void wait_if_vm_exited(); | |
374 public: | |
375 VM_Exit(int exit_code) { | |
376 _exit_code = exit_code; | |
377 } | |
378 static int wait_for_threads_in_native_to_block(); | |
379 static int set_vm_exited(); | |
380 static bool vm_exited() { return _vm_exited; } | |
381 static void block_if_vm_exited() { | |
382 if (_vm_exited) { | |
383 wait_if_vm_exited(); | |
384 } | |
385 } | |
386 VMOp_Type type() const { return VMOp_Exit; } | |
387 void doit(); | |
388 }; |