Index: vm/vmcore/include/environment.h =================================================================== --- vm/vmcore/include/environment.h (revision 513236) +++ vm/vmcore/include/environment.h (working copy) @@ -241,6 +241,11 @@ * VM initialization timestamp */ apr_time_t start_time; + + /** + * Total method compilation time in msec + */ + long total_compilation_time; /** * The VM state. See VM_STATE enum above. Index: vm/vmcore/src/jni/jni.cpp =================================================================== --- vm/vmcore/src/jni/jni.cpp (revision 513236) +++ vm/vmcore/src/jni/jni.cpp (working copy) @@ -485,6 +485,7 @@ } vm_env->start_time = apr_time_now()/1000; + vm_env->total_compilation_time = 0L; java_vm->functions = &java_vm_vtable; java_vm->pool = vm_global_pool; Index: vm/vmcore/src/jit/compile.cpp =================================================================== --- vm/vmcore/src/jit/compile.cpp (revision 513236) +++ vm/vmcore/src/jit/compile.cpp (working copy) @@ -615,6 +615,9 @@ JIT_Result compile_do_compilation_jit(Method* method, JIT* jit) { + // Time stamp for counting the total compilation time + apr_time_t start; + Global_Env * vm_env = VM_Global_State::loader_env; assert(method); @@ -642,12 +645,17 @@ ch.env = VM_Global_State::loader_env; ch.jit = jit; + start = apr_time_now(); + TRACE("compile_do_compilation_jit(): calling jit->compile_method_with_params() for method " << method ); JIT_Result res = jit->compile_method_with_params(&ch, method, flags); TRACE("compile_do_compilation_jit(): returned from jit->compile_method_with_params() for method " << method ); + // Convertion from microseconds to milliseconds + vm_env->total_compilation_time += (long)((apr_time_now() - start)/1000); + if (JIT_SUCCESS != res) { if (!parallel_jit) { vm_env->p_jit_a_method_lock->_unlock(); Index: vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_CompilationMXBeanImpl.cpp =================================================================== --- vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_CompilationMXBeanImpl.cpp (revision 513236) +++ vm/vmcore/src/kernel_classes/native/org_apache_harmony_lang_management_CompilationMXBeanImpl.cpp (working copy) @@ -28,6 +28,8 @@ */ #include +#include "interpreter.h" +#include "environment.h" #include "org_apache_harmony_lang_management_CompilationMXBeanImpl.h" /* * Class: org_apache_harmony_lang_management_CompilationMXBeanImpl @@ -37,9 +39,8 @@ JNIEXPORT jboolean JNICALL Java_org_apache_harmony_lang_management_CompilationMXBeanImpl_isJITEnabled (JNIEnv *, jclass) { - // TODO implement this method stub correctly - TRACE2("management","isJITEnabled stub invocation"); - return JNI_TRUE; + TRACE2("management","CompilationMXBeanImpl_isJITEnabled called"); + return interpreter_enabled() ? JNI_FALSE : JNI_TRUE; }; /* @@ -48,11 +49,12 @@ * Signature: ()J */ JNIEXPORT jlong JNICALL Java_org_apache_harmony_lang_management_CompilationMXBeanImpl_getTotalCompilationTimeImpl -(JNIEnv *, jobject) +(JNIEnv * env, jobject) { - // TODO implement this method stub correctly - TRACE2("management","getTotalCompilationTimeImpl stub invocation"); - return 1L<<5; + TRACE2("management","CompilationMXBeanImpl_getTotalCompilationTimeImpl called"); + JavaVM * vm = NULL; + env->GetJavaVM(&vm); + return ((JavaVM_Internal*)vm)->vm_env->total_compilation_time; }; /* @@ -63,8 +65,7 @@ JNIEXPORT jboolean JNICALL Java_org_apache_harmony_lang_management_CompilationMXBeanImpl_isCompilationTimeMonitoringSupportedImpl (JNIEnv *, jobject) { - // TODO implement this method stub correctly - TRACE2("management","isCompilationTimeMonitoringSupportedImpl stub invocation"); + TRACE2("management","CompilationMXBeanImpl_isCompilationTimeMonitoringSupportedImpl called"); return JNI_TRUE; };