< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page
rev 48551 : [mq]: heap8
rev 48552 : [mq]: heap10a
rev 48556 : [mq]: heap17


  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::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
2107 jvmtiError
2108 JvmtiEnv::GetLocalObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
2109   JavaThread* current_thread = JavaThread::current();
2110   // rm object is created to clean up the javaVFrame created in
2111   // doit_prologue(), but after doit() is finished with it.
2112   ResourceMark rm(current_thread);
2113 
2114   VM_GetOrSetLocal op(java_thread, current_thread, depth, slot);
2115   VMThread::execute(&op);
2116   jvmtiError err = op.result();


< prev index next >