src/share/vm/services/dtraceAttacher.cpp

Thu, 12 Mar 2009 18:16:36 -0700

author
trims
date
Thu, 12 Mar 2009 18:16:36 -0700
changeset 1063
7bb995fbd3c0
parent 435
a61af66fc99e
child 1759
e392695de029
permissions
-rw-r--r--

Merge

duke@435 1 /*
duke@435 2 * Copyright 2006-2007 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 # include "incls/_precompiled.incl"
duke@435 26 # include "incls/_dtraceAttacher.cpp.incl"
duke@435 27
duke@435 28 #ifdef SOLARIS
duke@435 29
duke@435 30 class VM_DeoptimizeTheWorld : public VM_Operation {
duke@435 31 public:
duke@435 32 VMOp_Type type() const {
duke@435 33 return VMOp_DeoptimizeTheWorld;
duke@435 34 }
duke@435 35 void doit() {
duke@435 36 CodeCache::mark_all_nmethods_for_deoptimization();
duke@435 37 ResourceMark rm;
duke@435 38 DeoptimizationMarker dm;
duke@435 39 // Deoptimize all activations depending on marked methods
duke@435 40 Deoptimization::deoptimize_dependents();
duke@435 41
duke@435 42 // Mark the dependent methods non entrant
duke@435 43 CodeCache::make_marked_nmethods_not_entrant();
duke@435 44 }
duke@435 45 };
duke@435 46
duke@435 47 static void set_bool_flag(const char* flag, bool value) {
duke@435 48 CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value,
duke@435 49 ATTACH_ON_DEMAND);
duke@435 50 }
duke@435 51
duke@435 52 // Enable only the "fine grained" flags. Do *not* touch
duke@435 53 // the overall "ExtendedDTraceProbes" flag.
duke@435 54 void DTrace::enable_dprobes(int probes) {
duke@435 55 bool changed = false;
duke@435 56 if (!DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {
duke@435 57 set_bool_flag("DTraceAllocProbes", true);
duke@435 58 changed = true;
duke@435 59 }
duke@435 60 if (!DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {
duke@435 61 set_bool_flag("DTraceMethodProbes", true);
duke@435 62 changed = true;
duke@435 63 }
duke@435 64 if (!DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {
duke@435 65 set_bool_flag("DTraceMonitorProbes", true);
duke@435 66 changed = true;
duke@435 67 }
duke@435 68
duke@435 69 if (changed) {
duke@435 70 // one or more flags changed, need to deoptimize
duke@435 71 VM_DeoptimizeTheWorld op;
duke@435 72 VMThread::execute(&op);
duke@435 73 }
duke@435 74 }
duke@435 75
duke@435 76 // Disable only the "fine grained" flags. Do *not* touch
duke@435 77 // the overall "ExtendedDTraceProbes" flag.
duke@435 78 void DTrace::disable_dprobes(int probes) {
duke@435 79 bool changed = false;
duke@435 80 if (DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {
duke@435 81 set_bool_flag("DTraceAllocProbes", false);
duke@435 82 changed = true;
duke@435 83 }
duke@435 84 if (DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {
duke@435 85 set_bool_flag("DTraceMethodProbes", false);
duke@435 86 changed = true;
duke@435 87 }
duke@435 88 if (DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {
duke@435 89 set_bool_flag("DTraceMonitorProbes", false);
duke@435 90 changed = true;
duke@435 91 }
duke@435 92 if (changed) {
duke@435 93 // one or more flags changed, need to deoptimize
duke@435 94 VM_DeoptimizeTheWorld op;
duke@435 95 VMThread::execute(&op);
duke@435 96 }
duke@435 97 }
duke@435 98
duke@435 99 // Do clean-up on "all door clients detached" event.
duke@435 100 void DTrace::detach_all_clients() {
duke@435 101 /*
duke@435 102 * We restore the state of the fine grained flags
duke@435 103 * to be consistent with overall ExtendedDTraceProbes.
duke@435 104 * This way, we will honour command line setting or the
duke@435 105 * last explicit modification of ExtendedDTraceProbes by
duke@435 106 * a call to set_extended_dprobes.
duke@435 107 */
duke@435 108 if (ExtendedDTraceProbes) {
duke@435 109 enable_dprobes(DTRACE_ALL_PROBES);
duke@435 110 } else {
duke@435 111 disable_dprobes(DTRACE_ALL_PROBES);
duke@435 112 }
duke@435 113 }
duke@435 114
duke@435 115 void DTrace::set_extended_dprobes(bool flag) {
duke@435 116 // explicit setting of ExtendedDTraceProbes flag
duke@435 117 set_bool_flag("ExtendedDTraceProbes", flag);
duke@435 118
duke@435 119 // make sure that the fine grained flags reflect the change.
duke@435 120 if (flag) {
duke@435 121 enable_dprobes(DTRACE_ALL_PROBES);
duke@435 122 } else {
duke@435 123 /*
duke@435 124 * FIXME: Revisit this: currently all-client-detach detection
duke@435 125 * does not work and hence disabled. The following scheme does
duke@435 126 * not work. So, we have to disable fine-grained flags here.
duke@435 127 *
duke@435 128 * disable_dprobes call has to be delayed till next "detach all "event.
duke@435 129 * This is to be done so that concurrent DTrace clients that may
duke@435 130 * have enabled one or more fine grained dprobes and may be running
duke@435 131 * still. On "detach all" clients event, we would sync ExtendedDTraceProbes
duke@435 132 * with fine grained flags which would take care of disabling fine grained flags.
duke@435 133 */
duke@435 134 disable_dprobes(DTRACE_ALL_PROBES);
duke@435 135 }
duke@435 136 }
duke@435 137
duke@435 138 #endif /* SOLARIS */

mercurial