hotspot/src/share/vm/runtime/dtraceJSDT.cpp
author phh
Wed, 28 Oct 2009 16:25:51 -0400
changeset 4434 4b41e5b42f81
parent 3261 c7d5aae8d3f7
child 5547 f4b087cbb361
permissions -rw-r--r--
6887571: Increase default heap config sizes Summary: Apply modification of existing server heap size ergo to all collectors except CMS. Reviewed-by: jmasa, ysr, xlu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
363
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     1
/*
3261
c7d5aae8d3f7 6862919: Update copyright year
xdono
parents: 2732
diff changeset
     2
 * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
363
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     4
 *
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     8
 *
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    13
 * accompanied this code).
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    14
 *
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    18
 *
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    21
 * have any questions.
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    22
 *
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    23
 */
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    24
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    26
#include "incls/_dtraceJSDT.cpp.incl"
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    27
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    28
#ifdef HAVE_DTRACE_H
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    29
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    30
jlong DTraceJSDT::activate(
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    31
    jint version, jstring module_name, jint providers_count,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    32
    JVM_DTraceProvider* providers, TRAPS) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    33
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    34
  size_t count = 0;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    35
  RegisteredProbes* probes = NULL;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    36
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    37
  if (!is_supported()) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    38
    return 0;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    39
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    40
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    41
  assert(module_name != NULL, "valid module name");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    42
  assert(providers != NULL, "valid provider array");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    43
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    44
  for (int i = 0; i < providers_count; ++i) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    45
    count += providers[i].probe_count;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    46
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    47
  probes = new RegisteredProbes(count);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    48
  count = 0;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    49
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    50
  for (int i = 0; i < providers_count; ++i) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    51
    assert(providers[i].name != NULL, "valid provider name");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    52
    assert(providers[i].probe_count == 0 || providers[i].probes != NULL,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    53
           "valid probe count");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    54
    for (int j = 0; j < providers[i].probe_count; ++j) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    55
      JVM_DTraceProbe* probe = &(providers[i].probes[j]);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    56
      assert(probe != NULL, "valid probe");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    57
      assert(probe->method != NULL, "valid method");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    58
      assert(probe->name != NULL, "valid probe name");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    59
      assert(probe->function != NULL, "valid probe function spec");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    60
      methodHandle h_method =
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    61
        methodHandle(THREAD, JNIHandles::resolve_jmethod_id(probe->method));
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    62
      nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method);
2732
3ab85419f523 6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents: 670
diff changeset
    63
      if (nm == NULL) {
3ab85419f523 6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents: 670
diff changeset
    64
        delete probes;
3ab85419f523 6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents: 670
diff changeset
    65
        THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
3ab85419f523 6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents: 670
diff changeset
    66
          "Unable to register DTrace probes (CodeCache: no room for DTrace nmethods).");
3ab85419f523 6834177: Running jsynprog on Solaris Nevada can cause JVM crash
kvn
parents: 670
diff changeset
    67
      }
363
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    68
      h_method()->set_not_compilable(CompLevel_highest_tier);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    69
      h_method()->set_code(h_method, nm);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    70
      probes->nmethod_at_put(count++, nm);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    71
    }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    72
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    73
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    74
  int handle = pd_activate((void*)probes,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    75
    module_name, providers_count, providers);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    76
  if (handle <= 0) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    77
    delete probes;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    78
    THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    79
      "Unable to register DTrace probes (internal error).");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    80
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    81
  probes->set_helper_handle(handle);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    82
  return RegisteredProbes::toOpaqueProbes(probes);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    83
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    84
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    85
jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    86
  methodOop m = JNIHandles::resolve_jmethod_id(method);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    87
  return nativeInstruction_at(m->code()->trap_address())->is_dtrace_trap();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    88
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    89
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    90
void DTraceJSDT::dispose(OpaqueProbes probes) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    91
  RegisteredProbes* p = RegisteredProbes::toRegisteredProbes(probes);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    92
  if (probes != -1 && p != NULL) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    93
    pd_dispose(p->helper_handle());
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    94
    delete p;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    95
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    96
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    97
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    98
jboolean DTraceJSDT::is_supported() {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    99
  return pd_is_supported();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   100
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   101
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   102
#else // HAVE_DTRACE_H
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   103
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   104
jlong DTraceJSDT::activate(
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   105
    jint version, jstring module_name, jint providers_count,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   106
    JVM_DTraceProvider* providers, TRAPS) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   107
  return 0;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   108
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   109
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   110
jboolean DTraceJSDT::is_probe_enabled(jmethodID method) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   111
  return false;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   112
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   113
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   114
void DTraceJSDT::dispose(OpaqueProbes probes) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   115
  return;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   116
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   117
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   118
jboolean DTraceJSDT::is_supported() {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   119
  return false;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   120
}
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   121
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
   122
#endif // ndef HAVE_DTRACE_H