sun.hotspot.code.BlobType Java Examples

The following examples show how to use sun.hotspot.code.BlobType. 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: JVMStartupRunner.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void verifyHeapSizesSum(long reserved, long profiled,
        long nonProfiled, long nonNmethods) throws Throwable {
    // JVM startup expected to fail when
    // sum(all code heap sizes) != reserved CC size
    CommandLineOptionTest.verifySameJVMStartup(
            new String[]{ INCONSISTENT_CH_SIZES_ERROR },
            /* unexpected messages */ null,
            "JVM startup should fail with inconsistent code heap size.",
            "JVM output should contain appropriate error message of code "
                    + "heap sizes are inconsistent",
            ExitCode.FAIL,
            CommandLineOptionTest.prepareBooleanFlag(
                    CodeCacheOptions.SEGMENTED_CODE_CACHE, true),
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.All.sizeOptionName, reserved),
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.MethodProfiled.sizeOptionName, profiled),
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.MethodNonProfiled.sizeOptionName, nonProfiled),
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.NonNMethod.sizeOptionName, nonNmethods));
}
 
Example #2
Source File: CodeCacheFreeSpaceRunner.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run(CodeCacheCLITestCase.Description testCaseDescription,
        CodeCacheOptions options) throws Throwable {
    long ccMinUseSpace = ((options.nonNmethods - 1) / MULTIPLIER + 1);

    String exitCodeErrorMessage = String.format("JVM startup should fail "
                    + "if %s's value lower then %s.",
            BlobType.NonNMethod.sizeOptionName, CC_MIN_USE_SPACE);
    String vmOutputErrorMessage = String.format("JVM's output should "
                    + "contain appropriate error message when %s lower "
                    + "then %s.", BlobType.NonNMethod.sizeOptionName,
            CC_MIN_USE_SPACE);

    CommandLineOptionTest.verifySameJVMStartup(
            new String[]{ TOO_SMALL_NMETHOD_CH_ERROR },
            /* unexpected messages */ null,
            exitCodeErrorMessage, vmOutputErrorMessage, ExitCode.FAIL,
            testCaseDescription.getTestOptions(options,
                    CommandLineOptionTest.prepareNumericFlag(
                            CC_MIN_USE_SPACE, ccMinUseSpace + 1)));
}
 
Example #3
Source File: CodeCacheOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public CodeCacheOptions mapOptions(EnumSet<BlobType> involvedCodeHeaps) {
    if (involvedCodeHeaps.isEmpty()
            || involvedCodeHeaps.equals(NON_SEGMENTED_HEAPS)
            || involvedCodeHeaps.equals(ALL_SEGMENTED_HEAPS)) {
        return this;
    } else if (involvedCodeHeaps.equals(SEGMENTED_HEAPS_WO_PROFILED)) {
        return new CodeCacheOptions(reserved, nonNmethods,
                profiled + nonProfiled, 0L);
    } else if (involvedCodeHeaps.equals(ONLY_NON_METHODS_HEAP)) {
        return new CodeCacheOptions(reserved, nonNmethods + profiled
                + nonProfiled, 0L, 0L);
    } else {
        throw new Error("Test bug: unexpected set of code heaps involved "
                + "into test.");
    }
}
 
Example #4
Source File: CodeCacheOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public String[] prepareOptions(String... additionalOptions) {
    List<String> options = new ArrayList<>();
    Collections.addAll(options, additionalOptions);
    Collections.addAll(options,
            CommandLineOptionTest.prepareBooleanFlag(
                    SEGMENTED_CODE_CACHE, segmented),
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.All.sizeOptionName, reserved));

    if (segmented) {
        Collections.addAll(options,
                CommandLineOptionTest.prepareNumericFlag(
                        BlobType.NonNMethod.sizeOptionName, nonNmethods),
                CommandLineOptionTest.prepareNumericFlag(
                        BlobType.MethodNonProfiled.sizeOptionName,
                        nonProfiled),
                CommandLineOptionTest.prepareNumericFlag(
                        BlobType.MethodProfiled.sizeOptionName, profiled));
    }
    return options.toArray(new String[options.size()]);
}
 
