comparison src/share/vm/runtime/sharedRuntime.cpp @ 4694:6336b144e391

Simplified and improved the speed of compiled exception handler lookup based on the Graal exception handler model.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 25 Feb 2012 00:49:04 +0100
parents 8021e46f4a99
children 33df1aeaebbf
comparison
equal deleted inserted replaced
4693:07bcee8b70a4 4694:6336b144e391
650 // for given exception 650 // for given exception
651 address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception, 651 address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
652 bool force_unwind, bool top_frame_only) { 652 bool force_unwind, bool top_frame_only) {
653 assert(nm != NULL, "must exist"); 653 assert(nm != NULL, "must exist");
654 ResourceMark rm; 654 ResourceMark rm;
655
656 #ifdef GRAAL
657 // lookup exception handler for this pc
658 int catch_pco = ret_pc - nm->code_begin();
659 ExceptionHandlerTable table(nm);
660 HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0);
661 if (t != NULL) {
662 return nm->code_begin() + t->pco();
663 } else {
664 // there is no exception handler for this pc => deoptimize
665 nm->make_not_entrant();
666 JavaThread* thread = JavaThread::current();
667 RegisterMap reg_map(thread);
668 frame runtime_frame = thread->last_frame();
669 frame caller_frame = runtime_frame.sender(&reg_map);
670 Deoptimization::deoptimize_frame(thread, caller_frame.id());
671 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
672 }
673
674 #else
655 675
656 ScopeDesc* sd = nm->scope_desc_at(ret_pc); 676 ScopeDesc* sd = nm->scope_desc_at(ret_pc);
657 // determine handler bci, if any 677 // determine handler bci, if any
658 EXCEPTION_MARK; 678 EXCEPTION_MARK;
659 679
712 t = table.entry_for(catch_pco, -1, 0); 732 t = table.entry_for(catch_pco, -1, 0);
713 } 733 }
714 734
715 #ifdef COMPILER1 735 #ifdef COMPILER1
716 if (t == NULL && nm->is_compiled_by_c1()) { 736 if (t == NULL && nm->is_compiled_by_c1()) {
717 #ifdef GRAAL
718 nm->make_not_entrant();
719 JavaThread* thread = JavaThread::current();
720 // save the exception for deoptimization
721 thread->set_exception_pc(ret_pc);
722 thread->set_exception_oop(exception());
723 // clear the pending exception and deoptimize the frame
724 thread->clear_pending_exception();
725 RegisterMap reg_map(thread, false);
726 frame runtime_frame = thread->last_frame();
727 frame caller_frame = runtime_frame.sender(&reg_map);
728 Deoptimization::deoptimize_frame(thread, caller_frame.id());
729 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
730 #else
731 assert(nm->unwind_handler_begin() != NULL, ""); 737 assert(nm->unwind_handler_begin() != NULL, "");
732 return nm->unwind_handler_begin(); 738 return nm->unwind_handler_begin();
733 #endif
734 } 739 }
735 #endif 740 #endif
736 741
737 if (t == NULL) { 742 if (t == NULL) {
738 tty->print_cr("MISSING EXCEPTION HANDLER for pc " INTPTR_FORMAT " and handler bci %d", ret_pc, handler_bci); 743 tty->print_cr("MISSING EXCEPTION HANDLER for pc " INTPTR_FORMAT " and handler bci %d", ret_pc, handler_bci);
745 guarantee(false, "missing exception handler"); 750 guarantee(false, "missing exception handler");
746 return NULL; 751 return NULL;
747 } 752 }
748 753
749 return nm->code_begin() + t->pco(); 754 return nm->code_begin() + t->pco();
755 #endif
750 } 756 }
751 757
752 JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread)) 758 JRT_ENTRY(void, SharedRuntime::throw_AbstractMethodError(JavaThread* thread))
753 // These errors occur only at call sites 759 // These errors occur only at call sites
754 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_AbstractMethodError()); 760 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_AbstractMethodError());