diff options
author | Andrew Haley <aph@redhat.com> | 2004-06-29 16:18:46 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2004-06-29 16:18:46 +0000 |
commit | ba60e4754adc4181784207396de5abbd349d894f (patch) | |
tree | 406cc493b14a7dbe0721aae139686fc7c954a0cc /gcc/java/decl.c | |
parent | 9f6eb0f4dbc2b394976b52d72f57ea33e1ef6ddf (diff) | |
download | gcc-ba60e4754adc4181784207396de5abbd349d894f.zip gcc-ba60e4754adc4181784207396de5abbd349d894f.tar.gz gcc-ba60e4754adc4181784207396de5abbd349d894f.tar.bz2 |
except.c (expand_start_java_handler): Push a new binding level.
2004-06-29 Andrew Haley <aph@redhat.com>
* except.c (expand_start_java_handler): Push a new binding level.
Don't build a TRY_CATCH_EXPR now, we'll do it later. Call
register_exception_range() to register where we'll do it.
(expand_end_java_handler): Remove old bogus code. Replace with
new logic that simply builds TRY_CATCH_EXPRs and inserts them at
the top of the expression we're curently building.
(maybe_end_try): Delete.
* decl.c (binding_level.exception_range): New field.
(clear_binding_level): Add field exception_range. Reformat.
(poplevel): Call expand_end_java_handler().
(poplevel): Call java_add_stmt only if functionbody is false.
(maybe_poplevels): Don't call maybe_end_try() from here.
(end_java_method): Clear no longer used trees in function decl.
(register_exception_range): New function.
* java-tree.h (register_exception_range, struct eh_range): Declare.
From-SVN: r83857
Diffstat (limited to 'gcc/java/decl.c')
-rw-r--r-- | gcc/java/decl.c | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 682c8b3..508727a 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -314,6 +314,9 @@ struct binding_level GTY(()) /* The statements in this binding level. */ tree stmts; + /* An exception range associated with this binding level. */ + struct eh_range * GTY((skip (""))) exception_range; + /* Binding depth at which this level began. Used only for debugging. */ unsigned binding_depth; }; @@ -341,8 +344,18 @@ static GTY(()) struct binding_level *global_binding_level; /* Binding level structures are initialized by copying this one. */ static const struct binding_level clear_binding_level - = {NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, - NULL_BINDING_LEVEL, LARGEST_PC, 0, NULL_TREE, 0}; += { + NULL_TREE, /* names */ + NULL_TREE, /* shadowed */ + NULL_TREE, /* blocks */ + NULL_TREE, /* this_lock */ + NULL_BINDING_LEVEL, /* level_chain */ + LARGEST_PC, /* end_pc */ + 0, /* start_pc */ + NULL, /* stmts */ + NULL, /* exception_range */ + 0, /* binding_depth */ + }; #if 0 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function @@ -1316,6 +1329,9 @@ poplevel (int keep, int reverse, int functionbody) TREE_TYPE (block) = void_type_node; } + if (current_binding_level->exception_range) + expand_end_java_handler (current_binding_level->exception_range); + if (block != 0) { /* If any statements have been generated at this level, create a @@ -1341,7 +1357,6 @@ poplevel (int keep, int reverse, int functionbody) bind = build (BIND_EXPR, TREE_TYPE (block), BLOCK_VARS (block), BLOCK_EXPR_BODY (block), block); - BIND_EXPR_BODY (bind) = current_binding_level->stmts; if (BIND_EXPR_BODY (bind) @@ -1448,24 +1463,27 @@ poplevel (int keep, int reverse, int functionbody) DECL_INITIAL (current_function_decl) = block; DECL_SAVED_TREE (current_function_decl) = bind; } - else if (block) + else { - if (!block_previously_created) - current_binding_level->blocks - = chainon (current_binding_level->blocks, block); + if (block) + { + if (!block_previously_created) + current_binding_level->blocks + = chainon (current_binding_level->blocks, block); + } + /* If we did not make a block for the level just exited, + any blocks made for inner levels + (since they cannot be recorded as subblocks in that level) + must be carried forward so they will later become subblocks + of something else. */ + else if (subblocks) + current_binding_level->blocks + = chainon (current_binding_level->blocks, subblocks); + + if (bind) + java_add_stmt (bind); } - /* If we did not make a block for the level just exited, - any blocks made for inner levels - (since they cannot be recorded as subblocks in that level) - must be carried forward so they will later become subblocks - of something else. */ - else if (subblocks) - current_binding_level->blocks - = chainon (current_binding_level->blocks, subblocks); - - if (bind) - java_add_stmt (bind); - + if (block) TREE_USED (block) = 1; return block; @@ -1521,11 +1539,7 @@ maybe_poplevels (int pc) #endif while (current_binding_level->end_pc <= pc) - { - maybe_end_try (current_binding_level->start_pc, pc); - poplevel (1, 0, 0); - } - maybe_end_try (0, pc); + poplevel (1, 0, 0); } /* Terminate any binding which began during the range beginning at @@ -1781,6 +1795,14 @@ end_java_method (void) flag_unit_at_a_time = 0; finish_method (fndecl); + if (! flag_unit_at_a_time) + { + /* Nulling these fields when we no longer need them saves + memory. */ + DECL_SAVED_TREE (fndecl) = NULL; + DECL_STRUCT_FUNCTION (fndecl) = NULL; + DECL_INITIAL (fndecl) = NULL_TREE; + } current_function_decl = NULL_TREE; } @@ -1929,5 +1951,19 @@ get_stmts (void) return ¤t_binding_level->stmts; } +/* Register an exception range as belonging to the current binding + level. There may only be one: if there are more, we'll create more + binding levels. However, each range can have multiple handlers, + and these are expanded when we call expand_end_java_handler(). */ + +void +register_exception_range (struct eh_range *range, int pc, int end_pc) +{ + if (current_binding_level->exception_range) + abort (); + current_binding_level->exception_range = range; + current_binding_level->end_pc = end_pc; + current_binding_level->start_pc = pc; +} #include "gt-java-decl.h" |