src/share/vm/runtime/dtraceJSDT.cpp

Thu, 05 Jun 2008 15:57:56 -0700

author
ysr
date
Thu, 05 Jun 2008 15:57:56 -0700
changeset 777
37f87013dfd8
parent 551
018d5b58dd4f
child 631
d1605aabd0a1
permissions
-rw-r--r--

6711316: Open source the Garbage-First garbage collector
Summary: First mercurial integration of the code for the Garbage-First garbage collector.
Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr

     1 /*
     2  * Copyright 1997-2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_dtraceJSDT.cpp.incl"
    28 #ifdef HAVE_DTRACE_H
    30 jlong DTraceJSDT::activate(
    31     jint version, jstring module_name, jint providers_count,
    32     JVM_DTraceProvider* providers, TRAPS) {
    34   size_t count = 0;
    35   RegisteredProbes* probes = NULL;
    37   if (!is_supported()) {
    38     return 0;
    39   }
    41   assert(module_name != NULL, "valid module name");
    42   assert(providers != NULL, "valid provider array");
    44   for (int i = 0; i < providers_count; ++i) {
    45     count += providers[i].probe_count;
    46   }
    47   probes = new RegisteredProbes(count);
    48   count = 0;
    50   for (int i = 0; i < providers_count; ++i) {
    51     assert(providers[i].name != NULL, "valid provider name");
    52     assert(providers[i].probe_count == 0 || providers[i].probes != NULL,
    53            "valid probe count");
    54     for (int j = 0; j < providers[i].probe_count; ++j) {
    55       JVM_DTraceProbe* probe = &(providers[i].probes[j]);
    56       assert(probe != NULL, "valid probe");
    57       assert(probe->method != NULL, "valid method");
    58       assert(probe->name != NULL, "valid probe name");
    59       assert(probe->function != NULL, "valid probe function spec");
    60       methodHandle h_method =
    61         methodHandle(THREAD, JNIHandles::resolve_jmethod_id(probe->method));
    62       nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method);
    63       h_method()->set_not_compilable(CompLevel_highest_tier);
    64       h_method()->set_code(h_method, nm);
    65       probes->nmethod_at_put(count++, nm);
    66     }
    67   }
    69   int handle = pd_activate((void*)probes,
    70     module_name, providers_count, providers);
    71   if (handle <= 0) {
    72     delete probes;
    73     THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
    74       "Unable to register DTrace probes (internal error).");
    75   }
    76   probes->set_helper_handle(handle);
    77   return RegisteredProbes::toOpaqueProbes(probes);
    78 }
    80 jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
    81   methodOop m = JNIHandles::resolve_jmethod_id(method);
    82   return nativeInstruction_at(m->code()->trap_address())->is_dtrace_trap();
    83 }
    85 void DTraceJSDT::dispose(OpaqueProbes probes) {
    86   RegisteredProbes* p = RegisteredProbes::toRegisteredProbes(probes);
    87   if (probes != -1 && p != NULL) {
    88     pd_dispose(p->helper_handle());
    89     delete p;
    90   }
    91 }
    93 jboolean DTraceJSDT::is_supported() {
    94   return pd_is_supported();
    95 }
    97 #else // HAVE_DTRACE_H
    99 jlong DTraceJSDT::activate(
   100     jint version, jstring module_name, jint providers_count,
   101     JVM_DTraceProvider* providers, TRAPS) {
   102   return 0;
   103 }
   105 jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
   106   return false;
   107 }
   109 void DTraceJSDT::dispose(OpaqueProbes probes) {
   110   return;
   111 }
   113 jboolean DTraceJSDT::is_supported() {
   114   return false;
   115 }
   117 #endif // ndef HAVE_DTRACE_H

mercurial