Example #5
Source File: TestSegmentedCodeCacheOption.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() throws Throwable {
    // SCC is enabled by default when TieredCompilation is on and
    // ReservedCodeCacheSize is large enough
    String errorMessage = String.format("Large enough %s and "
                    + "enabled tiered compilation should enable %s "
                    + "by default.", BlobType.All.sizeOptionName,
            SEGMENTED_CODE_CACHE);

    CommandLineOptionTest.verifyOptionValueForSameVM(
            SEGMENTED_CODE_CACHE, "true", errorMessage,
            CommandLineOptionTest.prepareNumericFlag(
                    BlobType.All.sizeOptionName,
                    THRESHOLD_CC_SIZE_VALUE),
            CommandLineOptionTest.prepareBooleanFlag(
                    TIERED_COMPILATION, true));
}
 
Example #6
Source File: MemoryPoolsPresenceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void runTest() {
    List<MemoryManagerMXBean> beans
            = ManagementFactory.getMemoryManagerMXBeans();
    Optional<MemoryManagerMXBean> any = beans
            .stream()
            .filter(bean -> CC_MANAGER.equals(bean.getName()))
            .findAny();
    Asserts.assertTrue(any.isPresent(), "Bean not found: " + CC_MANAGER);
    MemoryManagerMXBean ccManager = any.get();
    Asserts.assertNotNull(ccManager, "Found null for " + CC_MANAGER);
    String names[] = ccManager.getMemoryPoolNames();
    for (String name : names) {
        counters.put(name, counters.containsKey(name)
                ? counters.get(name) + 1 : 1);
    }
    for (BlobType btype : BlobType.getAvailable()) {
        Asserts.assertEQ(counters.get(btype.getMemoryPool().getName()), 1,
                "Found unexpected amount of beans for pool "
                + btype.getMemoryPool().getName());
    }
    Asserts.assertEQ(BlobType.getAvailable().size(),
            counters.keySet().size(), "Unexpected amount of bean names");
}
 
Example #7
Source File: TestCodeCacheFull.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void testWithBlobType(BlobType btype, long availableSize) throws Exception {
    Recording r = new Recording();
    r.enable(EventNames.CodeCacheFull);
    r.start();
    WhiteBox.getWhiteBox().allocateCodeBlob(availableSize, btype.id);
    r.stop();

    List<RecordedEvent> events = Events.fromRecording(r);
    Events.hasEvents(events);
    RecordedEvent event = events.get(0);

    String codeBlobType = Events.assertField(event, "codeBlobType").notNull().getValue();
    BlobType blobType = blobTypeFromName(codeBlobType);
    Asserts.assertTrue(blobType.allowTypeWhenOverflow(blobType), "Unexpected overflow BlobType " + blobType.id);
    Events.assertField(event, "entryCount").atLeast(0);
    Events.assertField(event, "methodCount").atLeast(0);
    Events.assertEventThread(event);
    Events.assertField(event, "fullCount").atLeast(0);
    Events.assertField(event, "startAddress").notEqual(0L);
    Events.assertField(event, "commitedTopAddress").notEqual(0L);
    Events.assertField(event, "reservedTopAddress").notEqual(0L);
}
 
Example #8
Source File: TestCodeCacheFull.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static void testWithBlobType(BlobType btype, long availableSize) throws Exception {
    Recording r = new Recording();
    r.enable(EventNames.CodeCacheFull);
    r.start();
    WhiteBox.getWhiteBox().allocateCodeBlob(availableSize, btype.id);
    r.stop();

    List<RecordedEvent> events = Events.fromRecording(r);
    Events.hasEvents(events);
    RecordedEvent event = events.get(0);

    String codeBlobType = Events.assertField(event, "codeBlobType").notNull().getValue();
    BlobType blobType = blobTypeFromName(codeBlobType);
    Asserts.assertTrue(blobType.allowTypeWhenOverflow(blobType), "Unexpected overflow BlobType " + blobType.id);
    Events.assertField(event, "entryCount").atLeast(0);
    Events.assertField(event, "methodCount").atLeast(0);
    Events.assertEventThread(event);
    Events.assertField(event, "fullCount").atLeast(0);
    Events.assertField(event, "startAddress").notEqual(0L);
    Events.assertField(event, "commitedTopAddress").notEqual(0L);
    Events.assertField(event, "reservedTopAddress").notEqual(0L);
}
 
Example #9
Source File: PoolsIndependenceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public PoolsIndependenceTest(BlobType btype) {
    counters = new HashMap<>();
    for (BlobType bt : BlobType.getAvailable()) {
        counters.put(bt.getMemoryPool().getName(), new AtomicInteger(0));
    }
    this.btype = btype;
    lastEventTimestamp = 0;
    CodeCacheUtils.disableCollectionUsageThresholds();
}
 
