public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Dan Nicolaescu <dann@godzilla.ICS.UCI.EDU>
To: tromey@redhat.com
Cc: java@gcc.gnu.org
Subject: Re: java aliasing rules
Date: Wed, 27 Mar 2002 16:03:00 -0000	[thread overview]
Message-ID: <200203271603.aa04279@gremlin-relay.ics.uci.edu> (raw)
In-Reply-To: <87zo0tprx4.fsf@creche.redhat.com>

Tom Tromey <tromey@redhat.com> writes:

Dan> The more general question is if 2 COMPONENT_REFs that refer to
Dan> classes that are in conflicting alias sets (ie
Dan> alias_sets_conflict_p) alias in java. I have a hunch that this
Dan> might be true, but I don't know enough about java to be sure.  If
Dan> the above is not true, is there a restricted case when it is
Dan> true?

Tom> My understanding, and please if you don't mind clear things up if I'm
Tom> wrong, is that each front end is free to write its own aliasing
Tom> function.  And as far as I know gcj doesn't have one.  So I don't know
Tom> how conflicting alias sets for Java are currently computed, but I
Tom> imagine it is just very conservative and doesn't follow the language
Tom> rules.

Yes, a language can define it's own alias set function, if it doesn't
alias sets will be computed based on the contents of the type. 

For example 

class one {int i;};
class two {int i;};

will be put in the same alias set even though, AFAIK, they are not
compatible. 

Tom> Better aliasing support is definitely something we'd like.  It's on my
Tom> to-do list (and, I'd wager, Bryce's), but I haven't had time to look
Tom> at it.

IMHO this might be as simple as a < 5 lines function (but I might be
wrong...)
Dealing with the the example above will take you a long way (I'd be
glad to help if you need it).

But all this is unrelated to my question. 
In my first mail the "first" and "second" were already in different
alias sets. 

Tom> Anyway, in Java, casts are *always* done according to the type system.
Tom> There is no way to circumvent it.  So in your above example, it is
Tom> never possible to turn a `first' into a `second' -- they are not
Tom> compatible.
Tom> 
Tom> Does this answer your questions?

Yes, this is exactly I wanted to know. 

Could you test the following hack (I'll create a proper langhook
later) on a big java program and see if it makes a difference? 
(it made cc1 1% smaller, and I expect even more on java). 

Just set the COMPONENT_REF_ALIAS environment variable and recompile
the program... 

Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.167
diff -c -3 -p -c -r1.167 alias.c
*** alias.c	2002/03/11 18:01:53	1.167
--- alias.c	2002/03/27 23:48:58
*************** nonoverlapping_component_refs_p (x, y)
*** 1810,1815 ****
--- 1855,1887 ----
  {
    tree fieldx, fieldy, typex, typey, orig_y;
  
+   /* Component refs that belong to structures that are known not to
+      alias, don't alias.  */
+   if (getenv ("COMPONENT_REF_ALIAS"))
+     {
+       typex = DECL_CONTEXT (TREE_OPERAND (x, 1));
+       typey = DECL_CONTEXT (TREE_OPERAND (y, 1));
+       if (typex != NULL && typey != NULL
+           && TREE_CODE (typex) == RECORD_TYPE
+           && TREE_CODE (typey) == RECORD_TYPE              
+           && ! alias_sets_conflict_p (get_alias_set (typex),
+                                       get_alias_set (typey)))
+         {
+               return 1;
+         }
+ 
+     }
    do
      {
        /* The comparison has to be done at a common type, since we don't


  reply	other threads:[~2002-03-28  0:03 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 [this message]
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
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=200203271603.aa04279@gremlin-relay.ics.uci.edu \
    --to=dann@godzilla.ics.uci.edu \
    --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).