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"
1930
1931
1932 // k_mirror - may be primitive, this must be checked
1933 // heap_object_callback - pre-checked for NULL
1934 // user_data - NULL is a valid value, must be checked
1935 jvmtiError
1936 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1937 if (java_lang_Class::is_primitive(k_mirror)) {
1938 // DO PRIMITIVE CLASS PROCESSING
1939 return JVMTI_ERROR_NONE;
1940 }
1941 Klass* klass = java_lang_Class::as_Klass(k_mirror);
1942 if (klass == NULL) {
1943 return JVMTI_ERROR_INVALID_CLASS;
1944 }
1945 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
1946 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
1947 return JVMTI_ERROR_NONE;
1948 } /* end IterateOverInstancesOfClass */
1949
1950
1951 //
1952 // Local Variable functions
1953 //
1954
1955 // Threads_lock NOT held, java_thread not protected by lock
1956 // java_thread - pre-checked
1957 // java_thread - unchecked
1958 // depth - pre-checked as non-negative
1959 // value_ptr - pre-checked for NULL
1960 jvmtiError
1961 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
1962 JavaThread* current_thread = JavaThread::current();
1963 // rm object is created to clean up the javaVFrame created in
1964 // doit_prologue(), but after doit() is finished with it.
1965 ResourceMark rm(current_thread);
1966
1967 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
1968 VMThread::execute(&op);
1969 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"
1931
1932
1933 // k_mirror - may be primitive, this must be checked
1934 // heap_object_callback - pre-checked for NULL
1935 // user_data - NULL is a valid value, must be checked
1936 jvmtiError
1937 JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) {
1938 if (java_lang_Class::is_primitive(k_mirror)) {
1939 // DO PRIMITIVE CLASS PROCESSING
1940 return JVMTI_ERROR_NONE;
1941 }
1942 Klass* klass = java_lang_Class::as_Klass(k_mirror);
1943 if (klass == NULL) {
1944 return JVMTI_ERROR_INVALID_CLASS;
1945 }
1946 TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging));
1947 JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data);
1948 return JVMTI_ERROR_NONE;
1949 } /* end IterateOverInstancesOfClass */
1950
1951 // Start the sampler.
1952 jvmtiError
1953 JvmtiEnv::StartHeapSampling(jint monitoring_rate, jint max_storage) {
1954 if (monitoring_rate < 0) {
1955 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1956 }
1957
1958 fprintf(stderr, "Initializing\n");
1959 HeapThreadTransition htt(Thread::current());
1960 HeapMonitoring::initialize_profiling(monitoring_rate, max_storage);
1961 return JVMTI_ERROR_NONE;
1962 } /* end StartHeapSampling */
1963
1964 // Get the currently live sampled allocations.
1965 jvmtiError
1966 JvmtiEnv::GetLiveTraces(jvmtiStackTraces *stack_traces) {
1967 HeapThreadTransition htt(Thread::current());
1968 if (stack_traces == NULL) {
1969 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1970 }
1971
1972 HeapMonitoring::get_live_traces(stack_traces);
1973 return JVMTI_ERROR_NONE;
1974 } /* end GetLiveTraces */
1975
1976 // Get the currently live sampled allocations.
1977 jvmtiError
1978 JvmtiEnv::GetGarbageTraces(jvmtiStackTraces *stack_traces) {
1979 HeapThreadTransition htt(Thread::current());
1980 if (stack_traces == NULL) {
1981 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1982 }
1983
1984 HeapMonitoring::get_garbage_traces(stack_traces);
1985 return JVMTI_ERROR_NONE;
1986 } /* end GetGarbageTraces */
1987
1988 // Get the currently live sampled allocations.
1989 jvmtiError
1990 JvmtiEnv::GetFrequentGarbageTraces(jvmtiStackTraces *stack_traces) {
1991 HeapThreadTransition htt(Thread::current());
1992 if (stack_traces == NULL) {
1993 return JVMTI_ERROR_ILLEGAL_ARGUMENT;
1994 }
1995
1996 HeapMonitoring::get_frequent_garbage_traces(stack_traces);
1997 return JVMTI_ERROR_NONE;
1998 } /* end GetFrequentGarbageTraces */
1999
2000 // Release sampled traces.
2001 jvmtiError
2002 JvmtiEnv::ReleaseTraces(jvmtiStackTraces *stack_traces) {
2003 if (stack_traces == NULL) {
2004 return JVMTI_ERROR_NONE;
2005 }
2006 HeapMonitoring::release_traces(stack_traces);
2007 return JVMTI_ERROR_NONE;
2008 } /* end ReleaseTraces */
2009
2010 //
2011 // Local Variable functions
2012 //
2013
2014 // Threads_lock NOT held, java_thread not protected by lock
2015 // java_thread - pre-checked
2016 // java_thread - unchecked
2017 // depth - pre-checked as non-negative
2018 // value_ptr - pre-checked for NULL
2019 jvmtiError
2020 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
2021 JavaThread* current_thread = JavaThread::current();
2022 // rm object is created to clean up the javaVFrame created in
2023 // doit_prologue(), but after doit() is finished with it.
2024 ResourceMark rm(current_thread);
2025
2026 VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
2027 VMThread::execute(&op);
2028 jvmtiError err = op.result();
|