2011 JvmtiEnv::StartHeapSampling(jint monitoring_rate, jint max_gc_storage) {
2012 if (monitoring_rate < 0) {
2013 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2014 }
2015
2016 HeapThreadTransition htt(Thread::current());
2017 HeapMonitoring::initialize_profiling(monitoring_rate, max_gc_storage);
2018 return JVMTI_ERROR_NONE;
2019 } /* end StartHeapSampling */
2020
2021 // Stop the sampler.
2022 jvmtiError
2023 JvmtiEnv::StopHeapSampling() {
2024 HeapThreadTransition htt(Thread::current());
2025 HeapMonitoring::stop_profiling();
2026 return JVMTI_ERROR_NONE;
2027 } /* end StopHeapSampling */
2028
2029 // Provoke a GC and get the currently live sampled allocations.
2030 jvmtiError
2031 JvmtiEnv::GetLiveTraces(jvmtiStackTraces* stack_traces) {
2032 ForceGarbageCollection();
2033 HeapThreadTransition htt(Thread::current());
2034 if (stack_traces == NULL) {
2035 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2036 }
2037
2038 HeapMonitoring::get_live_traces(stack_traces);
2039 return JVMTI_ERROR_NONE;
2040 } /* end GetLiveTraces */
2041
2042 // Get the recently garbage collected allocations.
2043 jvmtiError
2044 JvmtiEnv::GetGarbageTraces(jvmtiStackTraces* stack_traces) {
2045 HeapThreadTransition htt(Thread::current());
2046 if (stack_traces == NULL) {
2047 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2048 }
2049
2050 HeapMonitoring::get_garbage_traces(stack_traces);
2051 return JVMTI_ERROR_NONE;
2052 } /* end GetGarbageTraces */
2053
2054 // Get the frequently garbage collected traces.
2055 jvmtiError
2056 JvmtiEnv::GetFrequentGarbageTraces(jvmtiStackTraces* stack_traces) {
2057 HeapThreadTransition htt(Thread::current());
2058 if (stack_traces == NULL) {
2059 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2060 }
2061
2062 HeapMonitoring::get_frequent_garbage_traces(stack_traces);
2063 return JVMTI_ERROR_NONE;
2064 } /* end GetFrequentGarbageTraces */
2065
2066 // Get the traces that were garbage collected in the last full GC.
2067 jvmtiError
2068 JvmtiEnv::GetCachedTraces(jvmtiStackTraces* stack_traces) {
2069 HeapThreadTransition htt(Thread::current());
2070 if (stack_traces == NULL) {
2071 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2072 }
2073
2074 HeapMonitoring::get_cached_traces(stack_traces);
2075 return JVMTI_ERROR_NONE;
2076 } /* end GetCachedTraces */
2077
2078 // Release sampled traces.
2079 jvmtiError
2080 JvmtiEnv::ReleaseTraces(jvmtiStackTraces* stack_traces) {
2081 if (stack_traces == NULL) {
2082 return JVMTI_ERROR_NONE;
2083 }
2084 HeapMonitoring::release_traces(stack_traces);
2085 return JVMTI_ERROR_NONE;
2086 } /* end ReleaseTraces */
2087
2088 // Get the heap sampling statistics.
2089 jvmtiError
2090 JvmtiEnv::GetHeapSamplingStats(jvmtiHeapSamplingStats* stats) {
2091 if (stats == NULL) {
2092 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2093 }
2094 HeapMonitoring::get_sampling_statistics(stats);
2095 return JVMTI_ERROR_NONE;
2096 } /* end GetHeapSamplingStats */
2097
2098 //
2099 // Local Variable functions
2100 //
2101
2102 // Threads_lock NOT held, java_thread not protected by lock
2103 // java_thread - pre-checked
2104 // java_thread - unchecked
2105 // depth - pre-checked as non-negative
2106 // value_ptr - pre-checked for NULL
|
2011 JvmtiEnv::StartHeapSampling(jint monitoring_rate, jint max_gc_storage) {
2012 if (monitoring_rate < 0) {
2013 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2014 }
2015
2016 HeapThreadTransition htt(Thread::current());
2017 HeapMonitoring::initialize_profiling(monitoring_rate, max_gc_storage);
2018 return JVMTI_ERROR_NONE;
2019 } /* end StartHeapSampling */
2020
2021 // Stop the sampler.
2022 jvmtiError
2023 JvmtiEnv::StopHeapSampling() {
2024 HeapThreadTransition htt(Thread::current());
2025 HeapMonitoring::stop_profiling();
2026 return JVMTI_ERROR_NONE;
2027 } /* end StopHeapSampling */
2028
2029 // Provoke a GC and get the currently live sampled allocations.
2030 jvmtiError
2031 JvmtiEnv::GetObjectAllocTraces(jvmtiAllocTraceInfo** stack_traces,
2032 jint* trace_counter_ptr) {
2033 ForceGarbageCollection();
2034 HeapThreadTransition htt(Thread::current());
2035 if (stack_traces == NULL) {
2036 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2037 }
2038
2039 HeapMonitoring::get_live_traces(this, stack_traces, trace_counter_ptr);
2040 return JVMTI_ERROR_NONE;
2041 } /* end GetLiveTraces */
2042
2043 // Get the recently garbage collected allocations.
2044 jvmtiError
2045 JvmtiEnv::GetGarbageTraces(jvmtiAllocTraceInfo** stack_traces,
2046 jint* trace_counter_ptr) {
2047 HeapThreadTransition htt(Thread::current());
2048 if (stack_traces == NULL) {
2049 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2050 }
2051
2052 HeapMonitoring::get_garbage_traces(this, stack_traces, trace_counter_ptr);
2053 return JVMTI_ERROR_NONE;
2054 } /* end GetGarbageTraces */
2055
2056 // Get the frequently garbage collected traces.
2057 jvmtiError
2058 JvmtiEnv::GetFrequentGarbageTraces(jvmtiAllocTraceInfo** stack_traces,
2059 jint* trace_counter_ptr) {
2060 HeapThreadTransition htt(Thread::current());
2061 if (stack_traces == NULL) {
2062 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2063 }
2064
2065 HeapMonitoring::get_frequent_garbage_traces(this, stack_traces, trace_counter_ptr);
2066 return JVMTI_ERROR_NONE;
2067 } /* end GetFrequentGarbageTraces */
2068
2069 // Get the traces that were garbage collected in the last full GC.
2070 jvmtiError
2071 JvmtiEnv::GetCachedObjectAllocTraces(jvmtiAllocTraceInfo** stack_traces,
2072 jint* trace_counter_ptr) {
2073 HeapThreadTransition htt(Thread::current());
2074 if (stack_traces == NULL) {
2075 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2076 }
2077
2078 HeapMonitoring::get_cached_traces(this, stack_traces, trace_counter_ptr);
2079 return JVMTI_ERROR_NONE;
2080 } /* end GetObjectAllocTraces */
2081
2082 // Get the heap sampling statistics.
2083 jvmtiError
2084 JvmtiEnv::GetHeapSamplingStats(jvmtiHeapSamplingStats* stats) {
2085 if (stats == NULL) {
2086 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
2087 }
2088 HeapMonitoring::get_sampling_statistics(stats);
2089 return JVMTI_ERROR_NONE;
2090 } /* end GetHeapSamplingStats */
2091
2092 //
2093 // Local Variable functions
2094 //
2095
2096 // Threads_lock NOT held, java_thread not protected by lock
2097 // java_thread - pre-checked
2098 // java_thread - unchecked
2099 // depth - pre-checked as non-negative
2100 // value_ptr - pre-checked for NULL
|