< prev index next >

src/hotspot/share/prims/whitebox.cpp

Print this page




  56 #include "runtime/flags/jvmFlag.hpp"
  57 #include "runtime/frame.inline.hpp"
  58 #include "runtime/handshake.hpp"
  59 #include "runtime/interfaceSupport.inline.hpp"
  60 #include "runtime/javaCalls.hpp"
  61 #include "runtime/jniHandles.inline.hpp"
  62 #include "runtime/os.hpp"
  63 #include "runtime/sweeper.hpp"
  64 #include "runtime/thread.hpp"
  65 #include "runtime/threadSMR.hpp"
  66 #include "runtime/vm_version.hpp"
  67 #include "services/memoryService.hpp"
  68 #include "utilities/align.hpp"
  69 #include "utilities/debug.hpp"
  70 #include "utilities/elfFile.hpp"
  71 #include "utilities/exceptions.hpp"
  72 #include "utilities/macros.hpp"
  73 #if INCLUDE_CDS
  74 #include "prims/cdsoffsets.hpp"
  75 #endif // INCLUDE_CDS
  76 #if INCLUDE_ALL_GCS
  77 #include "gc/g1/g1CollectedHeap.inline.hpp"
  78 #include "gc/g1/g1ConcurrentMark.hpp"
  79 #include "gc/g1/g1ConcurrentMarkThread.hpp"
  80 #include "gc/g1/heapRegionRemSet.hpp"


  81 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  82 #include "gc/parallel/adjoiningGenerations.hpp"
  83 #endif // INCLUDE_ALL_GCS
  84 #if INCLUDE_NMT
  85 #include "services/mallocSiteTable.hpp"
  86 #include "services/memTracker.hpp"
  87 #include "utilities/nativeCallStack.hpp"
  88 #endif // INCLUDE_NMT
  89 
  90 #ifdef LINUX
  91 #include "osContainer_linux.hpp"
  92 #endif
  93 
  94 #define SIZE_T_MAX_VALUE ((size_t) -1)
  95 
  96 #define CHECK_JNI_EXCEPTION_(env, value)                               \
  97   do {                                                                 \
  98     JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
  99     if (HAS_PENDING_EXCEPTION) {                                       \
 100       return(value);                                                   \
 101     }                                                                  \
 102   } while (0)
 103 


 311   }
 312 
 313   return wb_stress_virtual_space_resize((size_t) reserved_space_size,
 314                                         (size_t) magnitude, (size_t) iterations);
 315 WB_END
 316 
 317 WB_ENTRY(jboolean, WB_IsGCSupported(JNIEnv* env, jobject o, jint name))
 318   return GCConfig::is_gc_supported((CollectedHeap::Name)name);
 319 WB_END
 320 
 321 WB_ENTRY(jboolean, WB_IsGCSelected(JNIEnv* env, jobject o, jint name))
 322   return GCConfig::is_gc_selected((CollectedHeap::Name)name);
 323 WB_END
 324 
 325 WB_ENTRY(jboolean, WB_IsGCSelectedErgonomically(JNIEnv* env, jobject o))
 326   return GCConfig::is_gc_selected_ergonomically();
 327 WB_END
 328 
 329 WB_ENTRY(jboolean, WB_isObjectInOldGen(JNIEnv* env, jobject o, jobject obj))
 330   oop p = JNIHandles::resolve(obj);
 331 #if INCLUDE_ALL_GCS
 332   if (UseG1GC) {
 333     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 334     const HeapRegion* hr = g1h->heap_region_containing(p);
 335     if (hr == NULL) {
 336       return false;
 337     }
 338     return !(hr->is_young());
 339   } else if (UseParallelGC) {



 340     ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
 341     return !psh->is_in_young(p);
 342   }
 343 #endif // INCLUDE_ALL_GCS
 344   GenCollectedHeap* gch = GenCollectedHeap::heap();
 345   return !gch->is_in_young(p);
 346 WB_END
 347 
 348 WB_ENTRY(jlong, WB_GetObjectSize(JNIEnv* env, jobject o, jobject obj))
 349   oop p = JNIHandles::resolve(obj);
 350   return p->size() * HeapWordSize;
 351 WB_END
 352 
 353 WB_ENTRY(jlong, WB_GetHeapSpaceAlignment(JNIEnv* env, jobject o))
 354   size_t alignment = Universe::heap()->collector_policy()->space_alignment();
 355   return (jlong)alignment;
 356 WB_END
 357 
 358 WB_ENTRY(jlong, WB_GetHeapAlignment(JNIEnv* env, jobject o))
 359   size_t alignment = Universe::heap()->collector_policy()->heap_alignment();
 360   return (jlong)alignment;
 361 WB_END
 362 
 363 WB_ENTRY(jboolean, WB_SupportsConcurrentGCPhaseControl(JNIEnv* env, jobject o))


 380   // If push fails, return with pending exception.
 381   if (env->PushLocalFrame(nphases) < 0) return NULL;
 382   for (jint i = 0; i < nphases; ++i) {
 383     jstring phase = env->NewStringUTF(phases[i]);
 384     CHECK_JNI_EXCEPTION_(env, NULL);
 385     env->SetObjectArrayElement(result, i, phase);
 386     CHECK_JNI_EXCEPTION_(env, NULL);
 387   }
 388   env->PopLocalFrame(NULL);
 389 
 390   return result;
 391 WB_END
 392 
 393 WB_ENTRY(jboolean, WB_RequestConcurrentGCPhase(JNIEnv* env, jobject o, jstring name))
 394   Handle h_name(THREAD, JNIHandles::resolve(name));
 395   ResourceMark rm;
 396   const char* c_name = java_lang_String::as_utf8_string(h_name());
 397   return Universe::heap()->request_concurrent_phase(c_name);
 398 WB_END
 399 
 400 #if INCLUDE_ALL_GCS

 401 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
 402   if (UseG1GC) {
 403     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 404     oop result = JNIHandles::resolve(obj);
 405     const HeapRegion* hr = g1h->heap_region_containing(result);
 406     return hr->is_humongous();
 407   }
 408   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1IsHumongous: G1 GC is not enabled");
 409 WB_END
 410 
 411 WB_ENTRY(jboolean, WB_G1BelongsToHumongousRegion(JNIEnv* env, jobject o, jlong addr))
 412   if (UseG1GC) {
 413     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 414     const HeapRegion* hr = g1h->heap_region_containing((void*) addr);
 415     return hr->is_humongous();
 416   }
 417   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1BelongsToHumongousRegion: G1 GC is not enabled");
 418 WB_END
 419 
 420 WB_ENTRY(jboolean, WB_G1BelongsToFreeRegion(JNIEnv* env, jobject o, jlong addr))


 454 
 455 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
 456   if (UseG1GC) {
 457     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 458     if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
 459       g1h->collect(GCCause::_wb_conc_mark);
 460       return true;
 461     }
 462     return false;
 463   }
 464   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
 465 WB_END
 466 
 467 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
 468   if (UseG1GC) {
 469     return (jint)HeapRegion::GrainBytes;
 470   }
 471   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
 472 WB_END
 473 




 474 WB_ENTRY(jlong, WB_PSVirtualSpaceAlignment(JNIEnv* env, jobject o))
 475 #if INCLUDE_ALL_GCS
 476   if (UseParallelGC) {
 477     return ParallelScavengeHeap::heap()->gens()->virtual_spaces()->alignment();
 478   }
 479 #endif // INCLUDE_ALL_GCS
 480   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSVirtualSpaceAlignment: Parallel GC is not enabled");
 481 WB_END
 482 
 483 WB_ENTRY(jlong, WB_PSHeapGenerationAlignment(JNIEnv* env, jobject o))
 484 #if INCLUDE_ALL_GCS
 485   if (UseParallelGC) {
 486     return ParallelScavengeHeap::heap()->generation_alignment();
 487   }
 488 #endif // INCLUDE_ALL_GCS
 489   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSHeapGenerationAlignment: Parallel GC is not enabled");
 490 WB_END
 491 




 492 WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
 493 #if INCLUDE_ALL_GCS
 494   if (UseG1GC) {
 495     ResourceMark rm(THREAD);
 496     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 497     MemoryUsage usage = g1h->get_auxiliary_data_memory_usage();
 498     Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
 499     return JNIHandles::make_local(env, h());
 500   }
 501 #endif // INCLUDE_ALL_GCS
 502   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1AuxiliaryMemoryUsage: G1 GC is not enabled");
 503 WB_END
 504 
 505 class OldRegionsLivenessClosure: public HeapRegionClosure {
 506 
 507  private:
 508   const int _liveness;
 509   size_t _total_count;
 510   size_t _total_memory;
 511   size_t _total_memory_to_free;
 512 
 513  public:
 514   OldRegionsLivenessClosure(int liveness) :
 515     _liveness(liveness),
 516     _total_count(0),
 517     _total_memory(0),
 518     _total_memory_to_free(0) { }
 519 
 520     size_t total_count() { return _total_count; }
 521     size_t total_memory() { return _total_memory; }


 544 
 545 WB_ENTRY(jlongArray, WB_G1GetMixedGCInfo(JNIEnv* env, jobject o, jint liveness))
 546   if (!UseG1GC) {
 547     THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1GetMixedGCInfo: G1 GC is not enabled");
 548   }
 549   if (liveness < 0) {
 550     THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "liveness value should be non-negative");
 551   }
 552 
 553   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 554   OldRegionsLivenessClosure rli(liveness);
 555   g1h->heap_region_iterate(&rli);
 556 
 557   typeArrayOop result = oopFactory::new_longArray(3, CHECK_NULL);
 558   result->long_at_put(0, rli.total_count());
 559   result->long_at_put(1, rli.total_memory());
 560   result->long_at_put(2, rli.total_memory_to_free());
 561   return (jlongArray) JNIHandles::make_local(env, result);
 562 WB_END
 563 
 564 #endif // INCLUDE_ALL_GCS
 565 
 566 #if INCLUDE_NMT
 567 // Alloc memory using the test memory type so that we can use that to see if
 568 // NMT picks it up correctly
 569 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
 570   jlong addr = 0;
 571   addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
 572   return addr;
 573 WB_END
 574 
 575 // Alloc memory with pseudo call stack. The test can create psudo malloc
 576 // allocation site to stress the malloc tracking.
 577 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack))
 578   address pc = (address)(size_t)pseudo_stack;
 579   NativeCallStack stack(&pc, 1);
 580   return (jlong)(uintptr_t)os::malloc(size, mtTest, stack);
 581 WB_END
 582 
 583 // Free the memory allocated by NMTAllocTest
 584 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem))


