public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bryce McKinlay <bryce@waitaki.otago.ac.nz>
To: tromey@redhat.com
Cc: Dan Nicolaescu <dann@godzilla.ics.uci.edu>,
	java@gcc.gnu.org, gcc@gcc.gnu.org
Subject: Re: java aliasing rules
Date: Fri, 29 Mar 2002 15:22:00 -0000	[thread overview]
Message-ID: <3CA4F734.6040706@waitaki.otago.ac.nz> (raw)
In-Reply-To: <873cyjoq4w.fsf@creche.redhat.com>

Tom Tromey wrote:

>Bryce> For Dan's test case, I can get optimal code simply by setting
>Bryce> DECL_NONADDRESSABLE_P on all Java FIELD_DECLS (see the patch
>Bryce> below), there's doesn't seem to be any need for
>Bryce> java_get_alias_set or changes to the generic alias code to get
>Bryce> this.
>
>That's a nice patch!
>

Unfortunately the code generated is not entirely correct for Java. The 
reason is nothing to do with aliasing but rather NullPointerExceptions.

  public  void f (first  ps1, second ps2)
  {
      ps1.f1++;
      ps2.f2++;
      ps1.f1++;
      ps2.f2++;
  }

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


With this code, if "ps2" is null then the second load (lhz) will throw 
before the ps1.f1 is seen as incremented. The optimal, correct code for 
Java is really something like:

lhz r9, [ps1.f1]
addi r9,r9,1
sth r9, [ps1.f1]
lhz r11, [ps2.f2]
addi r9,r9,1
addi r11,r11,2
sth r9, [ps1.f1]
sth r11, [ps2.f2]
blr

The second increment of ps1.f1 should not be allowed to be 
moved/combined ahead of the first "ps2.f2++", because it can trap/throw. 
The last two lines however cannot trap (since the first two would have 
done so already), so they can be safely moved/combined with other 
instructions)

None the less, I'm tempted to check in (to mainline) the 
DECL_NONADDRESSABLE_P change anyway, along with a PR and test case for 
the nullpointer problem. This is really just exposing a problem 
elsewhere in the compiler, which quite likely happens anyway in other 
situations when the aliasing stuff doesn't prevent it. Its also highly 
unlikely that any real applications are going to care about this 
behaviour, and exposing the problem will make it easier to fix it. What 
do you guys think?

regards

Bryce.



  reply	other threads:[~2002-03-29 23:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27 11:43 Dan Nicolaescu
2002-03-27 13:53 ` Tom Tromey
2002-03-27 16:03   ` Dan Nicolaescu
2002-03-27 16:47     ` Tom Tromey
2002-03-27 20:00       ` Dan Nicolaescu
2002-03-27 15:54 ` Bryce McKinlay
2002-03-27 16:45   ` Tom Tromey
2002-03-28 22:02     ` Bryce McKinlay
2002-03-28 22:13       ` Richard Henderson
2002-03-28 22:15       ` Tom Tromey
2002-03-29 15:22         ` Bryce McKinlay [this message]
2002-03-29 16:26           ` Richard Henderson
2002-03-30  6:37           ` Jeff Sturm
2002-03-30 13:55             ` Richard Henderson
2002-03-30 15:04             ` Bryce McKinlay
2002-04-04 10:57               ` Jeff Sturm
2002-04-04 12:57                 ` Andrew Haley
2002-04-04 14:20                   ` Jeff Sturm
2002-04-04 17:04                 ` Bryce McKinlay
2002-04-04 20:39                   ` Jeff Sturm
2002-04-05  1:07                     ` Bryce McKinlay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3CA4F734.6040706@waitaki.otago.ac.nz \
    --to=bryce@waitaki.otago.ac.nz \
    --cc=dann@godzilla.ics.uci.edu \
    --cc=gcc@gcc.gnu.org \
    --cc=java@gcc.gnu.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).