java aliasing rules
Bryce McKinlay
bryce@waitaki.otago.ac.nz
Thu Mar 28 22:02:00 GMT 2002
Tom Tromey wrote:
>Bryce> I implemented java_get_alias_set() by simply assigning a new
>Bryce> alias set to every unique field, storing it in
>Bryce> DECL_POINTER_ALIAS_SET for each FIELD_DECL. This managed to
>Bryce> eliminate some redundant loads in my tests, but didn't cause
>Bryce> any measurable improvements in benchmark scores so I didn't get
>Bryce> too excited about it
>
>This sounds like a nice approach.
>My only question is how it handles the length field of an array.
>
>Object[].length and Foo[].length can alias.
>But int[].length and Object[].length cannot.
>
I believe the array length field is not important for aliasing purposes
because it is read-only.
>Similarly for the interior of arrays.
>
>Maybe we could squeeze out some tiny percentage improvement by taking
>this into account too?
>
I think we can make sure arrays of different primitive types get
different alias sets. It might also be possible to make sure that A[]
and B[] are known not to alias when A and B do not extend each other.
For Dan's test case, I can get optimal code simply by setting
DECL_NONADDRESSABLE_P on all Java FIELD_DECLS (see the patch below),
there's doesn't seem to be any need for java_get_alias_set or changes to
the generic alias code to get this.
On PowerPC, before this patch I got:
t.f(first, second):
lhz 9,10(4) # <variable>.f1
addi 9,9,1
sth 9,10(4) # <variable>.f1
lhz 11,6(5) # <variable>.f2
addi 11,11,1
sth 11,6(5) # <variable>.f2
lhz 9,10(4) # <variable>.f1
addi 9,9,1
sth 9,10(4) # <variable>.f1
lhz 11,6(5) # <variable>.f2
addi 11,11,1
sth 11,6(5) # <variable>.f2
blr
and with DECL_NONADDRESSABLE_P:
t.f(first, second):
lhz 9,10(4) # <variable>.f1
lhz 11,6(5) # <variable>.f2
addi 9,9,2
addi 11,11,2
sth 9,10(4) # <variable>.f1
sth 11,6(5) # <variable>.f2
blr
regards
Bryce.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: java-alias-4.patch
URL: <http://gcc.gnu.org/pipermail/java/attachments/20020328/b9112dc7/attachment.ksh>
More information about the Java
mailing list