hotspot/test/testlibrary/whitebox/sun/hotspot/code/BlobType.java
author iignatyev
Mon, 10 Nov 2014 19:04:38 +0300
changeset 27642 8c9eff693145
child 27701 c6b49b72dc61
permissions -rw-r--r--
8059624: Test task: WhiteBox API for testing segmented codecache feature Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27642
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     1
/*
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     4
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     8
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    14
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    18
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    21
 * questions.
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    22
 *
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    23
 */
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    24
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    25
package sun.hotspot.code;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    26
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    27
import java.lang.management.ManagementFactory;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    28
import java.lang.management.MemoryPoolMXBean;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    29
import java.util.EnumSet;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    30
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    31
import sun.hotspot.WhiteBox;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    32
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    33
public enum BlobType {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    34
    // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    35
    MethodNonProfiled(0, "CodeHeap 'non-profiled nmethods'"),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    36
    // Execution level 2 and 3 (profiled) nmethods
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    37
    MethodProfiled(1, "CodeHeap 'profiled nmethods'"),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    38
    // Non-nmethods like Buffers, Adapters and Runtime Stubs
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    39
    NonNMethod(2, "CodeHeap 'non-nmethods'"),
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    40
    // All types (No code cache segmentation)
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    41
    All(3, "CodeCache");
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    42
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    43
    public final int id;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    44
    private final String beanName;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    45
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    46
    private BlobType(int id, String beanName) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    47
        this.id = id;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    48
        this.beanName = beanName;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    49
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    50
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    51
    public MemoryPoolMXBean getMemoryPool() {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    52
        for (MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    53
            String name = bean.getName();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    54
            if (beanName.equals(name)) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    55
                return bean;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    56
            }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    57
        }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    58
        return null;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    59
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    60
    public static EnumSet<BlobType> getAvailable() {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    61
        WhiteBox whiteBox = WhiteBox.getWhiteBox();
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    62
        if (!whiteBox.getBooleanVMFlag("SegmentedCodeCache")) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    63
            // only All for non segmented world
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    64
            return EnumSet.of(All);
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    65
        }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    66
        if (System.getProperty("java.vm.info").startsWith("interpreted ")) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    67
            // only NonNMethod for -Xint
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    68
            return EnumSet.of(NonNMethod);
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    69
        }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    70
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    71
        EnumSet<BlobType> result = EnumSet.complementOf(EnumSet.of(All));
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    72
        if (!whiteBox.getBooleanVMFlag("TieredCompilation")
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    73
                || whiteBox.getIntxVMFlag("TieredStopAtLevel") <= 1) {
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    74
            // there is no MethodProfiled in non tiered world or pure C1
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    75
            result.remove(MethodProfiled);
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    76
        }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    77
        return result;
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    78
    }
8c9eff693145 8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff changeset
    79
}