This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: jcf-write and last_bc
This patch seems to work. Basically, it re-implements "synchronized"
to used TRY_FINALLY_EXPR instead of WITH_CLEANUP_EXPR.
This works because the former already has working support for handling
empty statements. I also think TRY_FINALLY_EXPR is easier to
understand and work with and that WITH_CLEANUP_EXPR is redundant.
A follow-up patch (if this works) will remove remaining uses of
WITH_CLEANUP_EXPR and CLEANUP_POINT_EXPR.
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.318
diff -u -p -r1.318 parse.y
--- parse.y 2001/10/09 05:40:35 1.318
+++ parse.y 2001/10/10 00:02:47
@@ -11579,21 +11579,6 @@ java_complete_lhs (node)
TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
return node;
- case CLEANUP_POINT_EXPR:
- COMPLETE_CHECK_OP_0 (node);
- TREE_TYPE (node) = void_type_node;
- CAN_COMPLETE_NORMALLY (node) =
- CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
- return node;
-
- case WITH_CLEANUP_EXPR:
- COMPLETE_CHECK_OP_0 (node);
- COMPLETE_CHECK_OP_1 (node);
- CAN_COMPLETE_NORMALLY (node) =
- CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
- TREE_TYPE (node) = void_type_node;
- return node;
-
case LABELED_BLOCK_EXPR:
PUSH_LABELED_BLOCK (node);
if (LABELED_BLOCK_BODY (node))
@@ -15668,13 +15667,9 @@ patch_synchronized_statement (node, wfl_
CAN_COMPLETE_NORMALLY (exit) = 1;
assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
TREE_SIDE_EFFECTS (assignment) = 1;
- node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
- build (COMPOUND_EXPR, NULL_TREE,
- build (WITH_CLEANUP_EXPR, NULL_TREE,
- build (COMPOUND_EXPR, NULL_TREE,
- assignment, enter),
- exit, NULL_TREE),
- block));
+ node = build (COMPOUND_EXPR, NULL_TREE,
+ build (COMPOUND_EXPR, NULL_TREE, assignment, enter),
+ build (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
node = build_expr_block (node, expr_decl);
return java_complete_tree (node);
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.90
diff -u -p -r1.90 jcf-write.c
--- jcf-write.c 2001/10/08 20:35:03 1.90
+++ jcf-write.c 2001/10/10 00:36:12
@@ -57,7 +57,7 @@ char *jcf_write_base_directory = NULL;
/* Add a 1-byte instruction/operand I to bytecode.data,
assuming space has already been RESERVE'd. */
-#define OP1(I) (state->last_bc = *state->bytecode.ptr++ = (I), CHECK_OP(state))
+#define OP1(I) (*state->bytecode.ptr++ = (I), CHECK_OP(state))
/* Like OP1, but I is a 2-byte big endian integer. */
@@ -275,8 +275,6 @@ struct jcf_partial
/* Information about the current switch statement. */
struct jcf_switch_state *sw_state;
-
- enum java_opcode last_bc; /* The last emitted bytecode */
};
static void generate_bytecode_insns PARAMS ((tree, int, struct jcf_partial *));
@@ -2167,16 +2165,7 @@ generate_bytecode_insns (exp, target, st
tree src = TREE_OPERAND (exp, 0);
tree src_type = TREE_TYPE (src);
tree dst_type = TREE_TYPE (exp);
- /* Detect the situation of compiling an empty synchronized
- block. A nop should be emitted in order to produce
- verifiable bytecode. */
- if (exp == empty_stmt_node
- && state->last_bc == OPCODE_monitorenter
- && state->labeled_blocks
- && state->labeled_blocks->pc == PENDING_CLEANUP_PC)
- OP1 (OPCODE_nop);
- else
- generate_bytecode_insns (TREE_OPERAND (exp, 0), target, state);
+ generate_bytecode_insns (TREE_OPERAND (exp, 0), target, state);
if (target == IGNORE_TARGET || src_type == dst_type)
break;
if (TREE_CODE (dst_type) == POINTER_TYPE)