1201   MonitorLockerEx mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1202   WhiteBox::compilation_locked = false;
1203   mo.notify_all();
1204 WB_END
1205 
1206 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1207   // Force a code cache sweep and block until it finished
1208   NMethodSweeper::force_sweep();
1209 WB_END
1210 
1211 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1212   ResourceMark rm(THREAD);
1213   int len;
1214   jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1215   return (StringTable::lookup(name, len) != NULL);
1216 WB_END
1217 
1218 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1219   Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1220   Universe::heap()->collect(GCCause::_wb_full_gc);
1221 #if INCLUDE_ALL_GCS
1222   if (UseG1GC) {
1223     // Needs to be cleared explicitly for G1
1224     Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1225   }
1226 #endif // INCLUDE_ALL_GCS
1227 WB_END
1228 
1229 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1230   Universe::heap()->collect(GCCause::_wb_young_gc);
1231 WB_END
1232 
1233 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1234   // static+volatile in order to force the read to happen
1235   // (not be eliminated by the compiler)
1236   static char c;
1237   static volatile char* p;
1238 
1239   p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0);
1240   if (p == NULL) {
1241     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory");
1242   }
1243 
1244   c = *p;
1245 WB_END
1246 


1943   {CC"getHeapSpaceAlignment",            CC"()J",                   (void*)&WB_GetHeapSpaceAlignment},
1944   {CC"getHeapAlignment",                 CC"()J",                   (void*)&WB_GetHeapAlignment},
1945   {CC"isClassAlive0",                    CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive      },
1946   {CC"parseCommandLine0",
1947       CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
1948       (void*) &WB_ParseCommandLine
1949   },
1950   {CC"addToBootstrapClassLoaderSearch0", CC"(Ljava/lang/String;)V",
1951                                                       (void*)&WB_AddToBootstrapClassLoaderSearch},
1952   {CC"addToSystemClassLoaderSearch0",    CC"(Ljava/lang/String;)V",
1953                                                       (void*)&WB_AddToSystemClassLoaderSearch},
1954   {CC"getCompressedOopsMaxHeapSize", CC"()J",
1955       (void*)&WB_GetCompressedOopsMaxHeapSize},
1956   {CC"printHeapSizes",     CC"()V",                   (void*)&WB_PrintHeapSizes    },
1957   {CC"runMemoryUnitTests", CC"()V",                   (void*)&WB_RunMemoryUnitTests},
1958   {CC"readFromNoaccessArea",CC"()V",                  (void*)&WB_ReadFromNoaccessArea},
1959   {CC"stressVirtualSpaceResize",CC"(JJJ)I",           (void*)&WB_StressVirtualSpaceResize},
1960 #if INCLUDE_CDS
1961   {CC"getOffsetForName0", CC"(Ljava/lang/String;)I",  (void*)&WB_GetOffsetForName},
1962 #endif
1963 #if INCLUDE_ALL_GCS
1964   {CC"g1InConcurrentMark", CC"()Z",                   (void*)&WB_G1InConcurrentMark},
1965   {CC"g1IsHumongous0",      CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous     },
1966   {CC"g1BelongsToHumongousRegion0", CC"(J)Z",         (void*)&WB_G1BelongsToHumongousRegion},
1967   {CC"g1BelongsToFreeRegion0", CC"(J)Z",              (void*)&WB_G1BelongsToFreeRegion},
1968   {CC"g1NumMaxRegions",    CC"()J",                   (void*)&WB_G1NumMaxRegions  },
1969   {CC"g1NumFreeRegions",   CC"()J",                   (void*)&WB_G1NumFreeRegions  },
1970   {CC"g1RegionSize",       CC"()I",                   (void*)&WB_G1RegionSize      },
1971   {CC"g1StartConcMarkCycle",       CC"()Z",           (void*)&WB_G1StartMarkCycle  },
1972   {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
1973                                                       (void*)&WB_G1AuxiliaryMemoryUsage  },



