sun.hotspot.WhiteBox Java Examples

The following examples show how to use sun.hotspot.WhiteBox. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestConcMarkCycleWB.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();

    wb.youngGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }

    wb.fullGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }
    assertTrue(wb.g1StartConcMarkCycle());
}
 
Example #2
Source File: TestG1ClassUnloadingHWM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String [] args) throws Exception {
  if (args.length != 2) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize> <YoungGenSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  long youngGenSize = Long.parseLong(args[1]);
  triggerYoungGCs(youngGenSize);

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
Example #3
Source File: RunUnitTestsConcurrently.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
  if (!Platform.isDebugBuild() || !Platform.is64bit()) {
    return;
  }
  wb = WhiteBox.getWhiteBox();
  System.out.println("Starting threads");

  int threads = Integer.valueOf(args[0]);
  timeout = Long.valueOf(args[1]);

  timeStamp = System.currentTimeMillis();

  Thread[] threadsArray = new Thread[threads];
  for (int i = 0; i < threads; i++) {
    threadsArray[i] = new Thread(new Worker());
    threadsArray[i].start();
  }
  for (int i = 0; i < threads; i++) {
    threadsArray[i].join();
  }

  System.out.println("Quitting test.");
}
 
Example #4
Source File: RunUnitTestsConcurrently.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
  if (!Platform.isDebugBuild() || !Platform.is64bit()) {
    return;
  }
  wb = WhiteBox.getWhiteBox();
  System.out.println("Starting threads");

  int threads = Integer.valueOf(args[0]);
  timeout = Long.valueOf(args[1]);

  timeStamp = System.currentTimeMillis();

  Thread[] threadsArray = new Thread[threads];
  for (int i = 0; i < threads; i++) {
    threadsArray[i] = new Thread(new Worker());
    threadsArray[i].start();
  }
  for (int i = 0; i < threads; i++) {
    threadsArray[i].join();
  }

  System.out.println("Quitting test.");
}
 
Example #5
Source File: TestG1ClassUnloadingHWM.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String [] args) throws Exception {
  if (args.length != 2) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize> <YoungGenSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  long youngGenSize = Long.parseLong(args[1]);
  triggerYoungGCs(youngGenSize);

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
Example #6
Source File: TestCMSClassUnloadingEnabledHWM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String [] args) throws Exception {
  if (args.length != 1) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit.
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  // Wait for at least one GC to occur. The caller will parse the log files produced.
  GarbageCollectorMXBean cmsGCBean = getCMSGCBean();
  while (cmsGCBean.getCollectionCount() == 0) {
    Thread.sleep(100);
  }

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
Example #7
Source File: ReserveMemory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
  if (args.length > 0) {
    WhiteBox.getWhiteBox().readReservedMemory();

    throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-XX:-TransmitErrorReport",
        "ReserveMemory",
        "test");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  if (isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (isOsx()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
Example #8
Source File: RunUnitTestsConcurrently.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
  if (!Platform.isDebugBuild() || !Platform.is64bit()) {
    return;
  }
  wb = WhiteBox.getWhiteBox();
  System.out.println("Starting threads");

  int threads = Integer.valueOf(args[0]);
  timeout = Long.valueOf(args[1]);

  timeStamp = System.currentTimeMillis();

  Thread[] threadsArray = new Thread[threads];
  for (int i = 0; i < threads; i++) {
    threadsArray[i] = new Thread(new Worker());
    threadsArray[i].start();
  }
  for (int i = 0; i < threads; i++) {
    threadsArray[i].join();
  }

  System.out.println("Quitting test.");
}
 
Example #9
Source File: CompilerUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        Asserts.assertEQ(new Long(maxLevel), flagValue,
                "TieredStopAtLevel has value out of int capacity");
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
Example #10
Source File: SanityTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String... args) {

        WhiteBox wb = WhiteBox.getWhiteBox();
        StringBuilder sb = new StringBuilder();
        sb.append("1234x"); sb.append("x56789");
        String str = sb.toString();

        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is already interned");
        }
        str.intern();
        if (!wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is not interned");
        }
        str = sb.toString();
        wb.fullGC();
        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is in StringTable even after GC");
        }
    }
 
Example #11
Source File: MallocTestType.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Integer.toString(ProcessTools.getProcessId());
  ProcessBuilder pb = new ProcessBuilder();

  // Use WB API to alloc and free with the mtTest type
  long memAlloc3 = wb.NMTMalloc(128 * 1024);
  long memAlloc2 = wb.NMTMalloc(256 * 1024);
  wb.NMTFree(memAlloc3);
  long memAlloc1 = wb.NMTMalloc(512 * 1024);
  wb.NMTFree(memAlloc2);

  // Run 'jcmd <pid> VM.native_memory summary'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
  output = new OutputAnalyzer(pb.start());
  output.shouldContain("Test (reserved=512KB, committed=512KB)");

  // Free the memory allocated by NMTAllocTest
  wb.NMTFree(memAlloc1);

  output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("Test (reserved=");
}
 
