aoqi@0: /* aoqi@0: * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "code/codeCache.hpp" aoqi@0: #include "memory/resourceArea.hpp" aoqi@0: #include "runtime/deoptimization.hpp" aoqi@0: #include "runtime/vmThread.hpp" aoqi@0: #include "runtime/vm_operations.hpp" aoqi@0: #include "services/dtraceAttacher.hpp" aoqi@0: aoqi@0: #ifdef SOLARIS aoqi@0: aoqi@0: class VM_DeoptimizeTheWorld : public VM_Operation { aoqi@0: public: aoqi@0: VMOp_Type type() const { aoqi@0: return VMOp_DeoptimizeTheWorld; aoqi@0: } aoqi@0: void doit() { aoqi@0: CodeCache::mark_all_nmethods_for_deoptimization(); aoqi@0: ResourceMark rm; aoqi@0: DeoptimizationMarker dm; aoqi@0: // Deoptimize all activations depending on marked methods aoqi@0: Deoptimization::deoptimize_dependents(); aoqi@0: aoqi@0: // Mark the dependent methods non entrant aoqi@0: CodeCache::make_marked_nmethods_not_entrant(); aoqi@0: } aoqi@0: }; aoqi@0: aoqi@0: static void set_bool_flag(const char* flag, bool value) { aoqi@0: CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value, aoqi@0: Flag::ATTACH_ON_DEMAND); aoqi@0: } aoqi@0: aoqi@0: // Enable only the "fine grained" flags. Do *not* touch aoqi@0: // the overall "ExtendedDTraceProbes" flag. aoqi@0: void DTrace::enable_dprobes(int probes) { aoqi@0: bool changed = false; aoqi@0: if (!DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) { aoqi@0: set_bool_flag("DTraceAllocProbes", true); aoqi@0: changed = true; aoqi@0: } aoqi@0: if (!DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) { aoqi@0: set_bool_flag("DTraceMethodProbes", true); aoqi@0: changed = true; aoqi@0: } aoqi@0: if (!DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) { aoqi@0: set_bool_flag("DTraceMonitorProbes", true); aoqi@0: changed = true; aoqi@0: } aoqi@0: aoqi@0: if (changed) { aoqi@0: // one or more flags changed, need to deoptimize aoqi@0: VM_DeoptimizeTheWorld op; aoqi@0: VMThread::execute(&op); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Disable only the "fine grained" flags. Do *not* touch aoqi@0: // the overall "ExtendedDTraceProbes" flag. aoqi@0: void DTrace::disable_dprobes(int probes) { aoqi@0: bool changed = false; aoqi@0: if (DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) { aoqi@0: set_bool_flag("DTraceAllocProbes", false); aoqi@0: changed = true; aoqi@0: } aoqi@0: if (DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) { aoqi@0: set_bool_flag("DTraceMethodProbes", false); aoqi@0: changed = true; aoqi@0: } aoqi@0: if (DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) { aoqi@0: set_bool_flag("DTraceMonitorProbes", false); aoqi@0: changed = true; aoqi@0: } aoqi@0: if (changed) { aoqi@0: // one or more flags changed, need to deoptimize aoqi@0: VM_DeoptimizeTheWorld op; aoqi@0: VMThread::execute(&op); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Do clean-up on "all door clients detached" event. aoqi@0: void DTrace::detach_all_clients() { aoqi@0: /* aoqi@0: * We restore the state of the fine grained flags aoqi@0: * to be consistent with overall ExtendedDTraceProbes. aoqi@0: * This way, we will honour command line setting or the aoqi@0: * last explicit modification of ExtendedDTraceProbes by aoqi@0: * a call to set_extended_dprobes. aoqi@0: */ aoqi@0: if (ExtendedDTraceProbes) { aoqi@0: enable_dprobes(DTRACE_ALL_PROBES); aoqi@0: } else { aoqi@0: disable_dprobes(DTRACE_ALL_PROBES); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: void DTrace::set_extended_dprobes(bool flag) { aoqi@0: // explicit setting of ExtendedDTraceProbes flag aoqi@0: set_bool_flag("ExtendedDTraceProbes", flag); aoqi@0: aoqi@0: // make sure that the fine grained flags reflect the change. aoqi@0: if (flag) { aoqi@0: enable_dprobes(DTRACE_ALL_PROBES); aoqi@0: } else { aoqi@0: /* aoqi@0: * FIXME: Revisit this: currently all-client-detach detection aoqi@0: * does not work and hence disabled. The following scheme does aoqi@0: * not work. So, we have to disable fine-grained flags here. aoqi@0: * aoqi@0: * disable_dprobes call has to be delayed till next "detach all "event. aoqi@0: * This is to be done so that concurrent DTrace clients that may aoqi@0: * have enabled one or more fine grained dprobes and may be running aoqi@0: * still. On "detach all" clients event, we would sync ExtendedDTraceProbes aoqi@0: * with fine grained flags which would take care of disabling fine grained flags. aoqi@0: */ aoqi@0: disable_dprobes(DTRACE_ALL_PROBES); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: void DTrace::set_monitor_dprobes(bool flag) { aoqi@0: // explicit setting of DTraceMonitorProbes flag aoqi@0: set_bool_flag("DTraceMonitorProbes", flag); aoqi@0: } aoqi@0: aoqi@0: #endif /* SOLARIS */