Java Code Examples for jdk.test.lib.Asserts#assertEQ()

The following examples show how to use jdk.test.lib.Asserts#assertEQ() . 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: ResolvePossiblyCachedConstantInPoolTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void validateString(ConstantPool constantPoolCTVM,
                                   ConstantTypes cpType,
                                   DummyClasses dummyClass,
                                   int cpi) {
    TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
    if (entry == null) {
        return;
    }
    int index = cpi;
    String cached = "";
    int cpci = dummyClass.getCPCacheIndex(cpi);
    if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
        index = cpci;
        cached = "cached ";
    }
    Object constantInPool = CompilerToVMHelper.resolvePossiblyCachedConstantInPool(constantPoolCTVM, index);
    String stringToVerify = (String) constantInPool;
    String stringToRefer = entry.name;
    if (stringToRefer.equals("") && cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
        stringToRefer = null; // tested method returns null for cached empty strings
    }
    String msg = String.format("Wrong string accessed by %sconstant pool index %d", cached, index);
    Asserts.assertEQ(stringToRefer, stringToVerify, msg);
}
 
Example 2
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 3
Source File: TestBiasedLockRevocationEvents.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void testSingleRevocation() throws Throwable {
    class MyLock {};

    Recording recording = new Recording();

    recording.enable(EventNames.BiasedLockRevocation);
    recording.start();

    Thread biasBreaker = triggerRevocation(1, MyLock.class);

    recording.stop();
    List<RecordedEvent> events = getRevocationEvents(recording, "lockClass", MyLock.class);
    Asserts.assertEQ(events.size(), 1);

    RecordedEvent event = events.get(0);
    Events.assertEventThread(event, biasBreaker);
    Events.assertEventThread(event, "previousOwner", Thread.currentThread());

    RecordedClass lockClass = event.getValue("lockClass");
    Asserts.assertEquals(lockClass.getName(), MyLock.class.getName());

    validateStackTrace(event.getStackTrace());
}
 
Example 4
Source File: TestBiasedLockRevocationEvents.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void testBulkRevocation() throws Throwable {
    class MyLock {};

    Recording recording = new Recording();

    recording.enable(EventNames.BiasedLockClassRevocation);
    recording.start();

    Thread biasBreaker = triggerRevocation(BULK_REVOKE_THRESHOLD, MyLock.class);

    recording.stop();
    List<RecordedEvent> events = getRevocationEvents(recording, "revokedClass", MyLock.class);
    Asserts.assertEQ(events.size(), 1);

    RecordedEvent event = events.get(0);
    Events.assertEventThread(event, biasBreaker);
    Events.assertField(event, "disableBiasing").equal(false);

    RecordedClass lockClass = event.getValue("revokedClass");
    Asserts.assertEquals(lockClass.getName(), MyLock.class.getName());

    validateStackTrace(event.getStackTrace());
}
 
Example 5
Source File: LookupSignatureInPoolTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void validate(ConstantPool constantPoolCTVM,
                             ConstantTypes cpType,
                             DummyClasses dummyClass,
                             int cpi) {
    TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
    if (entry == null) {
        return;
    }
    int index = cpi;
    String cached = "";
    int cpci = dummyClass.getCPCacheIndex(cpi);
    if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
        index = cpci;
        cached = "cached ";
    }
    String sigToVerify = CompilerToVMHelper.lookupSignatureInPool(constantPoolCTVM, index);
    String sigToRefer = entry.type;
    String msg = String.format("Wrong signature accessed by %sconstant pool index %d",
                               cached,
                               index);
    Asserts.assertEQ(sigToVerify, sigToRefer, msg);
}
 