Example #12
Source File: TestConcMarkCycleWB.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();

    wb.youngGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }

    wb.fullGC();
    assertTrue(wb.g1StartConcMarkCycle());
    while (wb.g1InConcurrentMark()) {
        Thread.sleep(5);
    }
    assertTrue(wb.g1StartConcMarkCycle());
}
 
Example #13
Source File: RunUnitTestsConcurrently.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
  if (!Platform.isDebugBuild() || !Platform.is64bit()) {
    return;
  }
  wb = WhiteBox.getWhiteBox();
  System.out.println("Starting threads");

  int threads = Integer.valueOf(args[0]);
  timeout = Long.valueOf(args[1]);

  timeStamp = System.currentTimeMillis();

  Thread[] threadsArray = new Thread[threads];
  for (int i = 0; i < threads; i++) {
    threadsArray[i] = new Thread(new Worker());
    threadsArray[i].start();
  }
  for (int i = 0; i < threads; i++) {
    threadsArray[i].join();
  }

  System.out.println("Quitting test.");
}
 
Example #14
Source File: MallocTestType.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Integer.toString(ProcessTools.getProcessId());
  ProcessBuilder pb = new ProcessBuilder();

  // Use WB API to alloc and free with the mtTest type
  long memAlloc3 = wb.NMTMalloc(128 * 1024);
  long memAlloc2 = wb.NMTMalloc(256 * 1024);
  wb.NMTFree(memAlloc3);
  long memAlloc1 = wb.NMTMalloc(512 * 1024);
  wb.NMTFree(memAlloc2);

  // Run 'jcmd <pid> VM.native_memory summary'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
  output = new OutputAnalyzer(pb.start());
  output.shouldContain("Test (reserved=512KB, committed=512KB)");

  // Free the memory allocated by NMTAllocTest
  wb.NMTFree(memAlloc1);

  output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("Test (reserved=");
}
 
Example #15
Source File: TestCMSClassUnloadingEnabledHWM.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String [] args) throws Exception {
  if (args.length != 1) {
    throw new IllegalArgumentException("Usage: <MetaspaceSize>");
  }

  WhiteBox wb = WhiteBox.getWhiteBox();

  // Allocate past the MetaspaceSize limit.
  long metaspaceSize = Long.parseLong(args[0]);
  long allocationBeyondMetaspaceSize  = metaspaceSize * 2;
  long metaspace = wb.allocateMetaspace(null, allocationBeyondMetaspaceSize);

  // Wait for at least one GC to occur. The caller will parse the log files produced.
  GarbageCollectorMXBean cmsGCBean = getCMSGCBean();
  while (cmsGCBean.getCollectionCount() == 0) {
    Thread.sleep(100);
  }

  wb.freeMetaspace(null, metaspace, metaspace);
}
 
Example #16
Source File: MallocTestType.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
  OutputAnalyzer output;
  WhiteBox wb = WhiteBox.getWhiteBox();

  // Grab my own PID
  String pid = Integer.toString(ProcessTools.getProcessId());
  ProcessBuilder pb = new ProcessBuilder();

  // Use WB API to alloc and free with the mtTest type
  long memAlloc3 = wb.NMTMalloc(128 * 1024);
  long memAlloc2 = wb.NMTMalloc(256 * 1024);
  wb.NMTFree(memAlloc3);
  long memAlloc1 = wb.NMTMalloc(512 * 1024);
  wb.NMTFree(memAlloc2);

  // Run 'jcmd <pid> VM.native_memory summary'
  pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"});
  output = new OutputAnalyzer(pb.start());
  output.shouldContain("Test (reserved=512KB, committed=512KB)");

  // Free the memory allocated by NMTAllocTest
  wb.NMTFree(memAlloc1);

  output = new OutputAnalyzer(pb.start());
  output.shouldNotContain("Test (reserved=");
}
 
Example #17
Source File: TestJFRIntrinsic.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns available compilation levels
 *
 * @return int array with compilation levels
 */
