You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/04/03 15:53:56 UTC
svn commit: r525155 - in /harmony/enhanced/drlvm/trunk: build/make/targets/
vm/gc_cc/src/ vm/gc_gen/src/common/ vm/include/open/ vm/port/include/
vm/port/src/vmem/linux/ vm/port/src/vmem/win/ vm/vmcore/include/
vm/vmcore/src/class_support/ vm/vmcore/sr...
Author: gshimansky
Date: Tue Apr 3 06:53:54 2007
New Revision: 525155
URL: http://svn.apache.org/viewvc?view=rev&rev=525155
Log:
Applied HARMONY-3513, HARMONY-3427 and HARMONY-3534
Implementations of ClassLoadingMXBean, MemoryMXBean and GarbageCollectorMXBean for java.lang.management
Modified:
harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp
harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
harmony/enhanced/drlvm/trunk/vm/include/open/gc.h
harmony/enhanced/drlvm/trunk/vm/port/include/port_vmem.h
harmony/enhanced/drlvm/trunk/vm/port/src/vmem/linux/port_vmem.c
harmony/enhanced/drlvm/trunk/vm/port/src/vmem/win/port_vmem.c
harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.cpp
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_MemoryMXBeanImpl.cpp
Modified: harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml Tue Apr 3 06:53:54 2007
@@ -211,7 +211,7 @@
</select>
<select os="win">
- <syslibset libs="advapi32,odbc32,userenv,ws2_32,mswsock" />
+ <syslibset libs="advapi32,odbc32,userenv,ws2_32,mswsock,psapi" />
</select>
<select os="lnx" arch="ia32">
Modified: harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/src/gc_for_vm.cpp Tue Apr 3 06:53:54 2007
@@ -398,6 +398,16 @@
return (int64) ((heap.allocation_region_end() - heap.pos) + (heap.old_objects.end - heap.old_objects.pos));
}
+int64 gc_get_collection_count()
+{
+ return (int64) gc_num;
+}
+
+int64 gc_get_collection_time()
+{
+ return (int64) total_gc_time;
+}
+
void gc_pin_object (Managed_Object_Handle* p_object) {
#if 0
// FIXME: overflow check and handling
Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp Tue Apr 3 06:53:54 2007
@@ -166,6 +166,26 @@
return (int64)((POINTER_SIZE_INT)gc_gen_total_memory_size((GC_Gen*)p_global_gc));
}
+int64 gc_get_collection_count()
+{
+ GC* gc = p_global_gc;
+ if (gc != NULL) {
+ return (int64) gc->num_collections;
+ } else {
+ return -1;
+ }
+}
+
+int64 gc_get_collection_time()
+{
+ GC* gc = p_global_gc;
+ if (gc != NULL) {
+ return (int64) gc->time_collections;
+ } else {
+ return -1;
+ }
+}
+
void gc_vm_initialized()
{ return; }
Modified: harmony/enhanced/drlvm/trunk/vm/include/open/gc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/gc.h?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/gc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/gc.h Tue Apr 3 06:53:54 2007
@@ -521,6 +521,37 @@
GCExport void gc_class_prepared(Class_Handle ch, VTable_Handle vth);
+/*
+ * *****
+ * *
+ * * Routines to handle the <code>java.lang.management</code> requests.
+ * *
+ * *****
+ */
+
+/**
+ * <p>
+ * The number of collections that have been executed by this collector. A
+ * value of <code>-1</code> means that collection counts are undefined for
+ * this collector.
+ * </p>
+ *
+ * @return The number of collections executed.
+ */
+GCExport int64 gc_get_collection_count();
+
+/**
+ * <p>
+ * The approximate, cumulative time (in microseconds) spent executing
+ * collections for this collector.
+ * </p>
+ *
+ * @return The time spent collecting garbage.
+ */
+GCExport int64 gc_get_collection_time();
+
+
+
#else /* #if defined(USE_GC_STATIC) || defined(BUILDING_GC) */
/**
@@ -534,6 +565,8 @@
extern void (*gc_add_weak_root_set_entry)(Managed_Object_Handle *ref1, Boolean is_pinned,Boolean is_short_weak);
extern void (*gc_add_root_set_entry_managed_pointer)(void **slot, Boolean is_pinned);
extern void (*gc_class_prepared)(Class_Handle ch, VTable_Handle vth);
+extern int64 (*gc_get_collection_count)();
+extern int64 (*gc_get_collection_time)();
VMEXPORT extern void (*gc_force_gc)();
VMEXPORT extern int64 (*gc_free_memory)();
extern int (*gc_init)();
Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_vmem.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_vmem.h?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_vmem.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_vmem.h Tue Apr 3 06:53:54 2007
@@ -135,6 +135,26 @@
*/
APR_DECLARE(size_t *) port_vmem_page_sizes();
+/**
+ * Returns the amount of currently used memory in bytes.
+ */
+APR_DECLARE(size_t) port_vmem_used_size();
+
+/**
+ * Returns the amount of committed memory in bytes.
+ */
+APR_DECLARE(size_t) port_vmem_committed_size();
+
+/**
+ * Returns the amount of reserved memory in bytes.
+ */
+APR_DECLARE(size_t) port_vmem_reserved_size();
+
+/**
+ * Returns the maximum amount of memory which could be reserved in bytes.
+ */
+APR_DECLARE(size_t) port_vmem_max_size();
+
/** @} */
#ifdef __cplusplus
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/vmem/linux/port_vmem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/vmem/linux/port_vmem.c?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/vmem/linux/port_vmem.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/vmem/linux/port_vmem.c Tue Apr 3 06:53:54 2007
@@ -19,10 +19,12 @@
* @version $Revision: 1.1.2.1.4.3 $
*/
+#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>
#include <malloc.h>
+#include <limits.h>
#include "port_vmem.h"
#ifdef __cplusplus
@@ -129,6 +131,61 @@
}
}
return page_sizes;
+}
+
+APR_DECLARE(size_t) port_vmem_used_size(){
+ // TODO: Update this method when/if new common memory manager will be created
+ return port_vmem_committed_size();
+}
+
+APR_DECLARE(size_t) port_vmem_reserved_size(){
+ // TODO: Update this method when/if new common memory manager will be created
+ return port_vmem_committed_size();
+}
+
+APR_DECLARE(size_t) port_vmem_committed_size(){
+ char buf[PATH_MAX];
+
+ pid_t pid = getpid();
+ sprintf(buf, "/proc/%d/statm", pid);
+ FILE* file = fopen(buf, "rt");
+ if (!file) {
+ return port_vmem_page_sizes()[0];
+ }
+ size_t vmem;
+ int res = sscanf(buf, "%lu", &vmem);
+ return vmem * port_vmem_page_sizes()[0];
+}
+
+APR_DECLARE(size_t) port_vmem_max_size(){
+ char buf[PATH_MAX];
+
+ pid_t mypid = getpid();
+ sprintf(buf, "/proc/%d/stat", mypid);
+ FILE* file = fopen(buf, "rt");
+ if (!file) {
+ return UINT_MAX;
+ }
+ int pid, ppid, pgrp, session, tty_nr, tpgid, exit_signal, processor;
+ char comm[PATH_MAX];
+ char state;
+ unsigned long flags, minflt, cminflt, majflt, cmajflt, utime, stime,
+ starttime, vsize, rlim, startcode, endcode, startstack, kstkesp,
+ kstkeip, signal, blocked, sigignore, sigcatch, wchan, nswap, cnswap;
+ long cutime, cstime, priority, nice, unused, itrealvalue, rss;
+
+ int res = sscanf(buf, "%d %s %c %d %d %d %d %d %lu %lu %lu %lu "
+ "%lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu "
+ "%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %d %d",
+ &pid, &comm, &state, &ppid, &pgrp, &session, &tty_nr, &tpgid, &flags,
+ &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime, &cstime,
+ &priority, &nice, &unused, &itrealvalue, &starttime, &vsize, &rss, &rlim,
+ &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked,
+ &sigignore, &sigcatch, &wchan, &nswap, &cnswap, &exit_signal, &processor);
+ if (res < 25) { // rlim position
+ return UINT_MAX;
+ };
+ return rlim;
}
#ifdef __cplusplus
Modified: harmony/enhanced/drlvm/trunk/vm/port/src/vmem/win/port_vmem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/vmem/win/port_vmem.c?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/vmem/win/port_vmem.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/vmem/win/port_vmem.c Tue Apr 3 06:53:54 2007
@@ -20,6 +20,7 @@
*/
#include <windows.h>
+#include <psapi.h>
#include "port_vmem.h"
#undef LOG_DOMAIN
@@ -213,6 +214,34 @@
page_sizes[0] = si.dwPageSize;
}
return page_sizes;
+}
+
+APR_DECLARE(size_t) port_vmem_used_size(){
+ return port_vmem_committed_size();
+}
+
+APR_DECLARE(size_t) port_vmem_committed_size(){
+ // TODO: should return summarized commits instead of usage.
+ PROCESS_MEMORY_COUNTERS pmc;
+ if ( GetProcessMemoryInfo( GetCurrentProcess(), &pmc, sizeof(pmc)) ) {
+ return (pmc.QuotaNonPagedPoolUsage + pmc.QuotaPagedPoolUsage) * 1024;
+ } else {
+ return (size_t)0;
+ }
+}
+
+APR_DECLARE(size_t) port_vmem_reserved_size(){
+ // TODO: should return summarized reservaition instead of peak.
+ return port_vmem_committed_size();
+}
+
+APR_DECLARE(size_t) port_vmem_max_size(){
+ PERFORMANCE_INFORMATION pi;
+ if ( GetPerformanceInfo( &pi, sizeof(pi)) ) {
+ return (pi.CommitLimit - pi.CommitTotal) * pi.PageSize + port_vmem_committed_size();
+ } else {
+ return (size_t)0;
+ }
}
#ifdef __cplusplus
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/environment.h Tue Apr 3 06:53:54 2007
@@ -248,6 +248,31 @@
apr_time_t total_compilation_time;
/**
+ * Total loaded class count
+ */
+ unsigned total_loaded_class_count;
+
+ /**
+ * Total unloaded class count
+ */
+ unsigned unloaded_class_count;
+
+ /**
+ * Total unloaded class count
+ */
+ jboolean class_loading_verbose;
+
+ /**
+ * The initial amount of Java heap memory (bytes)
+ */
+ size_t init_gc_used_memory;
+
+ /**
+ * The initial amount of used memory (bytes)
+ */
+ size_t init_used_memory;
+
+ /**
* The VM state. See <code>VM_STATE</code> enum above.
*/
volatile int vm_state;
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Environment.cpp Tue Apr 3 06:53:54 2007
@@ -45,6 +45,10 @@
dcList(NULL),
assert_reg(NULL),
vm_methods(NULL),
+total_loaded_class_count(0),
+unloaded_class_count(0),
+class_loading_verbose(false),
+total_compilation_time(0),
bootstrapping(false),
ready_for_exceptions(false)
{
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Tue Apr 3 06:53:54 2007
@@ -106,7 +106,10 @@
}
if (GetLoadedClasses())
+ {
+ VM_Global_State::loader_env->unloaded_class_count += GetLoadedClasses()->GetItemCount();
delete GetLoadedClasses();
+ }
if (GetLoadingClasses())
delete GetLoadingClasses();
if (GetReportedClasses())
@@ -318,6 +321,7 @@
{
jvmti_send_class_load_event(env, clss);
}
+ ++(env->total_loaded_class_count);
return clss;
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/dll_gc.cpp Tue Apr 3 06:53:54 2007
@@ -79,6 +79,8 @@
void (*gc_add_root_set_entry_interior_pointer)(void **slot, int offset, Boolean is_pinned) = 0;
void (*gc_add_root_set_entry_managed_pointer)(void **slot, Boolean is_pinned) = 0;
void (*gc_class_prepared)(Class_Handle ch, VTable_Handle vth) = 0;
+int64 (*gc_get_collection_count)() = 0;
+int64 (*gc_get_collection_time)() = 0;
void (*gc_force_gc)() = 0;
int64 (*gc_free_memory)() = 0;
void (*gc_heap_slot_write_ref)(Managed_Object_Handle p_base_of_object_with_slot,
@@ -197,6 +199,8 @@
dllName,
(apr_dso_handle_sym_t)default_gc_add_root_set_entry_managed_pointer);
gc_class_prepared = (void (*)(Class_Handle ch, VTable_Handle vth)) getFunction(handle, "gc_class_prepared", dllName);
+ gc_get_collection_count = (int64 (*)()) getFunction(handle, "gc_get_collection_count", dllName);
+ gc_get_collection_time = (int64 (*)()) getFunction(handle, "gc_get_collection_time", dllName);
gc_force_gc = (void (*)()) getFunction(handle, "gc_force_gc", dllName);
gc_free_memory = (int64 (*)()) getFunction(handle, "gc_free_memory", dllName);
gc_heap_slot_write_ref = (void (*)(Managed_Object_Handle p_base_of_object_with_slot,
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Tue Apr 3 06:53:54 2007
@@ -26,7 +26,9 @@
#include <apr_pools.h>
#include <apr_thread_mutex.h>
#include <apr_time.h>
+#include "port_vmem.h"
+#include "open/gc.h"
#include "open/types.h"
#include "open/hythread.h"
#include "open/jthread.h"
@@ -487,7 +489,6 @@
}
vm_env->start_time = apr_time_now()/1000;
- vm_env->total_compilation_time = 0;
java_vm->functions = &java_vm_vtable;
java_vm->pool = vm_global_pool;
@@ -541,6 +542,12 @@
// Register created VM.
APR_RING_INSERT_TAIL(&GLOBAL_VMS, java_vm, JavaVM_Internal, link);
+
+ // Store Java heap memory size after initialization
+ vm_env->init_gc_used_memory = (size_t)gc_total_memory();
+
+ // Store native memory size after initialization
+ vm_env->init_used_memory = port_vmem_used_size();
status = JNI_OK;
done:
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.cpp Tue Apr 3 06:53:54 2007
@@ -28,6 +28,7 @@
*/
#include <cxxlog.h>
+#include "environment.h"
#include "org_apache_harmony_lang_management_ClassLoadingMXBeanImpl.h"
/*
* Class: org_apache_harmony_lang_management_ClassLoadingMXBeanImpl
@@ -35,12 +36,13 @@
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_getLoadedClassCountImpl
-(JNIEnv *, jobject)
+(JNIEnv * env, jobject this_bean)
{
- // TODO implement this method stub correctly
- TRACE2("management","getLoadedClassCountImpl stub invocation");
- return 1<<3;
-};
+ TRACE2("management", "ClassLoadingMXBeanImpl_getLoadedClassCountImpl invocation");
+ return (jint)
+ (Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_getTotalLoadedClassCountImpl(env, this_bean)
+ - Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_getUnloadedClassCountImpl(env, this_bean));
+}
/*
* Class: org_apache_harmony_lang_management_ClassLoadingMXBeanImpl
@@ -48,12 +50,13 @@
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_getTotalLoadedClassCountImpl
-(JNIEnv *, jobject)
+(JNIEnv * env, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getTotalLoadedClassCountImpl stub invocation");
- return 1<<4;
-};
+ TRACE2("management", "ClassLoadingMXBeanImpl_getTotalLoadedClassCountImpl invocation");
+ JavaVM * vm = NULL;
+ env->GetJavaVM(&vm);
+ return ((JavaVM_Internal*)vm)->vm_env->total_loaded_class_count;
+}
/*
* Class: org_apache_harmony_lang_management_ClassLoadingMXBeanImpl
@@ -61,15 +64,13 @@
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_getUnloadedClassCountImpl
-(JNIEnv *, jobject)
+(JNIEnv * env, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getUnloadedClassCountImpl stub invocation");
- return 1<<2;
-};
-
-jboolean ClassLoadingVerbose = JNI_FALSE;
-
+ TRACE2("management", "ClassLoadingMXBeanImpl_getUnloadedClassCountImpl invocation");
+ JavaVM * vm = NULL;
+ env->GetJavaVM(&vm);
+ return ((JavaVM_Internal*)vm)->vm_env->unloaded_class_count;
+}
/*
* Class: org_apache_harmony_lang_management_ClassLoadingMXBeanImpl
@@ -77,12 +78,13 @@
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_isVerboseImpl
-(JNIEnv *, jobject)
+(JNIEnv * env, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","ClassLoadingMXBeanImpl_isVerboseImpl stub invocation");
- return ClassLoadingVerbose;
-};
+ TRACE2("management", "ClassLoadingMXBeanImpl_isVerboseImpl invocation");
+ JavaVM * vm = NULL;
+ env->GetJavaVM(&vm);
+ return ((JavaVM_Internal*)vm)->vm_env->class_loading_verbose;
+}
/*
* Class: org_apache_harmony_lang_management_ClassLoadingMXBeanImpl
@@ -90,10 +92,18 @@
* Signature: (Z)V
*/
JNIEXPORT void JNICALL Java_org_apache_harmony_lang_management_ClassLoadingMXBeanImpl_setVerboseImpl
-(JNIEnv *, jobject, jboolean new_value)
+(JNIEnv * env, jobject, jboolean new_value)
{
- // TODO implement this method stub correctly
- TRACE2("management","ClassLoadingMXBeanImpl_setVerboseImpl stub invocation");
- ClassLoadingVerbose = new_value;
-};
+ TRACE2("management", "ClassLoadingMXBeanImpl_setVerboseImpl invocation");
+ JavaVM * vm = NULL;
+ env->GetJavaVM(&vm);
+ if (((JavaVM_Internal*)vm)->vm_env->class_loading_verbose != new_value) {
+ if (new_value) {
+ set_threshold(util::CLASS_LOGGER, INFO);
+ } else {
+ set_threshold(util::CLASS_LOGGER, WARN);
+ }
+ ((JavaVM_Internal*)vm)->vm_env->class_loading_verbose = new_value;
+ }
+}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.cpp Tue Apr 3 06:53:54 2007
@@ -28,6 +28,7 @@
*/
#include <cxxlog.h>
+#include <open/gc.h>
#include "org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl.h"
/*
@@ -36,9 +37,8 @@
JNIEXPORT jlong JNICALL
Java_org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl_getCollectionCountImpl(JNIEnv *, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getCollectionCountImpl stub invocation");
- return 7L;
+ TRACE2("management","GarbageCollectorMXBeanImpl_getCollectionCountImpl invocation");
+ return gc_get_collection_count();
};
/*
@@ -47,9 +47,8 @@
JNIEXPORT jlong JNICALL
Java_org_apache_harmony_lang_management_GarbageCollectorMXBeanImpl_getCollectionTimeImpl(JNIEnv *, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getCollectionTimeImpl stub invocation");
- return 2L<<17;
+ TRACE2("management","GarbageCollectorMXBeanImpl_getCollectionTimeImpl invocation");
+ return gc_get_collection_time()/1000;
};
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_MemoryMXBeanImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_MemoryMXBeanImpl.cpp?view=diff&rev=525155&r1=525154&r2=525155
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_MemoryMXBeanImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_MemoryMXBeanImpl.cpp Tue Apr 3 06:53:54 2007
@@ -28,8 +28,11 @@
*/
#include "org_apache_harmony_lang_management_MemoryMXBeanImpl.h"
+#include "open/gc.h"
#include <cxxlog.h>
#include "environment.h"
+#include "finalize.h"
+#include "port_vmem.h"
/* Header for class org_apache_harmony_lang_management_MemoryMXBeanImpl */
/*
@@ -41,8 +44,7 @@
JNIEXPORT void JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_createMemoryManagers
(JNIEnv * jenv_ext, jobject obj)
{
- // TODO implement this method stub correctly
- TRACE2("management","createMemoryManagers stub invocation");
+ TRACE2("management","MemoryMXBeanImpl_createMemoryManagers invocation");
JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
@@ -72,15 +74,17 @@
JNIEXPORT jobject JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_getHeapMemoryUsageImpl
(JNIEnv * jenv_ext, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getHeapMemoryUsageImpl stub invocation");
+ TRACE2("management","MemoryMXBeanImpl_getHeapMemoryUsageImpl invocation");
JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
- jlong init = 1L<<21;
- jlong used = 1L<<20;
- jlong committed = 1L<<20;
- jlong max = 1L<<22;
+ JavaVM * vm = NULL;
+ jenv_ext->GetJavaVM(&vm);
+
+ jlong init = ((JavaVM_Internal*)vm)->vm_env->init_gc_used_memory;
+ jlong used = gc_total_memory();
+ jlong committed = gc_total_memory();
+ jlong max = gc_max_memory();
jclass memoryUsageClazz =jenv->FindClass("java/lang/management/MemoryUsage");
if (jenv->ExceptionCheck()) {return NULL;};
@@ -101,16 +105,26 @@
JNIEXPORT jobject JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_getNonHeapMemoryUsageImpl
(JNIEnv * jenv_ext, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getNonHeapMemoryUsageImpl stub invocation");
+ TRACE2("management","MemoryMXBeanImpl_getNonHeapMemoryUsageImpl invocation");
Global_Env* genv = VM_Global_State::loader_env;
JNIEnv_Internal *jenv = (JNIEnv_Internal *)jenv_ext;
- jlong init = 1L<<21;
- jlong used = 1L<<20;
- jlong committed = 1L<<20;
- jlong max = 1L<<22;
+ JavaVM * vm = NULL;
+ jenv_ext->GetJavaVM(&vm);
+
+ jlong init = ((JavaVM_Internal*)vm)->vm_env->init_used_memory
+ - ((JavaVM_Internal*)vm)->vm_env->init_gc_used_memory;
+ if (init <= 0) {init = -1;}
+
+ jlong used = port_vmem_used_size() - gc_total_memory();
+ if (used < init) {used = init;}
+
+ jlong committed = port_vmem_committed_size() - gc_total_memory();
+ if (committed < used) {committed = used;}
+
+ jlong max = port_vmem_max_size() - gc_total_memory();
+ if (max < committed) {max = committed;}
jclass memoryUsageClazz =jenv->FindClass("java/lang/management/MemoryUsage");
if (jenv->ExceptionCheck()) {return NULL;};
@@ -131,12 +145,14 @@
JNIEXPORT jint JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_getObjectPendingFinalizationCountImpl
(JNIEnv *, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","getObjectPendingFinalizationCountImp stub invocation");
- return 20;
+ TRACE2("management","MemoryMXBeanImpl_getObjectPendingFinalizationCountImp invocation");
+ return vm_get_finalizable_objects_quantity();;
}
-jboolean memory_bean_verbose = JNI_TRUE;
+/**
+ * Stores current verbose state for the future request
+ */
+jboolean memory_bean_verbose = JNI_FALSE;
/*
* Class: org_apache_harmony_lang_management_MemoryMXBeanImpl
@@ -146,8 +162,7 @@
JNIEXPORT jboolean JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_isVerboseImpl
(JNIEnv *, jobject)
{
- // TODO implement this method stub correctly
- TRACE2("management","MemoryMXBeanImpl_isVerboseImpl stub invocation");
+ TRACE2("management","MemoryMXBeanImpl_MemoryMXBeanImpl_isVerboseImpl invocation");
return memory_bean_verbose;
};
@@ -159,8 +174,8 @@
JNIEXPORT void JNICALL Java_org_apache_harmony_lang_management_MemoryMXBeanImpl_setVerboseImpl
(JNIEnv *, jobject, jboolean newValue)
{
- // TODO implement this method stub correctly
- TRACE2("management","MemoryMXBeanImpl_setVerboseImpl stub invocation");
+ TRACE2("management","MemoryMXBeanImpl_MemoryMXBeanImpl_setVerboseImpl invocation");
+ // TODO: switch on/off management logging according to newValue
memory_bean_verbose = newValue;
};