1974   {CC"psVirtualSpaceAlignment",CC"()J",               (void*)&WB_PSVirtualSpaceAlignment},
1975   {CC"psHeapGenerationAlignment",CC"()J",             (void*)&WB_PSHeapGenerationAlignment},
1976   {CC"g1GetMixedGCInfo",   CC"(I)[J",                 (void*)&WB_G1GetMixedGCInfo },
1977 #endif // INCLUDE_ALL_GCS
1978 #if INCLUDE_NMT
1979   {CC"NMTMalloc",           CC"(J)J",                 (void*)&WB_NMTMalloc          },
1980   {CC"NMTMallocWithPseudoStack", CC"(JI)J",           (void*)&WB_NMTMallocWithPseudoStack},
1981   {CC"NMTFree",             CC"(J)V",                 (void*)&WB_NMTFree            },
1982   {CC"NMTReserveMemory",    CC"(J)J",                 (void*)&WB_NMTReserveMemory   },
1983   {CC"NMTAttemptReserveMemoryAt",    CC"(JJ)J",       (void*)&WB_NMTAttemptReserveMemoryAt },
1984   {CC"NMTCommitMemory",     CC"(JJ)V",                (void*)&WB_NMTCommitMemory    },
1985   {CC"NMTUncommitMemory",   CC"(JJ)V",                (void*)&WB_NMTUncommitMemory  },
1986   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
1987   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
1988   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
1989 #endif // INCLUDE_NMT
1990   {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
1991   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
1992   {CC"deoptimizeMethod0",   CC"(Ljava/lang/reflect/Executable;Z)I",
1993                                                       (void*)&WB_DeoptimizeMethod  },
1994   {CC"isMethodCompiled0",   CC"(Ljava/lang/reflect/Executable;Z)Z",
1995                                                       (void*)&WB_IsMethodCompiled  },
1996   {CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z",
1997                                                       (void*)&WB_IsMethodCompilable},




  56 #include "runtime/flags/jvmFlag.hpp"
  57 #include "runtime/frame.inline.hpp"
  58 #include "runtime/handshake.hpp"
  59 #include "runtime/interfaceSupport.inline.hpp"
  60 #include "runtime/javaCalls.hpp"
  61 #include "runtime/jniHandles.inline.hpp"
  62 #include "runtime/os.hpp"
  63 #include "runtime/sweeper.hpp"
  64 #include "runtime/thread.hpp"
  65 #include "runtime/threadSMR.hpp"
  66 #include "runtime/vm_version.hpp"
  67 #include "services/memoryService.hpp"
  68 #include "utilities/align.hpp"
  69 #include "utilities/debug.hpp"
  70 #include "utilities/elfFile.hpp"
  71 #include "utilities/exceptions.hpp"
  72 #include "utilities/macros.hpp"
  73 #if INCLUDE_CDS
  74 #include "prims/cdsoffsets.hpp"
  75 #endif // INCLUDE_CDS
  76 #if INCLUDE_G1GC
  77 #include "gc/g1/g1CollectedHeap.inline.hpp"
  78 #include "gc/g1/g1ConcurrentMark.hpp"
  79 #include "gc/g1/g1ConcurrentMarkThread.hpp"
  80 #include "gc/g1/heapRegionRemSet.hpp"
  81 #endif // INCLUDE_G1GC
  82 #if INCLUDE_PARALLELGC
  83 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
  84 #include "gc/parallel/adjoiningGenerations.hpp"
  85 #endif // INCLUDE_PARALLELGC
  86 #if INCLUDE_NMT
  87 #include "services/mallocSiteTable.hpp"
  88 #include "services/memTracker.hpp"
  89 #include "utilities/nativeCallStack.hpp"
  90 #endif // INCLUDE_NMT
  91 
  92 #ifdef LINUX
  93 #include "osContainer_linux.hpp"
  94 #endif
  95 
  96 #define SIZE_T_MAX_VALUE ((size_t) -1)
  97 
  98 #define CHECK_JNI_EXCEPTION_(env, value)                               \
  99   do {                                                                 \
 100     JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
 101     if (HAS_PENDING_EXCEPTION) {                                       \
 102       return(value);                                                   \
 103     }                                                                  \
 104   } while (0)
 105 


 313   }
 314 
 315   return wb_stress_virtual_space_resize((size_t) reserved_space_size,
 316                                         (size_t) magnitude, (size_t) iterations);
 317 WB_END
 318 
 319 WB_ENTRY(jboolean, WB_IsGCSupported(JNIEnv* env, jobject o, jint name))
 320   return GCConfig::is_gc_supported((CollectedHeap::Name)name);
 321 WB_END
 322 
 323 WB_ENTRY(jboolean, WB_IsGCSelected(JNIEnv* env, jobject o, jint name))
 324   return GCConfig::is_gc_selected((CollectedHeap::Name)name);
 325 WB_END
 326 
 327 WB_ENTRY(jboolean, WB_IsGCSelectedErgonomically(JNIEnv* env, jobject o))
 328   return GCConfig::is_gc_selected_ergonomically();
 329 WB_END
 330 
 331 WB_ENTRY(jboolean, WB_isObjectInOldGen(JNIEnv* env, jobject o, jobject obj))
 332   oop p = JNIHandles::resolve(obj);
 333 #if INCLUDE_G1GC
 334   if (UseG1GC) {
 335     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 336     const HeapRegion* hr = g1h->heap_region_containing(p);
 337     if (hr == NULL) {
 338       return false;
 339     }
 340     return !(hr->is_young());
 341   }
 342 #endif
 343 #if INCLUDE_PARALLELGC
 344   if (UseParallelGC) {
 345     ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
 346     return !psh->is_in_young(p);
 347   }
 348 #endif // INCLUDE_PARALLELGC
 349   GenCollectedHeap* gch = GenCollectedHeap::heap();
 350   return !gch->is_in_young(p);
 351 WB_END
 352 
 353 WB_ENTRY(jlong, WB_GetObjectSize(JNIEnv* env, jobject o, jobject obj))
 354   oop p = JNIHandles::resolve(obj);
 355   return p->size() * HeapWordSize;
 356 WB_END
 357 
 358 WB_ENTRY(jlong, WB_GetHeapSpaceAlignment(JNIEnv* env, jobject o))
 359   size_t alignment = Universe::heap()->collector_policy()->space_alignment();
 360   return (jlong)alignment;
 361 WB_END
 362 
 363 WB_ENTRY(jlong, WB_GetHeapAlignment(JNIEnv* env, jobject o))
 364   size_t alignment = Universe::heap()->collector_policy()->heap_alignment();
 365   return (jlong)alignment;
 366 WB_END
 367 
 368 WB_ENTRY(jboolean, WB_SupportsConcurrentGCPhaseControl(JNIEnv* env, jobject o))


 385   // If push fails, return with pending exception.
 386   if (env->PushLocalFrame(nphases) < 0) return NULL;
 387   for (jint i = 0; i < nphases; ++i) {
 388     jstring phase = env->NewStringUTF(phases[i]);
 389     CHECK_JNI_EXCEPTION_(env, NULL);
 390     env->SetObjectArrayElement(result, i, phase);
 391     CHECK_JNI_EXCEPTION_(env, NULL);
 392   }
 393   env->PopLocalFrame(NULL);
 394 
 395   return result;
 396 WB_END
 397 
 398 WB_ENTRY(jboolean, WB_RequestConcurrentGCPhase(JNIEnv* env, jobject o, jstring name))
 399   Handle h_name(THREAD, JNIHandles::resolve(name));
 400   ResourceMark rm;
 401   const char* c_name = java_lang_String::as_utf8_string(h_name());
 402   return Universe::heap()->request_concurrent_phase(c_name);
 403 WB_END
 404 
 405 #if INCLUDE_G1GC
 406 
 407 WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
 408   if (UseG1GC) {
 409     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 410     oop result = JNIHandles::resolve(obj);
 411     const HeapRegion* hr = g1h->heap_region_containing(result);
 412     return hr->is_humongous();
 413   }
 414   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1IsHumongous: G1 GC is not enabled");
 415 WB_END
 416 
 417 WB_ENTRY(jboolean, WB_G1BelongsToHumongousRegion(JNIEnv* env, jobject o, jlong addr))
 418   if (UseG1GC) {
 419     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 420     const HeapRegion* hr = g1h->heap_region_containing((void*) addr);
 421     return hr->is_humongous();
 422   }
 423   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1BelongsToHumongousRegion: G1 GC is not enabled");
 424 WB_END
 425 
 426 WB_ENTRY(jboolean, WB_G1BelongsToFreeRegion(JNIEnv* env, jobject o, jlong addr))


 460 
 461 WB_ENTRY(jboolean, WB_G1StartMarkCycle(JNIEnv* env, jobject o))
 462   if (UseG1GC) {
 463     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 464     if (!g1h->concurrent_mark()->cm_thread()->during_cycle()) {
 465       g1h->collect(GCCause::_wb_conc_mark);
 466       return true;
 467     }
 468     return false;
 469   }
 470   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1StartMarkCycle: G1 GC is not enabled");
 471 WB_END
 472 
 473 WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
 474   if (UseG1GC) {
 475     return (jint)HeapRegion::GrainBytes;
 476   }
 477   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1RegionSize: G1 GC is not enabled");
 478 WB_END
 479 
 480 #endif // INCLUDE_G1GC
 481 
 482 #if INCLUDE_PARALLELGC
 483 
 484 WB_ENTRY(jlong, WB_PSVirtualSpaceAlignment(JNIEnv* env, jobject o))

 485   if (UseParallelGC) {
 486     return ParallelScavengeHeap::heap()->gens()->virtual_spaces()->alignment();
 487   }

 488   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSVirtualSpaceAlignment: Parallel GC is not enabled");
 489 WB_END
 490 
 491 WB_ENTRY(jlong, WB_PSHeapGenerationAlignment(JNIEnv* env, jobject o))

 492   if (UseParallelGC) {
 493     return ParallelScavengeHeap::heap()->generation_alignment();
 494   }

 495   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_PSHeapGenerationAlignment: Parallel GC is not enabled");
 496 WB_END
 497 
 498 #endif // INCLUDE_PARALLELGC
 499 
 500 #if INCLUDE_G1GC
 501 
 502 WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))

 503   if (UseG1GC) {
 504     ResourceMark rm(THREAD);
 505     G1CollectedHeap* g1h = G1CollectedHeap::heap();
 506     MemoryUsage usage = g1h->get_auxiliary_data_memory_usage();
 507     Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
 508     return JNIHandles::make_local(env, h());
 509   }

 510   THROW_MSG_0(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1AuxiliaryMemoryUsage: G1 GC is not enabled");
 511 WB_END
 512 
 513 class OldRegionsLivenessClosure: public HeapRegionClosure {
 514 
 515  private:
 516   const int _liveness;
 517   size_t _total_count;
 518   size_t _total_memory;
 519   size_t _total_memory_to_free;
 520 
 521  public:
 522   OldRegionsLivenessClosure(int liveness) :
 523     _liveness(liveness),
 524     _total_count(0),
 525     _total_memory(0),
 526     _total_memory_to_free(0) { }
 527 
 528     size_t total_count() { return _total_count; }
 529     size_t total_memory() { return _total_memory; }


 552 
 553 WB_ENTRY(jlongArray, WB_G1GetMixedGCInfo(JNIEnv* env, jobject o, jint liveness))
 554   if (!UseG1GC) {
 555     THROW_MSG_NULL(vmSymbols::java_lang_UnsupportedOperationException(), "WB_G1GetMixedGCInfo: G1 GC is not enabled");
 556   }
 557   if (liveness < 0) {
 558     THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "liveness value should be non-negative");
 559   }
 560 
 561   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 562   OldRegionsLivenessClosure rli(liveness);
 563   g1h->heap_region_iterate(&rli);
 564 
 565   typeArrayOop result = oopFactory::new_longArray(3, CHECK_NULL);
 566   result->long_at_put(0, rli.total_count());
 567   result->long_at_put(1, rli.total_memory());
 568   result->long_at_put(2, rli.total_memory_to_free());
 569   return (jlongArray) JNIHandles::make_local(env, result);
 570 WB_END
 571 
 572 #endif // INCLUDE_G1GC
 573 
 574 #if INCLUDE_NMT
 575 // Alloc memory using the test memory type so that we can use that to see if
 576 // NMT picks it up correctly
 577 WB_ENTRY(jlong, WB_NMTMalloc(JNIEnv* env, jobject o, jlong size))
 578   jlong addr = 0;
 579   addr = (jlong)(uintptr_t)os::malloc(size, mtTest);
 580   return addr;
 581 WB_END
 582 
 583 // Alloc memory with pseudo call stack. The test can create psudo malloc
 584 // allocation site to stress the malloc tracking.
 585 WB_ENTRY(jlong, WB_NMTMallocWithPseudoStack(JNIEnv* env, jobject o, jlong size, jint pseudo_stack))
 586   address pc = (address)(size_t)pseudo_stack;
 587   NativeCallStack stack(&pc, 1);
 588   return (jlong)(uintptr_t)os::malloc(size, mtTest, stack);
 589 WB_END
 590 
 591 // Free the memory allocated by NMTAllocTest
 592 WB_ENTRY(void, WB_NMTFree(JNIEnv* env, jobject o, jlong mem))


1209   MonitorLockerEx mo(Compilation_lock, Mutex::_no_safepoint_check_flag);
1210   WhiteBox::compilation_locked = false;
1211   mo.notify_all();
1212 WB_END
1213 
1214 WB_ENTRY(void, WB_ForceNMethodSweep(JNIEnv* env, jobject o))
1215   // Force a code cache sweep and block until it finished
1216   NMethodSweeper::force_sweep();
1217 WB_END
1218 
1219 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString))
1220   ResourceMark rm(THREAD);
1221   int len;
1222   jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false);
1223   return (StringTable::lookup(name, len) != NULL);
1224 WB_END
1225 
1226 WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o))
1227   Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true);
1228   Universe::heap()->collect(GCCause::_wb_full_gc);
1229 #if INCLUDE_G1GC
1230   if (UseG1GC) {
1231     // Needs to be cleared explicitly for G1
1232     Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false);
1233   }
1234 #endif // INCLUDE_G1GC
1235 WB_END
1236 
1237 WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))
1238   Universe::heap()->collect(GCCause::_wb_young_gc);
1239 WB_END
1240 
1241 WB_ENTRY(void, WB_ReadReservedMemory(JNIEnv* env, jobject o))
1242   // static+volatile in order to force the read to happen
1243   // (not be eliminated by the compiler)
1244   static char c;
1245   static volatile char* p;
1246 
1247   p = os::reserve_memory(os::vm_allocation_granularity(), NULL, 0);
1248   if (p == NULL) {
1249     THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "Failed to reserve memory");
1250   }
1251 
1252   c = *p;
1253 WB_END
1254 