Example #10
Source File: OverflowCodeCacheTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void test() {
    System.out.printf("type %s%n", type);
    System.out.println("allocating till possible...");
    ArrayList<Long> blobs = new ArrayList<>();
    int compilationActivityMode = -1;
    try {
        long addr;
        int size = (int) (getHeapSize() >> 7);
        while ((addr = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) {
            blobs.add(addr);

            BlobType actualType = CodeBlob.getCodeBlob(addr).code_blob_type;
            if (actualType != type) {
                // check we got allowed overflow handling
                Asserts.assertTrue(type.allowTypeWhenOverflow(actualType),
                        type + " doesn't allow using " + actualType + " when overflow");
            }
        }
        /* now, remember compilationActivityMode to check it later, after freeing, since we
           possibly have no free cache for futher work */
        compilationActivityMode = WHITE_BOX.getCompilationActivityMode();
    } finally {
        for (Long blob : blobs) {
            WHITE_BOX.freeCodeBlob(blob);
        }
    }
    Asserts.assertNotEquals(compilationActivityMode, 1 /* run_compilation*/,
            "Compilation must be disabled when CodeCache(CodeHeap) overflows");
}
 
Example #11
Source File: CodeCacheCLITestCase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public Description(Function<CodeCacheOptions, Boolean> predicate,
        EnumSet<BlobType> involvedCodeHeaps,
        String... testCaseSpecificOptions) {
    this.involvedCodeHeaps = involvedCodeHeaps;
    this.testCaseSpecificOptions = testCaseSpecificOptions;
    this.predicate = predicate;
}
 
Example #12
Source File: ForceNMethodSweepTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private int getTotalUsage() {
    int usage = 0;
    for (BlobType type : blobTypes) {
       usage += type.getMemoryPool().getUsage().getUsed();
    }
    return usage;
}
 
Example #13
Source File: TestCodeCacheFull.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static long calculateAvailableSize(BlobType btype) {
    long availableSize = btype.getSize();
    for (BlobType alternative : BlobType.getAvailable()) {
        if (btype.allowTypeWhenOverflow(alternative)) {
            availableSize = Math.max(availableSize, alternative.getSize());
        }
    }
    return availableSize;
}
 
Example #14
Source File: CodeCacheOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public long sizeForHeap(BlobType heap) {
    switch (heap) {
        case All:
            return this.reserved;
        case NonNMethod:
            return this.nonNmethods;
        case MethodNonProfiled:
            return this.nonProfiled;
        case MethodProfiled:
            return this.profiled;
        default:
            throw new Error("Unknown heap: " + heap.name());
    }
}
 
Example #15
Source File: TestCodeCacheFull.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static BlobType blobTypeFromName(String codeBlobTypeName) throws Exception {
    for (BlobType t : BlobType.getAvailable()) {
        if (t.name.equals(codeBlobTypeName)) {
            return t;
        }
    }
    throw new Exception("Unexpected event " + codeBlobTypeName);
}
 
Example #16
Source File: GenericCodeHeapSizeRunner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run(CodeCacheCLITestCase.Description testCaseDescription,
        CodeCacheOptions options) throws Throwable {
    CodeCacheOptions expectedValues
            = options.mapOptions(testCaseDescription.involvedCodeHeaps);

    CommandLineOptionTest.verifyOptionValueForSameVM(
            BlobType.All.sizeOptionName,
            Long.toString(expectedValues.reserved),
            String.format("%s should have value %d.",
                    BlobType.All.sizeOptionName, expectedValues.reserved),
            testCaseDescription.getTestOptions(options));

    CommandLineOptionTest.verifyOptionValueForSameVM(
            BlobType.NonNMethod.sizeOptionName,
            Long.toString(expectedValues.nonNmethods),
            String.format("%s should have value %d.",
                    BlobType.NonNMethod.sizeOptionName,
                    expectedValues.nonNmethods),
            testCaseDescription.getTestOptions(options));

    CommandLineOptionTest.verifyOptionValueForSameVM(
            BlobType.MethodNonProfiled.sizeOptionName,
            Long.toString(expectedValues.nonProfiled),
            String.format("%s should have value %d.",
                    BlobType.MethodNonProfiled.sizeOptionName,
                    expectedValues.nonProfiled),
            testCaseDescription.getTestOptions(options));

    CommandLineOptionTest.verifyOptionValueForSameVM(
            BlobType.MethodProfiled.sizeOptionName,
            Long.toString(expectedValues.profiled),
            String.format("%s should have value %d.",
                    BlobType.MethodProfiled.sizeOptionName,
                    expectedValues.profiled),
            testCaseDescription.getTestOptions(options));
}
 
Example #17
Source File: TestCodeCacheFull.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static long calculateAvailableSize(BlobType btype) {
    long availableSize = btype.getSize();
    for (BlobType alternative : BlobType.getAvailable()) {
        if (btype.allowTypeWhenOverflow(alternative)) {
            availableSize = Math.max(availableSize, alternative.getSize());
        }
    }
    return availableSize;
}
 
Example #18
Source File: UsageThresholdExceededTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    int iterationsCount = Integer.getInteger("jdk.test.lib.iterations", 1);
    for (BlobType btype : BlobType.getAvailable()) {
        if (CodeCacheUtils.isCodeHeapPredictable(btype)) {
            new UsageThresholdExceededTest(btype, iterationsCount).runTest();
        }
    }
}
 
