author | phh |
Wed, 18 Sep 2019 05:41:08 -0700 | |
changeset 58208 | 0f3c23c374a4 |
parent 47592 | 68d46cb9be45 |
child 58223 | 778fc2dcbdaa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
58208
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <jni.h> |
|
27 |
#include "jvm.h" |
|
28 |
#include "management.h" |
|
29 |
#include "sun_management_ThreadImpl.h" |
|
30 |
||
31 |
JNIEXPORT void JNICALL |
|
32 |
Java_sun_management_ThreadImpl_setThreadContentionMonitoringEnabled0 |
|
33 |
(JNIEnv *env, jclass cls, jboolean flag) |
|
34 |
{ |
|
35 |
jmm_interface->SetBoolAttribute(env, JMM_THREAD_CONTENTION_MONITORING, flag); |
|
36 |
} |
|
37 |
||
38 |
JNIEXPORT void JNICALL |
|
39 |
Java_sun_management_ThreadImpl_setThreadCpuTimeEnabled0 |
|
40 |
(JNIEnv *env, jclass cls, jboolean flag) |
|
41 |
{ |
|
42 |
jmm_interface->SetBoolAttribute(env, JMM_THREAD_CPU_TIME, flag); |
|
43 |
} |
|
44 |
||
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
45 |
JNIEXPORT void JNICALL |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
46 |
Java_sun_management_ThreadImpl_setThreadAllocatedMemoryEnabled0 |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
47 |
(JNIEnv *env, jclass cls, jboolean flag) |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
48 |
{ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
49 |
jmm_interface->SetBoolAttribute(env, JMM_THREAD_ALLOCATED_MEMORY, flag); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
50 |
} |
2 | 51 |
|
52 |
JNIEXPORT void JNICALL |
|
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
53 |
Java_sun_management_ThreadImpl_getThreadInfo1 |
2 | 54 |
(JNIEnv *env, jclass cls, jlongArray ids, jint maxDepth, |
55 |
jobjectArray infoArray) |
|
56 |
{ |
|
57 |
jmm_interface->GetThreadInfo(env, ids, maxDepth, infoArray); |
|
58 |
} |
|
59 |
||
60 |
JNIEXPORT jobjectArray JNICALL |
|
61 |
Java_sun_management_ThreadImpl_getThreads |
|
62 |
(JNIEnv *env, jclass cls) |
|
63 |
{ |
|
64 |
return JVM_GetAllThreads(env, cls); |
|
65 |
} |
|
66 |
||
67 |
JNIEXPORT jlong JNICALL |
|
68 |
Java_sun_management_ThreadImpl_getThreadTotalCpuTime0 |
|
69 |
(JNIEnv *env, jclass cls, jlong tid) |
|
70 |
{ |
|
71 |
return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_TRUE /* user+sys */); |
|
72 |
} |
|
73 |
||
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
74 |
JNIEXPORT void JNICALL |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
75 |
Java_sun_management_ThreadImpl_getThreadTotalCpuTime1 |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
76 |
(JNIEnv *env, jclass cls, jlongArray ids, jlongArray timeArray) |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
77 |
{ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
78 |
jmm_interface->GetThreadCpuTimesWithKind(env, ids, timeArray, |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
79 |
JNI_TRUE /* user+sys */); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
80 |
} |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
81 |
|
2 | 82 |
JNIEXPORT jlong JNICALL |
83 |
Java_sun_management_ThreadImpl_getThreadUserCpuTime0 |
|
84 |
(JNIEnv *env, jclass cls, jlong tid) |
|
85 |
{ |
|
86 |
return jmm_interface->GetThreadCpuTimeWithKind(env, tid, JNI_FALSE /* user */); |
|
87 |
} |
|
88 |
||
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
89 |
JNIEXPORT void JNICALL |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
90 |
Java_sun_management_ThreadImpl_getThreadUserCpuTime1 |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
91 |
(JNIEnv *env, jclass cls, jlongArray ids, jlongArray timeArray) |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
92 |
{ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
93 |
jmm_interface->GetThreadCpuTimesWithKind(env, ids, timeArray, |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
94 |
JNI_FALSE /* user */); |
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 |
|
58208
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
97 |
JNIEXPORT jlong JNICALL |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
98 |
Java_sun_management_ThreadImpl_getThreadAllocatedMemory0 |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
99 |
(JNIEnv *env, jclass cls, jlong tid) |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
100 |
{ |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
101 |
return jmm_interface->GetOneThreadAllocatedMemory(env, tid); |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
102 |
} |
0f3c23c374a4
8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
phh
parents:
47592
diff
changeset
|
103 |
|
8001
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
104 |
JNIEXPORT void JNICALL |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
105 |
Java_sun_management_ThreadImpl_getThreadAllocatedMemory1 |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
106 |
(JNIEnv *env, jclass cls, jlongArray ids, jlongArray sizeArray) |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
107 |
{ |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
108 |
jmm_interface->GetThreadAllocatedMemory(env, ids, sizeArray); |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
109 |
} |
192adf3627b7
6173675: M&M: approximate memory allocation rate/amount per thread
phh
parents:
5506
diff
changeset
|
110 |
|
2 | 111 |
JNIEXPORT jobjectArray JNICALL |
112 |
Java_sun_management_ThreadImpl_findMonitorDeadlockedThreads0 |
|
113 |
(JNIEnv *env, jclass cls) |
|
114 |
{ |
|
115 |
return jmm_interface->FindCircularBlockedThreads(env); |
|
116 |
} |
|
117 |
||
118 |
JNIEXPORT jobjectArray JNICALL |
|
119 |
Java_sun_management_ThreadImpl_findDeadlockedThreads0 |
|
120 |
(JNIEnv *env, jclass cls) |
|
121 |
{ |
|
122 |
return jmm_interface->FindDeadlocks(env, JNI_FALSE /* !object_monitors_only */); |
|
123 |
} |
|
124 |
||
125 |
JNIEXPORT void JNICALL |
|
126 |
Java_sun_management_ThreadImpl_resetPeakThreadCount0 |
|
127 |
(JNIEnv *env, jclass cls) |
|
128 |
{ |
|
129 |
jvalue unused; |
|
130 |
unused.i = 0; |
|
131 |
jmm_interface->ResetStatistic(env, unused, JMM_STAT_PEAK_THREAD_COUNT); |
|
132 |
} |
|
133 |
||
134 |
JNIEXPORT void JNICALL |
|
135 |
Java_sun_management_ThreadImpl_resetContentionTimes0 |
|
136 |
(JNIEnv *env, jobject dummy, jlong tid) |
|
137 |
{ |
|
138 |
jvalue value; |
|
139 |
value.j = tid; |
|
140 |
jmm_interface->ResetStatistic(env, value, JMM_STAT_THREAD_CONTENTION_TIME); |
|
141 |
} |
|
142 |
||
143 |
JNIEXPORT jobjectArray JNICALL |
|
144 |
Java_sun_management_ThreadImpl_dumpThreads0 |
|
47592
68d46cb9be45
8185003: JMX: Add a version of ThreadMXBean.dumpAllThreads with a maxDepth argument
uvangapally
parents:
47216
diff
changeset
|
145 |
(JNIEnv *env, jclass cls, jlongArray ids, jboolean lockedMonitors, |
68d46cb9be45
8185003: JMX: Add a version of ThreadMXBean.dumpAllThreads with a maxDepth argument
uvangapally
parents:
47216
diff
changeset
|
146 |
jboolean lockedSynchronizers, jint maxDepth) |
2 | 147 |
{ |
47592
68d46cb9be45
8185003: JMX: Add a version of ThreadMXBean.dumpAllThreads with a maxDepth argument
uvangapally
parents:
47216
diff
changeset
|
148 |
return jmm_interface->DumpThreads(env, ids, lockedMonitors, |
68d46cb9be45
8185003: JMX: Add a version of ThreadMXBean.dumpAllThreads with a maxDepth argument
uvangapally
parents:
47216
diff
changeset
|
149 |
lockedSynchronizers, maxDepth); |
2 | 150 |
} |