Diese Code-Kontrolle kommt aus:Reihenfolge der Null-Zeiger
public class ReadAfterReadTest {
private final Holder h1 = new Holder();
private final Holder h2 = h1;
private static class Holder {
int a;
int trap;
}
@Actor
public void actor1() {
h1.a = 1;
}
@Actor
public void actor2(II_Result r) {
Holder h1 = this.h1;
Holder h2 = this.h2;
(*****)
// Spam null-pointer check folding: try to step on NPEs early.
// Doing this early frees compiler from moving h1.a and h2.a loads
// around, because it would not have to maintain exception order anymore.
(*****)
h1.trap = 0;
h2.trap = 0;
// Spam alias analysis: the code effectively reads the same field twice,
// but compiler does not know (h1 == h2) (i.e. does not check it, as
// this is not a profitable opt for real code), so it issues two independent
// loads.
r.r1 = h1.a;
r.r2 = h2.a;
}
}
ich nicht, was der Autor von den markierten mit (*****) Kommentar bedeutet das verstehen kann.
@ aleksey-shipilev, können Sie das bitte kommentieren? – ACV