< 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   JavaThread* java_thread;
2080 
2081   if (thread_id == 0) {
2082     // current thread
2083     java_thread = (JavaThread*)THREAD;
2084     if (java_thread->is_Java_thread()) {
2085       return java_thread->cooked_allocated_bytes();
2086     }
2087     return -1;
2088   }
2089 
2090   ThreadsListHandle tlh;
2091   java_thread = tlh.list()->find_JavaThread_from_java_tid(thread_id);
2092 
2093   if (java_thread != NULL) {
2094     return java_thread->cooked_allocated_bytes();
2095   }
2096   return -1;
2097 JVM_END
2098 
2099 // Gets an array containing the amount of memory allocated on the Java
2100 // heap for a set of threads (in bytes).  Each element of the array is
2101 // the amount of memory allocated for the thread ID specified in the
2102 // corresponding entry in the given array of thread IDs; or -1 if the
2103 // thread does not exist or has terminated.
2104 JVM_ENTRY(void, jmm_GetThreadAllocatedMemory(JNIEnv *env, jlongArray ids,
2105                                              jlongArray sizeArray))
2106   // Check if threads is null
2107   if (ids == NULL || sizeArray == NULL) {
2108     THROW(vmSymbols::java_lang_NullPointerException());
2109   }
2110 
2111   ResourceMark rm(THREAD);
2112   typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids));
2113   typeArrayHandle ids_ah(THREAD, ta);
2114 
2115   typeArrayOop sa = typeArrayOop(JNIHandles::resolve_non_null(sizeArray));
2116   typeArrayHandle sizeArray_h(THREAD, sa);
2117 
2118   // validate the thread id array


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


< prev index next >