Index: vm/vmcore/include/dll_jit_intf.h =================================================================== --- vm/vmcore/include/dll_jit_intf.h (revision 639268) +++ vm/vmcore/include/dll_jit_intf.h (working copy) @@ -42,6 +42,12 @@ //the library itself is unloaded by the pool destructor } + void dump_jit_statistics() { + if (_dump_jit_statistics != NULL) { + _dump_jit_statistics(this); + } + } + void next_command_line_argument(const char *option, const char *arg @@ -237,6 +243,8 @@ private: void (*_deinit)(JIT_Handle jit); + void (*_dump_jit_statistics)(JIT_Handle jit); + void (*_next_command_line_argument)(JIT_Handle jit, const char *option, Index: vm/vmcore/include/jit_intf_cpp.h =================================================================== --- vm/vmcore/include/jit_intf_cpp.h (revision 639268) +++ vm/vmcore/include/jit_intf_cpp.h (working copy) @@ -55,6 +55,12 @@ }; /** + * Dump JIT statistics, e.g. timer values. + */ + virtual void + dump_jit_statistics() {}; + + /** * Parse JIT command line arguments. */ virtual void Index: vm/vmcore/include/compile.h =================================================================== --- vm/vmcore/include/compile.h (revision 639268) +++ vm/vmcore/include/compile.h (working copy) @@ -26,6 +26,7 @@ extern JIT *jit_compilers[]; void vm_add_jit(JIT *jit); +void vm_dump_all_jits(); void vm_delete_all_jits(); /** Index: vm/vmcore/src/jit/dll_jit.cpp =================================================================== --- vm/vmcore/src/jit/dll_jit.cpp (revision 639268) +++ vm/vmcore/src/jit/dll_jit.cpp (working copy) @@ -80,6 +80,8 @@ GET_OPTIONAL_FUNCTION(fn, handle, "JIT_deinit"); _deinit = (void (*)(JIT_Handle)) fn; + GET_OPTIONAL_FUNCTION(fn, handle, "JIT_dump_jit_statistics"); + _dump_jit_statistics = (void (*)(JIT_Handle)) fn; GET_OPTIONAL_FUNCTION(fn, handle, "JIT_next_command_line_argument"); _next_command_line_argument = (void (*)(JIT_Handle, const char *, const char *)) fn; Index: vm/vmcore/src/jit/compile.cpp =================================================================== --- vm/vmcore/src/jit/compile.cpp (revision 639268) +++ vm/vmcore/src/jit/compile.cpp (working copy) @@ -179,6 +179,11 @@ assert(jit_compilers[max_jit_num + 1] == 0); } //vm_add_jit +void vm_dump_all_jits() { + for (JIT **jit = jit_compilers; *jit; jit++) { + (*jit)->dump_jit_statistics(); + } +} //vm_dump_all_jits void vm_delete_all_jits() { Index: vm/vmcore/src/init/vm_shutdown.cpp =================================================================== --- vm/vmcore/src/init/vm_shutdown.cpp (revision 639268) +++ vm/vmcore/src/init/vm_shutdown.cpp (working copy) @@ -210,6 +210,7 @@ #ifdef VM_STATS VM_Statistics::get_vm_stats().print(); #endif + vm_dump_all_jits(); } /** Index: vm/jitrino/src/vm/JITInterface.cpp =================================================================== --- vm/jitrino/src/vm/JITInterface.cpp (revision 639268) +++ vm/jitrino/src/vm/JITInterface.cpp (working copy) @@ -1,4 +1,4 @@ - /* +/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. @@ -106,8 +106,16 @@ Jitrino::DeInit(jit); } +// Called during exiting VM to dump statistics (timers) extern "C" JITEXPORT void +JIT_dump_jit_statistics(JIT_Handle jit) +{ + Jitrino::DumpStatistics(jit); +} + +extern "C" +JITEXPORT void JIT_next_command_line_argument(JIT_Handle jit, const char *name, const char *arg) { Index: vm/jitrino/src/main/Jitrino.cpp =================================================================== --- vm/jitrino/src/main/Jitrino.cpp (revision 639268) +++ vm/jitrino/src/main/Jitrino.cpp (working copy) @@ -156,27 +156,33 @@ return true; } -void Jitrino::DeInit(JIT_Handle jh) -{ +// it is called before DeInit to dump statsitics (timers) +void Jitrino::DumpStatistics(JIT_Handle jh) { + JITInstanceContext *jitInstance = getJITInstanceContext(jh); + assert(jitInstance != NULL); + + if (jitInstance == NULL || countWriter == 0) { + return; + } + jitInstance->getPMF().summTimes(summtimes); + delete countWriter; + countWriter = 0; +} + +void Jitrino::DeInit(JIT_Handle jh) { JITInstanceContext* jitInstance = getJITInstanceContext(jh); - if (jitInstance==NULL) { + + if (jitInstance == NULL) { assert(0); return; } - - if (countWriter != 0) { - jitInstance->getPMF().summTimes(summtimes); - } - jitInstance->getPMF().deinit(); - + jitInstance->getPMF().deinit(); killJITInstanceContext(jitInstance); - if (jitInstances->empty()) { - if (countWriter != 0) { + if (jitInstances->empty() && countWriter != 0) { delete countWriter; countWriter = 0; } - } } class FalseSessionAction: public SessionAction { Index: vm/jitrino/src/main/Jitrino.h =================================================================== --- vm/jitrino/src/main/Jitrino.h (revision 639268) +++ vm/jitrino/src/main/Jitrino.h (working copy) @@ -47,6 +47,7 @@ static void crash (const char* msg); static bool Init(JIT_Handle jit, const char* name); static void DeInit(JIT_Handle jit); + static void DumpStatistics(JIT_Handle jit); static bool CompileMethod(CompilationContext* compilationContext); static RuntimeInterface* getRuntimeInterface() {return runtimeInterface;} static MemoryManager& getGlobalMM() { return *global_mm; }