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/timerTrace.hpp"
66 #include "runtime/vframe.hpp"
67 #include "runtime/vmThread.hpp"
68 #include "services/threadService.hpp"
1918 // heap_object_callback - pre-checked for NULL
1919 // user_data - NULL is a valid value, must be checked
1920 jvmtiError
1921 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1922 if (java_lang_Class::is_primitive(k_mirror)) {
1923 // DO PRIMITIVE CLASS PROCESSING
1924 return JVMTI_ERROR_NONE;
1925 }
1926 Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
1927 if (k_oop == NULL) {
1928 return JVMTI_ERROR_INVALID_CLASS;
1929 }
1930 Thread *thread = Thread::current();
1931 HandleMark hm(thread);
1932 KlassHandle klass (thread, k_oop);
1933 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
1934 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
1935 return JVMTI_ERROR_NONE;
1936 } /* end IterateOverInstancesOfClass */
1937
1938
1939 //
1940 // Local Variable functions
1941 //
1942
1943 // Threads_lock NOT held, java_thread not protected by lock
1944 // java_thread - pre-checked
1945 // java_thread - unchecked
1946 // depth - pre-checked as non-negative
1947 // value_ptr - pre-checked for NULL
1948 jvmtiError
1949 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
1950 JavaThread* current_thread = JavaThread::current();
1951 // rm object is created to clean up the javaVFrame created in
1952 // doit_prologue(), but after doit() is finished with it.
1953 ResourceMark rm(current_thread);
1954
1955 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
1956 VMThread::execute(&op);
1957 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/interfaceSupport.hpp"
60 #include "runtime/javaCalls.hpp"
61 #include "runtime/jfieldIDWorkaround.hpp"
62 #include "runtime/osThread.hpp"
63 #include "runtime/reflectionUtils.hpp"
64 #include "runtime/signature.hpp"
65 #include "runtime/thread.inline.hpp"
66 #include "runtime/timerTrace.hpp"
67 #include "runtime/vframe.hpp"
68 #include "runtime/vmThread.hpp"
69 #include "services/threadService.hpp"
1919 // heap_object_callback - pre-checked for NULL
1920 // user_data - NULL is a valid value, must be checked
1921 jvmtiError
1922 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1923 if (java_lang_Class::is_primitive(k_mirror)) {
1924 // DO PRIMITIVE CLASS PROCESSING
1925 return JVMTI_ERROR_NONE;
1926 }
1927 Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
1928 if (k_oop == NULL) {
1929 return JVMTI_ERROR_INVALID_CLASS;
1930 }
1931 Thread *thread = Thread::current();
1932 HandleMark hm(thread);
1933 KlassHandle klass (thread, k_oop);
1934 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
1935 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
1936 return JVMTI_ERROR_NONE;
1937 } /* end IterateOverInstancesOfClass */
1938
1939 // Start the sampler.
1940 jvmtiError
1941 JvmtiEnv::StartHeapSampling(jint monitoring_period) {
1942 if (monitoring_period < 0) {
1943 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1944 }
1945
1946 HeapMonitor = true;
1947 HeapThreadTransition htt(Thread::current());
1948 HeapMonitoring::initialize_profiling(monitoring_period);
1949 return JVMTI_ERROR_NONE;
1950 } /* end StartHeapSampling */
1951
1952 // Get the currently live sampled allocations.
1953 jvmtiError
1954 JvmtiEnv::GetLiveTraces(jvmtiStackTraceData **stack_traces, jint *num_traces) {
1955 HeapThreadTransition htt(Thread::current());
1956 if (stack_traces == NULL || num_traces == NULL) {
1957 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1958 }
1959
1960 HeapMonitoring::get_live_traces(stack_traces, num_traces);
1961 return JVMTI_ERROR_NONE;
1962 } /* end GetLiveTraces */
1963
1964 //
1965 // Local Variable functions
1966 //
1967
1968 // Threads_lock NOT held, java_thread not protected by lock
1969 // java_thread - pre-checked
1970 // java_thread - unchecked
1971 // depth - pre-checked as non-negative
1972 // value_ptr - pre-checked for NULL
1973 jvmtiError
1974 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
1975 JavaThread* current_thread = JavaThread::current();
1976 // rm object is created to clean up the javaVFrame created in
1977 // doit_prologue(), but after doit() is finished with it.
1978 ResourceMark rm(current_thread);
1979
1980 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
1981 VMThread::execute(&op);
1982 jvmtiError err = op.result();
|