view jcstress-test-gen/src/main/resources/fences/ @ 297:2cb629dfc2be

Chapter 1.c: Further simplify Fences test generator.
author shade
date Fri, 10 Jun 2016 16:26:59 +0300
parents c47a1a95f97d
children 6d05ba34c4e9
line wrap: on
line source
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit if you need additional information or have any
 * questions.
package $package$;

import java.lang.invoke.VarHandle;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.$Type$Result2;

@Description("Tests VarHandle methods which take effect of load store fence.")
@Outcome(id = "$value0$, $value0$", expect = Expect.ACCEPTABLE, desc = "load y in actor2 before store $value1$ to y in actor1, all results are $value0$")
@Outcome(id = "$value1$, $value0$", expect = Expect.ACCEPTABLE, desc = "store $value1$ to y in actor1 before load y in actor2")
@Outcome(id = "$value1$, $value1$", expect = Expect.FORBIDDEN,  desc = "can't load var after store y in actor1.")
@Outcome(id = "$value0$, $value1$", expect = Expect.FORBIDDEN,  desc = "this won't happen even if load var after store y because only if r1 = $value1$ var may be assigned to $value1$ and then r2 can be $value1$ from var.")
@Outcome(expect = Expect.FORBIDDEN, desc = "Other values are forbidden: atomicity violation.")
@Outcome(id = ".*, $value0$", expect = Expect.ACCEPTABLE_SPEC, desc = "Non-atomic access detected, allowed by spec, r2 only can be assigned to 0.")
public class $TestClassName$ {

    $type$ y;

    $type$ field;

    public void actor1($Type$Result2 r) {
        $type$ i = %GetLoadStoreFence%
        y = $valueLiteral1$;
        r.r2 = i;

    public void actor2($Type$Result2 r) {
        r.r1 = y;
        field = r.r1;