public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
From: "tromey at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: java-prs@gcc.gnu.org
Subject: [Bug java/15525] suggestion to enable cast elimination
Date: Sun, 01 May 2005 00:57:00 -0000	[thread overview]
Message-ID: <20050501005743.26006.qmail@sourceware.org> (raw)
In-Reply-To: <20040518204228.15525.tromey@gcc.gnu.org>


------- Additional Comments From tromey at gcc dot gnu dot org  2005-05-01 00:57 -------
There are a couple more cases where explicit casts can be eliminated.

Code like this will introduce an unneeded cast:

   Object o = "something";
   String s = (String) o;

Of course this is the simplest possible case; I don't know whether
this occurs in real code or not.


Another case is rearranging an array:

   Object[] array = something();
   array[0] = array[1];

This will generate a call to check whether the array can hold the
object, due to the special role arrays play in the type system;
for example this is valid but throws an exception at runtime:

   String[] sarray = ...;
   Object[] oarray = sarray;
   oarray[0] = new Integer(5);

... because Integer can't be cast to String.
In the first array example, we know that the check can be
eliminated because the rhs of the assignment comes from the
same array.

Currently we emit calls to _Jv_CheckArrayStore for this situation.
While we could inline it (making the type check explicit and allowing
elimination in the style of the other parts of this PR), size of the generated
code might be a concern.

Sometimes the precise type of an array is known, for instance if it
is the result of a 'new'.  In this case it would be nice to be able
to eliminate even more checks.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15525


  parent reply	other threads:[~2005-05-01  0:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-18 20:42 [Bug java/15525] New: " tromey at gcc dot gnu dot org
2004-05-18 21:08 ` [Bug java/15525] " pinskia at gcc dot gnu dot org
2004-05-20 19:40 ` dnovillo at gcc dot gnu dot org
2004-08-27 20:55 ` tromey at gcc dot gnu dot org
2004-09-02  1:39 ` tromey at gcc dot gnu dot org
2005-03-09  9:04 ` pinskia at gcc dot gnu dot org
2005-05-01  0:57 ` tromey at gcc dot gnu dot org [this message]
     [not found] <bug-15525-8172@http.gcc.gnu.org/bugzilla/>
2015-10-20 15:07 ` aph at gcc dot gnu.org

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=20050501005743.26006.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=java-prs@gcc.gnu.org \
    /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).