#include "config.h"
+#if defined(ENABLE_OPAGENT)
+#include "vm/jit/oprofile-agent.hpp"
+#endif
+
/**
* Hook points are inline functions acting as probes scattered throughout
void breakpoint (Breakpoint *bp);
void class_linked (classinfo *c);
void class_loaded (classinfo *c);
+ void jit_generated (methodinfo *m, codeinfo *code);
+ void jit_recycled (methodinfo *m, codeinfo *code);
void method_enter (methodinfo *m);
void method_exit (methodinfo *m);
void method_unwind (methodinfo *m);
void thread_start (threadobject *t);
void thread_end (threadobject *t);
void vm_init ();
+ void vm_preinit ();
+ void vm_shutdown ();
}
/* nop */
}
+/**
+ * Hook point just after code was generated. Note that one method can have
+ * multiple code realizations, the hook is fired for each of them. The code
+ * was not yet executed.
+ *
+ * @param m The method for which code was generated.
+ * @param code The fully initialized codeinfo for the generated code.
+ */
+inline void Hook::jit_generated(methodinfo *m, codeinfo *code)
+{
+#if defined(ENABLE_OPAGENT)
+ if (opt_EnableOpagent)
+ OprofileAgent::newmethod(m);
+#endif
+}
+
inline void Hook::method_enter(methodinfo *m)
{
/* nop */
/* nop */
}
+/**
+ * Hook point after the VM is initialized. At this point the VM is fully
+ * operating and ready to execute Java code. Final intializations and thread
+ * startup should be done here.
+ */
inline void Hook::vm_init()
{
/* nop */
}
+/**
+ * Hook point before the VM is initialized. At this point the VM can not
+ * yet execute Java code but some central native subsystems are initialized.
+ * Only basic initialization steps should be done here.
+ */
+inline void Hook::vm_preinit()
+{
+#if defined(ENABLE_OPAGENT)
+ if (opt_EnableOpagent)
+ OprofileAgent::initialize();
+#endif
+}
+
+/**
+ * Hook point before the VM is actually destroyed. At this point the VM is
+ * still running, but all non-daemon threads have terminated and resources
+ * are ready to be reclaimed. Final cleanup tasks should be done here.
+ */
+inline void Hook::vm_shutdown()
+{
+#if defined(ENABLE_OPAGENT)
+ if (opt_EnableOpagent)
+ OprofileAgent::close();
+#endif
+}
+
#endif /* _HOOK_HPP */
#include "vm/class.hpp"
#include "vm/global.h"
#include "vm/globals.hpp"
+#include "vm/hook.hpp"
#include "vm/initialize.hpp"
#include "vm/loader.hpp"
#include "vm/method.hpp"
#include "vm/jit/stack.h"
#include "vm/jit/stubs.hpp"
-#if defined(ENABLE_OPAGENT)
-#include "vm/jit/oprofile-agent.hpp"
-#endif
-
#include "vm/jit/allocator/simplereg.h"
#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
# include "vm/jit/allocator/lsra.h"
#else
intrp_md_init();
#endif
-
-#if defined(ENABLE_OPAGENT)
- if (opt_EnableOpagent)
- OprofileAgent::initialize();
-#endif
}
void jit_close(void)
{
-#if defined(ENABLE_OPAGENT)
- if (opt_EnableOpagent)
- OprofileAgent::close();
-#endif
+ /* nop */
}
compilingtime_stop();
#endif
-#if defined(ENABLE_OPAGENT)
- if (opt_EnableOpagent)
- OprofileAgent::newmethod(m);
-#endif
+ // Hook point just after code was generated.
+ Hook::jit_generated(m, m->code);
/* leave the monitor */
compilingtime_stop();
#endif
-#if defined(ENABLE_OPAGENT)
- if (opt_EnableOpagent)
- OprofileAgent::newmethod(m);
-#endif
+ // Hook point just after code was generated.
+ Hook::jit_generated(m, m->code);
DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");