diff options
author | Andrew MacLeod <amacleod@cygnus.com> | 1998-06-08 12:43:28 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 1998-06-08 12:43:28 +0000 |
commit | a1622f838f1188fca74ba0186300882f33006ae7 (patch) | |
tree | 8c6db0a08fe59e66faaa88318e5d8e194578463d /gcc/libgcc2.c | |
parent | aeb302bbec86aff44fadaad0c9c9bf5e59cbe3f5 (diff) | |
download | gcc-a1622f838f1188fca74ba0186300882f33006ae7.zip gcc-a1622f838f1188fca74ba0186300882f33006ae7.tar.gz gcc-a1622f838f1188fca74ba0186300882f33006ae7.tar.bz2 |
[multiple changes]
Thu Jun 8 14:16:15 EDT 1998 Andrew MacLeod <amacleod@cygnus.com>
* eh-common.h: Remove NEW_EH_MODEL compile time flag, and replace with
flag_new_exceptions runtime flag.
(struct old_exception_table): New struct which represents what
the exception table looks like without the new model.
(NEW_EH_RUNTIME): New value used as a tag in the exception table to
flag that this is a new style table.
* except.h: Remove compile time flag NEW_EH_MODEL.
(expand_builtin_eh_stub_old): New prototype.
* tree.h (enum built_in_function): Add BUILT_IN_EH_STUB_OLD.
* expr.c (expand_builtin): New builtin func BUILT_IN_EH_STUB_OLD.
* c-decl.c (init_decl_processing): Add new builtin function
__builtin_eh_stub_old.
* final.c (final_scan_insn): Replace compile time flag NEW_EH_MODEL.
* flags.h (flag_new_exceptions): New runtime flag.
* toplev.c (flag_new_exceptions): Initialize default to 0,
-fnew-exceptions sets to 1.
* except.c (output_exception_table_entry): Output New style exception
identifier into table, and replace compile time flag NEW_EH_MODEL
with runtime flag flag_new_exceptions.
(output_exception_table): Replace compile time flag NEW_EH_MODEL.
(expand_builtin_eh_stub_old): Duplicates original functionality of
expand_builtin_eh_stub.
(expand_builtin_eh_stub): Replace compile time flag NEW_EH_MODEL.
* libgcc2.c (find_exception_handler): Remove NEW_EH_MODEL #ifdefs.
(old_find_exception_handler): New func, same as find_exception_handler
except it works on the old style exception table.
(__throw): Replace NEW_EH_MODEL. Detect new model based on presence
of identifier in the exception table, and call appropriate routines.
1998-06-08 Andrew MacLeod <amacleod@cygnus.com>
* except.c (init_exception_processing): Remove NEW_EH_MODEL compile
time flag. Call __cp_eh_info instead of __cp_exception_info.
* exception.cc (struct cp_eh_info): Remove NEW_EH_MODEL flag.
(__cp_exception_info): Return offset into cp_eh_info structure to
match what use to be the start of this structure.
(__cp_eh_info): New function to return a pointer to cp_eh_info struct.
(__cplus_type_matcher, __cp_push_exception): Remove NEW_EH_MODEL
compile time flag.
(__uncatch_exception, __check_eh_spec, std::uncaught_exception): Call
__cp_eh_info instead of __cp_exception_info.
From-SVN: r20336
Diffstat (limited to 'gcc/libgcc2.c')
-rw-r--r-- | gcc/libgcc2.c | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index c860412..1999931 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -3367,11 +3367,41 @@ EH_TABLE_LOOKUP an inner block. */ static void * +old_find_exception_handler (void *pc, old_exception_table *table) +{ + if (table) + { + int pos; + int best = -1; + + /* We can't do a binary search because the table isn't guaranteed + to be sorted from function to function. */ + for (pos = 0; table[pos].start_region != (void *) -1; ++pos) + { + if (table[pos].start_region <= pc && table[pos].end_region > pc) + { + /* This can apply. Make sure it is at least as small as + the previous best. */ + if (best == -1 || (table[pos].end_region <= table[best].end_region + && table[pos].start_region >= table[best].start_region)) + best = pos; + } + /* But it is sorted by starting PC within a function. */ + else if (best >= 0 && table[pos].start_region > pc) + break; + } + if (best != -1) + return table[best].exception_handler; + } + + return (void *) 0; +} + +static void * find_exception_handler (void *pc, exception_descriptor *table, void *eh_info) { if (table) { -#ifdef NEW_EH_MODEL /* The new model assumed the table is sorted inner-most out so the first region we find which matches is the correct one */ @@ -3406,29 +3436,6 @@ find_exception_handler (void *pc, exception_descriptor *table, void *eh_info) return tab[pos].exception_handler; } } -#else - int pos; - int best = -1; - - /* We can't do a binary search because the table isn't guaranteed - to be sorted from function to function. */ - for (pos = 0; table[pos].start_region != (void *) -1; ++pos) - { - if (table[pos].start_region <= pc && table[pos].end_region > pc) - { - /* This can apply. Make sure it is at least as small as - the previous best. */ - if (best == -1 || (table[pos].end_region <= table[best].end_region - && table[pos].start_region >= table[best].start_region)) - best = pos; - } - /* But it is sorted by starting PC within a function. */ - else if (best >= 0 && table[pos].start_region > pc) - break; - } - if (best != -1) - return table[best].exception_handler; -#endif } return (void *) 0; @@ -3568,6 +3575,7 @@ __throw () frame_state *sub_udata = &ustruct2; frame_state my_ustruct, *my_udata = &my_ustruct; long args_size; + int new_exception_model; /* This is required for C++ semantics. We must call terminate if we try and rethrow an exception, when there is no exception currently @@ -3611,7 +3619,16 @@ label: if (! udata) break; - handler = find_exception_handler (pc, udata->eh_ptr, eh->info); + if (udata->eh_ptr == NULL) + new_exception_model = 0; + else + new_exception_model = (((exception_descriptor *)(udata->eh_ptr))-> + runtime_id_field == NEW_EH_RUNTIME); + + if (new_exception_model) + handler = find_exception_handler (pc, udata->eh_ptr, eh->info); + else + handler = old_find_exception_handler (pc, udata->eh_ptr); /* If we found one, we can stop searching. */ if (handler) @@ -3630,9 +3647,7 @@ label: if (! handler) __terminate (); -#ifdef NEW_EH_MODEL eh->handler_label = handler; -#endif if (pc == saved_pc) /* We found a handler in the throw context, no need to unwind. */ @@ -3691,7 +3706,10 @@ label: /* udata now refers to the frame called by the handler frame. */ /* Emit the stub to adjust sp and jump to the handler. */ - retaddr = __builtin_eh_stub (); + if (new_exception_model) + retaddr = __builtin_eh_stub (); + else + retaddr = __builtin_eh_stub_old (); /* And then set our return address to point to the stub. */ if (my_udata->saved[my_udata->retaddr_column] == REG_SAVED_OFFSET) @@ -3702,19 +3720,23 @@ label: /* Set up the registers we use to communicate with the stub. We check STACK_GROWS_DOWNWARD so the stub can use adjust_stack. */ -#ifdef NEW_EH_MODEL - __builtin_set_eh_regs ((void *)eh, + if (new_exception_model) + __builtin_set_eh_regs ((void *)eh, +#ifdef STACK_GROWS_DOWNWARD + udata->cfa - my_udata->cfa #else - __builtin_set_eh_regs (handler, + my_udata->cfa - udata->cfa #endif + + args_size); + else + __builtin_set_eh_regs (handler, #ifdef STACK_GROWS_DOWNWARD udata->cfa - my_udata->cfa #else my_udata->cfa - udata->cfa #endif - + args_size - ); + + args_size); /* Epilogue: restore the handler frame's register values and return to the stub. */ |