Wed, 27 Aug 2014 09:36:55 +0200
Merge
duke@435 | 1 | /* |
mikael@6198 | 2 | * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "code/codeCache.hpp" |
stefank@2314 | 27 | #include "memory/resourceArea.hpp" |
stefank@2314 | 28 | #include "runtime/deoptimization.hpp" |
stefank@2314 | 29 | #include "runtime/vmThread.hpp" |
stefank@2314 | 30 | #include "runtime/vm_operations.hpp" |
stefank@2314 | 31 | #include "services/dtraceAttacher.hpp" |
duke@435 | 32 | |
duke@435 | 33 | #ifdef SOLARIS |
duke@435 | 34 | |
duke@435 | 35 | class VM_DeoptimizeTheWorld : public VM_Operation { |
duke@435 | 36 | public: |
duke@435 | 37 | VMOp_Type type() const { |
duke@435 | 38 | return VMOp_DeoptimizeTheWorld; |
duke@435 | 39 | } |
duke@435 | 40 | void doit() { |
duke@435 | 41 | CodeCache::mark_all_nmethods_for_deoptimization(); |
duke@435 | 42 | ResourceMark rm; |
duke@435 | 43 | DeoptimizationMarker dm; |
duke@435 | 44 | // Deoptimize all activations depending on marked methods |
duke@435 | 45 | Deoptimization::deoptimize_dependents(); |
duke@435 | 46 | |
duke@435 | 47 | // Mark the dependent methods non entrant |
duke@435 | 48 | CodeCache::make_marked_nmethods_not_entrant(); |
duke@435 | 49 | } |
duke@435 | 50 | }; |
duke@435 | 51 | |
duke@435 | 52 | static void set_bool_flag(const char* flag, bool value) { |
duke@435 | 53 | CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value, |
twisti@5790 | 54 | Flag::ATTACH_ON_DEMAND); |
duke@435 | 55 | } |
duke@435 | 56 | |
duke@435 | 57 | // Enable only the "fine grained" flags. Do *not* touch |
duke@435 | 58 | // the overall "ExtendedDTraceProbes" flag. |
duke@435 | 59 | void DTrace::enable_dprobes(int probes) { |
duke@435 | 60 | bool changed = false; |
duke@435 | 61 | if (!DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) { |
duke@435 | 62 | set_bool_flag("DTraceAllocProbes", true); |
duke@435 | 63 | changed = true; |
duke@435 | 64 | } |
duke@435 | 65 | if (!DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) { |
duke@435 | 66 | set_bool_flag("DTraceMethodProbes", true); |
duke@435 | 67 | changed = true; |
duke@435 | 68 | } |
duke@435 | 69 | if (!DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) { |
duke@435 | 70 | set_bool_flag("DTraceMonitorProbes", true); |
duke@435 | 71 | changed = true; |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | if (changed) { |
duke@435 | 75 | // one or more flags changed, need to deoptimize |
duke@435 | 76 | VM_DeoptimizeTheWorld op; |
duke@435 | 77 | VMThread::execute(&op); |
duke@435 | 78 | } |
duke@435 | 79 | } |
duke@435 | 80 | |
duke@435 | 81 | // Disable only the "fine grained" flags. Do *not* touch |
duke@435 | 82 | // the overall "ExtendedDTraceProbes" flag. |
duke@435 | 83 | void DTrace::disable_dprobes(int probes) { |
duke@435 | 84 | bool changed = false; |
duke@435 | 85 | if (DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) { |
duke@435 | 86 | set_bool_flag("DTraceAllocProbes", false); |
duke@435 | 87 | changed = true; |
duke@435 | 88 | } |
duke@435 | 89 | if (DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) { |
duke@435 | 90 | set_bool_flag("DTraceMethodProbes", false); |
duke@435 | 91 | changed = true; |
duke@435 | 92 | } |
duke@435 | 93 | if (DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) { |
duke@435 | 94 | set_bool_flag("DTraceMonitorProbes", false); |
duke@435 | 95 | changed = true; |
duke@435 | 96 | } |
duke@435 | 97 | if (changed) { |
duke@435 | 98 | // one or more flags changed, need to deoptimize |
duke@435 | 99 | VM_DeoptimizeTheWorld op; |
duke@435 | 100 | VMThread::execute(&op); |
duke@435 | 101 | } |
duke@435 | 102 | } |
duke@435 | 103 | |
duke@435 | 104 | // Do clean-up on "all door clients detached" event. |
duke@435 | 105 | void DTrace::detach_all_clients() { |
duke@435 | 106 | /* |
duke@435 | 107 | * We restore the state of the fine grained flags |
duke@435 | 108 | * to be consistent with overall ExtendedDTraceProbes. |
duke@435 | 109 | * This way, we will honour command line setting or the |
duke@435 | 110 | * last explicit modification of ExtendedDTraceProbes by |
duke@435 | 111 | * a call to set_extended_dprobes. |
duke@435 | 112 | */ |
duke@435 | 113 | if (ExtendedDTraceProbes) { |
duke@435 | 114 | enable_dprobes(DTRACE_ALL_PROBES); |
duke@435 | 115 | } else { |
duke@435 | 116 | disable_dprobes(DTRACE_ALL_PROBES); |
duke@435 | 117 | } |
duke@435 | 118 | } |
duke@435 | 119 | |
duke@435 | 120 | void DTrace::set_extended_dprobes(bool flag) { |
duke@435 | 121 | // explicit setting of ExtendedDTraceProbes flag |
duke@435 | 122 | set_bool_flag("ExtendedDTraceProbes", flag); |
duke@435 | 123 | |
duke@435 | 124 | // make sure that the fine grained flags reflect the change. |
duke@435 | 125 | if (flag) { |
duke@435 | 126 | enable_dprobes(DTRACE_ALL_PROBES); |
duke@435 | 127 | } else { |
duke@435 | 128 | /* |
duke@435 | 129 | * FIXME: Revisit this: currently all-client-detach detection |
duke@435 | 130 | * does not work and hence disabled. The following scheme does |
duke@435 | 131 | * not work. So, we have to disable fine-grained flags here. |
duke@435 | 132 | * |
duke@435 | 133 | * disable_dprobes call has to be delayed till next "detach all "event. |
duke@435 | 134 | * This is to be done so that concurrent DTrace clients that may |
duke@435 | 135 | * have enabled one or more fine grained dprobes and may be running |
duke@435 | 136 | * still. On "detach all" clients event, we would sync ExtendedDTraceProbes |
duke@435 | 137 | * with fine grained flags which would take care of disabling fine grained flags. |
duke@435 | 138 | */ |
duke@435 | 139 | disable_dprobes(DTRACE_ALL_PROBES); |
duke@435 | 140 | } |
duke@435 | 141 | } |
duke@435 | 142 | |
fparain@1759 | 143 | void DTrace::set_monitor_dprobes(bool flag) { |
fparain@1759 | 144 | // explicit setting of DTraceMonitorProbes flag |
fparain@1759 | 145 | set_bool_flag("DTraceMonitorProbes", flag); |
fparain@1759 | 146 | } |
fparain@1759 | 147 | |
duke@435 | 148 | #endif /* SOLARIS */ |