From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26042 invoked by alias); 1 May 2005 00:57:44 -0000 Mailing-List: contact java-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-prs-owner@gcc.gnu.org Received: (qmail 26007 invoked by uid 48); 1 May 2005 00:57:43 -0000 Date: Sun, 01 May 2005 00:57:00 -0000 Message-ID: <20050501005743.26006.qmail@sourceware.org> From: "tromey at gcc dot gnu dot org" To: java-prs@gcc.gnu.org In-Reply-To: <20040518204228.15525.tromey@gcc.gnu.org> References: <20040518204228.15525.tromey@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug java/15525] suggestion to enable cast elimination X-Bugzilla-Reason: CC X-SW-Source: 2005-q2/txt/msg00308.txt.bz2 List-Id: ------- 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