Example #19
Source File: GetUsageTest.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 {
    for (BlobType btype : BlobType.getAvailable()) {
        for (int allocSize = 10; allocSize < 100000; allocSize *= 10) {
            new GetUsageTest(btype, allocSize).runTest();
        }
    }
}
 
Example #20
Source File: GetUsageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected final Map<MemoryPoolMXBean, Long> getBeanUsages() {
    Map<MemoryPoolMXBean, Long> beanUsages = new HashMap<>();
    for (BlobType bt : BlobType.getAvailable()) {
        beanUsages.put(bt.getMemoryPool(),
                bt.getMemoryPool().getUsage().getUsed());
    }
    return beanUsages;
}
 
Example #21
Source File: ThresholdNotificationsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    for (BlobType bt : BlobType.getAvailable()) {
        if (CodeCacheUtils.isCodeHeapPredictable(bt)) {
            new ThresholdNotificationsTest(bt).runTest();
        }
    }
}
 
Example #22
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static boolean isAvailableCodeHeapPoolName(String name) {
    return BlobType.getAvailable().stream()
            .map(BlobType::getMemoryPool)
            .map(MemoryPoolMXBean::getName)
            .filter(name::equals)
            .findAny().isPresent();
}
 
Example #23
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static final void hitUsageThreshold(MemoryPoolMXBean bean,
        BlobType btype) {
    long initialSize = bean.getUsage().getUsed();
    bean.setUsageThreshold(initialSize + 1);
    long usageThresholdCount = bean.getUsageThresholdCount();
    long addr = WB.allocateCodeBlob(1, btype.id);
    WB.fullGC();
    Utils.waitForCondition(()
            -> bean.getUsageThresholdCount() == usageThresholdCount + 1);
    WB.freeCodeBlob(addr);
}
 
Example #24
Source File: InitialAndMaxUsageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public InitialAndMaxUsageTest(BlobType btype) {
    this.btype = btype;
    this.maxSize = btype.getSize();
    /* Only profiled code cache initial size should be 0, because of
     -XX:CompileCommand=compileonly,null::* non-methods might be not empty,
     as well as non-profiled methods, because it's used as fallback in
     case non-methods is full */
    lowerBoundIsZero = btype == BlobType.MethodProfiled;
}
 
Example #25
Source File: TestCodeCacheFull.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static BlobType blobTypeFromName(String codeBlobTypeName) throws Exception {
    for (BlobType t : BlobType.getAvailable()) {
        if (t.name.equals(codeBlobTypeName)) {
            return t;
        }
    }
    throw new Exception("Unexpected event " + codeBlobTypeName);
}
 
Example #26
Source File: TestCodeCacheFull.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (BlobType btype : BlobType.getAvailable()) {
        testWithBlobType(btype, calculateAvailableSize(btype));
    }
}
 
Example #27
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static final long getHeaderSize(BlobType btype) {
    long addr = WB.allocateCodeBlob(0, btype.id);
    int size = CodeBlob.getCodeBlob(addr).size;
    WB.freeCodeBlob(addr);
    return size;
}
 
Example #28
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void disableCollectionUsageThresholds() {
    BlobType.getAvailable().stream()
            .map(BlobType::getMemoryPool)
            .filter(MemoryPoolMXBean::isCollectionUsageThresholdSupported)
            .forEach(b -> b.setCollectionUsageThreshold(0L));
}
 
Example #29
Source File: CodeCacheInfoFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static CodeCacheInfoFormatter forHeap(BlobType heap) {
    return new CodeCacheInfoFormatter(heap);
}
 
Example #30
Source File: InitialAndMaxUsageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    for (BlobType btype : BlobType.getAvailable()) {
        new InitialAndMaxUsageTest(btype).runTest();
    }
}