This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: jcf-write and last_bc
The checked in the following patch.
2001-10-11 Per Bothner <per@bothner.com>
* parse.y (patch_synchronized_statement): Use a TRY_FINALLY_EXPR
rather than a CLEANUP_POINT_EXPR/WITH_CLEANUP_EXPR pair.
The former is simpler, and jcf-write.c handles it better.
(java_complete_lhs): No longer need to handle CLEANUP_POINT_EXPR
or WITH_CLEANUP_EXPR.
* jcf-write.c: Revert Alex's change from 2000-10-18. It is no
longer needed, as we already handle empty TRY_FINALLY_EXPR bodies fine.
>------------------------------------------------------------------------
>
>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)
>