# HG changeset patch # User Thomas Wuerthinger # Date 1330127344 -3600 # Node ID 6336b144e391985aed7b60eae785d89d8a20587d # Parent 07bcee8b70a46eaf0c7eadfe0d6723e07d16e8be Simplified and improved the speed of compiled exception handler lookup based on the Graal exception handler model. diff -r 07bcee8b70a4 -r 6336b144e391 src/share/vm/runtime/sharedRuntime.cpp --- a/src/share/vm/runtime/sharedRuntime.cpp Sat Feb 25 00:40:34 2012 +0100 +++ b/src/share/vm/runtime/sharedRuntime.cpp Sat Feb 25 00:49:04 2012 +0100 @@ -653,6 +653,26 @@ assert(nm != NULL, "must exist"); ResourceMark rm; +#ifdef GRAAL + // lookup exception handler for this pc + int catch_pco = ret_pc - nm->code_begin(); + ExceptionHandlerTable table(nm); + HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0); + if (t != NULL) { + return nm->code_begin() + t->pco(); + } else { + // there is no exception handler for this pc => deoptimize + nm->make_not_entrant(); + JavaThread* thread = JavaThread::current(); + RegisterMap reg_map(thread); + frame runtime_frame = thread->last_frame(); + frame caller_frame = runtime_frame.sender(®_map); + Deoptimization::deoptimize_frame(thread, caller_frame.id()); + return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); + } + +#else + ScopeDesc* sd = nm->scope_desc_at(ret_pc); // determine handler bci, if any EXCEPTION_MARK; @@ -714,23 +734,8 @@ #ifdef COMPILER1 if (t == NULL && nm->is_compiled_by_c1()) { -#ifdef GRAAL - nm->make_not_entrant(); - JavaThread* thread = JavaThread::current(); - // save the exception for deoptimization - thread->set_exception_pc(ret_pc); - thread->set_exception_oop(exception()); - // clear the pending exception and deoptimize the frame - thread->clear_pending_exception(); - RegisterMap reg_map(thread, false); - frame runtime_frame = thread->last_frame(); - frame caller_frame = runtime_frame.sender(®_map); - Deoptimization::deoptimize_frame(thread, caller_frame.id()); - return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); -#else assert(nm->unwind_handler_begin() != NULL, ""); return nm->unwind_handler_begin(); -#endif } #endif @@ -747,6 +752,7 @@ } return nm->code_begin() + t->pco(); +#endif } JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread))