Merge from subtype.
[cacao.git] / src / native / vm / openjdk / management.cpp
1  /* src/native/vm/openjdk/management.cpp - HotSpot management interface functions
2
3    Copyright (C) 2008 Theobroma Systems Ltd.
4
5    This file is part of CACAO.
6
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2, or (at
10    your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301, USA.
21
22 */
23
24
25 #include "config.h"
26
27 #include <stdint.h>
28
29 // Include our JNI header before the JMM header, because the JMM
30 // header include jni.h and we want to override the typedefs in jni.h.
31 #include "native/jni.hpp"
32
33 #include INCLUDE_JMM_H
34
35 #include "native/vm/openjdk/management.hpp"
36
37 #include "toolbox/logging.h"
38
39 #include "vm/os.hpp"
40 #include "vm/vm.hpp"
41
42
43 /**
44  * Initialize the Management subsystem.
45  */
46 Management::Management()
47 {
48         // Initialize optional support
49         _optional_support.isLowMemoryDetectionSupported = 1;
50         _optional_support.isCompilationTimeMonitoringSupported = 1;
51         _optional_support.isThreadContentionMonitoringSupported = 1;
52
53 //      if (os::is_thread_cpu_time_supported()) {
54         if (false) {
55                 _optional_support.isCurrentThreadCpuTimeSupported = 1;
56                 _optional_support.isOtherThreadCpuTimeSupported = 1;
57         }
58         else {
59                 _optional_support.isCurrentThreadCpuTimeSupported = 0;
60                 _optional_support.isOtherThreadCpuTimeSupported = 0;
61         }
62
63         _optional_support.isBootClassPathSupported = 1;
64         _optional_support.isObjectMonitorUsageSupported = 1;
65         _optional_support.isSynchronizerUsageSupported = 1;
66 }
67
68
69 /**
70  * Return a pointer to the optional support structure.
71  *
72  * @param Pointer to optional support structure.
73  */
74 const jmmOptionalSupport& Management::get_optional_support() const
75 {
76         return _optional_support;
77 }
78
79
80 // Interface functions are exported as C functions.
81 extern "C" {
82
83 // Returns a version string and sets major and minor version if the
84 // input parameters are non-null.
85 jint jmm_GetVersion(JNIEnv* env)
86 {
87         return JMM_VERSION;
88 }
89
90
91 // Gets the list of VM monitoring and management optional supports
92 // Returns 0 if succeeded; otherwise returns non-zero.
93 jint jmm_GetOptionalSupport(JNIEnv* env, jmmOptionalSupport* support)
94 {
95         if (support == NULL) {
96                 return -1;
97         }
98
99         Management& mm = VM::get_current()->get_management();
100
101         // memcpy the structure.
102         os::memcpy(support, &mm.get_optional_support(), sizeof(jmmOptionalSupport));
103
104         return 0;
105 }
106
107
108 jobject jmm_GetInputArguments(JNIEnv* env)
109 {
110         log_println("jmm_GetInputArguments: IMPLEMENT ME!");
111         return NULL;
112 }
113
114
115 jobjectArray jmm_GetInputArgumentArray(JNIEnv* env)
116 {
117         log_println("jmm_GetInputArgumentArray: IMPLEMENT ME!");
118         return NULL;
119 }
120
121
122 jobjectArray jmm_GetMemoryPools(JNIEnv* env, jobject obj)
123 {
124         log_println("jmm_GetMemoryPools: IMPLEMENT ME!");
125         return NULL;
126 }
127
128
129 jobjectArray jmm_GetMemoryManagers(JNIEnv* env, jobject obj)
130 {
131         log_println("jmm_GetMemoryManagers: IMPLEMENT ME!");
132         return NULL;
133 }
134
135
136 jobject jmm_GetMemoryPoolUsage(JNIEnv* env, jobject obj)
137 {
138         log_println("jmm_GetMemoryPoolUsage: IMPLEMENT ME!");
139         return NULL;
140 }
141
142
143 jobject jmm_GetPeakMemoryPoolUsage(JNIEnv* env, jobject obj)
144 {
145         log_println("jmm_GetPeakMemoryPoolUsage: IMPLEMENT ME!");
146         return NULL;
147 }
148
149
150 jobject jmm_GetPoolCollectionUsage(JNIEnv* env, jobject obj)
151 {
152         log_println("jmm_GetPoolCollectionUsage: IMPLEMENT ME!");
153         return NULL;
154 }
155
156
157 void jmm_SetPoolSensor(JNIEnv* env, jobject obj, jmmThresholdType type, jobject sensorObj)
158 {
159         log_println("jmm_SetPoolSensor: IMPLEMENT ME!");
160 }
161
162
163 jlong jmm_SetPoolThreshold(JNIEnv* env, jobject obj, jmmThresholdType type, jlong threshold)
164 {
165         log_println("jmm_SetPoolThreshold: IMPLEMENT ME!");
166         return 0;
167 }
168
169
170 jobject jmm_GetMemoryUsage(JNIEnv* env, jboolean heap)
171 {
172         log_println("jmm_GetMemoryUsage: IMPLEMENT ME!");
173         return NULL;
174 }
175
176
177 jboolean jmm_GetBoolAttribute(JNIEnv* env, jmmBoolAttribute att)
178 {
179         log_println("jmm_GetBoolAttribute: IMPLEMENT ME!");
180         return 0;
181 }
182
183
184 jboolean jmm_SetBoolAttribute(JNIEnv* env, jmmBoolAttribute att, jboolean flag)
185 {
186         log_println("jmm_SetBoolAttribute: IMPLEMENT ME!");
187         return 0;
188 }
189
190
191 jlong jmm_GetLongAttribute(JNIEnv* env, jobject obj, jmmLongAttribute att)
192 {
193         log_println("jmm_GetLongAttribute: IMPLEMENT ME!");
194         return 0;
195 }
196
197
198 jint jmm_GetLongAttributes(JNIEnv* env, jobject obj, jmmLongAttribute* atts, jint count, jlong* result)
199 {
200         log_println("jmm_GetLongAttributes: IMPLEMENT ME!");
201         return 0;
202 }
203
204
205 jint jmm_GetThreadInfo(JNIEnv* env, jlongArray ids, jint maxDepth, jobjectArray infoArray)
206 {
207         log_println("jmm_GetThreadInfo: IMPLEMENT ME!");
208         return 0;
209 }
210
211
212 jobjectArray jmm_DumpThreads(JNIEnv* env, jlongArray thread_ids, jboolean locked_monitors, jboolean locked_synchronizers)
213 {
214         log_println("jmm_DumpThreads: IMPLEMENT ME!");
215         return NULL;
216 }
217
218
219 jobjectArray jmm_GetLoadedClasses(JNIEnv* env)
220 {
221         log_println("jmm_GetLoadedClasses: IMPLEMENT ME!");
222         return NULL;
223 }
224
225
226 jboolean jmm_ResetStatistic(JNIEnv* env, jvalue obj, jmmStatisticType type)
227 {
228         log_println("jmm_ResetStatistic: IMPLEMENT ME!");
229         return 0;
230 }
231
232
233 jlong jmm_GetThreadCpuTime(JNIEnv* env, jlong thread_id)
234 {
235         log_println("jmm_GetThreadCpuTime: IMPLEMENT ME!");
236         return 0;
237 }
238
239
240 jlong jmm_GetThreadCpuTimeWithKind(JNIEnv* env, jlong thread_id, jboolean user_sys_cpu_time)
241 {
242         log_println("jmm_GetThreadCpuTimeWithKind: IMPLEMENT ME!");
243         return 0;
244 }
245
246
247 jobjectArray jmm_GetVMGlobalNames(JNIEnv* env)
248 {
249         log_println("jmm_GetVMGlobalNames: IMPLEMENT ME!");
250         return NULL;
251 }
252
253
254 jint jmm_GetVMGlobals(JNIEnv* env, jobjectArray names, jmmVMGlobal* globals, jint count)
255 {
256         log_println("jmm_GetVMGlobals: IMPLEMENT ME!");
257         return 0;
258 }
259
260
261 void jmm_SetVMGlobal(JNIEnv* env, jstring flag_name, jvalue new_value)
262 {
263         log_println("jmm_SetVMGlobal: IMPLEMENT ME!");
264 }
265
266
267 jint jmm_GetInternalThreadTimes(JNIEnv* env, jobjectArray names, jlongArray times)
268 {
269         log_println("jmm_GetInternalThreadTimes: IMPLEMENT ME!");
270         return 0;
271 }
272
273
274 jobjectArray jmm_FindDeadlockedThreads(JNIEnv* env, jboolean object_monitors_only)
275 {
276         log_println("jmm_FindDeadlockedThreads: IMPLEMENT ME!");
277         return NULL;
278 }
279
280
281 jobjectArray jmm_FindMonitorDeadlockedThreads(JNIEnv* env)
282 {
283         log_println("jmm_FindMonitorDeadlockedThreads: IMPLEMENT ME!");
284         return NULL;
285 }
286
287
288 jint jmm_GetGCExtAttributeInfo(JNIEnv* env, jobject mgr, jmmExtAttributeInfo* info, jint count)
289 {
290         log_println("jmm_GetGCExtAttributeInfo: IMPLEMENT ME!");
291         return 0;
292 }
293
294
295 void jmm_GetLastGCStat(JNIEnv* env, jobject obj, jmmGCStat* gc_stat)
296 {
297         log_println("jmm_GetLastGCStat: IMPLEMENT ME!");
298 }
299
300
301 jint jmm_DumpHeap0(JNIEnv* env, jstring outputfile, jboolean live)
302 {
303         log_println("jmm_DumpHeap0: IMPLEMENT ME!");
304         return 0;
305 }
306
307 } // extern "C"
308
309
310 const struct jmmInterface_1_ jmm_interface = {
311         NULL,
312         NULL,
313         jmm_GetVersion,
314         jmm_GetOptionalSupport,
315         jmm_GetInputArguments,
316         jmm_GetThreadInfo,
317         jmm_GetInputArgumentArray,
318         jmm_GetMemoryPools,
319         jmm_GetMemoryManagers,
320         jmm_GetMemoryPoolUsage,
321         jmm_GetPeakMemoryPoolUsage,
322         NULL,
323         jmm_GetMemoryUsage,
324         jmm_GetLongAttribute,
325         jmm_GetBoolAttribute,
326         jmm_SetBoolAttribute,
327         jmm_GetLongAttributes,
328         jmm_FindMonitorDeadlockedThreads,
329         jmm_GetThreadCpuTime,
330         jmm_GetVMGlobalNames,
331         jmm_GetVMGlobals,
332         jmm_GetInternalThreadTimes,
333         jmm_ResetStatistic,
334         jmm_SetPoolSensor,
335         jmm_SetPoolThreshold,
336         jmm_GetPoolCollectionUsage,
337         jmm_GetGCExtAttributeInfo,
338         jmm_GetLastGCStat,
339         jmm_GetThreadCpuTimeWithKind,
340         NULL,
341         jmm_DumpHeap0,
342         jmm_FindDeadlockedThreads,
343         jmm_SetVMGlobal,
344         NULL,
345         jmm_DumpThreads
346 };
347
348
349 /**
350  * Return the requested management interface.
351  *
352  * @param version Requested management interface version.
353  *
354  * @return Pointer to management interface structure.
355  */
356 void* Management::get_jmm_interface(int version)
357 {
358         if (version == JMM_VERSION_1_0) {
359                 return (void*) &jmm_interface;
360         }
361
362         return NULL;
363 }
364
365 /*
366  * These are local overrides for various environment variables in Emacs.
367  * Please do not remove this and leave it at the end of the file, where
368  * Emacs will automagically detect them.
369  * ---------------------------------------------------------------------
370  * Local variables:
371  * mode: c++
372  * indent-tabs-mode: t
373  * c-basic-offset: 4
374  * tab-width: 4
375  * End:
376  * vim:noexpandtab:sw=4:ts=4:
377  */