1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/symbolTable.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "compiler/compilerOracle.hpp"
30 #include "gc_implementation/shared/isGCActiveMark.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/symbol.hpp"
33 #include "runtime/arguments.hpp"
34 #include "runtime/deoptimization.hpp"
35 #include "runtime/interfaceSupport.hpp"
36 #include "runtime/sweeper.hpp"
37 #include "runtime/thread.inline.hpp"
38 #include "runtime/vm_operations.hpp"
39 #include "services/threadService.hpp"
40
41 #define VM_OP_NAME_INITIALIZE(name) #name,
42
43 const char* VM_Operation::_names[VM_Operation::VMOp_Terminating] = \
44 { VM_OPS_DO(VM_OP_NAME_INITIALIZE) };
45
46 void VM_Operation::set_calling_thread(Thread* thread, ThreadPriority priority) {
47 _calling_thread = thread;
48 assert(MinPriority <= priority && priority <= MaxPriority, "sanity check");
49 _priority = priority;
50 }
51
52
53 void VM_Operation::evaluate() {
54 ResourceMark rm;
55 if (TraceVMOperation) {
56 tty->print("[");
57 NOT_PRODUCT(print();)
58 }
59 doit();
60 if (TraceVMOperation) {
61 tty->print_cr("]");
62 }
63 }
64
65 // Called by fatal error handler.
66 void VM_Operation::print_on_error(outputStream* st) const {
67 st->print("VM_Operation (" PTR_FORMAT "): ", this);
68 st->print("%s", name());
69
70 const char* mode;
71 switch(evaluation_mode()) {
72 case _safepoint : mode = "safepoint"; break;
73 case _no_safepoint : mode = "no safepoint"; break;
74 case _concurrent : mode = "concurrent"; break;
75 case _async_safepoint: mode = "async safepoint"; break;
76 default : mode = "unknown"; break;
77 }
78 st->print(", mode: %s", mode);
79
80 if (calling_thread()) {
81 st->print(", requested by thread " PTR_FORMAT, calling_thread());
82 }
83 }
84
85 void VM_ThreadStop::doit() {
86 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
87 JavaThread* target = java_lang_Thread::thread(target_thread());
88 // Note that this now allows multiple ThreadDeath exceptions to be
89 // thrown at a thread.
90 if (target != NULL) {
91 // the thread has run and is not already in the process of exiting
92 target->send_thread_stop(throwable());
93 }
94 }
95
96 void VM_Deoptimize::doit() {
97 // We do not want any GCs to happen while we are in the middle of this VM operation
|
1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/symbolTable.hpp"
27 #include "classfile/vmSymbols.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "compiler/compilerOracle.hpp"
30 #include "gc_implementation/shared/isGCActiveMark.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/symbol.hpp"
33 #include "runtime/arguments.hpp"
34 #include "runtime/deoptimization.hpp"
35 #include "runtime/interfaceSupport.hpp"
36 #include "runtime/sweeper.hpp"
37 #include "runtime/thread.inline.hpp"
38 #include "runtime/vm_operations.hpp"
39 #include "services/threadService.hpp"
40 #include "trace/tracing.hpp"
41
42 #define VM_OP_NAME_INITIALIZE(name) #name,
43
44 const char* VM_Operation::_names[VM_Operation::VMOp_Terminating] = \
45 { VM_OPS_DO(VM_OP_NAME_INITIALIZE) };
46
47 void VM_Operation::set_calling_thread(Thread* thread, ThreadPriority priority) {
48 _calling_thread = thread;
49 assert(MinPriority <= priority && priority <= MaxPriority, "sanity check");
50 _priority = priority;
51 }
52
53
54 void VM_Operation::evaluate() {
55 ResourceMark rm;
56 if (TraceVMOperation) {
57 tty->print("[");
58 NOT_PRODUCT(print();)
59 }
60 doit();
61 if (TraceVMOperation) {
62 tty->print_cr("]");
63 }
64 }
65
66 const char* VM_Operation::mode_to_string(Mode mode) {
67 switch(mode) {
68 case _safepoint : return "safepoint";
69 case _no_safepoint : return "no safepoint";
70 case _concurrent : return "concurrent";
71 case _async_safepoint: return "async safepoint";
72 default : return "unknown";
73 }
74 }
75 // Called by fatal error handler.
76 void VM_Operation::print_on_error(outputStream* st) const {
77 st->print("VM_Operation (" PTR_FORMAT "): ", this);
78 st->print("%s", name());
79
80 const char* mode = mode_to_string(evaluation_mode());
81 st->print(", mode: %s", mode);
82
83 if (calling_thread()) {
84 st->print(", requested by thread " PTR_FORMAT, calling_thread());
85 }
86 }
87
88 void VM_ThreadStop::doit() {
89 assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
90 JavaThread* target = java_lang_Thread::thread(target_thread());
91 // Note that this now allows multiple ThreadDeath exceptions to be
92 // thrown at a thread.
93 if (target != NULL) {
94 // the thread has run and is not already in the process of exiting
95 target->send_thread_stop(throwable());
96 }
97 }
98
99 void VM_Deoptimize::doit() {
100 // We do not want any GCs to happen while we are in the middle of this VM operation
|