Example 6
Source File: TestRTMRetryCount.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void verifyRTMRetryCount(int retryCount) throws Throwable {
    CompilableTest busyLock = new BusyLock();
    long expectedAborts = retryCount + 1L;

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            busyLock,
            "-XX:-UseRTMXendForLockBusy",
            "-XX:RTMTotalCountIncrRate=1",
            CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
                    retryCount),
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            BusyLock.class.getName(),
            Boolean.toString(TestRTMRetryCount.INFLATE_MONITOR),
            Integer.toString(TestRTMRetryCount.LOCKING_TIME)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            busyLock.getMethodWithLockName(), outputAnalyzer.getStdout());

    Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
            + "exactly one rtm locking statistics entry for method "
            + busyLock.getMethodWithLockName());

    Asserts.assertEQ(statistics.get(0).getTotalAborts(), expectedAborts,
            String.format("It is expected to get %d aborts",
                    expectedAborts));
}
 
Example 7
Source File: VmFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void testWriteNegative(T value, T expected) {
    // Should always return false for non-existing flags
    Asserts.assertFalse(WHITE_BOX.isConstantVMFlag(flagName));
    Asserts.assertFalse(WHITE_BOX.isLockedVMFlag(flagName));
    String oldValue = getVMOptionAsString();
    Asserts.assertEQ(oldValue, asString(getValue()));
    Asserts.assertEQ(oldValue, asString(WHITE_BOX.getVMFlag(flagName)));
    setNewValue(value);
    String newValue = getVMOptionAsString();
    Asserts.assertEQ(oldValue, newValue);
}
 
Example 8
Source File: TestRTMSpinLoopCount.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private long getAbortsCountOnLockBusy(int spinLoopCount) throws Throwable {
    CompilableTest test = new BusyLock();

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            test,
            CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
                    TestRTMSpinLoopCount.RTM_RETRY_COUNT),
            CommandLineOptionTest.prepareNumericFlag("RTMSpinLoopCount",
                    spinLoopCount),
            "-XX:-UseRTMXendForLockBusy",
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            BusyLock.class.getName(),
            Boolean.toString(TestRTMSpinLoopCount.INFLATE_MONITOR),
            Integer.toString(TestRTMSpinLoopCount.LOCKING_TIME)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            test.getMethodWithLockName(), outputAnalyzer.getOutput());

    Asserts.assertEQ(statistics.size(), 1,
            "VM output should contain exactly one entry for method "
             + test.getMethodWithLockName());

    RTMLockingStatistics lock = statistics.get(0);

    Asserts.assertLTE(lock.getTotalAborts(),
            TestRTMSpinLoopCount.MAX_ABORTS, String.format("Total aborts "
                    + "count (%d) should be less or equal to %d",
                    lock.getTotalAborts(),
                    TestRTMSpinLoopCount.MAX_ABORTS));

    return lock.getTotalAborts();
}
 
Example 9
Source File: UseSHASpecificTestCaseForUnsupportedCPU.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public UseSHASpecificTestCaseForUnsupportedCPU(String optionName) {
    super(SHAOptionsBase.USE_SHA_OPTION, new AndPredicate(
            new OrPredicate(Platform::isSparc, Platform::isAArch64),
            new NotPredicate(
                    IntrinsicPredicates.ANY_SHA_INSTRUCTION_AVAILABLE)));

    Asserts.assertEQ(optionName, SHAOptionsBase.USE_SHA_OPTION,
            "Test case should be used for " + SHAOptionsBase.USE_SHA_OPTION
                    + " option only.");
}
 
Example 10
Source File: TestLargeJavaEvent64k.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void verify(RecordedEvent event, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        String fieldName = entry.getKey();
        Object value = event.getValue(fieldName);
        Object expected = fields.get(fieldName);
        Asserts.assertEQ(value, expected);
    }
}
 
