hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java
author dpochepk
Thu, 25 Dec 2014 15:57:38 +0300
changeset 28392 f64a0abbff20
child 30604 b8d532cb6420
permissions -rw-r--r--
8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature Reviewed-by: sspitsyn, twisti, fzhinkin, iignatyev
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
/*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    24
import com.oracle.java.testlibrary.Asserts;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    25
import com.oracle.java.testlibrary.JDKToolFinder;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    26
import com.oracle.java.testlibrary.OutputAnalyzer;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    27
import com.oracle.java.testlibrary.Utils;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    28
import com.oracle.java.testlibrary.dtrace.DtraceResultsAnalyzer;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    29
import com.oracle.java.testlibrary.dtrace.DtraceRunner;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    30
import java.io.IOException;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    31
import java.lang.reflect.Executable;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    32
import java.nio.file.Files;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    33
import java.nio.file.Paths;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    34
import java.util.Arrays;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    35
import java.util.Collections;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    36
import java.util.HashMap;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    37
import java.util.HashSet;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    38
import java.util.List;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    39
import java.util.Map;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    40
import java.util.Random;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    41
import java.util.Set;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    42
import java.util.regex.Matcher;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    43
import java.util.regex.Pattern;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    44
import java.util.stream.Collectors;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    45
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    46
/*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    47
 * @test SegmentedCodeCacheDtraceTest
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    48
 * @bug 8015774
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    49
 * @requires os.family=="solaris"
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    50
 * @library /testlibrary /compiler/testlibrary /../../test/lib
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    51
 * @build SegmentedCodeCacheDtraceTestWorker
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    52
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    53
 *     sun.hotspot.WhiteBox$WhiteBoxPermission
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    54
 * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+TieredCompilation
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    55
 *     -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    56
 *     SegmentedCodeCacheDtraceTest
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    57
 * @summary testing of dtrace for segmented code cache
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    58
 */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    59
