src/share/vm/services/dtraceAttacher.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 6198
55fb97c4c58d
parent 0
f90c822e73f8
permissions
-rw-r--r--

merge

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

mercurial