Example 11
Source File: InitialAndMaxUsageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void runTest() {
    long headerSize = CodeCacheUtils.getHeaderSize(btype);
    MemoryPoolMXBean bean = btype.getMemoryPool();
    long initialUsage = btype.getMemoryPool().getUsage().getUsed();
    System.out.printf("INFO: trying to test %s of max size %d and initial"
            + " usage %d%n", bean.getName(), maxSize, initialUsage);
    Asserts.assertLT(initialUsage + headerSize + 1L, maxSize,
            "Initial usage is close to total size for " + bean.getName());
    if (lowerBoundIsZero) {
        Asserts.assertEQ(initialUsage, 0L, "Unexpected initial usage");
    }
    ArrayList<Long> blobs = new ArrayList<>();
    long minAllocationUnit = Math.max(1, CodeCacheUtils.MIN_ALLOCATION - headerSize);
    /* now filling code cache with large-sized allocation first, since
     lots of small allocations takes too much time, so, just a small
     optimization */
    try {
        for (int coef = 1000000; coef > 0; coef /= 10) {
            fillWithSize(coef * minAllocationUnit, blobs, bean);
        }
        Asserts.assertGT((double) bean.getUsage().getUsed(),
                CACHE_USAGE_COEF * maxSize, String.format("Unable to fill "
                        + "more than %f of %s. Reported usage is %d ",
                        CACHE_USAGE_COEF, bean.getName(),
                        bean.getUsage().getUsed()));
    } finally {
        for (long entry : blobs) {
            CodeCacheUtils.WB.freeCodeBlob(entry);
        }
    }
    System.out.printf("INFO: Scenario finished successfully for %s%n",
            bean.getName());
}
 
Example 12
Source File: CallsBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A method checking values. Should be used to verify if all parameters are
 * passed as expected. Parameter N should have a value indicating number "N"
 * in respective type representation.
 */
public static void checkValues(int param1, long param2, float param3,
        double param4, String param5) {
    Asserts.assertEQ(param1, 1);
    Asserts.assertEQ(param2, 2L);
    Asserts.assertEQ(param3, 3.0f);
    Asserts.assertEQ(param4, 4.0d);
    Asserts.assertEQ(param5, "5");
}
 
Example 13
Source File: MaterializeVirtualObjectTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void recurse(int depth, int iteration) {
    if (depth == 0) {
        check(iteration);
    } else {
        Integer s = new Integer(depth);
        recurse(depth - 1, iteration);
        Asserts.assertEQ(s.intValue(), depth,
                String.format("different values: %s != %s", s.intValue(), depth));
    }
}
 
Example 14
Source File: TestRTMTotalCountIncrRate.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void verifyLocksCount(int incrRate, boolean useStackLock)
        throws Throwable{
    CompilableTest test = new Test();

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            test,
            CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
                    useStackLock),
            CommandLineOptionTest.prepareNumericFlag(
                    "RTMTotalCountIncrRate", incrRate),
            "-XX:RTMRetryCount=0",
            "-XX:+PrintPreciseRTMLockingStatistics",
            Test.class.getName(),
            Boolean.toString(!useStackLock)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            test.getMethodWithLockName(), outputAnalyzer.getOutput());

    Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
            + "exactly one RTM locking statistics entry for method "
            + test.getMethodWithLockName());

    RTMLockingStatistics lock = statistics.get(0);
    if (incrRate == 1) {
        Asserts.assertEQ(lock.getTotalLocks(), Test.TOTAL_ITERATIONS,
                "Total locks should be exactly the same as amount of "
                + "iterations.");
    }
}
 
