When I am suspicious certain instruction reordering is allowed by the java language specification, I want to reproduce it in a jcstress test. How can I do that? For example, in the following code, the Load and Store instructions (I believe) are allowed to be reordered in execution in some runtime environment. However, when I run the jcstress in Intel x84_64 Ubuntu, the result does not show any reordering happened.
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.I_Result;
@JCStressTest
@Outcome(id = "0", expect = Expect.ACCEPTABLE,
desc = "Default outcome.")
@Outcome(id = "2", expect = Expect.ACCEPTABLE_INTERESTING,
desc = "Load-Store reordering happens.")
@State
public class ReorderingTest {
int d;
int e;
int f;
@Actor
public void actor1() {
int ee = e; // Load
d = 1; // Store
if (ee == 2) {
f = 2;
}
}
@Actor
public void actor2() {
if (d == 1) {
e = 2;
}
}
@Arbiter
public void arbiter(I_Result r) {
r.r1 = f;
}
}