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