hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java
author tpivovarova
Tue, 12 Jul 2016 18:24:48 +0300
changeset 40059 c2304140ed64
parent 38152 80e5da81fb2c
child 40631 ed82623d7831
permissions -rw-r--r--
8132919: Put compiler tests in packages Reviewed-by: vlivanov, dpochepk Contributed-by: igor.ignatyev@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28392
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     1
/*
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
28392
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     4
 *
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     8
 *
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    13
 * accompanied this code).
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    14
 *
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    18
 *
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    21
 * questions.
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    22
 */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    23
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    24
/*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    25
 * @test SegmentedCodeCacheDtraceTest
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    26
 * @bug 8015774
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    27
 * @summary testing of dtrace for segmented code cache
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    28
 * @requires os.family=="solaris"
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    29
 * @modules java.base/jdk.internal.misc
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    30
 * @library /testlibrary /test/lib /
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    31
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    32
 * @build compiler.codecache.dtrace.SegmentedCodeCacheDtraceTest
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    33
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    34
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    35
 * @run main/othervm/timeout=600 -Xbootclasspath/a:.
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    36
 *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    37
 *     compiler.codecache.dtrace.SegmentedCodeCacheDtraceTest
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    38
 */
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    39
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    40
package compiler.codecache.dtrace;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    41
33072
71f9b0782023 8136693: add package statement 'compiler.testlibrary' to CompilerUtils
tpivovarova
parents: 30604
diff changeset
    42
import compiler.testlibrary.CompilerUtils;
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    43
import jdk.test.lib.Asserts;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    44
import jdk.test.lib.JDKToolFinder;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    45
import jdk.test.lib.OutputAnalyzer;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    46
import jdk.test.lib.Utils;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    47
import jdk.test.lib.dtrace.DtraceResultsAnalyzer;
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
    48
import jdk.test.lib.dtrace.DtraceRunner;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 38152
diff changeset
    49