public class SegmentedCodeCacheDtraceTest {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    60
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    61
    private static final String WORKER_CLASS_NAME
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    62
            = SegmentedCodeCacheDtraceTestWorker.class.getName();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    63
    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
    64
            + "-Xbootclasspath/a:" + System.getProperty("test.classes") + " "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    65
            + "-XX:+UnlockDiagnosticVMOptions "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    66
            + "-XX:+WhiteBoxAPI -XX:+SegmentedCodeCache "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    67
            + "-XX:CompileCommand=compileonly,"
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    68
            + WORKER_CLASS_NAME + "::* "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    69
            + " -classpath " + System.getProperty("test.class.path") + " "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    70
            + String.join(" ", Utils.getTestJavaOpts());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    71
    private static final String DTRACE_SCRIPT
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    72
            = "SegmentedCodeCacheDtraceTestScript.d";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    73
    private static final List<Executable> MLIST =
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    74
            SegmentedCodeCacheDtraceTestWorker.TESTED_METHODS_LIST;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    75
    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
    76
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    77
    private void runTest(TestCombination tc) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    78
        String params = MLIST.stream()
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    79
                .map(Executable::getName)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    80
                .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
    81
                .collect(Collectors.joining(" "));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    82
        DtraceRunner runner = new DtraceRunner();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    83
        runner.runDtrace(JDKToolFinder.getTestJDKTool("java"), JAVA_OPTS,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    84
                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
    85
                        DTRACE_SCRIPT).toString(),
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    86
                DtraceRunner.PERMIT_DESTRUCTIVE_ACTIONS_DTRACE_OPTION,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    87
                new SegmentedCodeCacheDtraceResultsAnalyzer());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    88
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    89
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    90
    private static TestCombination generateUniqueCombination(
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    91
            int[] availableLevels, Set<TestCombination> combinations) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    92
        int len = availableLevels.length;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    93
        /* 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
    94
        int maxCombinationsCount
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    95
                = (1 << WORKER_METHODS_COUNT)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    96
                * (int) Math.pow(len, WORKER_METHODS_COUNT);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    97
        if (combinations.size() == maxCombinationsCount) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    98
            return null;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
    99
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   100
        Random r = Utils.getRandomInstance();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   101
        while (combinations.size() < maxCombinationsCount) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   102
            int levels[] = new int[WORKER_METHODS_COUNT];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   103
            boolean inlines[] = new boolean[WORKER_METHODS_COUNT];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   104
            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
   105
                levels[i] = availableLevels[r.nextInt(len)];
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   106
                inlines[i] = r.nextBoolean();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   107
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   108
            TestCombination tc = new TestCombination(levels, inlines);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   109
            if (combinations.add(tc)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   110
                return tc;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   111
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   112
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   113
        return null;
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
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   116
    public static void main(String args[]) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   117
        int iterations
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   118
                = Integer.getInteger("com.oracle.java.testlibrary.iterations", 1);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   119
        if (!DtraceRunner.dtraceAvailable()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   120
            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
   121
            return;
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
        int[] availableLevels = CompilerUtils.getAvailableCompilationLevels();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   124
        // adding one more entry(zero) for interpeter
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   125
        availableLevels
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   126
                = Arrays.copyOf(availableLevels, availableLevels.length + 1);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   127
        Set<TestCombination> combinations = new HashSet<>();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   128
        for (int i = 0; i < iterations; i++) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   129
            TestCombination tc
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   130
                    = generateUniqueCombination(availableLevels, combinations);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   131
            if (tc == null) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   132
                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
   133
                return;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   134
            } else {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   135
                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
   136
                new SegmentedCodeCacheDtraceTest().runTest(tc);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   137
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   138
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   139
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   140
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   141
    private static class MethodData {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   142
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   143
        public final int compileLevel;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   144
        public final boolean isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   145
        public final String name;
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
        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
   148
            this.name = name;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   149
            this.compileLevel = compileLevel;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   150
            this.isInlined = isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   151
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   152
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   153
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   154
        public boolean equals(Object o) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   155
            if (o == null || !(o instanceof MethodData)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   156
                return false;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   157
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   158
            MethodData md = (MethodData) o;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   159
            return md.compileLevel == compileLevel
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   160
                    && md.isInlined == isInlined
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   161
                    && md.name.equals(name);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   162
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   163
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   164
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   165
        public int hashCode() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   166
            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
   167
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   168
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   169
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   170
        public String toString() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   171
            return name + " " + compileLevel + " " + isInlined;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   172
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   173
    }
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
    private static class TestCombination {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   176
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   177
        private final Map<String, MethodData> data;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   178
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   179
        public TestCombination(int compLevels[], boolean inlines[]) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   180
            Map<String, MethodData> d = new HashMap<>();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   181
            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
   182
                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
   183
                        compLevels[i], inlines[i]));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   184
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   185
            data = Collections.unmodifiableMap(d);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   186
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   187
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   188
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   189
        public boolean equals(Object o) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   190
            if (o == null || !(o instanceof TestCombination)) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   191
                return false;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   192
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   193
            TestCombination second = (TestCombination) o;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   194
            return second.data.equals(data);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   195
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   196
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   197
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   198
        public int hashCode() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   199
            int sum = 0;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   200
            for (MethodData md : data.values()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   201
                sum += md.hashCode();
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
            return sum;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   204
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   205
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   206
        private String getMethodDescString(MethodData md) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   207
            return (md == null)
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   208
                    ? null
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   209
                    : 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
   210
                            md.name, md.compileLevel,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   211
                            md.isInlined ? "inlined" : "not inlined");
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
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   214
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   215
        public String toString() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   216
            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
   217
                    .collect(Collectors.joining(Utils.NEW_LINE,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   218
                                    "Combination: ", ""));
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
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   222
    private class SegmentedCodeCacheDtraceResultsAnalyzer
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   223
            implements DtraceResultsAnalyzer {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   224
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   225
        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
   226
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   227
        private final Pattern checkPattern;
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
        public SegmentedCodeCacheDtraceResultsAnalyzer() {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   230
            String workerClassRegExp = "\\s*" + WORKER_CLASS_NAME + "\\.";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   231
            String delimeter = "\\(\\)V\\*?" + workerClassRegExp;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   232
            String suffix = "test\\(\\)V\\*?" + workerClassRegExp
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   233
                    + "main\\(\\[Ljava\\/lang\\/String;\\)V";
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   234
            StringBuilder sb = new StringBuilder(workerClassRegExp);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   235
            // 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
   236
            // accoring to call order representation in stacktrace
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   237
            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
   238
                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
   239
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   240
            sb.append(suffix);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   241
            checkPattern = Pattern.compile(sb.toString());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   242
            /* 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
   243
             CPU     ID                    FUNCTION:NAME
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   244
             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
   245
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   246
             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
   247
             SegmentedCodeCacheDtraceTestWorker.baz()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   248
             SegmentedCodeCacheDtraceTestWorker.bar()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   249
             SegmentedCodeCacheDtraceTestWorker.foo()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   250
             SegmentedCodeCacheDtraceTestWorker.test()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   251
             SegmentedCodeCacheDtraceTestWorker.main([Ljava/lang/String;)V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   252
             0xffffffff6b0004b8
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   253
             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
   254
             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
   255
             libjvm.so`jni_CallStaticVoidMethod+0x508
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   256
             libjli.so`JavaMain+0x584
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   257
             libc.so.1`_lwp_start
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   258
             jstack:
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   259
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   260
             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
   261
             SegmentedCodeCacheDtraceTestWorker.baz()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   262
             SegmentedCodeCacheDtraceTestWorker.bar()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   263
             SegmentedCodeCacheDtraceTestWorker.foo()V*
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   264
             SegmentedCodeCacheDtraceTestWorker.test()V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   265
             SegmentedCodeCacheDtraceTestWorker.main([Ljava/lang/String;)V
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   266
             0xffffffff6b0004b8
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   267
             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
   268
             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
   269
             libjvm.so`jni_CallStaticVoidMethod+0x508
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   270
             libjli.so`JavaMain+0x584
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   271
             libc.so.1`_lwp_start
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   272
             */
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   273
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   274
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   275
        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
   276
            return Files.readAllLines(Paths.get(dtraceOutFile));
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   277
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   278
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   279
        @Override
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   280
        public void analyze(OutputAnalyzer oa, String dtraceOutFilePath) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   281
            oa.shouldHaveExitValue(0);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   282
            List<String> dOut;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   283
            try {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   284
                dOut = loadLog(dtraceOutFilePath);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   285
            } catch (IOException e) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   286
                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
   287
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   288
            StringBuilder allDtraceOutput = new StringBuilder();
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   289
            for (String entry : dOut) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   290
                allDtraceOutput.append(entry);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   291
            }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   292
            int matchCount = getMatchCount(allDtraceOutput.toString());
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   293
            Asserts.assertEQ(matchCount, EXPECTED_MATCH_COUNT,
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   294
                    "Unexpected output match amount. expected: "
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   295
                    + EXPECTED_MATCH_COUNT + " but found " + matchCount);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   296
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   297
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   298
        protected int getMatchCount(String source) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   299
            Matcher m = checkPattern.matcher(source);
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   300
            int matchCount = 0;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   301
            while (m.find()) {
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   302
                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
            return matchCount;
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   305
        }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   306
    }
f64a0abbff20 8059625: JEP-JDK-8043304: Test task: DTrace- tests for segmented codecache feature
dpochepk
parents:
diff changeset
   307
}