1 /* 2 * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "jfr/jfr.hpp" 27 #include "jfr/periodic/sampling/jfrThreadSampler.hpp" 28 #include "jfr/recorder/access/jfrbackend.hpp" 29 #include "jfr/recorder/jfrEventSetting.inline.hpp" 30 31 void JfrBackend::on_javathread_exit(JavaThread *thread) { 32 Jfr::on_thread_exit(thread); 33 } 34 35 void JfrBackend::on_thread_destruct(Thread* thread) { 36 // vm thread shouldn't call Jfr::on_thread_destruct(), ref jdk11. 37 if (thread == VMThread::vm_thread()) { 38 return; 39 } 40 Jfr::on_thread_destruct(thread); 41 } 42 43 void JfrBackend::on_javathread_suspend(JavaThread* thread) { 44 JfrThreadSampler::on_javathread_suspend(thread); 45 } 46 47 bool JfrBackend::enabled() { 48 return Jfr::is_enabled(); 49 } 50 51 bool JfrBackend::is_event_enabled(TraceEventId event_id) { 52 return JfrEventSetting::is_enabled(event_id); 53 } 54 55 bool JfrBackend::is_stacktrace_enabled(TraceEventId event_id) { 56 return JfrEventSetting::has_stacktrace(event_id); 57 } 58 59 jlong JfrBackend::threshold(TraceEventId event_id) { 60 return JfrEventSetting::threshold(event_id); 61 } 62 63 void JfrBackend::on_unloading_classes() { 64 Jfr::on_unloading_classes(); 65 } 66 67 JfrTraceTime JfrBackend::time() { 68 return JfrTraceTime::now(); 69 }