jdk/src/share/native/sun/management/VMManagementImpl.c
author phh
Thu, 20 Jan 2011 19:34:40 -0500
changeset 8001 192adf3627b7
parent 5506 202f599c92aa
child 9698 8b66cd6c5ebc
permissions -rw-r--r--
6173675: M&M: approximate memory allocation rate/amount per thread Summary: Subclass com.sun.management.ThreadMXBean from java.lang.management.ThreadMXBean, add getAllocatedBytes() and friends to c.s.m.ThreadMXBean and have sun.management.ThreadImpl implement c.s.m.ThreadMXBean rather than j.l.m.ThreadMXBean. Reviewed-by: mchung, alanb, dholmes, emcmanus
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jni.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "management.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "sun_management_VMManagementImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#define MAX_VERSION_LEN   20
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
JNIEXPORT jstring JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
Java_sun_management_VMManagementImpl_getVersion0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  (JNIEnv *env, jclass dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    char buf[MAX_VERSION_LEN];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    jstring version_string = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    unsigned int major = ((unsigned int) jmm_version & 0x0FFF0000) >> 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    unsigned int minor = ((unsigned int) jmm_version & 0xFF00) >> 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    // for internal use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    unsigned int micro = (unsigned int) jmm_version & 0xFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    sprintf(buf, "%d.%d", major, minor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    version_string = (*env)->NewStringUTF(env, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    return version_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
static void setStaticBooleanField
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
   (JNIEnv* env, jclass cls, const char* name, jboolean value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    jfieldID fid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    fid = (*env)->GetStaticFieldID(env, cls, name, "Z");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    if (fid != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        (*env)->SetStaticBooleanField(env, cls, fid, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
Java_sun_management_VMManagementImpl_initOptionalSupportFields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  (JNIEnv *env, jclass cls)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    jmmOptionalSupport mos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    jint ret = jmm_interface->GetOptionalSupport(env, &mos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    jboolean value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    value = mos.isCompilationTimeMonitoringSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    setStaticBooleanField(env, cls, "compTimeMonitoringSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    value = mos.isThreadContentionMonitoringSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    setStaticBooleanField(env, cls, "threadContentionMonitoringSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    value = mos.isCurrentThreadCpuTimeSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    setStaticBooleanField(env, cls, "currentThreadCpuTimeSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    value = mos.isOtherThreadCpuTimeSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    setStaticBooleanField(env, cls, "otherThreadCpuTimeSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    value = mos.isBootClassPathSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    setStaticBooleanField(env, cls, "bootClassPathSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    if (jmm_version >= JMM_VERSION_1_1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        value = mos.isObjectMonitorUsageSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        setStaticBooleanField(env, cls, "objectMonitorUsageSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        value = mos.isSynchronizerUsageSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        setStaticBooleanField(env, cls, "synchronizerUsageSupport", value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        setStaticBooleanField(env, cls, "objectMonitorUsageSupport", JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        setStaticBooleanField(env, cls, "synchronizerUsageSupport", JNI_FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    95
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    96
    value = mos.isThreadAllocatedMemorySupported;
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
    97
    setStaticBooleanField(env, cls, "threadAllocatedMemorySupport", value);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
JNIEXPORT jobjectArray JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
Java_sun_management_VMManagementImpl_getVmArguments0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    return jmm_interface->GetInputArgumentArray(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
Java_sun_management_VMManagementImpl_getTotalClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /* JMM_CLASS_LOADED_COUNT is the total number of classes loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                                                  JMM_CLASS_LOADED_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
Java_sun_management_VMManagementImpl_getUnloadedClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    /* JMM_CLASS_UNLOADED_COUNT is the total number of classes unloaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                                                  JMM_CLASS_UNLOADED_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
Java_sun_management_VMManagementImpl_getVerboseGC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_GC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
Java_sun_management_VMManagementImpl_getVerboseClass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    return jmm_interface->GetBoolAttribute(env, JMM_VERBOSE_CLASS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
Java_sun_management_VMManagementImpl_getTotalThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                           JMM_THREAD_TOTAL_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
Java_sun_management_VMManagementImpl_getLiveThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                                  JMM_THREAD_LIVE_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
Java_sun_management_VMManagementImpl_getPeakThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                                  JMM_THREAD_PEAK_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
Java_sun_management_VMManagementImpl_getDaemonThreadCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    jlong count = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                                  JMM_THREAD_DAEMON_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    return (jint) count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
Java_sun_management_VMManagementImpl_getTotalCompileTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                                           JMM_COMPILE_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
Java_sun_management_VMManagementImpl_getStartupTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                                           JMM_JVM_INIT_DONE_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
Java_sun_management_VMManagementImpl_isThreadContentionMonitoringEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    return jmm_interface->GetBoolAttribute(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                           JMM_THREAD_CONTENTION_MONITORING);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
Java_sun_management_VMManagementImpl_isThreadCpuTimeEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    return jmm_interface->GetBoolAttribute(env, JMM_THREAD_CPU_TIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
8001
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   207
JNIEXPORT jboolean JNICALL
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   208
Java_sun_management_VMManagementImpl_isThreadAllocatedMemoryEnabled
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   209
  (JNIEnv *env, jobject dummy)
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   210
{
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   211
    return jmm_interface->GetBoolAttribute(env, JMM_THREAD_ALLOCATED_MEMORY);
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   212
}
192adf3627b7 6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents: 5506
diff changeset
   213
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
Java_sun_management_VMManagementImpl_getProcessId
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    jlong pid = jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                                JMM_OS_PROCESS_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    return (jint) pid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
Java_sun_management_VMManagementImpl_getAvailableProcessors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    return JVM_ActiveProcessorCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
Java_sun_management_VMManagementImpl_getSafepointCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                                           JMM_SAFEPOINT_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
Java_sun_management_VMManagementImpl_getTotalSafepointTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                                           JMM_TOTAL_STOPPED_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
Java_sun_management_VMManagementImpl_getSafepointSyncTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                                           JMM_TOTAL_SAFEPOINTSYNC_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
Java_sun_management_VMManagementImpl_getTotalApplicationNonStoppedTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                           JMM_TOTAL_APP_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
Java_sun_management_VMManagementImpl_getLoadedClassSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                           JMM_CLASS_LOADED_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
Java_sun_management_VMManagementImpl_getUnloadedClassSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                                           JMM_CLASS_UNLOADED_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
Java_sun_management_VMManagementImpl_getClassLoadingTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                                           JMM_TOTAL_CLASSLOAD_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
Java_sun_management_VMManagementImpl_getMethodDataSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                                           JMM_METHOD_DATA_SIZE_BYTES);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
Java_sun_management_VMManagementImpl_getInitializedClassCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                           JMM_CLASS_INIT_TOTAL_COUNT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
Java_sun_management_VMManagementImpl_getClassInitializationTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                                           JMM_CLASS_INIT_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
Java_sun_management_VMManagementImpl_getClassVerificationTime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
  (JNIEnv *env, jobject dummy)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    return jmm_interface->GetLongAttribute(env, NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                                           JMM_CLASS_VERIFY_TOTAL_TIME_MS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
}