java aliasing rules

Dan Nicolaescu dann@godzilla.ICS.UCI.EDU
Wed Mar 27 11:43:00 GMT 2002


Given this code:
class first { int i; char a; char f1; char f2; double d;};
class second { char b; char f2; int f3;};
public class t
{
 public void f (first ps1, second ps2)
 {
 ps1.f1++;
 ps2.f2++;
 ps1.f1++;
 ps2.f2++;
 }
}
can it be assumed that given that "first" and "second" are
incompatible then ps1.f1 and ps2.f2 don't alias and we can generate
code like the following: (SPARC assembly)
 !#PROLOGUE# 0
 !#PROLOGUE# 1
 lduh [%o1+14], %o0
 lduh [%o2+10], %o3
 add %o0, 2, %o0
 add %o3, 2, %o3
 sth %o0, [%o1+14]
 retl
 sth %o3, [%o2+10]
instead of what is generated now: 
 !#PROLOGUE# 0
 !#PROLOGUE# 1
 lduh [%o1+14], %o3
 add %o3, 1, %o3
 sth %o3, [%o1+14]
 lduh [%o2+10], %o0
 add %o0, 1, %o0
 sth %o0, [%o2+10]
 lduh [%o1+14], %o3
 add %o3, 1, %o3
 sth %o3, [%o1+14]
 lduh [%o2+10], %o0
 add %o0, 1, %o0
 retl
 sth %o0, [%o2+10]
The more general question is if 2 COMPONENT_REFs that refer to classes
that are in conflicting alias sets (ie alias_sets_conflict_p) alias in
java. I have a hunch that this might be true, but I don't know enough
about java to be sure. If the above is not true, is there a
restricted case when it is true?
(for the curious this is related to the patch at
http://gcc.gnu.org/ml/gcc-patches/2002-03/msg00576.html that is not
totally correct for C, but I have a hunch that it might be OK for
java, if that is the case I will change the patch to be language
specific).


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /