This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: gcj and redundant null pointer check


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);
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]