Example 15
Source File: TestRTMDeoptOnLowAbortRatio.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void verifyRTMDeopt(boolean useStackLock) throws Throwable {
    CompilableTest test = new Test();
    String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
                                       useStackLock ? "use" : "no");

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            logFileName,
            test,
            "-XX:+UseRTMDeopt",
            CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
                    useStackLock),
            CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
                    TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD),
            CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
                    TestRTMDeoptOnLowAbortRatio.ABORT_THRESHOLD),
            "-XX:RTMAbortRatio=100",
            "-XX:CompileThreshold=1",
            "-XX:RTMRetryCount=0",
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            Test.class.getName(),
            Boolean.toString(!useStackLock)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);

    Asserts.assertEQ(firedTraps, 1,
                    "Expected to get only one deoptimization due to rtm"
                    + " state change");

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            test.getMethodWithLockName(), outputAnalyzer.getOutput());

    Asserts.assertEQ(statistics.size(), 2,
                     "VM output should contain two RTM locking "
                     + "statistics entries for method "
                     + test.getMethodWithLockName());

    RTMLockingStatistics statisticsBeforeDeopt = null;

    for (RTMLockingStatistics s : statistics) {
        if (s.getTotalLocks()
                == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD) {
            Asserts.assertNull(statisticsBeforeDeopt,
                    "Only one abort was expected during test run");
            statisticsBeforeDeopt = s;
        }
    }

    Asserts.assertNotNull(statisticsBeforeDeopt,
            "After LockThreshold was reached, method should be recompiled "
            + "with rtm lock eliding.");
}
 
Example 16
Source File: TestIsEnabledMultiple.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void assertEnablement(boolean enabled) {
    Asserts.assertEQ(EventType.getEventType(MyEvent.class).isEnabled(), enabled, "Event enablement not as expected");
}
 
Example 17
Source File: ResolveFieldInPoolTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void validate(ConstantPool constantPoolCTVM,
                             ConstantTypes cpType,
                             DummyClasses dummyClass,
                             int cpi) {
    TestedCPEntry entry = cpType.getTestedCPEntry(dummyClass, cpi);
    if (entry == null) {
        return;
    }
    int index = cpi;
    String cached = "";
    int cpci = dummyClass.getCPCacheIndex(cpi);
    if (cpci != ConstantPoolTestsHelper.NO_CP_CACHE_PRESENT) {
        index = cpci;
        cached = "cached ";
    }
    for (int j = 0; j < entry.opcodes.length; j++) {
        int[] info = new int[3];
        HotSpotResolvedObjectType fieldToVerify
                = CompilerToVMHelper.resolveFieldInPool(constantPoolCTVM,
                                                       index,
                                                       entry.methods == null ? null : entry.methods[j],
                                                       entry.opcodes[j],
                                                       info);
        String msg = String.format("Object returned by resolveFieldInPool method"
                                           + " for %sindex %d  should not be null",
                                   cached,
                                   index);
        Asserts.assertNotNull(fieldToVerify, msg);
        String classNameToRefer = entry.klass;
        String fieldToVerifyKlassToString = fieldToVerify.klass().toValueString();
        if (!fieldToVerifyKlassToString.contains(classNameToRefer)) {
            msg = String.format("String representation \"%s\" of the object"
                                        + " returned by resolveFieldInPool method"
                                        + " for index %d does not contain a field's class name,"
                                        + " should contain %s",
                                fieldToVerifyKlassToString,
                                index,
                                classNameToRefer);
            throw new AssertionError(msg);
        }
        msg = String.format("Access flags returned by resolveFieldInPool"
                                    + " method are wrong for the field %s.%s"
                                    + " at %sindex %d",
                            entry.klass,
                            entry.name,
                            cached,
                            index);
        Asserts.assertEQ(info[0], entry.accFlags, msg);
        if (cpci == -1) {
            return;
        }
        Class classOfTheField = null;
        Field fieldToRefer = null;
        try {
            classOfTheField = Class.forName(classNameToRefer.replaceAll("/", "\\."));
            fieldToRefer = classOfTheField.getDeclaredField(entry.name);
            fieldToRefer.setAccessible(true);
        } catch (Exception ex) {
            throw new Error("Unexpected exception", ex);
        }
        int offsetToRefer;
        if ((entry.accFlags & Opcodes.ACC_STATIC) != 0) {
            offsetToRefer = (int) UNSAFE.staticFieldOffset(fieldToRefer);
        } else {
            offsetToRefer = (int) UNSAFE.objectFieldOffset(fieldToRefer);
        }
        msg = String.format("Field offset returned by resolveFieldInPool"
                                    + " method is wrong for the field %s.%s"
                                    + " at %sindex %d",
                            entry.klass,
                            entry.name,
                            cached,
                            index);
        Asserts.assertEQ(info[1], offsetToRefer, msg);
    }
}
 
