public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: java-prs@gcc.gnu.org Subject: [Bug java/21855] array bounds checking elimination Date: Tue, 10 Jan 2012 16:31:00 -0000 [thread overview] Message-ID: <bug-21855-8172-cpwITztEVU@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-21855-8172@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21855 --- Comment #17 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-10 16:30:30 UTC --- (In reply to comment #16) > (In reply to comment #15) > > (In reply to comment #14) > > > (In reply to comment #13) > > > > We can't optimize this because System.out.println can change args[]. > > > > > > That's the whole point: System.out.println cannot change args[], which is a > > > java array, and the length of a Java array is constant. It is not an invalid > > > test case. > > > > I suppose > > > > public static void main(String[] args) > > > > is passing args by value (but the implementation detail uses reference > > passing for efficiency?). > > args is indeed a reference to a Java array. The length field of a Java > array is immutable. The elements of an array are not immutable. You mean that System.out.println could change the elements of the array (well, it doesn't, but theoretically it could)? > > In this case the Java frontend should do > > like the C++ frontend and tell this to the middle-end by properly > > marking args as 1) DECL_BY_REFERENCE, 2) use a TYPE_RESTRICT qualified > > pointer for the reference. Then we would optimize this case. > > If we could mark the length field as immutable that would fix it. Is there any > way to do that? No. What you can do is, via the method I outlined, tell GCC that args is to be treated similar to a local automatic variable - thus it cannot be refered to from other functions (unless you pass them its address of course).
next prev parent reply other threads:[~2012-01-10 16:31 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-21855-8172@http.gcc.gnu.org/bugzilla/> 2012-01-10 15:43 ` [Bug tree-optimization/21855] " rguenth at gcc dot gnu.org 2012-01-10 15:53 ` aph at gcc dot gnu.org 2012-01-10 16:20 ` [Bug java/21855] " rguenth at gcc dot gnu.org 2012-01-10 16:28 ` aph at gcc dot gnu.org 2012-01-10 16:31 ` rguenth at gcc dot gnu.org [this message] 2012-01-10 16:36 ` rguenth at gcc dot gnu.org 2012-01-10 16:46 ` aph at gcc dot gnu.org 2012-01-10 16:58 ` rguenth at gcc dot gnu.org 2012-01-10 16:59 ` rguenth at gcc dot gnu.org 2012-01-10 17:08 ` aph at gcc dot gnu.org 2012-01-10 17:18 ` tromey at gcc dot gnu.org 2012-01-10 17:22 ` tromey at gcc dot gnu.org 2015-10-20 15:08 ` 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=bug-21855-8172-cpwITztEVU@http.gcc.gnu.org/bugzilla/ \ --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: linkBe 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).