28392
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    50
import java.io.IOException;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    51
import java.lang.reflect.Executable;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    52
import java.nio.file.Files;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    53
import java.nio.file.Paths;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    54
import java.util.Arrays;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    55
import java.util.Collections;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    56
import java.util.HashMap;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    57
import java.util.HashSet;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    58
import java.util.List;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    59
import java.util.Map;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    60
import java.util.Random;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    61
import java.util.Set;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    62
import java.util.regex.Matcher;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    63
import java.util.regex.Pattern;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    64
import java.util.stream.Collectors;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    65
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    66
public class SegmentedCodeCacheDtraceTest {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    67
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    68
    private static final String WORKER_CLASS_NAME
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    69
            = SegmentedCodeCacheDtraceTestWorker.class.getName();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    70
    private static final String JAVA_OPTS = " -XX:+DTraceMethodProbes "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    71
            + "-Xbootclasspath/a:" + System.getProperty("test.classes") + " "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    72
            + "-XX:+UnlockDiagnosticVMOptions "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    73
            + "-XX:+WhiteBoxAPI -XX:+SegmentedCodeCache "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    74
            + "-XX:CompileCommand=compileonly,"
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    75
            + WORKER_CLASS_NAME + "::* "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    76
            + " -classpath " + System.getProperty("test.class.path") + " "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    77
            + String.join(" ", Utils.getTestJavaOpts());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    78
    private static final String DTRACE_SCRIPT
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    79
            = "SegmentedCodeCacheDtraceTestScript.d";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    80
    private static final List<Executable> MLIST =
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    81
            SegmentedCodeCacheDtraceTestWorker.TESTED_METHODS_LIST;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    82
    private static final int WORKER_METHODS_COUNT = MLIST.size();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    83
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    84
    private void runTest(TestCombination tc) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    85
        String params = MLIST.stream()
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    86
                .map(Executable::getName)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    87
                .map(x -> tc.data.get(x).compileLevel + " " + tc.data.get(x).isInlined)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    88
                .collect(Collectors.joining(" "));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    89
        DtraceRunner runner = new DtraceRunner();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    90
        runner.runDtrace(JDKToolFinder.getTestJDKTool("java"), JAVA_OPTS,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    91
                WORKER_CLASS_NAME, params, Paths.get(System.getProperty("test.src"),
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    92
                        DTRACE_SCRIPT).toString(),
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    93
                DtraceRunner.PERMIT_DESTRUCTIVE_ACTIONS_DTRACE_OPTION,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    94
                new SegmentedCodeCacheDtraceResultsAnalyzer());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    95
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    96
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    97
    private static TestCombination generateUniqueCombination(
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    98
            int[] availableLevels, Set<TestCombination> combinations) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    99
        int len = availableLevels.length;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   100
        /* first, check if we're out of combinations. */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   101
        int maxCombinationsCount
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   102
                = (1 << WORKER_METHODS_COUNT)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   103
                * (int) Math.pow(len, WORKER_METHODS_COUNT);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   104
        if (combinations.size() == maxCombinationsCount) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   105
            return null;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   106
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   107
        Random r = Utils.getRandomInstance();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   108
        while (combinations.size() < maxCombinationsCount) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   109
            int levels[] = new int[WORKER_METHODS_COUNT];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   110
            boolean inlines[] = new boolean[WORKER_METHODS_COUNT];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   111
            for (int i = 0; i < WORKER_METHODS_COUNT; i++) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   112
                levels[i] = availableLevels[r.nextInt(len)];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   113
                inlines[i] = r.nextBoolean();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   114
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   115
            TestCombination tc = new TestCombination(levels, inlines);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   116
            if (combinations.add(tc)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   117
                return tc;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   118
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   119
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   120
        return null;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   121
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   122
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   123
    public static void main(String args[]) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   124
        int iterations
30604
b8d532cb6420 8067013: Rename the com.oracle.java.testlibary package
ykantser
parents: 28392
diff changeset
   125
                = Integer.getInteger("jdk.test.lib.iterations", 1);
28392
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   126
        if (!DtraceRunner.dtraceAvailable()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   127
            System.out.println("INFO: There is no dtrace avaiable. Skipping.");
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   128
            return;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   129
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   130
        int[] availableLevels = CompilerUtils.getAvailableCompilationLevels();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   131
        // adding one more entry(zero) for interpeter
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   132
        availableLevels
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   133
                = Arrays.copyOf(availableLevels, availableLevels.length + 1);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   134
        Set<TestCombination> combinations = new HashSet<>();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   135
        for (int i = 0; i < iterations; i++) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   136
            TestCombination tc
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   137
                    = generateUniqueCombination(availableLevels, combinations);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   138
            if (tc == null) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   139
                System.out.println("INFO: no more combinations available");
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   140
                return;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   141
            } else {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   142
                System.out.println("INFO: Running testcase for: " + tc);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   143
                new SegmentedCodeCacheDtraceTest().runTest(tc);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   144
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   145
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   146
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   147
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   148
    private static class MethodData {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   149
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   150
        public final int compileLevel;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   151
        public final boolean isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   152
        public final String name;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   153
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   154
        public MethodData(String name, int compileLevel, boolean isInlined) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   155
            this.name = name;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   156
            this.compileLevel = compileLevel;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   157
            this.isInlined = isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   158
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   159
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   160
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   161
        public boolean equals(Object o) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   162
            if (o == null || !(o instanceof MethodData)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   163
                return false;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   164
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   165
            MethodData md = (MethodData) o;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   166
            return md.compileLevel == compileLevel
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   167
                    && md.isInlined == isInlined
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   168
                    && md.name.equals(name);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   169
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   170
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   171
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   172
        public int hashCode() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   173
            return 100 * name.hashCode() + 10 * compileLevel + (isInlined ? 1 : 0);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   174
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   175
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   176
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   177
        public String toString() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   178
            return name + " " + compileLevel + " " + isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   179
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   180
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   181
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   182
    private static class TestCombination {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   183
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   184
        private final Map<String, MethodData> data;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   185
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   186
        public TestCombination(int compLevels[], boolean inlines[]) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   187
            Map<String, MethodData> d = new HashMap<>();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   188
            for (int i = 0; i < MLIST.size(); i++) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   189
                d.put(MLIST.get(i).getName(), new MethodData(MLIST.get(i).getName(),
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   190
                        compLevels[i], inlines[i]));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   191
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   192
            data = Collections.unmodifiableMap(d);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   193
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   194
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   195
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   196
        public boolean equals(Object o) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   197
            if (o == null || !(o instanceof TestCombination)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   198
                return false;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   199
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   200
            TestCombination second = (TestCombination) o;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   201
            return second.data.equals(data);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   202
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   203
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   204
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   205
        public int hashCode() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   206
            int sum = 0;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   207
            for (MethodData md : data.values()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   208
                sum += md.hashCode();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   209
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   210
            return sum;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   211
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   212
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   213
        private String getMethodDescString(MethodData md) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   214
            return (md == null)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   215
                    ? null
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   216
                    : String.format("Method %s compilation level %d and %s",
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   217
                            md.name, md.compileLevel,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   218
                            md.isInlined ? "inlined" : "not inlined");
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   219
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   220
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   221
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   222
        public String toString() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   223
            return data.values().stream().map(m -> getMethodDescString(m))
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   224
                    .collect(Collectors.joining(Utils.NEW_LINE,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   225
                                    "Combination: ", ""));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   226
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   227
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   228
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   229
    private class SegmentedCodeCacheDtraceResultsAnalyzer
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   230
            implements DtraceResultsAnalyzer {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   231
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   232
        private static final int EXPECTED_MATCH_COUNT = 2;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   233
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   234
        private final Pattern checkPattern;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   235
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   236
        public SegmentedCodeCacheDtraceResultsAnalyzer() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   237
            String workerClassRegExp = "\\s*" + WORKER_CLASS_NAME + "\\.";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   238
            String delimeter = "\\(\\)V\\*?" + workerClassRegExp;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   239
            String suffix = "test\\(\\)V\\*?" + workerClassRegExp
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   240
                    + "main\\(\\[Ljava\\/lang\\/String;\\)V";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   241
            StringBuilder sb = new StringBuilder(workerClassRegExp);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   242
            // method order is important, so, going from list tail to head,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   243
            // accoring to call order representation in stacktrace
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   244
            for (int i = MLIST.size() - 1; i > -1; i--) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   245
                sb.append(MLIST.get(i).getName()).append(delimeter);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   246
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   247
            sb.append(suffix);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   248
            checkPattern = Pattern.compile(sb.toString());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   249
            /* such pattern match should pass on a stacktrace like
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   250
             CPU     ID                    FUNCTION:NAME
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   251
             0  53573 __1cNSharedRuntimeTdtrace_method_entry6FpnKJavaThread_pnGMethod__i_:method-entry ustack:
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   252
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   253
             libjvm.so`__1cNSharedRuntimeTdtrace_method_entry6FpnKJavaThread_pnGMethod__i_+0x39c
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   254
             SegmentedCodeCacheDtraceTestWorker.baz()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   255
             SegmentedCodeCacheDtraceTestWorker.bar()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   256
             SegmentedCodeCacheDtraceTestWorker.foo()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   257
             SegmentedCodeCacheDtraceTestWorker.test()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   258
             SegmentedCodeCacheDtraceTestWorker.main([Ljava/lang/String;)V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   259
             0xffffffff6b0004b8
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   260
             libjvm.so`__1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v_+0x94c
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   261
             libjvm.so`__1cRjni_invoke_static6FpnHJNIEnv__pnJJavaValue_pnI_jobject_nLJNICallType_pnK_jmethodID_pnSJNI_ArgumentPusher_pnGThread__v_+0xa64
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   262
             libjvm.so`jni_CallStaticVoidMethod+0x508
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   263
             libjli.so`JavaMain+0x584
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   264
             libc.so.1`_lwp_start
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   265
             jstack:
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   266
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   267
             libjvm.so`__1cNSharedRuntimeTdtrace_method_entry6FpnKJavaThread_pnGMethod__i_+0x39c
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   268
             SegmentedCodeCacheDtraceTestWorker.baz()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   269
             SegmentedCodeCacheDtraceTestWorker.bar()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   270
             SegmentedCodeCacheDtraceTestWorker.foo()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   271
             SegmentedCodeCacheDtraceTestWorker.test()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   272
             SegmentedCodeCacheDtraceTestWorker.main([Ljava/lang/String;)V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   273
             0xffffffff6b0004b8
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   274
             libjvm.so`__1cJJavaCallsLcall_helper6FpnJJavaValue_pnMmethodHandle_pnRJavaCallArguments_pnGThread__v_+0x94c
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   275
             libjvm.so`__1cRjni_invoke_static6FpnHJNIEnv__pnJJavaValue_pnI_jobject_nLJNICallType_pnK_jmethodID_pnSJNI_ArgumentPusher_pnGThread__v_+0xa64
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   276
             libjvm.so`jni_CallStaticVoidMethod+0x508
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   277
             libjli.so`JavaMain+0x584
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   278
             libc.so.1`_lwp_start
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   279
             */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   280
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   281
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   282
        protected List<String> loadLog(String dtraceOutFile) throws IOException {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   283
            return Files.readAllLines(Paths.get(dtraceOutFile));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   284
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   285
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   286
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   287
        public void analyze(OutputAnalyzer oa, String dtraceOutFilePath) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   288
            oa.shouldHaveExitValue(0);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   289
            List<String> dOut;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   290
            try {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   291
                dOut = loadLog(dtraceOutFilePath);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   292
            } catch (IOException e) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   293
                throw new Error("Can't load log", e);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   294
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   295
            StringBuilder allDtraceOutput = new StringBuilder();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   296
            for (String entry : dOut) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   297
                allDtraceOutput.append(entry);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   298
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   299
            int matchCount = getMatchCount(allDtraceOutput.toString());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   300
            Asserts.assertEQ(matchCount, EXPECTED_MATCH_COUNT,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   301
                    "Unexpected output match amount. expected: "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   302
                    + EXPECTED_MATCH_COUNT + " but found " + matchCount);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   303
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   304
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   305
        protected int getMatchCount(String source) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   306
            Matcher m = checkPattern.matcher(source);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   307
            int matchCount = 0;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   308
            while (m.find()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   309
                matchCount++;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   310
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   311
            return matchCount;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   312
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   313
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   314
}