src/share/vm/runtime/dtraceJSDT.cpp

Fri, 22 Oct 2010 15:59:34 -0400

author
acorn
date
Fri, 22 Oct 2010 15:59:34 -0400
changeset 2233
fa83ab460c54
parent 2138
d5d065957597
child 2314
f95d63e2154a
permissions
-rw-r--r--

6988353: refactor contended sync subsystem
Summary: reduce complexity by factoring synchronizer.cpp
Reviewed-by: dholmes, never, coleenp

     1 /*
     2  * Copyright (c) 1997, 2009, 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  */
    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       if (nm == NULL) {
    64         delete probes;
    65         THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
    66           "Unable to register DTrace probes (CodeCache: no room for DTrace nmethods).");
    67       }
    68       h_method()->set_not_compilable();
    69       h_method()->set_code(h_method, nm);
    70       probes->nmethod_at_put(count++, nm);
    71     }
    72   }
    74   int handle = pd_activate((void*)probes,
    75     module_name, providers_count, providers);
    76   if (handle <= 0) {
    77     delete probes;
    78     THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
    79       "Unable to register DTrace probes (internal error).");
    80   }
    81   probes->set_helper_handle(handle);
    82   return RegisteredProbes::toOpaqueProbes(probes);
    83 }
    85 jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
    86   methodOop m = JNIHandles::resolve_jmethod_id(method);
    87   return nativeInstruction_at(m->code()->trap_address())->is_dtrace_trap();
    88 }
    90 void DTraceJSDT::dispose(OpaqueProbes probes) {
    91   RegisteredProbes* p = RegisteredProbes::toRegisteredProbes(probes);
    92   if (probes != -1 && p != NULL) {
    93     pd_dispose(p->helper_handle());
    94     delete p;
    95   }
    96 }
    98 jboolean DTraceJSDT::is_supported() {
    99   return pd_is_supported();
   100 }
   102 #else // HAVE_DTRACE_H
   104 jlong DTraceJSDT::activate(
   105     jint version, jstring module_name, jint providers_count,
   106     JVM_DTraceProvider* providers, TRAPS) {
   107   return 0;
   108 }
   110 jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
   111   return false;
   112 }
   114 void DTraceJSDT::dispose(OpaqueProbes probes) {
   115   return;
   116 }
   118 jboolean DTraceJSDT::is_supported() {
   119   return false;
   120 }
   122 #endif // ndef HAVE_DTRACE_H

mercurial