1 /* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 #include "mm/gc-common.h"
32 #include "native/jni.h"
33 #include "native/native.h"
35 #include "native/include/java_lang_management_MemoryUsage.h"
37 #include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
39 #include "vm/builtin.h"
40 #include "vm/global.h"
43 #include "vmcore/class.h"
44 #include "vmcore/loader.h" /* XXX only for load_class_bootstrap */
45 #include "vmcore/options.h"
48 /* native methods implemented by this file ************************************/
50 static JNINativeMethod methods[] = {
51 { "getHeapMemoryUsage", "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage },
52 { "getNonHeapMemoryUsage", "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage },
53 { "getObjectPendingFinalizationCount", "()I", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
54 { "isVerbose", "()Z", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose },
55 { "setVerbose", "(Z)V", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose },
59 /* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************
61 Register native functions.
63 *******************************************************************************/
65 void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void)
69 u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl");
71 native_method_register(u, methods, NATIVE_METHODS_COUNT);
76 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
77 * Method: getHeapMemoryUsage
78 * Signature: ()Ljava/lang/management/MemoryUsage;
80 JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz)
82 classinfo *class_java_lang_management_MemoryUsage;
84 java_lang_management_MemoryUsage *mu;
92 /* XXX optimize me! sometime... */
94 if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage"))))
97 /* create the object */
99 o = builtin_new(class_java_lang_management_MemoryUsage);
104 /* cast the object to a MemoryUsage object (for debugability) */
106 mu = (java_lang_management_MemoryUsage *) o;
108 /* find initializer */
110 m = class_findmethod(class_java_lang_management_MemoryUsage,
111 utf_init, utf_new_char("(JJJJ)V"));
113 /* initializer not found */
118 /* get values from the VM */
119 /* XXX if we ever support more than one VM, change this */
121 init = opt_heapstartsize;
122 used = gc_get_total_bytes();
123 commited = gc_get_heap_size();
124 maximum = gc_get_max_heap_size();
126 /* call initializer */
128 (void) vm_call_method(m, o, init, used, commited, maximum);
135 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
136 * Method: getNonHeapMemoryUsage
137 * Signature: ()Ljava/lang/management/MemoryUsage;
139 JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz)
141 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!");
148 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
149 * Method: getObjectPendingFinalizationCount
152 JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz)
154 log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!");
161 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
165 JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz)
167 return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose;
172 * Class: gnu/java/lang/management/VMMemoryMXBeanImpl
176 JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose)
178 _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose;
183 * These are local overrides for various environment variables in Emacs.
184 * Please do not remove this and leave it at the end of the file, where
185 * Emacs will automagically detect them.
186 * ---------------------------------------------------------------------
189 * indent-tabs-mode: t
193 * vim:noexpandtab:sw=4:ts=4: