test/lib/sun/hotspot/code/BlobType.java
author thartmann
Mon, 23 Feb 2015 08:48:19 +0100
changeset 29306 6448e5033ebe
parent 28349 1fcc39ead265
child 41533 64e1caddf380
permissions -rw-r--r--
8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion Summary: Store profiled code in the non-profiled code heap (and vice versa) if the code cache is really full. Reviewed-by: kvn, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     1
/*
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     4
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     7
 * published by the Free Software Foundation.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     8
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    13
 * accompanied this code).
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    14
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    18
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    21
 * questions.
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    22
 *
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    23
 */
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    24
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    25
package sun.hotspot.code;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    26
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    27
import java.lang.management.ManagementFactory;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    28
import java.lang.management.MemoryPoolMXBean;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    29
import java.util.EnumSet;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    30
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    31
import sun.hotspot.WhiteBox;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    32
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    33
public enum BlobType {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    34
    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
29306
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    35
    MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'", "NonProfiledCodeHeapSize") {
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    36
        @Override
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    37
        public boolean allowTypeWhenOverflow(BlobType type) {
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    38
            return super.allowTypeWhenOverflow(type)
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    39
                    || type == BlobType.MethodProfiled;
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    40
        }
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    41
    },
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    42
    // Execution level 2 and 3 (profiled) nmethods
29306
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    43
    MethodProfiled(1, "CodeHeap 'profiled nmethods'", "ProfiledCodeHeapSize") {
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    44
        @Override
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    45
        public boolean allowTypeWhenOverflow(BlobType type) {
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    46
            return super.allowTypeWhenOverflow(type)
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    47
                    || type == BlobType.MethodNonProfiled;
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    48
        }
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    49
    },
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    50
    // Non-nmethods like Buffers, Adapters and Runtime Stubs
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    51
    NonNMethod(2, "CodeHeap 'non-nmethods'", "NonNMethodCodeHeapSize") {
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    52
        @Override
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    53
        public boolean allowTypeWhenOverflow(BlobType type) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    54
            return super.allowTypeWhenOverflow(type)
29306
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    55
                    || type == BlobType.MethodNonProfiled
6448e5033ebe 8072774: bigapps/Weblogic+medrec/nowarnings fails due to CodeHeap 'profiled nmethods' exhaustion
thartmann
parents: 28349
diff changeset
    56
                    || type == BlobType.MethodProfiled;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    57
        }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    58
    },
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    59
    // All types (No code cache segmentation)
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    60
    All(3, "CodeCache", "ReservedCodeCacheSize");
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    61
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    62
    public final int id;
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    63
    public final String sizeOptionName;
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    64
    public final String beanName;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    65
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    66
    private BlobType(int id, String beanName, String sizeOptionName) {
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    67
        this.id = id;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    68
        this.beanName = beanName;
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
    69
        this.sizeOptionName = sizeOptionName;
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    70
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    71
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    72
    public MemoryPoolMXBean getMemoryPool() {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    73
        for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    74
            String name = bean.getName();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    75
            if (beanName.equals(name)) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    76
                return bean;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    77
            }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    78
        }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    79
        return null;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    80
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    81
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    82
    public boolean allowTypeWhenOverflow(BlobType type) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    83
        return type == this;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    84
    }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    85
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    86
    public static EnumSet<BlobType> getAvailable() {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    87
        WhiteBox whiteBox = WhiteBox.getWhiteBox();
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    88
        if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    89
            // only All for non segmented world
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    90
            return EnumSet.of(All);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    91
        }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    92
        if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    93
            // only NonNMethod for -Xint
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    94
            return EnumSet.of(NonNMethod);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    95
        }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    96
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    97
        EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    98
        if (!whiteBox.getBooleanVMFlag("TieredCompilation")
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
    99
                || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   100
            // there is no MethodProfiled in non tiered world or pure C1
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   101
            result.remove(MethodProfiled);
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   102
        }
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   103
        return result;
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   104
    }
28349
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
   105
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
   106
    public long getSize() {
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
   107
        return WhiteBox.getWhiteBox().getUintxVMFlag(sizeOptionName);
1fcc39ead265 8059613: JEP-JDK-8043304: Test task: JMX- tests
iignatyev
parents: 28154
diff changeset
   108
    }
28154
342e86350dc8 8066433: Move Whitebox test library to top level repository
thartmann
parents:
diff changeset
   109
}