src/share/vm/runtime/dtraceJSDT.hpp

Wed, 03 Jul 2019 20:42:37 +0800

author
aoqi
date
Wed, 03 Jul 2019 20:42:37 +0800
changeset 9637
eef07cd490d4
parent 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
aoqi@0 31 #ifndef SHARE_VM_RUNTIME_DTRACEJSDT_HPP
aoqi@0 32 #define SHARE_VM_RUNTIME_DTRACEJSDT_HPP
aoqi@0 33
aoqi@0 34 #include "code/nmethod.hpp"
aoqi@0 35 #ifdef TARGET_ARCH_x86
aoqi@0 36 # include "nativeInst_x86.hpp"
aoqi@0 37 #endif
aoqi@0 38 #ifdef TARGET_ARCH_sparc
aoqi@0 39 # include "nativeInst_sparc.hpp"
aoqi@0 40 #endif
aoqi@0 41 #ifdef TARGET_ARCH_zero
aoqi@0 42 # include "nativeInst_zero.hpp"
aoqi@0 43 #endif
aoqi@0 44 #ifdef TARGET_ARCH_arm
aoqi@0 45 # include "nativeInst_arm.hpp"
aoqi@0 46 #endif
aoqi@0 47 #ifdef TARGET_ARCH_ppc
aoqi@0 48 # include "nativeInst_ppc.hpp"
aoqi@0 49 #endif
aoqi@1 50 #ifdef TARGET_ARCH_mips
aoqi@1 51 # include "nativeInst_mips.hpp"
aoqi@1 52 #endif
aoqi@0 53
aoqi@0 54 class RegisteredProbes;
aoqi@0 55 typedef jlong OpaqueProbes;
aoqi@0 56
aoqi@0 57 class DTraceJSDT : AllStatic {
aoqi@0 58 private:
aoqi@0 59
aoqi@0 60 static int pd_activate(void* moduleBaseAddress, jstring module,
aoqi@0 61 jint providers_count, JVM_DTraceProvider* providers);
aoqi@0 62 static void pd_dispose(int handle);
aoqi@0 63 static jboolean pd_is_supported();
aoqi@0 64
aoqi@0 65 public:
aoqi@0 66
aoqi@0 67 static OpaqueProbes activate(
aoqi@0 68 jint version, jstring module_name, jint providers_count,
aoqi@0 69 JVM_DTraceProvider* providers, TRAPS);
aoqi@0 70 static jboolean is_probe_enabled(jmethodID method);
aoqi@0 71 static void dispose(OpaqueProbes handle);
aoqi@0 72 static jboolean is_supported();
aoqi@0 73 };
aoqi@0 74
aoqi@0 75 class RegisteredProbes : public CHeapObj<mtInternal> {
aoqi@0 76 private:
aoqi@0 77 nmethod** _nmethods; // all the probe methods
aoqi@0 78 size_t _count; // number of probe methods
aoqi@0 79 int _helper_handle; // DTrace-assigned identifier
aoqi@0 80
aoqi@0 81 public:
aoqi@0 82 RegisteredProbes(size_t count) {
aoqi@0 83 _count = count;
aoqi@0 84 _nmethods = NEW_C_HEAP_ARRAY(nmethod*, count, mtInternal);
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 ~RegisteredProbes() {
aoqi@0 88 for (size_t i = 0; i < _count; ++i) {
aoqi@0 89 // Let the sweeper reclaim it
aoqi@0 90 _nmethods[i]->make_not_entrant();
aoqi@0 91 _nmethods[i]->method()->clear_code();
aoqi@0 92 }
aoqi@0 93 FREE_C_HEAP_ARRAY(nmethod*, _nmethods, mtInternal);
aoqi@0 94 _nmethods = NULL;
aoqi@0 95 _count = 0;
aoqi@0 96 }
aoqi@0 97
aoqi@0 98 static RegisteredProbes* toRegisteredProbes(OpaqueProbes p) {
aoqi@0 99 return (RegisteredProbes*)(intptr_t)p;
aoqi@0 100 }
aoqi@0 101
aoqi@0 102 static OpaqueProbes toOpaqueProbes(RegisteredProbes* p) {
aoqi@0 103 return (OpaqueProbes)(intptr_t)p;
aoqi@0 104 }
aoqi@0 105
aoqi@0 106 void set_helper_handle(int handle) { _helper_handle = handle; }
aoqi@0 107 int helper_handle() const { return _helper_handle; }
aoqi@0 108
aoqi@0 109 nmethod* nmethod_at(size_t i) {
aoqi@0 110 assert(i >= 0 && i < _count, "bad nmethod index");
aoqi@0 111 return _nmethods[i];
aoqi@0 112 }
aoqi@0 113
aoqi@0 114 void nmethod_at_put(size_t i, nmethod* nm) {
aoqi@0 115 assert(i >= 0 && i < _count, "bad nmethod index");
aoqi@0 116 _nmethods[i] = nm;
aoqi@0 117 }
aoqi@0 118 };
aoqi@0 119
aoqi@0 120 #endif // SHARE_VM_RUNTIME_DTRACEJSDT_HPP

mercurial