This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: gcj and redundant null pointer check
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>, Alexandre Petit-Bianco <apbianco at redhat dot com>
- Date: 27 Mar 2002 11:34:10 -0700
- Subject: Patch: gcj and redundant null pointer check
- Reply-to: tromey at redhat dot com
While looking at PR 5986 I found that the CrashEH program had explicit
null pointer checks in the generated code. I tracked this down to
some code in expr.c.
This patch removes that check. We know that if we're calling <init>
then we don't need it.
This patch could be refined further, but per the existing comment it
doesn't look easy.
Ok?
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* expr.c (expand_invoke): Don't generate null pointer check if
we're calling <init>.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.132.2.5
diff -u -r1.132.2.5 expr.c
--- expr.c 2002/03/23 01:17:52 1.132.2.5
+++ expr.c 2002/03/27 17:57:20
@@ -2143,12 +2143,15 @@
method's `this'. In other cases we just rely on an
optimization pass to eliminate redundant checks. FIXME:
Unfortunately there doesn't seem to be a way to determine
- what the current method is right now. */
+ what the current method is right now.
+ We do omit the check if we're calling <init>. */
/* We use a SAVE_EXPR here to make sure we only evaluate
the new `self' expression once. */
tree save_arg = save_expr (TREE_VALUE (arg_list));
TREE_VALUE (arg_list) = save_arg;
- check = java_check_reference (save_arg, 1);
+ check
+ = java_check_reference (save_arg,
+ DECL_NAME (method) != init_identifier_node);
func = build_known_method_ref (method, method_type, self_type,
method_signature, arg_list);
}