hotspot/test/compiler/codecache/jmx/CodeCacheUtils.java
author dsamersoff
Thu, 18 Aug 2016 12:10:18 +0300
changeset 40624 cb96161ede05
parent 40059 c2304140ed64
permissions -rw-r--r--
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot Reviewed-by: sla, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     1
/*
40624
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     4
 *
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     8
 *
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    14
 *
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    18
 *
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    21
 * questions.
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    22
 */
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    23
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31522
diff changeset
    24
package compiler.codecache.jmx;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31522
diff changeset
    25
31522
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    26
import jdk.test.lib.Asserts;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28384
diff changeset
    27
import jdk.test.lib.Utils;
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    28
import sun.hotspot.WhiteBox;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    29
import sun.hotspot.code.BlobType;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    30
import sun.hotspot.code.CodeBlob;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    31
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31522
diff changeset
    32
import javax.management.Notification;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31522
diff changeset
    33
import java.lang.management.MemoryPoolMXBean;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 31522
diff changeset
    34
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    35
public final class CodeCacheUtils {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    36
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    37
    /**
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    38
    * Returns the value to be used for code heap allocation
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    39
    */
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    40
    public static final int ALLOCATION_SIZE
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    41
            = Integer.getInteger("codecache.allocation.size", 100);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    42
    public static final WhiteBox WB = WhiteBox.getWhiteBox();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    43
    public static final long SEGMENT_SIZE
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    44
            = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheSegmentSize");
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    45
    public static final long MIN_BLOCK_LENGTH
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    46
            = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheMinBlockLength");
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    47
    public static final long MIN_ALLOCATION = SEGMENT_SIZE * MIN_BLOCK_LENGTH;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    48
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    49
    private CodeCacheUtils() {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    50
        // To prevent from instantiation
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    51
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    52
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    53
    public static final void hitUsageThreshold(MemoryPoolMXBean bean,
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    54
            BlobType btype) {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    55
        long initialSize = bean.getUsage().getUsed();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    56
        bean.setUsageThreshold(initialSize + 1);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    57
        long usageThresholdCount = bean.getUsageThresholdCount();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    58
        long addr = WB.allocateCodeBlob(1, btype.id);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    59
        WB.fullGC();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    60
        Utils.waitForCondition(()
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    61
                -> bean.getUsageThresholdCount() == usageThresholdCount + 1);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    62
        WB.freeCodeBlob(addr);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    63
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    64
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    65
    public static final long getHeaderSize(BlobType btype) {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    66
        long addr = WB.allocateCodeBlob(0, btype.id);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    67
        int size = CodeBlob.getCodeBlob(addr).size;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    68
        WB.freeCodeBlob(addr);
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    69
        return size;
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    70
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    71
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    72
    public static String getPoolNameFromNotification(
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    73
            Notification notification) {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    74
        return ((javax.management.openmbean.CompositeDataSupport)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    75
                notification.getUserData()).get("poolName").toString();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    76
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    77
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    78
    public static boolean isAvailableCodeHeapPoolName(String name) {
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    79
        return BlobType.getAvailable().stream()
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    80
                .map(BlobType::getMemoryPool)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    81
                .map(MemoryPoolMXBean::getName)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    82
                .filter(name::equals)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    83
                .findAny().isPresent();
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    84
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    85
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    86
    /**
31522
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    87
     * Checks if the usage of the code heap corresponding to 'btype' can be
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    88
     * predicted at runtime if we disable compilation. The usage of the
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    89
     * 'NonNMethod' code heap can not be predicted because we generate adapters
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    90
     * and buffers at runtime. The 'MethodNonProfiled' code heap is also not
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    91
     * predictable because we may generate compiled versions of method handle
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    92
     * intrinsics while resolving methods at runtime. Same applies to 'All'.
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    93
     *
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    94
     * @param btype BlobType to be checked
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    95
     * @return boolean value, true if respective code heap is predictable
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    96
     */
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    97
    public static boolean isCodeHeapPredictable(BlobType btype) {
31522
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
    98
        return btype == BlobType.MethodProfiled;
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
    99
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   100
31522
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   101
    /**
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   102
     * Verifies that 'newValue' is equal to 'oldValue' if usage of the
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   103
     * corresponding code heap is predictable. Checks the weaker condition
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   104
     * 'newValue >= oldValue' if usage is not predictable because intermediate
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   105
     * allocations may happen.
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   106
     *
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   107
     * @param btype BlobType of the code heap to be checked
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   108
     * @param newValue New value to be verified
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   109
     * @param oldValue Old value to be verified
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   110
     * @param msg Error message if verification fails
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   111
     */
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   112
    public static void assertEQorGTE(BlobType btype, long newValue, long oldValue, String msg) {
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   113
        if (CodeCacheUtils.isCodeHeapPredictable(btype)) {
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   114
            // Usage is predictable, check strong == condition
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   115
            Asserts.assertEQ(newValue, oldValue, msg);
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   116
        } else {
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   117
            // Usage is not predictable, check weaker >= condition
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   118
            Asserts.assertGTE(newValue, oldValue, msg);
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   119
        }
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   120
    }
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   121
40624
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   122
    /**
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   123
     * Verifies that 'newValue' is equal to 'oldValue' if usage of the
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   124
     * corresponding code heap is predictable. Checks the weaker condition
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   125
     * 'newValue <= oldValue' if usage is not predictable because intermediate
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   126
     * allocations may happen.
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   127
     *
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   128
     * @param btype BlobType of the code heap to be checked
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   129
     * @param newValue New value to be verified
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   130
     * @param oldValue Old value to be verified
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   131
     * @param msg Error message if verification fails
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   132
     */
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   133
    public static void assertEQorLTE(BlobType btype, long newValue, long oldValue, String msg) {
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   134
        if (CodeCacheUtils.isCodeHeapPredictable(btype)) {
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   135
            // Usage is predictable, check strong == condition
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   136
            Asserts.assertEQ(newValue, oldValue, msg);
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   137
        } else {
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   138
            // Usage is not predictable, check weaker <= condition
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   139
            Asserts.assertLTE(newValue, oldValue, msg);
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   140
        }
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   141
    }
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   142
cb96161ede05 8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents: 40059
diff changeset
   143
31522
2d29f2e927fc 8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents: 30604
diff changeset
   144
    public static void disableCollectionUsageThresholds() {
28384
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   145
        BlobType.getAvailable().stream()
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   146
                .map(BlobType::getMemoryPool)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   147
                .filter(MemoryPoolMXBean::isCollectionUsageThresholdSupported)
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   148
                .forEach(b -> b.setCollectionUsageThreshold(0L));
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   149
    }
918bbbe51796 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents:
diff changeset
   150
}