test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java
author adinn
Fri, 29 Nov 2019 15:37:13 +0000
changeset 59326 851a389fc54d
parent 59053 ba6c248cae19
permissions -rw-r--r--
8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776 Reviewed-by: aph
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     1
/*
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     2
 * Copyright (c) 2018, Red Hat, Inc. All rights reserved.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     4
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     8
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    13
 * accompanied this code).
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    14
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    18
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    21
 * questions.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    22
 */
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    23
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    24
/*
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    25
 * common code to run and validate tests of code generation for
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    26
 * volatile ops on AArch64
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    27
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    28
 * incoming args are <testclass> <testtype>
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    29
 *
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    30
 * where <testclass> in {TestVolatileLoad,
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    31
 *                       TestVolatileStore,
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    32
 *                       TestUnsafeVolatileLoad,
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    33
 *                       TestUnsafeVolatileStore,
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    34
 *                       TestUnsafeVolatileCAS,
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    35
 *                       TestUnsafeVolatileWeakCAS,
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    36
 *                       TestUnsafeVolatileCAE,
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    37
 *                       TestUnsafeVolatileGAS}
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    38
 * and <testtype> in {G1,
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    39
 *                    Serial,
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    40
 *                    Parallel,
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    41
 *                    Shenandoah,
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    42
 *                    ShenandoahTraversal}
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    43
 */
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    44
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    45
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    46
package compiler.c2.aarch64;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    47
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    48
import java.util.List;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    49
import java.util.ListIterator;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    50
import java.util.Iterator;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    51
import java.util.regex.Pattern;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    52
import java.io.*;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    53
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    54
import jdk.test.lib.Asserts;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    55
import jdk.test.lib.compiler.InMemoryJavaCompiler;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    56
import jdk.test.lib.process.OutputAnalyzer;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    57
import jdk.test.lib.process.ProcessTools;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    58
import sun.hotspot.WhiteBox;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    59
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    60
// runner class that spawns a new JVM to exercises a combination of
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    61
// volatile MemOp and GC. The ops are compiled with the dmb -->
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    62
// ldar/stlr transforms either enabled or disabled. this runner parses
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    63
// the PrintOptoAssembly output checking that the generated code is
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    64
// correct.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    65
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    66
public class TestVolatiles {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    67
    public void runtest(String classname, String testType) throws Throwable {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    68
        // n.b. clients omit the package name for the class
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    69
        String fullclassname = "compiler.c2.aarch64." + classname;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    70
        // build up a command line for the spawned JVM
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    71
        String[] procArgs;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    72
        int argcount;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    73
        // add one or two extra arguments according to test type
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    74
        // i.e. GC type plus GC conifg
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    75
        switch(testType) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    76
        case "G1":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    77
            argcount = 9;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    78
            procArgs = new String[argcount];
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    79
            procArgs[argcount - 2] = "-XX:+UseG1GC";
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    80
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    81
        case "Parallel":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    82
            argcount = 9;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    83
            procArgs = new String[argcount];
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    84
            procArgs[argcount - 2] = "-XX:+UseParallelGC";
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    85
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    86
        case "Serial":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
    87
            argcount = 9;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    88
            procArgs = new String[argcount];
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    89
            procArgs[argcount - 2] = "-XX:+UseSerialGC";
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
    90
            break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    91
        case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    92
            argcount = 10;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    93
            procArgs = new String[argcount];
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    94
            procArgs[argcount - 3] = "-XX:+UnlockExperimentalVMOptions";
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    95
            procArgs[argcount - 2] = "-XX:+UseShenandoahGC";
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    96
            break;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    97
        case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    98
            argcount = 11;
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
    99
            procArgs = new String[argcount];
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   100
            procArgs[argcount - 4] = "-XX:+UnlockExperimentalVMOptions";
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   101
            procArgs[argcount - 3] = "-XX:+UseShenandoahGC";
55587
4644b3155fce 8226757: Shenandoah: Make traversal and passive modes explicit
rkennke
parents: 52925
diff changeset
   102
            procArgs[argcount - 2] = "-XX:ShenandoahGCMode=traversal";
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   103
            break;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   104
        default:
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   105
            throw new RuntimeException("unexpected test type " + testType);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   106
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   107
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   108
        // fill in arguments common to all cases
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   109
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   110
        // the first round of test enables transform of barriers to
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   111
        // use acquiring loads and releasing stores by setting arg
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   112
        // zero appropriately. this arg is reset in the second run to
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   113
        // disable the transform.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   114
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   115
        procArgs[0] = "-XX:-UseBarriersForVolatile";
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   116
        procArgs[1] = "-XX:+UseCompressedOops";
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   117
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   118
        procArgs[2] = "-XX:-TieredCompilation";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   119
        procArgs[3] = "-XX:+PrintOptoAssembly";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   120
        procArgs[4] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   121
        procArgs[5] = "--add-exports";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   122
        procArgs[6] = "java.base/jdk.internal.misc=ALL-UNNAMED";
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   123
        procArgs[argcount - 1] = fullclassname;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   124
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   125
        runtest(classname, testType, false, true, procArgs);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   126
        // rerun the test class without the transform applied and
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   127
        // check the alternative generation is as expected
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   128
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   129
        procArgs[0] = "-XX:+UseBarriersForVolatile";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   130
        runtest(classname, testType, true, true, procArgs);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   131
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   132
        if (!classname.equals("TestUnsafeVolatileGAA")) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   133
            procArgs[0] = "-XX:-UseBarriersForVolatile";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   134
            procArgs[1] = "-XX:-UseCompressedOops";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   135
            runtest(classname, testType, false, false, procArgs);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   136
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   137
            procArgs[0] = "-XX:+UseBarriersForVolatile";
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   138
            runtest(classname, testType, true, false, procArgs);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   139
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   140
    }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   141
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   142
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   143
    public void runtest(String classname, String testType, boolean useBarriersForVolatile, boolean useCompressedOops, String[] procArgs) throws Throwable {
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   144
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   145
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   146
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   147
        output.stderrShouldBeEmptyIgnoreVMWarnings();
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   148
        output.stdoutShouldNotBeEmpty();
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   149
        output.shouldHaveExitValue(0);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   150
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   151
        // check the output for the correct asm sequence as
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   152
        // appropriate to test class, test type and whether transform
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   153
        // was applied
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   154
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   155
        checkoutput(output, classname, testType, useBarriersForVolatile, useCompressedOops);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   156
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   157
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   158
    // skip through output returning a line containing the desireed
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   159
    // substring or null
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   160
    private String skipTo(Iterator<String> iter, String substring)
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   161
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   162
        while (iter.hasNext()) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   163
            String nextLine = iter.next();
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   164
            if (nextLine.matches(".*" + substring + ".*")) {
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   165
                return nextLine;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   166
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   167
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   168
        return null;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   169
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   170
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   171
    // locate the start of compiler output for the desired method and
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   172
    // then check that each expected instruction occurs in the output
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   173
    // in the order supplied. throw an excpetion if not found.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   174
    // n.b. the spawned JVM's output is included in the exception
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   175
    // message to make it easeir to identify what is missing.
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   176
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   177
    private boolean checkCompile(Iterator<String> iter, String methodname, String[] expected, OutputAnalyzer output, boolean do_throw)
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   178
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   179
        // trace call to allow eyeball check of what we are checking against
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   180
        System.out.println("checkCompile(" + methodname + ",");
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   181
        String sepr = "  { ";
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   182
        for (String s : expected) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   183
            System.out.print(sepr);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   184
            System.out.print(s);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   185
            sepr = ",\n    ";
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   186
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   187
        System.out.println(" })");
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   188
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   189
        // look for the start of an opto assembly print block
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   190
        String match = skipTo(iter, Pattern.quote("{method}"));
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   191
        if (match == null) {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   192
            if (do_throw) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   193
                throw new RuntimeException("Missing compiler output for " + methodname + "!\n\n" + output.getOutput());
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   194
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   195
            return false;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   196
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   197
        // check the compiled method name is right
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   198
        match = skipTo(iter, Pattern.quote("- name:"));
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   199
        if (match == null) {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   200
            if (do_throw) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   201
                throw new RuntimeException("Missing compiled method name!\n\n" + output.getOutput());
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   202
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   203
            return false;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   204
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   205
        if (!match.contains(methodname)) {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   206
            if (do_throw) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   207
                throw new RuntimeException("Wrong method " + match + "!\n  -- expecting " + methodname + "\n\n" + output.getOutput());
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   208
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   209
            return false;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   210
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   211
        // make sure we can match each expected term in order
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   212
        for (String s : expected) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   213
            match = skipTo(iter, s);
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   214
            if (match == null) {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   215
                if (do_throw) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   216
                    throw new RuntimeException("Missing expected output " + s + "!\n\n" + output.getOutput());
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   217
                }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   218
                return false;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   219
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   220
        }
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   221
        return true;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   222
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   223
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   224
    // check for expected asm output from a volatile load
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   225
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   226
    private void checkload(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   227
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   228
        Iterator<String> iter = output.asLines().listIterator();
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   229
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   230
        // we shoud see this same sequence for normal or unsafe volatile load
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   231
        // for both int and Object fields
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   232
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   233
        String[] matches;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   234
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   235
        if (!useBarriersForVolatile) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   236
            matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   237
                "ldarw",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   238
                "membar_acquire \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   239
                "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   240
            };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   241
        } else {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   242
            matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   243
                "ldrw",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   244
                "membar_acquire",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   245
                "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   246
                "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   247
            };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   248
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   249
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   250
        checkCompile(iter, "testInt", matches, output, true);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   251
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   252
        if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   253
            matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   254
                useCompressedOops ? "ldarw?" : "ldar",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   255
                "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   256
                "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   257
            };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   258
        } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   259
            matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   260
                useCompressedOops ? "ldrw?" : "ldr",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   261
                "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   262
                "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   263
                "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   264
            };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   265
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   266
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   267
        checkCompile(iter, "testObj", matches, output, true);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   268
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   269
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   270
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   271
    // check for expected asm output from a volatile store
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   272
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   273
    private void checkstore(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   274
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   275
        Iterator<String> iter = output.asLines().listIterator();
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   276
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   277
        String[] matches;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   278
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   279
        // non object stores are straightforward
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   280
        if (!useBarriersForVolatile) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   281
            // this is the sequence of instructions for all cases
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   282
            matches = new String[] {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   283
                "membar_release \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   284
                "stlrw",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   285
                "membar_volatile \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   286
                "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   287
            };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   288
        } else {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   289
            // this is the alternative sequence of instructions
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   290
            matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   291
                "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   292
                "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   293
                "strw",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   294
                "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   295
                "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   296
                "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   297
            };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   298
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   299
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   300
        checkCompile(iter, "testInt", matches, output, true);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   301
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   302
        // object stores will be as above except for when the GC
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   303
        // introduces barriers for card marking
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   304
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   305
        if (!useBarriersForVolatile) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   306
            switch (testType) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   307
            default:
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   308
                // this is the basic sequence of instructions
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   309
                matches = new String[] {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   310
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   311
                    useCompressedOops ? "stlrw?" : "stlr",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   312
                    "membar_volatile \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   313
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   314
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   315
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   316
            case "G1":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   317
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   318
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   319
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   320
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   321
                // scheduled out of line after the membar volatile and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   322
                // and subsequent return
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   323
                matches = new String[] {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   324
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   325
                    useCompressedOops ? "stlrw?" : "stlr",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   326
                    "membar_volatile \\(elided\\)",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   327
                    "ret",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   328
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   329
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   330
                    "strb"
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   331
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   332
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   333
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   334
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   335
                 // Shenandoah generates normal object graphs for
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   336
                 // volatile stores
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   337
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   338
                    "membar_release \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   339
                    useCompressedOops ? "stlrw?" : "stlr",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   340
                    "membar_volatile \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   341
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   342
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   343
                break;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   344
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   345
        } else {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   346
            switch (testType) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   347
            default:
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   348
                // this is the basic sequence of instructions
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   349
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   350
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   351
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   352
                    useCompressedOops ? "strw?" : "str",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   353
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   354
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   355
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   356
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   357
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   358
            case "G1":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   359
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   360
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   361
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   362
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   363
                // scheduled out of line after the membar volatile and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   364
                // and subsequent return
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   365
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   366
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   367
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   368
                    useCompressedOops ? "strw?" : "str",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   369
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   370
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   371
                    "ret",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   372
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   373
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   374
                    "strb"
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   375
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   376
                break;
51008
8df91a1b549b 8206163: AArch64: incorrect code generation for StoreCM
adinn
parents: 50874
diff changeset
   377
            case "CMSCondMark":
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   378
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   379
                // before the card mark strb from the StoreCM and the
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   380
                // storestore barrier from the StoreCM should be elided
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   381
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   382
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   383
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   384
                    useCompressedOops ? "strw?" : "str",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   385
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   386
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   387
                    "storestore \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   388
                    "strb",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   389
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   390
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   391
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   392
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   393
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   394
            case "CMS":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   395
                // a volatile card mark membar should not be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   396
                // before the card mark strb from the StoreCM and the
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   397
                // storestore barrier from the StoreCM should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   398
                // as "dmb ishst"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   399
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   400
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   401
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   402
                    useCompressedOops ? "strw?" : "str",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   403
                    "storestore",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   404
                    "dmb ishst",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   405
                    "strb",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   406
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   407
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   408
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   409
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   410
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   411
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   412
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   413
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   414
                 // Shenandoah generates normal object graphs for
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   415
                 // volatile stores
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   416
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   417
                    "membar_release",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   418
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   419
                    useCompressedOops ? "strw?" : "str",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   420
                    "membar_volatile",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   421
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   422
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   423
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   424
                break;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   425
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   426
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   427
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   428
        checkCompile(iter, "testObj", matches, output, true);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   429
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   430
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   431
    // check for expected asm output from a volatile cas
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   432
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   433
    private void checkcas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   434
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   435
        Iterator<String> iter = output.asLines().listIterator();
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   436
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   437
        String[] matches;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   438
        String[][] tests = {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   439
            { "testInt", "cmpxchgw" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   440
            { "testLong", "cmpxchg" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   441
            { "testByte", "cmpxchgb" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   442
            { "testShort", "cmpxchgs" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   443
        };
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   444
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   445
        for (String[] test : tests) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   446
            // non object stores are straightforward
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   447
            if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   448
                // this is the sequence of instructions for all cases
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   449
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   450
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   451
                    test[1] + "_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   452
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   453
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   454
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   455
            } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   456
                // this is the alternative sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   457
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   458
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   459
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   460
                    test[1] + " ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   461
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   462
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   463
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   464
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   465
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   466
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   467
            checkCompile(iter, test[0], matches, output, true);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   468
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   469
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   470
        // object stores will be as above except for when the GC
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   471
        // introduces barriers for card marking
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   472
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   473
        if (!useBarriersForVolatile) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   474
            switch (testType) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   475
            default:
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   476
                // this is the basic sequence of instructions
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   477
                matches = new String[] {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   478
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   479
                    useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   480
                    "strb",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   481
                    "membar_acquire \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   482
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   483
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   484
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   485
            case "G1":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   486
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   487
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   488
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   489
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   490
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   491
                // and subsequent return
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   492
                matches = new String[] {
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   493
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   494
                    useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   495
                    "membar_acquire \\(elided\\)",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   496
                    "ret",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   497
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   498
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   499
                    "strb"
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   500
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   501
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   502
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   503
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   504
                // For volatile CAS, Shenanodoah generates normal
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   505
                // graphs with a shenandoah-specific cmpxchg
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   506
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   507
                    "membar_release \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   508
                    useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   509
                    "membar_acquire \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   510
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   511
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   512
                break;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   513
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   514
        } else {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   515
            switch (testType) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   516
            default:
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   517
                // this is the basic sequence of instructions
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   518
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   519
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   520
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   521
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   522
                    "membar_acquire",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   523
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   524
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   525
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   526
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   527
            case "G1":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   528
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   529
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   530
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   531
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   532
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   533
                // and subsequent return
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   534
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   535
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   536
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   537
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   538
                    "membar_acquire",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   539
                    "dmb ish",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   540
                    "ret",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   541
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   542
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   543
                    "strb"
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   544
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   545
                break;
51008
8df91a1b549b 8206163: AArch64: incorrect code generation for StoreCM
adinn
parents: 50874
diff changeset
   546
            case "CMSCondMark":
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   547
                // a card mark volatile barrier should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   548
                // before the card mark strb from the StoreCM and the
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   549
                // storestore barrier from the StoreCM should be elided
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   550
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   551
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   552
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   553
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   554
                    "membar_volatile",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   555
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   556
                    "storestore \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   557
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   558
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   559
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   560
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   561
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   562
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   563
            case "CMS":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   564
                // a volatile card mark membar should not be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   565
                // before the card mark strb from the StoreCM and the
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   566
                // storestore barrier from the StoreCM should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   567
                // as "dmb ishst"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   568
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   569
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   570
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   571
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   572
                    "storestore",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   573
                    "dmb ishst",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   574
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   575
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   576
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   577
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   578
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   579
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   580
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   581
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   582
                // For volatile CAS, Shenanodoah generates normal
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   583
                // graphs with a shenandoah-specific cmpxchg
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   584
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   585
                    "membar_release",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   586
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   587
                    useCompressedOops ? "cmpxchgw?_shenandoah" : "cmpxchg_shenandoah",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   588
                    "membar_acquire",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   589
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   590
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   591
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   592
                break;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   593
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   594
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   595
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   596
        checkCompile(iter, "testObj", matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   597
    }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   598
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   599
    private void checkcae(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   600
    {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   601
        ListIterator<String> iter = output.asLines().listIterator();
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   602
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   603
        String[] matches;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   604
        String[][] tests = {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   605
            { "testInt", "cmpxchgw" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   606
            { "testLong", "cmpxchg" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   607
            { "testByte", "cmpxchgb" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   608
            { "testShort", "cmpxchgs" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   609
        };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   610
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   611
        for (String[] test : tests) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   612
            // non object stores are straightforward
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   613
            if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   614
                // this is the sequence of instructions for all cases
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   615
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   616
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   617
                    test[1] + "_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   618
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   619
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   620
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   621
            } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   622
                // this is the alternative sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   623
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   624
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   625
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   626
                    test[1] + " ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   627
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   628
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   629
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   630
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   631
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   632
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   633
            checkCompile(iter, test[0], matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   634
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   635
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   636
        // object stores will be as above except for when the GC
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   637
        // introduces barriers for card marking
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   638
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   639
        if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   640
            switch (testType) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   641
            default:
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   642
                // this is the basic sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   643
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   644
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   645
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   646
                    useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   647
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   648
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   649
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   650
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   651
                // card marking store may be scheduled before or after
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   652
                // the cmpxchg so try both sequences.
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   653
                int idx = iter.nextIndex();
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   654
                if (!checkCompile(iter, "testObj", matches, output, false)) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   655
                    iter = output.asLines().listIterator(idx);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   656
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   657
                    matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   658
                        "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   659
                        useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   660
                        "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   661
                        "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   662
                        "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   663
                    };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   664
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   665
                    checkCompile(iter, "testObj", matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   666
                }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   667
                return;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   668
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   669
            case "G1":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   670
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   671
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   672
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   673
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   674
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   675
                // and subsequent return
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   676
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   677
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   678
                    useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   679
                    "membar_acquire \\(elided\\)",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   680
                    "ret",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   681
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   682
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   683
                    "strb"
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   684
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   685
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   686
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   687
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   688
                // For volatile CAS, Shenanodoah generates normal
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   689
                // graphs with a shenandoah-specific cmpxchg
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   690
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   691
                    "membar_release \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   692
                    useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   693
                    "membar_acquire \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   694
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   695
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   696
                break;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   697
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   698
        } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   699
            switch (testType) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   700
            default:
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   701
                // this is the basic sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   702
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   703
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   704
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   705
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   706
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   707
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   708
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   709
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   710
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   711
            case "G1":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   712
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   713
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   714
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   715
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   716
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   717
                // and subsequent return
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   718
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   719
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   720
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   721
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   722
                    "membar_acquire",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   723
                    "dmb ish",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   724
                    "ret",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   725
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   726
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   727
                    "strb"
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   728
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   729
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   730
            case "CMSCondMark":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   731
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   732
                // before the card mark strb from the StoreCM and the
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   733
                // storestore barrier from the StoreCM should be elided
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   734
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   735
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   736
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   737
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   738
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   739
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   740
                    "storestore \\(elided\\)",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   741
                    "strb",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   742
                    "membar_acquire",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   743
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   744
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   745
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   746
                break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   747
            case "CMS":
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   748
                // a volatile card mark membar should not be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   749
                // before the card mark strb from the StoreCM and the
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   750
                // storestore barrier from the StoreCM should be generated
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   751
                // as "dmb ishst"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   752
                matches = new String[] {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   753
                    "membar_release",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   754
                    "dmb ish",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   755
                    useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   756
                    "storestore",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   757
                    "dmb ishst",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   758
                    "strb",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   759
                    "membar_acquire",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   760
                    "dmb ish",
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   761
                    "ret"
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   762
                };
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   763
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   764
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   765
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   766
                // For volatile CAS, Shenanodoah generates normal
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   767
                // graphs with a shenandoah-specific cmpxchg
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   768
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   769
                    "membar_release",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   770
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   771
                    useCompressedOops ? "cmpxchgw?_shenandoah" : "cmpxchg_shenandoah",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   772
                    "membar_acquire",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   773
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   774
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   775
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   776
                break;
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   777
            }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   778
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   779
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   780
        checkCompile(iter, "testObj", matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   781
    }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   782
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   783
    private void checkgas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   784
    {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   785
        Iterator<String> iter = output.asLines().listIterator();
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   786
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   787
        String[] matches;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   788
        String[][] tests = {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   789
            { "testInt", "atomic_xchgw" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   790
            { "testLong", "atomic_xchg" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   791
        };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   792
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   793
        for (String[] test : tests) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   794
            // non object stores are straightforward
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   795
            if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   796
                // this is the sequence of instructions for all cases
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   797
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   798
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   799
                    test[1] + "_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   800
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   801
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   802
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   803
            } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   804
                // this is the alternative sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   805
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   806
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   807
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   808
                    test[1] + " ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   809
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   810
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   811
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   812
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   813
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   814
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   815
            checkCompile(iter, test[0], matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   816
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   817
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   818
        // object stores will be as above except for when the GC
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   819
        // introduces barriers for card marking
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   820
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   821
        if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   822
            switch (testType) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   823
            default:
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   824
                // this is the basic sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   825
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   826
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   827
                    useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   828
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   829
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   830
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   831
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   832
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   833
            case "G1":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   834
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   835
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   836
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   837
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   838
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   839
                // and subsequent return
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   840
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   841
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   842
                    useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   843
                    "membar_acquire \\(elided\\)",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   844
                    "ret",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   845
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   846
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   847
                    "strb"
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   848
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   849
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   850
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   851
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   852
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   853
                    "membar_release \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   854
                    useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   855
                    "membar_acquire \\(elided\\)",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   856
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   857
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   858
                break;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   859
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   860
        } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   861
            switch (testType) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   862
            default:
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   863
                // this is the basic sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   864
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   865
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   866
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   867
                    useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   868
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   869
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   870
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   871
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   872
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   873
            case "G1":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   874
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   875
                // before the card mark strb
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   876
                //
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   877
                // following the fix for 8225776 the G1 barrier is now
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   878
                // scheduled out of line after the membar acquire and
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   879
                // and subsequent return
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   880
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   881
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   882
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   883
                    useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   884
                    "membar_acquire",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   885
                    "dmb ish",
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   886
                    "ret",
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   887
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   888
                    "dmb ish",
59326
851a389fc54d 8232828: AArch64: compiler/c2/aarch64/TestVolatilesG1.java fails after JDK-8225776
adinn
parents: 59053
diff changeset
   889
                    "strb"
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   890
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   891
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   892
            case "CMSCondMark":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   893
                // a card mark volatile barrier should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   894
                // before the card mark strb from the StoreCM and the
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   895
                // storestore barrier from the StoreCM should be elided
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   896
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   897
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   898
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   899
                    useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   900
                    "membar_volatile",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   901
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   902
                    "storestore \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   903
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   904
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   905
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   906
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   907
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   908
                break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   909
            case "CMS":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   910
                // a volatile card mark membar should not be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   911
                // before the card mark strb from the StoreCM and the
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   912
                // storestore barrier from the StoreCM should be generated
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   913
                // as "dmb ishst"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   914
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   915
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   916
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   917
                    useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   918
                    "storestore",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   919
                    "dmb ishst",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   920
                    "strb",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   921
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   922
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   923
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   924
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   925
                break;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   926
            case "Shenandoah":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   927
            case "ShenandoahTraversal":
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   928
                matches = new String[] {
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   929
                    "membar_release",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   930
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   931
                    useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   932
                    "membar_acquire",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   933
                    "dmb ish",
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   934
                    "ret"
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   935
                };
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 52409
diff changeset
   936
                break;
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   937
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   938
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   939
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   940
        checkCompile(iter, "testObj", matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   941
    }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   942
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   943
    private void checkgaa(OutputAnalyzer output, String testType, boolean useBarriersForVolatile) throws Throwable
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   944
    {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   945
        Iterator<String> iter = output.asLines().listIterator();
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   946
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   947
        String[] matches;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   948
        String[][] tests = {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   949
            { "testInt", "get_and_addI" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   950
            { "testLong", "get_and_addL" },
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   951
        };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   952
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   953
        for (String[] test : tests) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   954
            // non object stores are straightforward
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   955
            if (!useBarriersForVolatile) {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   956
                // this is the sequence of instructions for all cases
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   957
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   958
                    "membar_release \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   959
                    test[1] + "_acq",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   960
                    "membar_acquire \\(elided\\)",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   961
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   962
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   963
            } else {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   964
                // this is the alternative sequence of instructions
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   965
                matches = new String[] {
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   966
                    "membar_release",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   967
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   968
                    test[1] + " ",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   969
                    "membar_acquire",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   970
                    "dmb ish",
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   971
                    "ret"
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   972
                };
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   973
            }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   974
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   975
            checkCompile(iter, test[0], matches, output, true);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   976
        }
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   977
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   978
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   979
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   980
    // perform a check appropriate to the classname
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   981
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   982
    private void checkoutput(OutputAnalyzer output, String classname, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   983
    {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   984
        // trace call to allow eyeball check of what is being checked
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   985
        System.out.println("checkoutput(" +
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   986
                           classname + ", " +
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   987
                           testType + ", " +
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   988
                           useBarriersForVolatile + ")\n" +
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   989
                           output.getOutput());
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   990
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   991
        switch (classname) {
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   992
        case "TestVolatileLoad":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   993
            checkload(output, testType, useBarriersForVolatile, useCompressedOops);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   994
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   995
        case "TestVolatileStore":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   996
            checkstore(output, testType, useBarriersForVolatile, useCompressedOops);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   997
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
   998
        case "TestUnsafeVolatileLoad":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
   999
            checkload(output, testType, useBarriersForVolatile, useCompressedOops);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1000
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1001
        case "TestUnsafeVolatileStore":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1002
            checkstore(output, testType, useBarriersForVolatile, useCompressedOops);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1003
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1004
        case "TestUnsafeVolatileCAS":
52409
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1005
        case "TestUnsafeVolatileWeakCAS":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1006
            checkcas(output, testType, useBarriersForVolatile, useCompressedOops);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1007
            break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1008
        case "TestUnsafeVolatileCAE":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1009
            checkcae(output, testType, useBarriersForVolatile, useCompressedOops);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1010
            break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1011
        case "TestUnsafeVolatileGAS":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1012
            checkgas(output, testType, useBarriersForVolatile, useCompressedOops);
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1013
            break;
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1014
        case "TestUnsafeVolatileGAA":
87bc444ca642 8209835: Aarch64: elide barriers on all volatile operations
roland
parents: 51008
diff changeset
  1015
            checkgaa(output, testType, useBarriersForVolatile);
50874
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1016
            break;
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1017
        }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1018
    }
551c340ca01a 8205694: AArch64: Add test to validate volatile load, store and CAS code generation
adinn
parents:
diff changeset
  1019
}