1951   {CC"getHeapSpaceAlignment",            CC"()J",                   (void*)&WB_GetHeapSpaceAlignment},
1952   {CC"getHeapAlignment",                 CC"()J",                   (void*)&WB_GetHeapAlignment},
1953   {CC"isClassAlive0",                    CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive      },
1954   {CC"parseCommandLine0",
1955       CC"(Ljava/lang/String;C[Lsun/hotspot/parser/DiagnosticCommand;)[Ljava/lang/Object;",
1956       (void*) &WB_ParseCommandLine
1957   },
1958   {CC"addToBootstrapClassLoaderSearch0", CC"(Ljava/lang/String;)V",
1959                                                       (void*)&WB_AddToBootstrapClassLoaderSearch},
1960   {CC"addToSystemClassLoaderSearch0",    CC"(Ljava/lang/String;)V",
1961                                                       (void*)&WB_AddToSystemClassLoaderSearch},
1962   {CC"getCompressedOopsMaxHeapSize", CC"()J",
1963       (void*)&WB_GetCompressedOopsMaxHeapSize},
1964   {CC"printHeapSizes",     CC"()V",                   (void*)&WB_PrintHeapSizes    },
1965   {CC"runMemoryUnitTests", CC"()V",                   (void*)&WB_RunMemoryUnitTests},
1966   {CC"readFromNoaccessArea",CC"()V",                  (void*)&WB_ReadFromNoaccessArea},
1967   {CC"stressVirtualSpaceResize",CC"(JJJ)I",           (void*)&WB_StressVirtualSpaceResize},
1968 #if INCLUDE_CDS
1969   {CC"getOffsetForName0", CC"(Ljava/lang/String;)I",  (void*)&WB_GetOffsetForName},
1970 #endif
1971 #if INCLUDE_G1GC
1972   {CC"g1InConcurrentMark", CC"()Z",                   (void*)&WB_G1InConcurrentMark},
1973   {CC"g1IsHumongous0",      CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous     },
1974   {CC"g1BelongsToHumongousRegion0", CC"(J)Z",         (void*)&WB_G1BelongsToHumongousRegion},
1975   {CC"g1BelongsToFreeRegion0", CC"(J)Z",              (void*)&WB_G1BelongsToFreeRegion},
1976   {CC"g1NumMaxRegions",    CC"()J",                   (void*)&WB_G1NumMaxRegions  },
1977   {CC"g1NumFreeRegions",   CC"()J",                   (void*)&WB_G1NumFreeRegions  },
1978   {CC"g1RegionSize",       CC"()I",                   (void*)&WB_G1RegionSize      },
1979   {CC"g1StartConcMarkCycle",       CC"()Z",           (void*)&WB_G1StartMarkCycle  },
1980   {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
1981                                                       (void*)&WB_G1AuxiliaryMemoryUsage  },
1982   {CC"g1GetMixedGCInfo",   CC"(I)[J",                 (void*)&WB_G1GetMixedGCInfo },
1983 #endif // INCLUDE_G1GC
1984 #if INCLUDE_PARALLELGC
1985   {CC"psVirtualSpaceAlignment",CC"()J",               (void*)&WB_PSVirtualSpaceAlignment},
1986   {CC"psHeapGenerationAlignment",CC"()J",             (void*)&WB_PSHeapGenerationAlignment},
1987 #endif

