hotspot/src/share/vm/runtime/dtraceJSDT.hpp
author twisti
Tue, 09 Mar 2010 20:16:19 +0100
changeset 5046 27e801a857cb
parent 670 ddf3e9583f2f
child 5547 f4b087cbb361
permissions -rw-r--r--
6919934: JSR 292 needs to support x86 C1 Summary: This implements JSR 292 support for C1 x86. Reviewed-by: never, jrose, kvn
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
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 363
diff changeset
     2
 * Copyright 1997-2008 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
class RegisteredProbes;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    26
typedef jlong OpaqueProbes;
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
class DTraceJSDT : AllStatic {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    29
 private:
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    30
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    31
  static int pd_activate(void* moduleBaseAddress, jstring module,
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    32
      jint providers_count, JVM_DTraceProvider* providers);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    33
  static void pd_dispose(int handle);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    34
  static jboolean pd_is_supported();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    35
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    36
 public:
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    37
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    38
  static OpaqueProbes activate(
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    39
      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
    40
      JVM_DTraceProvider* providers, TRAPS);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    41
  static jboolean is_probe_enabled(jmethodID method);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    42
  static void dispose(OpaqueProbes handle);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    43
  static jboolean is_supported();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    44
};
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    45
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    46
class RegisteredProbes : public CHeapObj {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    47
 private:
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    48
  nmethod** _nmethods;      // all the probe methods
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    49
  size_t    _count;         // number of probe methods
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    50
  int       _helper_handle; // DTrace-assigned identifier
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    51
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    52
 public:
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    53
  RegisteredProbes(size_t count) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    54
    _count = count;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    55
    _nmethods = NEW_C_HEAP_ARRAY(nmethod*, count);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    56
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    57
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    58
  ~RegisteredProbes() {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    59
    for (size_t i = 0; i < _count; ++i) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    60
      // Let the sweeper reclaim it
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    61
      _nmethods[i]->make_not_entrant();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    62
      _nmethods[i]->method()->clear_code();
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    63
    }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    64
    FREE_C_HEAP_ARRAY(nmethod*, _nmethods);
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    65
    _nmethods = NULL;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    66
    _count = 0;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    67
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    68
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    69
  static RegisteredProbes* toRegisteredProbes(OpaqueProbes p) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    70
    return (RegisteredProbes*)(intptr_t)p;
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
  static OpaqueProbes toOpaqueProbes(RegisteredProbes* p) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    74
    return (OpaqueProbes)(intptr_t)p;
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    75
  }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    76
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    77
  void set_helper_handle(int handle) { _helper_handle = handle; }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    78
  int helper_handle() const { return _helper_handle; }
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    79
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    80
  nmethod* nmethod_at(size_t i) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    81
    assert(i >= 0 && i < _count, "bad nmethod index");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    82
    return _nmethods[i];
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
  void nmethod_at_put(size_t i, nmethod* nm) {
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    86
    assert(i >= 0 && i < _count, "bad nmethod index");
99d43e8a76ad 6537506: Provide a mechanism for specifying Java-level USDT-like dtrace probes
kamg
parents:
diff changeset
    87
    _nmethods[i] = nm;
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
};