public static int[] getAvailableCompilationLevels() {
    if (!WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompiler")) {
        return new int[0];
    }
    if (WhiteBox.getWhiteBox().getBooleanVMFlag("TieredCompilation")) {
        Long flagValue = WhiteBox.getWhiteBox()
                .getIntxVMFlag("TieredStopAtLevel");
        int maxLevel = flagValue.intValue();
        return IntStream.rangeClosed(1, maxLevel).toArray();
    } else {
        if (Platform.isServer() && !Platform.isEmulatedClient()) {
            return new int[]{4};
        }
        if (Platform.isClient() || Platform.isMinimal() || Platform.isEmulatedClient()) {
            return new int[]{1};
        }
    }
    return new int[0];
}
 
Example #18
Source File: SanityTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String... args) {

        WhiteBox wb = WhiteBox.getWhiteBox();
        StringBuilder sb = new StringBuilder();
        sb.append("1234x"); sb.append("x56789");
        String str = sb.toString();

        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is already interned");
        }
        str.intern();
        if (!wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is not interned");
        }
        str = sb.toString();
        wb.fullGC();
        if (wb.isInStringTable(str)) {
            throw new RuntimeException("String " + str + " is in StringTable even after GC");
        }
    }
 
Example #19
Source File: ReserveMemory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
  if (args.length > 0) {
    WhiteBox.getWhiteBox().readReservedMemory();

    throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!");
  }

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-Xbootclasspath/a:.",
        "-XX:+UnlockDiagnosticVMOptions",
        "-XX:+WhiteBoxAPI",
        "-XX:-TransmitErrorReport",
        "ReserveMemory",
        "test");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  if (isWindows()) {
    output.shouldContain("EXCEPTION_ACCESS_VIOLATION");
  } else if (isOsx()) {
    output.shouldContain("SIGBUS");
  } else {
    output.shouldContain("SIGSEGV");
  }
}
 
Example #20
Source File: ReleaseCommittedMemory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  long reserveSize = 256 * 1024;
  long addr;

  addr = wb.NMTReserveMemory(reserveSize);
  wb.NMTCommitMemory(addr, 128*1024);
  wb.NMTReleaseMemory(addr, reserveSize);
}
 
Example #21
Source File: MallocRoundingReportTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    OutputAnalyzer output;
    WhiteBox wb = WhiteBox.getWhiteBox();

    // Grab my own PID
    String pid = Integer.toString(ProcessTools.getProcessId());
    ProcessBuilder pb = new ProcessBuilder();

    long[] additionalBytes = {0, 1, 512, 650};
    long[] kByteSize = {1024, 2048};
    long mallocd_total = 0;
    for ( int i = 0; i < kByteSize.length; i++)
    {
        for (int j = 0; j < (additionalBytes.length); j++) {
            long curKB = kByteSize[i] + additionalBytes[j];
            // round up/down to the nearest KB to match NMT reporting
            long numKB = (curKB % kByteSize[i] >= 512) ? ((curKB / K) + 1) : curKB / K;
            // Use WB API to alloc and free with the mtTest type
            mallocd_total = wb.NMTMalloc(curKB);
            // Run 'jcmd <pid> VM.native_memory summary', check for expected output
            // NMT does not track memory allocations less than 1KB, and rounds to the nearest KB
            String expectedOut = ("Test (reserved=" + numKB + "KB, committed=" + numKB + "KB)");

            pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" });
            output = new OutputAnalyzer(pb.start());
            output.shouldContain(expectedOut);

            wb.NMTFree(mallocd_total);
            // Run 'jcmd <pid> VM.native_memory summary', check for expected output
            pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary" });
            output = new OutputAnalyzer(pb.start());
            output.shouldNotContain("Test (reserved=");
        }
    }
}
 
Example #22
Source File: PrintNMTStatistics.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {

    // We start a new java process running with an argument and use WB API to ensure
    // we have data for NMT on VM exit
    if (args.length > 0) {
      // Use WB API to ensure that all data has been merged before we continue
      if (!WhiteBox.getWhiteBox().NMTWaitForDataMerge()) {
        throw new Exception("Call to WB API NMTWaitForDataMerge() failed");
      }
      return;
    }

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UnlockDiagnosticVMOptions",
        "-Xbootclasspath/a:.",
        "-XX:+WhiteBoxAPI",
        "-XX:NativeMemoryTracking=summary",
        "-XX:+PrintNMTStatistics",
        "PrintNMTStatistics",
        "test");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    output.shouldContain("Java Heap (reserved=");
    output.shouldNotContain("error");
    output.shouldNotContain("warning");
    output.shouldHaveExitValue(0);
  }
 
