/* * Copyright (c) 2013 SAP SE. 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. * * 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.
*/
/** * @test * @key stress randomness * @bug 8007898 * @summary Incorrect optimization of Memory Barriers in Matcher::post_store_load_barrier(). * @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+StressGCM -XX:+StressLCM * compiler.membars.DekkerTest * @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+StressGCM -XX:+StressLCM * compiler.membars.DekkerTest * @run main/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+StressGCM -XX:+StressLCM * compiler.membars.DekkerTest * @author Martin Doerr martin DOT doerr AT sap DOT com * * Run 3 times since the failure is intermittent.
*/
package compiler.membars;
publicclass DekkerTest {
/* Read After Write Test (basically a simple Dekker test with volatile variables) Derived from the original jcstress test, available at: hhttps://git.openjdk.org/jcstress/commit/15acd86 tests-custom/src/main/java/org/openjdk/jcstress/tests/volatiles/DekkerTest.java
*/
public DekkerTest() {
testDataArray = new TestData[ITERATIONS];
results = new ResultData[ITERATIONS]; for (int i = 0; i < ITERATIONS; ++i) {
testDataArray[i] = new TestData();
results[i] = new ResultData();
}
start = false;
}
publicvoid reset() { for (int i = 0; i < ITERATIONS; ++i) {
testDataArray[i].a = 0;
testDataArray[i].b = 0;
results[i].a = 0;
results[i].b = 0;
}
start = false;
}
int actor1(TestData t) {
t.a = 1; return t.b;
}
int actor2(TestData t) {
t.b = 1; return t.a;
}
class Runner1 extendsThread { publicvoid run() { do {} while (!start); for (int i = 0; i < ITERATIONS; ++i) {
results[i].a = actor1(testDataArray[i]);
}
}
}
class Runner2 extendsThread { publicvoid run() { do {} while (!start); for (int i = 0; i < ITERATIONS; ++i) {
results[i].b = actor2(testDataArray[i]);
}
}
}
void testRunner() { Thread thread1 = new Runner1(); Thread thread2 = new Runner2();
thread1.start();
thread2.start(); do {} while (!thread1.isAlive()); do {} while (!thread2.isAlive());
start = true; Thread.yield(); try {
thread1.join();
thread2.join();
} catch (InterruptedException e) {
System.out.println("interrupted!");
System.exit(1);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.