/* * Copyright (c) 2017, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * 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 www.oracle.com if you need additional information or have any * questions. */ package org.openjdk.jcstress.tests.acqrel.varHandles.byteBuffer.direct.big.acqrel; import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.nio.ByteOrder; import java.nio.ByteBuffer; import org.openjdk.jcstress.annotations.*; import org.openjdk.jcstress.infra.results.*; // -- This file was mechanically generated: Do not edit! -- // /** * Tests if byte array views accessors experience coherence failures. */ @JCStressTest @Outcome(id = { "false, false, 0", "true, false, 0", "false, true, 0", "true, true, 0", }, expect = Expect.ACCEPTABLE, desc = "Default value for guard, allowed to see anything.") @Outcome(id = { "false, true, -1", "true, true, -1", }, expect = Expect.ACCEPTABLE, desc = "Observing the value for guard, allowed to see latest value.") @Outcome(id = { "false, false, -1", "true, false, -1", }, expect = Expect.FORBIDDEN, desc = "Seeing previous writes, forbidden with proper guard.") @State public class IntBooleanTest { static final VarHandle VH = MethodHandles.byteBufferViewVarHandle(int[].class, ByteOrder.BIG_ENDIAN); ByteBuffer g = ByteBuffer.allocateDirect(16); int off = g.alignmentOffset(0, 8); boolean v; @Actor public void actor1() { v = false; v = true; VH.setRelease(g, off, -1); } @Actor public void actor2(ZZI_Result r) { boolean v1 = v; int g1 = (int)VH.getAcquire(g, off); boolean v2 = v; r.r1 = v1; r.r2 = v2; r.r3 = g1; } }