< prev index next >

src/hotspot/share/services/management.cpp

Print this page




2051     THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(),
2052                    "Command line content cannot be null.");
2053   }
2054   bufferedStream output;
2055   DCmd::parse_and_execute(DCmd_Source_MBean, &output, cmdline, ' ', CHECK_NULL);
2056   oop result = java_lang_String::create_oop_from_str(output.as_string(), CHECK_NULL);
2057   return (jstring) JNIHandles::make_local(env, result);
2058 JVM_END
2059 
2060 JVM_ENTRY(void, jmm_SetDiagnosticFrameworkNotificationEnabled(JNIEnv *env, jboolean enabled))
2061   DCmdFactory::set_jmx_notification_enabled(enabled?true:false);
2062 JVM_END
2063 
2064 jlong Management::ticks_to_ms(jlong ticks) {
2065   assert(os::elapsed_frequency() > 0, "Must be non-zero");
2066   return (jlong)(((double)ticks / (double)os::elapsed_frequency())
2067                  * (double)1000.0);
2068 }
2069 #endif // INCLUDE_MANAGEMENT
2070 

























2071 // Gets an array containing the amount of memory allocated on the Java
2072 // heap for a set of threads (in bytes).  Each element of the array is
2073 // the amount of memory allocated for the thread ID specified in the
2074 // corresponding entry in the given array of thread IDs; or -1 if the
2075 // thread does not exist or has terminated.
2076 JVM_ENTRY(void, jmm_GetThreadAllocatedMemory(JNIEnv *env, jlongArray ids,
2077                                              jlongArray sizeArray))
2078   // Check if threads is null
2079   if (ids == NULL || sizeArray == NULL) {
2080     THROW(vmSymbols::java_lang_NullPointerException());
2081   }
2082 
2083   ResourceMark rm(THREAD);
2084   typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids));
2085   typeArrayHandle ids_ah(THREAD, ta);
2086 
2087   typeArrayOop sa = typeArrayOop(JNIHandles::resolve_non_null(sizeArray));
2088   typeArrayHandle sizeArray_h(THREAD, sa);
2089 
2090   // validate the thread id array


