aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/services
diff options
context:
space:
mode:
authorfparain <none@none>2011-05-12 10:30:11 -0700
committerfparain <none@none>2011-05-12 10:30:11 -0700
commitf31a92a1336fbd929e82bf150ef381eca44cb584 (patch)
tree77c8a1519d6e56b8727c48039bbc463f51795dee /src/share/vm/services
parent0466ad091bb01c844a5d7d16be3a34c2f6319457 (diff)
7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
Summary: Add a notification to the GarbageCollectorMXBeans Reviewed-by: acorn, mchung
Diffstat (limited to 'src/share/vm/services')
-rw-r--r--src/share/vm/services/gcNotifier.cpp216
-rw-r--r--src/share/vm/services/gcNotifier.hpp69
-rw-r--r--src/share/vm/services/jmm.h5
-rw-r--r--src/share/vm/services/management.cpp29
-rw-r--r--src/share/vm/services/management.hpp4
-rw-r--r--src/share/vm/services/memoryManager.cpp10
-rw-r--r--src/share/vm/services/memoryManager.hpp5
-rw-r--r--src/share/vm/services/memoryService.cpp16
-rw-r--r--src/share/vm/services/memoryService.hpp18
9 files changed, 359 insertions, 13 deletions
diff --git a/src/share/vm/services/gcNotifier.cpp b/src/share/vm/services/gcNotifier.cpp
new file mode 100644
index 000000000..3f07668b3
--- /dev/null
+++ b/src/share/vm/services/gcNotifier.cpp
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "classfile/vmSymbols.hpp"
+#include "oops/oop.inline.hpp"
+#include "runtime/interfaceSupport.hpp"
+#include "runtime/java.hpp"
+#include "runtime/javaCalls.hpp"
+#include "runtime/mutex.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "services/gcNotifier.hpp"
+#include "services/management.hpp"
+#include "services/memoryService.hpp"
+#include "memoryManager.hpp"
+#include "memory/oopFactory.hpp"
+
+GCNotificationRequest *GCNotifier::first_request = NULL;
+GCNotificationRequest *GCNotifier::last_request = NULL;
+
+void GCNotifier::pushNotification(GCMemoryManager *mgr, const char *action, const char *cause) {
+ // Make a copy of the last GC statistics
+ // GC may occur between now and the creation of the notification
+ int num_pools = MemoryService::num_memory_pools();
+ GCStatInfo* stat = new GCStatInfo(num_pools);
+ mgr->get_last_gc_stat(stat);
+ GCNotificationRequest *request = new GCNotificationRequest(os::javaTimeMillis(),mgr,action,cause,stat);
+ addRequest(request);
+ }
+
+void GCNotifier::addRequest(GCNotificationRequest *request) {
+ MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
+ if(first_request == NULL) {
+ first_request = request;
+ } else {
+ last_request->next = request;
+ }
+ last_request = request;
+ Service_lock->notify_all();
+}
+
+GCNotificationRequest *GCNotifier::getRequest() {
+ MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
+ GCNotificationRequest *request = first_request;
+ if(first_request != NULL) {
+ first_request = first_request->next;
+ }
+ return request;
+}
+
+bool GCNotifier::has_event() {
+ return first_request != NULL;
+}
+
+static Handle getGcInfoBuilder(GCMemoryManager *gcManager,TRAPS) {
+
+ klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK_NH);
+ instanceKlassHandle gcMBeanKlass (THREAD, k);
+
+ instanceOop i = gcManager->get_memory_manager_instance(THREAD);
+ instanceHandle ih(THREAD, i);
+
+ JavaValue result(T_OBJECT);
+ JavaCallArguments args(ih);
+
+ JavaCalls::call_virtual(&result,
+ gcMBeanKlass,
+ vmSymbols::getGcInfoBuilder_name(),
+ vmSymbols::getGcInfoBuilder_signature(),
+ &args,
+ CHECK_NH);
+ return Handle(THREAD,(oop)result.get_jobject());
+
+}
+
+static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {
+
+ // Fill the arrays of MemoryUsage objects with before and after GC
+ // per pool memory usage
+
+ klassOop muKlass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH); objArrayOop bu = oopFactory::new_objArray( muKlass,MemoryService::num_memory_pools(), CHECK_NH);
+ objArrayHandle usage_before_gc_ah(THREAD, bu);
+ objArrayOop au = oopFactory::new_objArray(muKlass,MemoryService::num_memory_pools(), CHECK_NH);
+ objArrayHandle usage_after_gc_ah(THREAD, au);
+
+ for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
+ Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
+ Handle after_usage;
+
+ MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
+ if (u.max_size() == 0 && u.used() > 0) {
+ // If max size == 0, this pool is a survivor space.
+ // Set max size = -1 since the pools will be swapped after GC.
+ MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
+ after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
+ } else {
+ after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
+ }
+ usage_before_gc_ah->obj_at_put(i, before_usage());
+ usage_after_gc_ah->obj_at_put(i, after_usage());
+ }
+
+ // Current implementation only has 1 attribute (number of GC threads)
+ // The type is 'I'
+ objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
+ objArrayHandle extra_array (THREAD, extra_args_array);
+ klassOop itKlass= SystemDictionary::Integer_klass();
+ instanceKlassHandle intK(THREAD, itKlass);
+
+ instanceHandle extra_arg_val = intK->allocate_instance_handle(CHECK_NH);
+
+ {
+ JavaValue res(T_VOID);
+ JavaCallArguments argsInt;
+ argsInt.push_oop(extra_arg_val);
+ argsInt.push_int(gcManager->num_gc_threads());
+
+ JavaCalls::call_special(&res,
+ intK,
+ vmSymbols::object_initializer_name(),
+ vmSymbols::int_void_signature(),
+ &argsInt,
+ CHECK_NH);
+ }
+ extra_array->obj_at_put(0,extra_arg_val());
+
+ klassOop gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
+ instanceKlassHandle ik (THREAD,gcInfoklass);
+
+ Handle gcInfo_instance = ik->allocate_instance_handle(CHECK_NH);
+
+ JavaValue constructor_result(T_VOID);
+ JavaCallArguments constructor_args(16);
+ constructor_args.push_oop(gcInfo_instance);
+ constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
+ constructor_args.push_long(gcStatInfo->gc_index());
+ constructor_args.push_long(gcStatInfo->start_time());
+ constructor_args.push_long(gcStatInfo->end_time());
+ constructor_args.push_oop(usage_before_gc_ah);
+ constructor_args.push_oop(usage_after_gc_ah);
+ constructor_args.push_oop(extra_array);
+
+ JavaCalls::call_special(&constructor_result,
+ ik,
+ vmSymbols::object_initializer_name(),
+ vmSymbols::com_sun_management_GcInfo_constructor_signature(),
+ &constructor_args,
+ CHECK_NH);
+
+ return Handle(gcInfo_instance());
+}
+
+void GCNotifier::sendNotification(TRAPS) {
+ ResourceMark rm(THREAD);
+ GCNotificationRequest *request = getRequest();
+ if(request != NULL) {
+ Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo,THREAD);
+
+ Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
+ Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
+ Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
+
+ klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
+ instanceKlassHandle gc_mbean_klass (THREAD, k);
+
+ instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
+ instanceHandle gc_mbean_h(THREAD, gc_mbean);
+ if (!gc_mbean_h->is_a(k)) {
+ THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+ "This GCMemoryManager doesn't have a GarbageCollectorMXBean");
+ }
+
+ JavaValue result(T_VOID);
+ JavaCallArguments args(gc_mbean_h);
+ args.push_long(request->timestamp);
+ args.push_oop(objName);
+ args.push_oop(objAction);
+ args.push_oop(objCause);
+ args.push_oop(objGcInfo);
+
+ JavaCalls::call_virtual(&result,
+ gc_mbean_klass,
+ vmSymbols::createGCNotification_name(),
+ vmSymbols::createGCNotification_signature(),
+ &args,
+ CHECK);
+ if (HAS_PENDING_EXCEPTION) {
+ CLEAR_PENDING_EXCEPTION;
+ }
+
+ delete request;
+ }
+}
+
diff --git a/src/share/vm/services/gcNotifier.hpp b/src/share/vm/services/gcNotifier.hpp
new file mode 100644
index 000000000..7e0d8462e
--- /dev/null
+++ b/src/share/vm/services/gcNotifier.hpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_SERVICES_GCNOTIFIER_HPP
+#define SHARE_VM_SERVICES_GCNOTIFIER_HPP
+
+#include "memory/allocation.hpp"
+#include "services/memoryPool.hpp"
+#include "services/memoryService.hpp"
+#include "services/memoryManager.hpp"
+
+class GCNotificationRequest : public CHeapObj {
+ friend class GCNotifier;
+ GCNotificationRequest *next;
+ jlong timestamp;
+ GCMemoryManager *gcManager;
+ const char *gcAction;
+ const char *gcCause;
+ GCStatInfo *gcStatInfo;
+public:
+ GCNotificationRequest(jlong ts, GCMemoryManager *manager, const char*action, const char *cause,GCStatInfo *info) {
+ next = NULL;
+ timestamp = ts;
+ gcManager = manager;
+ gcAction = action;
+ gcCause = cause;
+ gcStatInfo = info;
+ }
+
+ ~GCNotificationRequest() {
+ delete gcStatInfo;
+ }
+};
+
+class GCNotifier : public AllStatic {
+ friend class ServiceThread;
+private:
+ static GCNotificationRequest *first_request;
+ static GCNotificationRequest *last_request;
+ static void addRequest(GCNotificationRequest *request);
+ static GCNotificationRequest *getRequest();
+public:
+ static void pushNotification(GCMemoryManager *manager, const char *action, const char *cause);
+ static bool has_event();
+ static void sendNotification(TRAPS);
+};
+
+#endif // SHARE_VM_SERVICES_GCNOTIFIER_HPP
diff --git a/src/share/vm/services/jmm.h b/src/share/vm/services/jmm.h
index df08124e5..d91d87847 100644
--- a/src/share/vm/services/jmm.h
+++ b/src/share/vm/services/jmm.h
@@ -48,7 +48,7 @@ enum {
JMM_VERSION_1_0 = 0x20010000,
JMM_VERSION_1_1 = 0x20010100, // JDK 6
JMM_VERSION_1_2 = 0x20010200, // JDK 7
- JMM_VERSION = 0x20010200
+ JMM_VERSION = 0x20010201
};
typedef struct {
@@ -293,6 +293,9 @@ typedef struct jmmInterface_1_ {
jlongArray ids,
jboolean lockedMonitors,
jboolean lockedSynchronizers);
+ void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
+ jobject mgr,
+ jboolean enabled);
} JmmInterface;
#ifdef __cplusplus
diff --git a/src/share/vm/services/management.cpp b/src/share/vm/services/management.cpp
index 3c4f1481c..9c8116c89 100644
--- a/src/share/vm/services/management.cpp
+++ b/src/share/vm/services/management.cpp
@@ -42,6 +42,7 @@
#include "services/classLoadingService.hpp"
#include "services/heapDumper.hpp"
#include "services/lowMemoryDetector.hpp"
+#include "services/gcNotifier.hpp"
#include "services/management.hpp"
#include "services/memoryManager.hpp"
#include "services/memoryPool.hpp"
@@ -60,6 +61,8 @@ klassOop Management::_memoryPoolMXBean_klass = NULL;
klassOop Management::_memoryManagerMXBean_klass = NULL;
klassOop Management::_garbageCollectorMXBean_klass = NULL;
klassOop Management::_managementFactory_klass = NULL;
+klassOop Management::_garbageCollectorImpl_klass = NULL;
+klassOop Management::_gcInfo_klass = NULL;
jmmOptionalSupport Management::_optional_support = {0};
TimeStamp Management::_stamp;
@@ -179,6 +182,8 @@ void Management::oops_do(OopClosure* f) {
f->do_oop((oop*) &_memoryManagerMXBean_klass);
f->do_oop((oop*) &_garbageCollectorMXBean_klass);
f->do_oop((oop*) &_managementFactory_klass);
+ f->do_oop((oop*) &_garbageCollectorImpl_klass);
+ f->do_oop((oop*) &_gcInfo_klass);
}
klassOop Management::java_lang_management_ThreadInfo_klass(TRAPS) {
@@ -230,6 +235,20 @@ klassOop Management::sun_management_ManagementFactory_klass(TRAPS) {
return _managementFactory_klass;
}
+klassOop Management::sun_management_GarbageCollectorImpl_klass(TRAPS) {
+ if (_garbageCollectorImpl_klass == NULL) {
+ _garbageCollectorImpl_klass = load_and_initialize_klass(vmSymbols::sun_management_GarbageCollectorImpl(), CHECK_NULL);
+ }
+ return _garbageCollectorImpl_klass;
+}
+
+klassOop Management::com_sun_management_GcInfo_klass(TRAPS) {
+ if (_gcInfo_klass == NULL) {
+ _gcInfo_klass = load_and_initialize_klass(vmSymbols::com_sun_management_GcInfo(), CHECK_NULL);
+ }
+ return _gcInfo_klass;
+}
+
static void initialize_ThreadInfo_constructor_arguments(JavaCallArguments* args, ThreadSnapshot* snapshot, TRAPS) {
Handle snapshot_thread(THREAD, snapshot->threadObj());
@@ -2056,6 +2075,13 @@ JVM_ENTRY(void, jmm_GetLastGCStat(JNIEnv *env, jobject obj, jmmGCStat *gc_stat))
}
JVM_END
+JVM_ENTRY(void, jmm_SetGCNotificationEnabled(JNIEnv *env, jobject obj, jboolean enabled))
+ ResourceMark rm(THREAD);
+ // Get the GCMemoryManager
+ GCMemoryManager* mgr = get_gc_memory_manager_from_jobject(obj, CHECK);
+ mgr->set_notification_enabled(enabled?true:false);
+JVM_END
+
// Dump heap - Returns 0 if succeeds.
JVM_ENTRY(jint, jmm_DumpHeap0(JNIEnv *env, jstring outputfile, jboolean live))
#ifndef SERVICES_KERNEL
@@ -2122,7 +2148,8 @@ const struct jmmInterface_1_ jmm_interface = {
jmm_FindDeadlockedThreads,
jmm_SetVMGlobal,
NULL,
- jmm_DumpThreads
+ jmm_DumpThreads,
+ jmm_SetGCNotificationEnabled
};
void* Management::get_jmm_interface(int version) {
diff --git a/src/share/vm/services/management.hpp b/src/share/vm/services/management.hpp
index 1598f2261..9d97988df 100644
--- a/src/share/vm/services/management.hpp
+++ b/src/share/vm/services/management.hpp
@@ -49,6 +49,8 @@ private:
static klassOop _memoryManagerMXBean_klass;
static klassOop _garbageCollectorMXBean_klass;
static klassOop _managementFactory_klass;
+ static klassOop _garbageCollectorImpl_klass;
+ static klassOop _gcInfo_klass;
static klassOop load_and_initialize_klass(Symbol* sh, TRAPS);
@@ -86,6 +88,8 @@ public:
static klassOop java_lang_management_GarbageCollectorMXBean_klass(TRAPS);
static klassOop sun_management_Sensor_klass(TRAPS);
static klassOop sun_management_ManagementFactory_klass(TRAPS);
+ static klassOop sun_management_GarbageCollectorImpl_klass(TRAPS);
+ static klassOop com_sun_management_GcInfo_klass(TRAPS);
static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, TRAPS);
static instanceOop create_thread_info_instance(ThreadSnapshot* snapshot, objArrayHandle monitors_array, typeArrayHandle depths_array, objArrayHandle synchronizers_array, TRAPS);
diff --git a/src/share/vm/services/memoryManager.cpp b/src/share/vm/services/memoryManager.cpp
index e13b64376..3977a4562 100644
--- a/src/share/vm/services/memoryManager.cpp
+++ b/src/share/vm/services/memoryManager.cpp
@@ -33,6 +33,7 @@
#include "services/memoryManager.hpp"
#include "services/memoryPool.hpp"
#include "services/memoryService.hpp"
+#include "services/gcNotifier.hpp"
#include "utilities/dtrace.hpp"
HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int,
@@ -202,6 +203,7 @@ GCMemoryManager::GCMemoryManager() : MemoryManager() {
_last_gc_lock = new Mutex(Mutex::leaf, "_last_gc_lock", true);
_current_gc_stat = NULL;
_num_gc_threads = 1;
+ _notification_enabled = false;
}
GCMemoryManager::~GCMemoryManager() {
@@ -250,7 +252,8 @@ void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
// to ensure the current gc stat is placed in _last_gc_stat.
void GCMemoryManager::gc_end(bool recordPostGCUsage,
bool recordAccumulatedGCTime,
- bool recordGCEndTime, bool countCollection) {
+ bool recordGCEndTime, bool countCollection,
+ GCCause::Cause cause) {
if (recordAccumulatedGCTime) {
_accumulated_timer.stop();
}
@@ -283,6 +286,11 @@ void GCMemoryManager::gc_end(bool recordPostGCUsage,
pool->set_last_collection_usage(usage);
LowMemoryDetector::detect_after_gc_memory(pool);
}
+ if(is_notification_enabled()) {
+ bool isMajorGC = this == MemoryService::get_major_gc_manager();
+ GCNotifier::pushNotification(this, isMajorGC ? "end of major GC" : "end of minor GC",
+ GCCause::to_string(cause));
+ }
}
if (countCollection) {
_num_collections++;
diff --git a/src/share/vm/services/memoryManager.hpp b/src/share/vm/services/memoryManager.hpp
index 4a3eadb54..cd4d953bf 100644
--- a/src/share/vm/services/memoryManager.hpp
+++ b/src/share/vm/services/memoryManager.hpp
@@ -166,6 +166,7 @@ private:
Mutex* _last_gc_lock;
GCStatInfo* _current_gc_stat;
int _num_gc_threads;
+ volatile bool _notification_enabled;
public:
GCMemoryManager();
~GCMemoryManager();
@@ -181,7 +182,7 @@ public:
void gc_begin(bool recordGCBeginTime, bool recordPreGCUsage,
bool recordAccumulatedGCTime);
void gc_end(bool recordPostGCUsage, bool recordAccumulatedGCTime,
- bool recordGCEndTime, bool countCollection);
+ bool recordGCEndTime, bool countCollection, GCCause::Cause cause);
void reset_gc_stat() { _num_collections = 0; _accumulated_timer.reset(); }
@@ -189,6 +190,8 @@ public:
// the collection count. Zero signifies no gc has taken place.
size_t get_last_gc_stat(GCStatInfo* dest);
+ void set_notification_enabled(bool enabled) { _notification_enabled = enabled; }
+ bool is_notification_enabled() { return _notification_enabled; }
virtual MemoryManager::Name kind() = 0;
};
diff --git a/src/share/vm/services/memoryService.cpp b/src/share/vm/services/memoryService.cpp
index eca4d6418..d1bb9c2d6 100644
--- a/src/share/vm/services/memoryService.cpp
+++ b/src/share/vm/services/memoryService.cpp
@@ -565,7 +565,8 @@ void MemoryService::gc_begin(bool fullGC, bool recordGCBeginTime,
void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
bool recordAccumulatedGCTime,
- bool recordGCEndTime, bool countCollection) {
+ bool recordGCEndTime, bool countCollection,
+ GCCause::Cause cause) {
GCMemoryManager* mgr;
if (fullGC) {
@@ -577,7 +578,7 @@ void MemoryService::gc_end(bool fullGC, bool recordPostGCUsage,
// register the GC end statistics and memory usage
mgr->gc_end(recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
- countCollection);
+ countCollection, cause);
}
void MemoryService::oops_do(OopClosure* f) {
@@ -633,7 +634,7 @@ Handle MemoryService::create_MemoryUsage_obj(MemoryUsage usage, TRAPS) {
// gc manager (so _fullGC is set to false ) and for other generation kinds
// doing mark-sweep-compact uses major gc manager (so _fullGC is set
// to true).
-TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind) {
+TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause) {
switch (kind) {
case Generation::DefNew:
#ifndef SERIALGC
@@ -654,9 +655,10 @@ TraceMemoryManagerStats::TraceMemoryManagerStats(Generation::Name kind) {
}
// this has to be called in a stop the world pause and represent
// an entire gc pause, start to finish:
- initialize(_fullGC, true, true, true, true, true, true, true);
+ initialize(_fullGC, cause,true, true, true, true, true, true, true);
}
TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
+ GCCause::Cause cause,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
@@ -664,7 +666,7 @@ TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
bool recordAccumulatedGCTime,
bool recordGCEndTime,
bool countCollection) {
- initialize(fullGC, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
+ initialize(fullGC, cause, recordGCBeginTime, recordPreGCUsage, recordPeakUsage,
recordPostGCUsage, recordAccumulatedGCTime, recordGCEndTime,
countCollection);
}
@@ -672,6 +674,7 @@ TraceMemoryManagerStats::TraceMemoryManagerStats(bool fullGC,
// for a subclass to create then initialize an instance before invoking
// the MemoryService
void TraceMemoryManagerStats::initialize(bool fullGC,
+ GCCause::Cause cause,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
@@ -687,6 +690,7 @@ void TraceMemoryManagerStats::initialize(bool fullGC,
_recordAccumulatedGCTime = recordAccumulatedGCTime;
_recordGCEndTime = recordGCEndTime;
_countCollection = countCollection;
+ _cause = cause;
MemoryService::gc_begin(_fullGC, _recordGCBeginTime, _recordAccumulatedGCTime,
_recordPreGCUsage, _recordPeakUsage);
@@ -694,6 +698,6 @@ void TraceMemoryManagerStats::initialize(bool fullGC,
TraceMemoryManagerStats::~TraceMemoryManagerStats() {
MemoryService::gc_end(_fullGC, _recordPostGCUsage, _recordAccumulatedGCTime,
- _recordGCEndTime, _countCollection);
+ _recordGCEndTime, _countCollection, _cause);
}
diff --git a/src/share/vm/services/memoryService.hpp b/src/share/vm/services/memoryService.hpp
index 295316b5f..2200d214b 100644
--- a/src/share/vm/services/memoryService.hpp
+++ b/src/share/vm/services/memoryService.hpp
@@ -29,6 +29,7 @@
#include "memory/generation.hpp"
#include "runtime/handles.hpp"
#include "services/memoryUsage.hpp"
+#include "gc_interface/gcCause.hpp"
// Forward declaration
class MemoryPool;
@@ -162,7 +163,8 @@ public:
bool recordPreGCUsage, bool recordPeakUsage);
static void gc_end(bool fullGC, bool recordPostGCUsage,
bool recordAccumulatedGCTime,
- bool recordGCEndTime, bool countCollection);
+ bool recordGCEndTime, bool countCollection,
+ GCCause::Cause cause);
static void oops_do(OopClosure* f);
@@ -172,6 +174,14 @@ public:
// Create an instance of java/lang/management/MemoryUsage
static Handle create_MemoryUsage_obj(MemoryUsage usage, TRAPS);
+
+ static const GCMemoryManager* get_minor_gc_manager() {
+ return _minor_gc_manager;
+ }
+
+ static const GCMemoryManager* get_major_gc_manager() {
+ return _major_gc_manager;
+ }
};
class TraceMemoryManagerStats : public StackObj {
@@ -184,10 +194,11 @@ private:
bool _recordAccumulatedGCTime;
bool _recordGCEndTime;
bool _countCollection;
-
+ GCCause::Cause _cause;
public:
TraceMemoryManagerStats() {}
TraceMemoryManagerStats(bool fullGC,
+ GCCause::Cause cause,
bool recordGCBeginTime = true,
bool recordPreGCUsage = true,
bool recordPeakUsage = true,
@@ -197,6 +208,7 @@ public:
bool countCollection = true);
void initialize(bool fullGC,
+ GCCause::Cause cause,
bool recordGCBeginTime,
bool recordPreGCUsage,
bool recordPeakUsage,
@@ -205,7 +217,7 @@ public:
bool recordGCEndTime,
bool countCollection);
- TraceMemoryManagerStats(Generation::Name kind);
+ TraceMemoryManagerStats(Generation::Name kind, GCCause::Cause cause);
~TraceMemoryManagerStats();
};