Example 18
Source File: TestRTMAfterNonRTMDeopt.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void verifyRTMAfterDeopt(boolean useStackLock,
        boolean useRTMDeopt) throws Throwable {
    CompilableTest test = new Test();
    String logFile = String.format("rtm_%s_stack_lock_%s_deopt.xml",
            (useStackLock ? "use" : "no"), (useRTMDeopt ? "use" : "no"));

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            logFile,
            test,
            "-XX:CompileThreshold=1",
            CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
                    useStackLock),
            CommandLineOptionTest.prepareBooleanFlag("UseRTMDeopt",
                    useRTMDeopt),
            "-XX:RTMAbortRatio=100",
            CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
                    TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD),
            CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
                    TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD / 2L),
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            Test.class.getName(),
            Boolean.toString(!useStackLock)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    int traps = RTMTestBase.firedRTMStateChangeTraps(logFile);

    if (useRTMDeopt) {
        Asserts.assertEQ(traps, 2, "Two uncommon traps with "
                + "reason rtm_state_change should be fired.");
    } else {
        Asserts.assertEQ(traps, 0, "No uncommon traps with "
                + "reason rtm_state_change should be fired.");
    }

    int rangeCheckTraps = RTMTestBase.firedUncommonTraps(logFile,
            TestRTMAfterNonRTMDeopt.RANGE_CHECK);

    Asserts.assertEQ(rangeCheckTraps, 1,
            "One range_check uncommon trap should be fired.");

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            test.getMethodWithLockName(), outputAnalyzer.getOutput());

    int expectedStatEntries = (useRTMDeopt ? 4 : 2);

    Asserts.assertEQ(statistics.size(), expectedStatEntries,
            String.format("VM output should contain %d RTM locking "
                    + "statistics entries.", expectedStatEntries));
}
 
Example 19
Source File: GetNMethodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();

    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    Asserts.assertNotNull(nmethod,
            "nmethod of compiled method is null");
    Asserts.assertNotNull(nmethod.insts,
            "nmethod.insts of compiled method is null");
    Asserts.assertGT(nmethod.insts.length, 0,
            "compiled method's instructions is empty");
    Asserts.assertNotNull(nmethod.code_blob_type, "blob type is null");
    if (WHITE_BOX.getBooleanVMFlag("SegmentedCodeCache")) {
        Asserts.assertNE(nmethod.code_blob_type, BlobType.All);
        switch (nmethod.comp_level) {
        case 1:
        case 4:
            checkBlockType(nmethod, BlobType.MethodNonProfiled);
            break;
        case 2:
        case 3:
            checkBlockType(nmethod, BlobType.MethodProfiled);
            break;
        default:
            throw new Error("unexpected comp level " + nmethod);
        }
    } else {
        Asserts.assertEQ(nmethod.code_blob_type, BlobType.All);
    }

    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    Asserts.assertNull(nmethod,
            "nmethod of non-compiled method isn't null");
}
 
Example 20
Source File: CodeCacheUtils.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Verifies that 'newValue' is equal to 'oldValue' if usage of the
 * corresponding code heap is predictable. Checks the weaker condition
 * 'newValue >= oldValue' if usage is not predictable because intermediate
 * allocations may happen.
 *
 * @param btype BlobType of the code heap to be checked
 * @param newValue New value to be verified
 * @param oldValue Old value to be verified
 * @param msg Error message if verification fails
 */
public static void assertEQorGTE(BlobType btype, long newValue, long oldValue, String msg) {
    if (CodeCacheUtils.isCodeHeapPredictable(btype)) {
        // Usage is predictable, check strong == condition
        Asserts.assertEQ(newValue, oldValue, msg);
    } else {
        // Usage is not predictable, check weaker >= condition
        Asserts.assertGTE(newValue, oldValue, msg);
    }
}