2175     if (java_thread != NULL) {
2176       timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread,
2177                                                       user_sys_cpu_time != 0));
2178     }
2179   }
2180 JVM_END
2181 
2182 
2183 
2184 #if INCLUDE_MANAGEMENT
2185 const struct jmmInterface_1_ jmm_interface = {
2186   NULL,
2187   NULL,
2188   jmm_GetVersion,
2189   jmm_GetOptionalSupport,
2190   jmm_GetThreadInfo,
2191   jmm_GetMemoryPools,
2192   jmm_GetMemoryManagers,
2193   jmm_GetMemoryPoolUsage,
2194   jmm_GetPeakMemoryPoolUsage,

2195   jmm_GetThreadAllocatedMemory,
2196   jmm_GetMemoryUsage,
2197   jmm_GetLongAttribute,
2198   jmm_GetBoolAttribute,
2199   jmm_SetBoolAttribute,
2200   jmm_GetLongAttributes,
2201   jmm_FindMonitorDeadlockedThreads,
2202   jmm_GetThreadCpuTime,
2203   jmm_GetVMGlobalNames,
2204   jmm_GetVMGlobals,
2205   jmm_GetInternalThreadTimes,
2206   jmm_ResetStatistic,
2207   jmm_SetPoolSensor,
2208   jmm_SetPoolThreshold,
2209   jmm_GetPoolCollectionUsage,
2210   jmm_GetGCExtAttributeInfo,
2211   jmm_GetLastGCStat,
2212   jmm_GetThreadCpuTimeWithKind,
2213   jmm_GetThreadCpuTimesWithKind,
2214   jmm_DumpHeap0,




2051     THROW_MSG_NULL(vmSymbols::java_lang_NullPointerException(),
2052                    "Command line content cannot be null.");
2053   }
2054   bufferedStream output;
2055   DCmd::parse_and_execute(DCmd_Source_MBean, &output, cmdline, ' ', CHECK_NULL);
2056   oop result = java_lang_String::create_oop_from_str(output.as_string(), CHECK_NULL);
2057   return (jstring) JNIHandles::make_local(env, result);
2058 JVM_END
2059 
2060 JVM_ENTRY(void, jmm_SetDiagnosticFrameworkNotificationEnabled(JNIEnv *env, jboolean enabled))
2061   DCmdFactory::set_jmx_notification_enabled(enabled?true:false);
2062 JVM_END
2063 
2064 jlong Management::ticks_to_ms(jlong ticks) {
2065   assert(os::elapsed_frequency() > 0, "Must be non-zero");
2066   return (jlong)(((double)ticks / (double)os::elapsed_frequency())
2067                  * (double)1000.0);
2068 }
2069 #endif // INCLUDE_MANAGEMENT
2070 
2071 // Gets the amount of memory allocated on the Java heap for a single thread.
2072 // Returns -1 if the thread does not exist or has terminated.
2073 JVM_ENTRY(jlong, jmm_GetOneThreadAllocatedMemory(JNIEnv *env, jlong thread_id))
2074   if (thread_id < 0) {
2075     THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(),
2076                "Invalid thread ID", -1);
2077   }
2078 
2079   if (thread_id == 0) {
2080     // current thread
2081     if (THREAD->is_Java_thread()) {
2082       return ((JavaThread*)THREAD)->cooked_allocated_bytes();
2083     }
2084     return -1;
2085   }
2086 
2087   ThreadsListHandle tlh;
2088   JavaThread* java_thread = tlh.list()->find_JavaThread_from_java_tid(thread_id);
2089 
2090   if (java_thread != NULL) {
2091     return java_thread->cooked_allocated_bytes();
2092   }
2093   return -1;
2094 JVM_END
2095 
2096 // Gets an array containing the amount of memory allocated on the Java
2097 // heap for a set of threads (in bytes).  Each element of the array is
2098 // the amount of memory allocated for the thread ID specified in the
2099 // corresponding entry in the given array of thread IDs; or -1 if the
2100 // thread does not exist or has terminated.
2101 JVM_ENTRY(void, jmm_GetThreadAllocatedMemory(JNIEnv *env, jlongArray ids,
2102                                              jlongArray sizeArray))
2103   // Check if threads is null
2104   if (ids == NULL || sizeArray == NULL) {
2105     THROW(vmSymbols::java_lang_NullPointerException());
2106   }
2107 
2108   ResourceMark rm(THREAD);
2109   typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids));
2110   typeArrayHandle ids_ah(THREAD, ta);
2111 
2112   typeArrayOop sa = typeArrayOop(JNIHandles::resolve_non_null(sizeArray));
2113   typeArrayHandle sizeArray_h(THREAD, sa);
2114 
2115   // validate the thread id array


2200     if (java_thread != NULL) {
2201       timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread,
2202                                                       user_sys_cpu_time != 0));
2203     }
2204   }
2205 JVM_END
2206 
2207 
2208 
2209 #if INCLUDE_MANAGEMENT
2210 const struct jmmInterface_1_ jmm_interface = {
2211   NULL,
2212   NULL,
2213   jmm_GetVersion,
2214   jmm_GetOptionalSupport,
2215   jmm_GetThreadInfo,
2216   jmm_GetMemoryPools,
2217   jmm_GetMemoryManagers,
2218   jmm_GetMemoryPoolUsage,
2219   jmm_GetPeakMemoryPoolUsage,
2220   jmm_GetOneThreadAllocatedMemory,
2221   jmm_GetThreadAllocatedMemory,
2222   jmm_GetMemoryUsage,
2223   jmm_GetLongAttribute,
2224   jmm_GetBoolAttribute,
2225   jmm_SetBoolAttribute,
2226   jmm_GetLongAttributes,
2227   jmm_FindMonitorDeadlockedThreads,
2228   jmm_GetThreadCpuTime,
2229   jmm_GetVMGlobalNames,
2230   jmm_GetVMGlobals,
2231   jmm_GetInternalThreadTimes,
2232   jmm_ResetStatistic,
2233   jmm_SetPoolSensor,
2234   jmm_SetPoolThreshold,
2235   jmm_GetPoolCollectionUsage,
2236   jmm_GetGCExtAttributeInfo,
2237   jmm_GetLastGCStat,
2238   jmm_GetThreadCpuTimeWithKind,
2239   jmm_GetThreadCpuTimesWithKind,
2240   jmm_DumpHeap0,


< prev index next >