1988 #if INCLUDE_NMT
1989   {CC"NMTMalloc",           CC"(J)J",                 (void*)&WB_NMTMalloc          },
1990   {CC"NMTMallocWithPseudoStack", CC"(JI)J",           (void*)&WB_NMTMallocWithPseudoStack},
1991   {CC"NMTFree",             CC"(J)V",                 (void*)&WB_NMTFree            },
1992   {CC"NMTReserveMemory",    CC"(J)J",                 (void*)&WB_NMTReserveMemory   },
1993   {CC"NMTAttemptReserveMemoryAt",    CC"(JJ)J",       (void*)&WB_NMTAttemptReserveMemoryAt },
1994   {CC"NMTCommitMemory",     CC"(JJ)V",                (void*)&WB_NMTCommitMemory    },
1995   {CC"NMTUncommitMemory",   CC"(JJ)V",                (void*)&WB_NMTUncommitMemory  },
1996   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
1997   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
1998   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
1999 #endif // INCLUDE_NMT
2000   {CC"deoptimizeFrames",   CC"(Z)I",                  (void*)&WB_DeoptimizeFrames  },
2001   {CC"deoptimizeAll",      CC"()V",                   (void*)&WB_DeoptimizeAll     },
2002   {CC"deoptimizeMethod0",   CC"(Ljava/lang/reflect/Executable;Z)I",
2003                                                       (void*)&WB_DeoptimizeMethod  },
2004   {CC"isMethodCompiled0",   CC"(Ljava/lang/reflect/Executable;Z)Z",
2005                                                       (void*)&WB_IsMethodCompiled  },
2006   {CC"isMethodCompilable0", CC"(Ljava/lang/reflect/Executable;IZ)Z",
2007                                                       (void*)&WB_IsMethodCompilable},


< prev index next >