changeset 169:855a307943b1

Bug 2980: [REFACTORING][JDK 9] Change FullGC hookpoint for G1
author Yasumasa Suenaga <yasuenag@gmail.com>
date Thu, 02 Jun 2016 22:23:54 +0900
parents ce4c68bbea97
children 4e8b210515cc
files agent/src/heapstats-engines/overrideFunc.S agent/src/heapstats-engines/overrider.cpp agent/src/heapstats-engines/overrider.hpp agent/src/heapstats-engines/vmFunctions.cpp
diffstat 4 files changed, 24 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/heapstats-engines/overrideFunc.S	Thu Jun 02 22:23:44 2016 +0900
+++ b/agent/src/heapstats-engines/overrideFunc.S	Thu Jun 02 22:23:54 2016 +0900
@@ -181,10 +181,10 @@
 
 /* CMCleanUp::do_void() */
 OVERRIDE_DEFINE_WITHOUT_PERMCHECK(g1Event, 0, 1)
-/* G1CollectedHeap::gc_prologue(bool) */
-OVERRIDE_DEFINE_WITHOUT_PERMCHECK(g1Event, 1, 2)
-/* G1CollectedHeap::gc_epilogue(bool) */
-OVERRIDE_DEFINE_WITHOUT_PERMCHECK(g1Event, 2, 2)
+/* VM_G1CollectFull::doit_prologue() */
+OVERRIDE_DEFINE_WITHOUT_PERMCHECK(g1Event, 1, 1)
+/* VM_G1CollectFull::doit_epilogue() */
+OVERRIDE_DEFINE_WITHOUT_PERMCHECK(g1Event, 2, 1)
 
 /* for Klass relocation. */
 
--- a/agent/src/heapstats-engines/overrider.cpp	Thu Jun 02 22:23:44 2016 +0900
+++ b/agent/src/heapstats-engines/overrider.cpp	Thu Jun 02 22:23:54 2016 +0900
@@ -737,10 +737,10 @@
 THookFunctionInfo default_g1Event_hook[] = {
     HOOK_FUNC(g1Event, 0, "_ZTV9CMCleanUp", "_ZN9CMCleanUp7do_voidEv",
               &callbackForG1Cleanup),
-    HOOK_FUNC(g1Event, 1, "_ZTV15G1CollectedHeap",
-              "_ZN15G1CollectedHeap11gc_prologueEb", &callbackForG1Full),
-    HOOK_FUNC(g1Event, 2, "_ZTV15G1CollectedHeap",
-              "_ZN15G1CollectedHeap11gc_epilogueEb", &callbackForG1FullReturn),
+    HOOK_FUNC(g1Event, 1, "_ZTV16VM_G1CollectFull",
+              "_ZN15VM_GC_Operation13doit_prologueEv", &callbackForG1Full),
+    HOOK_FUNC(g1Event, 2, "_ZTV16VM_G1CollectFull",
+              "_ZN15VM_GC_Operation13doit_epilogueEv", &callbackForG1FullReturn),
     HOOK_FUNC_END};
 
 /*!
@@ -1703,8 +1703,9 @@
 
 /*!
  * \brief Callback function for before G1 GC cleanup.
+ * \param thisptr [in] this pointer of caller C++ instance.
  */
-void callbackForG1Cleanup(void) {
+void callbackForG1Cleanup(void *thisptr) {
   if (likely(g1FinishCallbackFunc != NULL)) {
     /* Invoke callback. */
     g1FinishCallbackFunc();
@@ -1716,16 +1717,9 @@
 
 /*!
  * \brief Callback function for before System.gc() on using G1GC.
- * \param isFull [in] Is this event FullGC?
+ * \param thisptr [in] this pointer of caller C++ instance.
  */
-void callbackForG1Full(bool isFull) {
-  /* This function must be processed when FullGC occurs.
-   * e.g. System.gc(), evacuation failure, etc...
-   */
-  if (!isFull) {
-    return;
-  }
-
+void callbackForG1Full(void *thisptr) {
   /*
    * Disable G1 callback function:
    *  OopClosure for typeArrayKlass is called by G1 FullCollection.
@@ -1739,16 +1733,9 @@
 
 /*!
  * \brief Callback function for after System.gc() on using G1GC.
- * \param isFull [in] Is this event FullGC?
+ * \param thisptr [in] this pointer of caller C++ instance.
  */
-void callbackForG1FullReturn(bool isFull) {
-  /* This function must be processed when FullGC occurs.
-   * e.g. System.gc(), evacuation failure, etc...
-   */
-  if (!isFull) {
-    return;
-  }
-
+void callbackForG1FullReturn(void *thisptr) {
   /* Restore G1 callback. */
   switchOverrideFunction(g1_hook, true);
 
--- a/agent/src/heapstats-engines/overrider.hpp	Thu Jun 02 22:23:44 2016 +0900
+++ b/agent/src/heapstats-engines/overrider.hpp	Thu Jun 02 22:23:54 2016 +0900
@@ -253,9 +253,9 @@
 extern "C" void callbackForDoAddr(void *oop);
 extern "C" void callbackForUpdatePtr(void *oop);
 extern "C" void callbackForJvmtiIterate(void *oop);
-extern "C" void callbackForG1Cleanup(void);
-extern "C" void callbackForG1Full(bool isFull);
-extern "C" void callbackForG1FullReturn(bool isFull);
+extern "C" void callbackForG1Cleanup(void *thisptr);
+extern "C" void callbackForG1Full(void *thisptr);
+extern "C" void callbackForG1FullReturn(void *thisptr);
 extern "C" void callbackForInnerGCStart(void);
 extern "C" void callbackForWatcherThreadRun(void);
 
--- a/agent/src/heapstats-engines/vmFunctions.cpp	Thu Jun 02 22:23:44 2016 +0900
+++ b/agent/src/heapstats-engines/vmFunctions.cpp	Thu Jun 02 22:23:54 2016 +0900
@@ -255,18 +255,20 @@
  * \return Result of this function.
  */
 bool TVMFunctions::getG1VTableFromSymbol(void) {
-/* Add vtable offset */
+  /* Add vtable offset */
+  if (jvmInfo->isAfterJDK9()) {
 #ifdef __LP64__
-  VTableForTypeArrayOopClosure[0] =
+    VTableForTypeArrayOopClosure[0] =
       incAddress(symFinder->findSymbol("_ZTV14G1CMOopClosure"), 16);
-  VTableForTypeArrayOopClosure[1] =
+    VTableForTypeArrayOopClosure[1] =
       incAddress(symFinder->findSymbol("_ZTV23G1RootRegionScanClosure"), 16);
 #else
-  VTableForTypeArrayOopClosure[0] =
+    VTableForTypeArrayOopClosure[0] =
       incAddress(symFinder->findSymbol("_ZTV14G1CMOopClosure"), 8);
-  VTableForTypeArrayOopClosure[1] =
+    VTableForTypeArrayOopClosure[1] =
       incAddress(symFinder->findSymbol("_ZTV23G1RootRegionScanClosure"), 8);
 #endif
+  }
 
   if (unlikely(VTableForTypeArrayOopClosure[0] == NULL ||
                VTableForTypeArrayOopClosure[1] == NULL)) {