Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/services/dtraceAttacher.cpp
32285 views
/*1* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "code/codeCache.hpp"26#include "memory/resourceArea.hpp"27#include "runtime/deoptimization.hpp"28#include "runtime/vmThread.hpp"29#include "runtime/vm_operations.hpp"30#include "services/dtraceAttacher.hpp"3132#ifdef SOLARIS3334class VM_DeoptimizeTheWorld : public VM_Operation {35public:36VMOp_Type type() const {37return VMOp_DeoptimizeTheWorld;38}39void doit() {40CodeCache::mark_all_nmethods_for_deoptimization();41ResourceMark rm;42DeoptimizationMarker dm;43// Deoptimize all activations depending on marked methods44Deoptimization::deoptimize_dependents();4546// Mark the dependent methods non entrant47CodeCache::make_marked_nmethods_not_entrant();48}49};5051static void set_bool_flag(const char* flag, bool value) {52CommandLineFlags::boolAtPut((char*)flag, strlen(flag), &value,53Flag::ATTACH_ON_DEMAND);54}5556// Enable only the "fine grained" flags. Do *not* touch57// the overall "ExtendedDTraceProbes" flag.58void DTrace::enable_dprobes(int probes) {59bool changed = false;60if (!DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {61set_bool_flag("DTraceAllocProbes", true);62changed = true;63}64if (!DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {65set_bool_flag("DTraceMethodProbes", true);66changed = true;67}68if (!DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {69set_bool_flag("DTraceMonitorProbes", true);70changed = true;71}7273if (changed) {74// one or more flags changed, need to deoptimize75VM_DeoptimizeTheWorld op;76VMThread::execute(&op);77}78}7980// Disable only the "fine grained" flags. Do *not* touch81// the overall "ExtendedDTraceProbes" flag.82void DTrace::disable_dprobes(int probes) {83bool changed = false;84if (DTraceAllocProbes && (probes & DTRACE_ALLOC_PROBES)) {85set_bool_flag("DTraceAllocProbes", false);86changed = true;87}88if (DTraceMethodProbes && (probes & DTRACE_METHOD_PROBES)) {89set_bool_flag("DTraceMethodProbes", false);90changed = true;91}92if (DTraceMonitorProbes && (probes & DTRACE_MONITOR_PROBES)) {93set_bool_flag("DTraceMonitorProbes", false);94changed = true;95}96if (changed) {97// one or more flags changed, need to deoptimize98VM_DeoptimizeTheWorld op;99VMThread::execute(&op);100}101}102103// Do clean-up on "all door clients detached" event.104void DTrace::detach_all_clients() {105/*106* We restore the state of the fine grained flags107* to be consistent with overall ExtendedDTraceProbes.108* This way, we will honour command line setting or the109* last explicit modification of ExtendedDTraceProbes by110* a call to set_extended_dprobes.111*/112if (ExtendedDTraceProbes) {113enable_dprobes(DTRACE_ALL_PROBES);114} else {115disable_dprobes(DTRACE_ALL_PROBES);116}117}118119void DTrace::set_extended_dprobes(bool flag) {120// explicit setting of ExtendedDTraceProbes flag121set_bool_flag("ExtendedDTraceProbes", flag);122123// make sure that the fine grained flags reflect the change.124if (flag) {125enable_dprobes(DTRACE_ALL_PROBES);126} else {127/*128* FIXME: Revisit this: currently all-client-detach detection129* does not work and hence disabled. The following scheme does130* not work. So, we have to disable fine-grained flags here.131*132* disable_dprobes call has to be delayed till next "detach all "event.133* This is to be done so that concurrent DTrace clients that may134* have enabled one or more fine grained dprobes and may be running135* still. On "detach all" clients event, we would sync ExtendedDTraceProbes136* with fine grained flags which would take care of disabling fine grained flags.137*/138disable_dprobes(DTRACE_ALL_PROBES);139}140}141142void DTrace::set_monitor_dprobes(bool flag) {143// explicit setting of DTraceMonitorProbes flag144set_bool_flag("DTraceMonitorProbes", flag);145}146147#endif /* SOLARIS */148149150