29 #include "classfile/modules.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "interpreter/bytecodeStream.hpp"
33 #include "interpreter/interpreter.hpp"
34 #include "jvmtifiles/jvmtiEnv.hpp"
35 #include "logging/log.hpp"
36 #include "logging/logConfiguration.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "memory/universe.inline.hpp"
39 #include "oops/instanceKlass.hpp"
40 #include "oops/objArrayOop.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "prims/jniCheck.hpp"
43 #include "prims/jvm_misc.hpp"
44 #include "prims/jvmtiAgentThread.hpp"
45 #include "prims/jvmtiClassFileReconstituter.hpp"
46 #include "prims/jvmtiCodeBlobEvents.hpp"
47 #include "prims/jvmtiExtensions.hpp"
48 #include "prims/jvmtiGetLoadedClasses.hpp"
49 #include "prims/jvmtiImpl.hpp"
50 #include "prims/jvmtiManageCapabilities.hpp"
51 #include "prims/jvmtiRawMonitor.hpp"
52 #include "prims/jvmtiRedefineClasses.hpp"
53 #include "prims/jvmtiTagMap.hpp"
54 #include "prims/jvmtiThreadState.inline.hpp"
55 #include "prims/jvmtiUtil.hpp"
56 #include "runtime/arguments.hpp"
57 #include "runtime/deoptimization.hpp"
58 #include "runtime/interfaceSupport.hpp"
59 #include "runtime/javaCalls.hpp"
60 #include "runtime/jfieldIDWorkaround.hpp"
61 #include "runtime/osThread.hpp"
62 #include "runtime/reflectionUtils.hpp"
63 #include "runtime/signature.hpp"
64 #include "runtime/thread.inline.hpp"
65 #include "runtime/threadSMR.hpp"
66 #include "runtime/timerTrace.hpp"
67 #include "runtime/vframe.hpp"
68 #include "runtime/vmThread.hpp"
69 #include "services/threadService.hpp"
70 #include "utilities/exceptions.hpp"
71 #include "utilities/preserveException.hpp"
72
73
74 #define FIXLATER 0 // REMOVE this when completed.
75
76 // FIXLATER: hook into JvmtiTrace
77 #define TraceJVMTICalls false
1987
1988
1989 // k_mirror - may be primitive, this must be checked
1990 // heap_object_callback - pre-checked for NULL
1991 // user_data - NULL is a valid value, must be checked
1992 jvmtiError
1993 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1994 if (java_lang_Class::is_primitive(k_mirror)) {
1995 // DO PRIMITIVE CLASS PROCESSING
1996 return JVMTI_ERROR_NONE;
1997 }
1998 Klass* klass = java_lang_Class::as_Klass(k_mirror);
1999 if (klass == NULL) {
2000 return JVMTI_ERROR_INVALID_CLASS;
2001 }
2002 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
2003 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
2004 return JVMTI_ERROR_NONE;
2005 } /* end IterateOverInstancesOfClass */
2006
2007
2008 //
2009 // Local Variable functions
2010 //
2011
2012 // Threads_lock NOT held, java_thread not protected by lock
2013 // java_thread - pre-checked
2014 // java_thread - unchecked
2015 // depth - pre-checked as non-negative
2016 // value_ptr - pre-checked for NULL
2017 jvmtiError
2018 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
2019 JavaThread* current_thread = JavaThread::current();
2020 // rm object is created to clean up the javaVFrame created in
2021 // doit_prologue(), but after doit() is finished with it.
2022 ResourceMark rm(current_thread);
2023
2024 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
2025 VMThread::execute(&op);
2026 jvmtiError err = op.result();
|
29 #include "classfile/modules.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/vmSymbols.hpp"
32 #include "interpreter/bytecodeStream.hpp"
33 #include "interpreter/interpreter.hpp"
34 #include "jvmtifiles/jvmtiEnv.hpp"
35 #include "logging/log.hpp"
36 #include "logging/logConfiguration.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "memory/universe.inline.hpp"
39 #include "oops/instanceKlass.hpp"
40 #include "oops/objArrayOop.inline.hpp"
41 #include "oops/oop.inline.hpp"
42 #include "prims/jniCheck.hpp"
43 #include "prims/jvm_misc.hpp"
44 #include "prims/jvmtiAgentThread.hpp"
45 #include "prims/jvmtiClassFileReconstituter.hpp"
46 #include "prims/jvmtiCodeBlobEvents.hpp"
47 #include "prims/jvmtiExtensions.hpp"
48 #include "prims/jvmtiGetLoadedClasses.hpp"
49 #include "prims/jvmtiHeapTransition.hpp"
50 #include "prims/jvmtiImpl.hpp"
51 #include "prims/jvmtiManageCapabilities.hpp"
52 #include "prims/jvmtiRawMonitor.hpp"
53 #include "prims/jvmtiRedefineClasses.hpp"
54 #include "prims/jvmtiTagMap.hpp"
55 #include "prims/jvmtiThreadState.inline.hpp"
56 #include "prims/jvmtiUtil.hpp"
57 #include "runtime/arguments.hpp"
58 #include "runtime/deoptimization.hpp"
59 #include "runtime/heapMonitoring.hpp"
60 #include "runtime/interfaceSupport.hpp"
61 #include "runtime/javaCalls.hpp"
62 #include "runtime/jfieldIDWorkaround.hpp"
63 #include "runtime/osThread.hpp"
64 #include "runtime/reflectionUtils.hpp"
65 #include "runtime/signature.hpp"
66 #include "runtime/thread.inline.hpp"
67 #include "runtime/threadSMR.hpp"
68 #include "runtime/timerTrace.hpp"
69 #include "runtime/vframe.hpp"
70 #include "runtime/vmThread.hpp"
71 #include "services/threadService.hpp"
72 #include "utilities/exceptions.hpp"
73 #include "utilities/preserveException.hpp"
74
75
76 #define FIXLATER 0 // REMOVE this when completed.
77
78 // FIXLATER: hook into JvmtiTrace
79 #define TraceJVMTICalls false
1989
1990
1991 // k_mirror - may be primitive, this must be checked
1992 // heap_object_callback - pre-checked for NULL
1993 // user_data - NULL is a valid value, must be checked
1994 jvmtiError
1995 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1996 if (java_lang_Class::is_primitive(k_mirror)) {
1997 // DO PRIMITIVE CLASS PROCESSING
1998 return JVMTI_ERROR_NONE;
1999 }
2000 Klass* klass = java_lang_Class::as_Klass(k_mirror);
2001 if (klass == NULL) {
2002 return JVMTI_ERROR_INVALID_CLASS;
2003 }
2004 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
2005 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
2006 return JVMTI_ERROR_NONE;
2007 } /* end IterateOverInstancesOfClass */
2008
2009 // Start the sampler.
2010 jvmtiError
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
2101 jvmtiError
2102 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
2103 JavaThread* current_thread = JavaThread::current();
2104 // rm object is created to clean up the javaVFrame created in
2105 // doit_prologue(), but after doit() is finished with it.
2106 ResourceMark rm(current_thread);
2107
2108 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
2109 VMThread::execute(&op);
2110 jvmtiError err = op.result();
|