Example #23
Source File: TestGCHeapConfigurationEventWith32BitOops.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void verify() throws Exception {
    WhiteBox wb = WhiteBox.getWhiteBox();
    long heapAlignment = wb.getHeapAlignment();
    long alignedHeapSize = GCHelper.alignUp(megabytes(100), heapAlignment);
    verifyMinHeapSizeIs(megabytes(100));
    verifyInitialHeapSizeIs(alignedHeapSize);
    verifyMaxHeapSizeIs(alignedHeapSize);
    verifyUsesCompressedOopsIs(true);
    verifyObjectAlignmentInBytesIs(8);
    verifyHeapAddressBitsIs(32);
    verifyCompressedOopModeIs("32-bit");
}
 
Example #24
Source File: TestShrinkAuxiliaryData.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks is this environment suitable to run this test
 * - memory is enough to decommit (page size is not big)
 * - RSet cache size is not too big
 *
 * @return true if test could run, false if test should be skipped
 */
protected boolean checkEnvApplicability() {

    int pageSize = WhiteBox.getWhiteBox().getVMPageSize();
    System.out.println( "Page size = " + pageSize
            + " region size = " + REGION_SIZE
            + " aux data ~= " + (REGION_SIZE * 3 / 100));
    // If auxdata size will be less than page size it wouldn't decommit.
    // Auxiliary data size is about ~3.6% of heap size.
    if (pageSize >= REGION_SIZE * 3 / 100) {
        System.out.format("Skipping test for too large page size = %d",
               pageSize
        );
        return false;
    }

    if (REGION_SIZE * REGIONS_TO_ALLOCATE > Runtime.getRuntime().maxMemory()) {
        System.out.format("Skipping test for too low available memory. "
                + "Need %d, available %d",
                REGION_SIZE * REGIONS_TO_ALLOCATE,
                Runtime.getRuntime().maxMemory()
        );
        return false;
    }

    return true;
}
 
Example #25
Source File: TestCapacityUntilGCWrapAround.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example #26
Source File: TestShrinkAuxiliaryData.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks is this environment suitable to run this test
 * - memory is enough to decommit (page size is not big)
 * - RSet cache size is not too big
 *
 * @return true if test could run, false if test should be skipped
 */
protected boolean checkEnvApplicability() {

    int pageSize = WhiteBox.getWhiteBox().getVMPageSize();
    System.out.println( "Page size = " + pageSize
            + " region size = " + REGION_SIZE
            + " aux data ~= " + (REGION_SIZE * 3 / 100));
    // If auxdata size will be less than page size it wouldn't decommit.
    // Auxiliary data size is about ~3.6% of heap size.
    if (pageSize >= REGION_SIZE * 3 / 100) {
        System.out.format("Skipping test for too large page size = %d",
               pageSize
        );
        return false;
    }

    if (REGION_SIZE * REGIONS_TO_ALLOCATE > Runtime.getRuntime().maxMemory()) {
        System.out.format("Skipping test for too low available memory. "
                + "Need %d, available %d",
                REGION_SIZE * REGIONS_TO_ALLOCATE,
                Runtime.getRuntime().maxMemory()
        );
        return false;
    }

    return true;
}
 
Example #27
Source File: ParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ParserTest() throws Exception {
    wb = WhiteBox.getWhiteBox();

    testNanoTime();
    testJLong();
    testBool();
    testQuotes();
    testMemorySize();
    testSingleLetterArg();
}
 
Example #28
Source File: CompilerWhiteBoxTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Deoptimizes all non-osr versions of the given executable after
 * compilation finished.
 *
 * @param e Executable
 * @throws Exception
 */
private static void waitAndDeoptimize(Executable e) {
    CompilerWhiteBoxTest.waitBackgroundCompilation(e);
    if (WhiteBox.getWhiteBox().isMethodQueuedForCompilation(e)) {
        throw new RuntimeException(e + " must not be in queue");
    }
    // Deoptimize non-osr versions of executable
    WhiteBox.getWhiteBox().deoptimizeMethod(e, false);
}
 
Example #29
Source File: BlobSanityTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    System.out.println("Crash means that sanity check failed");

    WhiteBox wb = WhiteBox.getWhiteBox();

    runTest(wb::freeCodeBlob, 0, "wb::freeCodeBlob(0)", null);
    runTest(wb::getCodeBlob, 0, "wb::getCodeBlob(0)", NullPointerException.class);
    runTest(x -> wb.allocateCodeBlob(x, 0), -1, "wb::allocateCodeBlob(-1,0)", IllegalArgumentException.class);
}
 
Example #30
Source File: ReleaseCommittedMemory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  long reserveSize = 256 * 1024;
  long addr;

  addr = wb.NMTReserveMemory(reserveSize);
  wb.NMTCommitMemory(addr, 128*1024);
  wb.NMTReleaseMemory(addr, reserveSize);
}