diff options
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" |