This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Java & aliasing question


Consider:

class A
{
  int a;
  int b;
}

class B
{
  int a = 5;
}

class Alias
{
  void foo(A a, B b)
  {
    a.a = b.a;
    a.b = b.a;
  }
}

In Java, incompatible types like A and B can never alias each other, yet 
we currently generate code that assumes they could:

Alias::foo(A*, B*):
    lwz 0,4(5)
    stw 0,4(4)
    lwz 9,4(5)
    stw 9,8(4)
    blr

If the Java front end implements lang_hooks.get_alias_set(), can gcc 
eliminate the redundant load?

Further, given something like:

class A {}
class B extends A {}
class C extends A {}

an "A" could alias either a "B" or a "C", but a "B" can't alias a "C" 
simply because they cannot possibly point to the same object. Is it 
possible for gcj to express this to the aliasing code? Even better, 
could it operate on the individual elements, so that only fields 
declared in A would be considered aliasing?

regards

Bryce.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]