This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Repost: [PATCH] java/12739
- From: Jeff Sturm <jsturm at one-point dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: java-patches at gcc dot gnu dot org
- Date: Sun, 16 Nov 2003 17:16:11 -0500 (EST)
- Subject: Repost: [PATCH] java/12739
Tom Tromey pointed out that the orignal patch was incorrectly formatted
according to GNU standards.
The patch restores a simple bytecode optimization present in 3.3 and
earlier releases. OK for 3.4?
Jeff
2003-11-16 Jeff Sturm <jsturm@one-point.com>
Fix PR java/12739.
* java-tree.h (BLOCK_EMPTY_P): Define.
* parse.y (java_complete_lhs): Check for empty blocks
in TRY_FINALLY_EXPR case.
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.186
diff -u -p -r1.186 java-tree.h
--- java-tree.h 24 Oct 2003 09:29:40 -0000 1.186
+++ java-tree.h 16 Nov 2003 22:09:10 -0000
@@ -1727,6 +1727,8 @@ while (0)
#define BLOCK_EXPR_BODY(NODE) BLOCK_SUBBLOCKS(NODE)
/* True for an implicit block surrounding declaration not at start of {...}. */
#define BLOCK_IS_IMPLICIT(NODE) TREE_LANG_FLAG_1 (NODE)
+#define BLOCK_EMPTY_P(NODE) \
+ (TREE_CODE (NODE) == BLOCK && BLOCK_EXPR_BODY (NODE) == empty_stmt_node)
#define BUILD_MONITOR_ENTER(WHERE, ARG) \
{ \
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.455
diff -u -p -r1.455 parse.y
--- parse.y 12 Nov 2003 17:00:53 -0000 1.455
+++ parse.y 16 Nov 2003 22:09:11 -0000
@@ -11719,9 +11719,13 @@ java_complete_lhs (tree node)
case TRY_FINALLY_EXPR:
COMPLETE_CHECK_OP_0 (node);
COMPLETE_CHECK_OP_1 (node);
- if (TREE_OPERAND (node, 0) == empty_stmt_node)
+ /* Reduce try/finally nodes with an empty try block. */
+ if (TREE_OPERAND (node, 0) == empty_stmt_node
+ || BLOCK_EMPTY_P (TREE_OPERAND (node, 0)))
return TREE_OPERAND (node, 1);
- if (TREE_OPERAND (node, 1) == empty_stmt_node)
+ /* Likewise for an empty finally block. */
+ if (TREE_OPERAND (node, 1) == empty_stmt_node
+ || BLOCK_EMPTY_P (TREE_OPERAND (node, 1)))
return TREE_OPERAND (node, 0);
CAN_COMPLETE_NORMALLY (node)
= (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))