diff --git a/src/hotspot/share/prims/jvmti.xml b/src/hotspot/share/prims/jvmti.xml
index 2d1d8c0330dc1..13b2fad68e823 100644
--- a/src/hotspot/share/prims/jvmti.xml
+++ b/src/hotspot/share/prims/jvmti.xml
@@ -10522,6 +10522,12 @@ myInit() {
thread CPU time
+
+
+ Can get
+ GC CPU time
+
+
@@ -11225,6 +11231,62 @@ myInit() {
+
+ Get Total GC Cpu Timer Information
+
+ Get information about the
+ timer.
+ The fields of the structure
+ are filled in with details about the timer.
+ This information will not change during a particular invocation of the VM.
+
+ new
+
+
+ Can get GC cpu time.
+
+
+
+
+ jvmtiTimerInfo
+
+ On return, filled with information describing the time
+ returned by .
+
+
+
+
+
+
+
+
+ Get Total GC CPU Time
+
+ Return the current value of the total GC CPU timer, in nanoseconds.
+
+ Get information about this timer with
+ .
+
+ new
+
+
+ Can get GC cpu time.
+
+
+
+
+
+
+ On return, points to the time in nanoseconds.
+ This is an unsigned value. If tested or printed as a jlong (signed value)
+ it may appear to be a negative number.
+
+
+
+
+
+
+
Get Available Processors
@@ -15470,6 +15532,11 @@ typedef void (JNICALL *jvmtiEventVMInit)
Add new function ClearAllFramePops. Needed to speedup debugger single stepping.
+
+ Provide GC CPU time details.
+ Add new functions: GetGCCpuTimerInfo and GetTotalGCCpuTime.
+ Add new capability: can_get_gc_cpu_time.
+
diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp
index 5642cd9ff8f06..a723ea3ffbf7c 100644
--- a/src/hotspot/share/prims/jvmtiEnv.cpp
+++ b/src/hotspot/share/prims/jvmtiEnv.cpp
@@ -76,6 +76,7 @@
#include "runtime/timerTrace.hpp"
#include "runtime/vframe.inline.hpp"
#include "runtime/vmThread.hpp"
+#include "services/cpuTimeUsage.hpp"
#include "services/threadService.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/preserveException.hpp"
@@ -3785,6 +3786,29 @@ JvmtiEnv::GetTime(jlong* nanos_ptr) {
} /* end GetTime */
+// info_ptr - pre-checked for null
+jvmtiError
+JvmtiEnv::GetGCCpuTimerInfo(jvmtiTimerInfo* info_ptr) {
+ os::thread_cpu_time_info(info_ptr);
+ return JVMTI_ERROR_NONE;
+} /* end GetGCCpuTimerInfo */
+
+
+// nanos_ptr - pre-checked for null
+jvmtiError
+JvmtiEnv::GetTotalGCCpuTime(jlong* nanos_ptr) {
+ {
+ MutexLocker hl(Heap_lock);
+ if (Universe::heap()->is_shutting_down()) {
+ *nanos_ptr = -1;
+ }
+ *nanos_ptr = CPUTimeUsage::GC::total();
+ }
+ return JVMTI_ERROR_NONE;
+} /* end GetTotalGCCpuTime */
+
+
+
// processor_count_ptr - pre-checked for null
jvmtiError
JvmtiEnv::GetAvailableProcessors(jint* processor_count_ptr) {
diff --git a/src/hotspot/share/prims/jvmtiH.xsl b/src/hotspot/share/prims/jvmtiH.xsl
index 8119ae6ee741a..d62f4722daf65 100644
--- a/src/hotspot/share/prims/jvmtiH.xsl
+++ b/src/hotspot/share/prims/jvmtiH.xsl
@@ -1,6 +1,6 @@