301 return (jlong)nr;
302 WB_END
303
304 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
305 G1CollectedHeap* g1 = G1CollectedHeap::heap();
306 return g1->concurrent_mark()->cmThread()->during_cycle();
307 WB_END
308
309 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
310 G1CollectedHeap* g1h = G1CollectedHeap::heap();
311 if (!g1h->concurrent_mark()->cmThread()->during_cycle()) {
312 g1h->collect(GCCause::_wb_conc_mark);
313 return true;
314 }
315 return false;
316 WB_END
317
318 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
319 return (jint)HeapRegion::GrainBytes;
320 WB_END
321 #endif // INCLUDE_ALL_GCS
322
323 #if INCLUDE_NMT
324 // Alloc memory using the test memory type so that we can use that to see if
325 // NMT picks it up correctly
326 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
327 jlong addr = 0;
328 addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
329 return addr;
330 WB_END
331
332 // Alloc memory with pseudo call stack. The test can create psudo malloc
333 // allocation site to stress the malloc tracking.
334 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack))
335 address pc = (address)(size_t)pseudo_stack;
336 NativeCallStack stack(&pc, 1);
337 return (jlong)(uintptr_t)os::malloc(size, mtTest, stack);
338 WB_END
339
340 // Free the memory allocated by NMTAllocTest
1226 {CC"parseCommandLine",
1227 CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
1228 (void*) &WB_ParseCommandLine
1229 },
1230 {CC"addToBootstrapClassLoaderSearch", CC"(Ljava/lang/String;)V",
1231 (void*)&WB_AddToBootstrapClassLoaderSearch},
1232 {CC"addToSystemClassLoaderSearch", CC"(Ljava/lang/String;)V",
1233 (void*)&WB_AddToSystemClassLoaderSearch},
1234 {CC"getCompressedOopsMaxHeapSize", CC"()J",
1235 (void*)&WB_GetCompressedOopsMaxHeapSize},
1236 {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes },
1237 {CC"runMemoryUnitTests", CC"()V", (void*)&WB_RunMemoryUnitTests},
1238 {CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea},
1239 {CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize},
1240 #if INCLUDE_ALL_GCS
1241 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
1242 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
1243 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
1244 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
1245 {CC"g1StartConcMarkCycle", CC"()Z", (void*)&WB_G1StartMarkCycle },
1246 #endif // INCLUDE_ALL_GCS
1247 #if INCLUDE_NMT
1248 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
1249 {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack},
1250 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree },
1251 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory },
1252 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory },
1253 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory },
1254 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory },
1255 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported},
1256 {CC"NMTChangeTrackingLevel", CC"()Z", (void*)&WB_NMTChangeTrackingLevel},
1257 {CC"NMTGetHashSize", CC"()I", (void*)&WB_NMTGetHashSize },
1258 #endif // INCLUDE_NMT
1259 {CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames },
1260 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
1261 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I",
1262 (void*)&WB_DeoptimizeMethod },
1263 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Executable;Z)Z",
1264 (void*)&WB_IsMethodCompiled },
1265 {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Executable;IZ)Z",
|
301 return (jlong)nr;
302 WB_END
303
304 WB_ENTRY(jboolean, WB_G1InConcurrentMark(JNIEnv* env, jobject o))
305 G1CollectedHeap* g1 = G1CollectedHeap::heap();
306 return g1->concurrent_mark()->cmThread()->during_cycle();
307 WB_END
308
309 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
310 G1CollectedHeap* g1h = G1CollectedHeap::heap();
311 if (!g1h->concurrent_mark()->cmThread()->during_cycle()) {
312 g1h->collect(GCCause::_wb_conc_mark);
313 return true;
314 }
315 return false;
316 WB_END
317
318 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
319 return (jint)HeapRegion::GrainBytes;
320 WB_END
321
322 WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
323 ResourceMark rm(THREAD);
324 ThreadToNativeFromVM ttn(thread);
325 G1CollectedHeap* g1h = G1CollectedHeap::heap();
326 MemoryUsage mu = g1h->get_auxiliary_data_memory_usage();
327
328
329 jclass jclass_memory_usage = env->FindClass("java/lang/management/MemoryUsage");
330 CHECK_JNI_EXCEPTION_(env, NULL);
331 if (jclass_memory_usage == NULL) {
332 THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(),
333 "Cannot find class java/lang/management/MemoryUsage.");
334 }
335
336 jmethodID ctor = env->GetMethodID(jclass_memory_usage, "<init>", "(JJJJ)V");
337 CHECK_JNI_EXCEPTION_(env, NULL);
338 if (ctor == NULL) {
339 THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(),
340 "Cannot find constructor for MemoryUsage(long, long, long, long).");
341 }
342
343 jvalue args[4];
344 args[0].j = 0;
345 args[1].j = mu.used();
346 args[2].j = args[3].j = mu.committed();
347 return env->NewObjectA(jclass_memory_usage, ctor, args);
348 WB_END
349 #endif // INCLUDE_ALL_GCS
350
351 #if INCLUDE_NMT
352 // Alloc memory using the test memory type so that we can use that to see if
353 // NMT picks it up correctly
354 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
355 jlong addr = 0;
356 addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
357 return addr;
358 WB_END
359
360 // Alloc memory with pseudo call stack. The test can create psudo malloc
361 // allocation site to stress the malloc tracking.
362 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack))
363 address pc = (address)(size_t)pseudo_stack;
364 NativeCallStack stack(&pc, 1);
365 return (jlong)(uintptr_t)os::malloc(size, mtTest, stack);
366 WB_END
367
368 // Free the memory allocated by NMTAllocTest
1254 {CC"parseCommandLine",
1255 CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
1256 (void*) &WB_ParseCommandLine
1257 },
1258 {CC"addToBootstrapClassLoaderSearch", CC"(Ljava/lang/String;)V",
1259 (void*)&WB_AddToBootstrapClassLoaderSearch},
1260 {CC"addToSystemClassLoaderSearch", CC"(Ljava/lang/String;)V",
1261 (void*)&WB_AddToSystemClassLoaderSearch},
1262 {CC"getCompressedOopsMaxHeapSize", CC"()J",
1263 (void*)&WB_GetCompressedOopsMaxHeapSize},
1264 {CC"printHeapSizes", CC"()V", (void*)&WB_PrintHeapSizes },
1265 {CC"runMemoryUnitTests", CC"()V", (void*)&WB_RunMemoryUnitTests},
1266 {CC"readFromNoaccessArea",CC"()V", (void*)&WB_ReadFromNoaccessArea},
1267 {CC"stressVirtualSpaceResize",CC"(JJJ)I", (void*)&WB_StressVirtualSpaceResize},
1268 #if INCLUDE_ALL_GCS
1269 {CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
1270 {CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
1271 {CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
1272 {CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
1273 {CC"g1StartConcMarkCycle", CC"()Z", (void*)&WB_G1StartMarkCycle },
1274 {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
1275 (void*)&WB_G1AuxiliaryMemoryUsage },
1276 #endif // INCLUDE_ALL_GCS
1277 #if INCLUDE_NMT
1278 {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
1279 {CC"NMTMallocWithPseudoStack", CC"(JI)J", (void*)&WB_NMTMallocWithPseudoStack},
1280 {CC"NMTFree", CC"(J)V", (void*)&WB_NMTFree },
1281 {CC"NMTReserveMemory", CC"(J)J", (void*)&WB_NMTReserveMemory },
1282 {CC"NMTCommitMemory", CC"(JJ)V", (void*)&WB_NMTCommitMemory },
1283 {CC"NMTUncommitMemory", CC"(JJ)V", (void*)&WB_NMTUncommitMemory },
1284 {CC"NMTReleaseMemory", CC"(JJ)V", (void*)&WB_NMTReleaseMemory },
1285 {CC"NMTIsDetailSupported",CC"()Z", (void*)&WB_NMTIsDetailSupported},
1286 {CC"NMTChangeTrackingLevel", CC"()Z", (void*)&WB_NMTChangeTrackingLevel},
1287 {CC"NMTGetHashSize", CC"()I", (void*)&WB_NMTGetHashSize },
1288 #endif // INCLUDE_NMT
1289 {CC"deoptimizeFrames", CC"(Z)I", (void*)&WB_DeoptimizeFrames },
1290 {CC"deoptimizeAll", CC"()V", (void*)&WB_DeoptimizeAll },
1291 {CC"deoptimizeMethod", CC"(Ljava/lang/reflect/Executable;Z)I",
1292 (void*)&WB_DeoptimizeMethod },
1293 {CC"isMethodCompiled", CC"(Ljava/lang/reflect/Executable;Z)Z",
1294 (void*)&WB_IsMethodCompiled },
1295 {CC"isMethodCompilable", CC"(Ljava/lang/reflect/Executable;IZ)Z",
|