This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Why does GCJ generate so many explicit checks for null pointers?
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: David Daney <ddaney at avtrex dot com>, <java at gcc dot gnu dot org>
- Date: Tue, 29 Jul 2003 11:06:14 -0400 (EDT)
- Subject: Re: Why does GCJ generate so many explicit checks for null pointers?
On 29 Jul 2003, Tom Tromey wrote:
> >> Why check before the constructor call? Is it ever possible for
> >> _Jv_AllocObjectNoFinalizer to return null?
>
> Jeff> No, but the backend optimizers don't know that, or else DCE would
> Jeff> eliminate the test.
>
> Hmm, on the C++ side we mark this function, and others like it, with
> __attribute__((__malloc__)). We do this in gcj as well; from
> java/decl.c:
But malloc can return NULL, right? From what I understand the malloc
attribute is a hint for alias analysis, and doesn't say anything about the
null-ness of its return value.
The CCP pass currently handles integer and boolean types just fine, but
doesn't appear to do anything special for pointers. Like Andrew said,
tree-ssa will be a good opportunity for experimentation here.
Jeff