712 |
712 |
713 int remaining = handlers.count_remaining(); |
713 int remaining = handlers.count_remaining(); |
714 |
714 |
715 // iterate through all entries sequentially |
715 // iterate through all entries sequentially |
716 for (;!handlers.is_done(); handlers.next()) { |
716 for (;!handlers.is_done(); handlers.next()) { |
717 // Do nothing if turned off |
|
718 if( !DeutschShiffmanExceptions ) break; |
|
719 ciExceptionHandler* handler = handlers.handler(); |
717 ciExceptionHandler* handler = handlers.handler(); |
720 |
718 |
721 if (handler->is_rethrow()) { |
719 if (handler->is_rethrow()) { |
722 // If we fell off the end of the table without finding an imprecise |
720 // If we fell off the end of the table without finding an imprecise |
723 // exception klass (and without finding a generic handler) then we |
721 // exception klass (and without finding a generic handler) then we |
739 #endif |
737 #endif |
740 merge_exception(handler_bci); // jump to handler |
738 merge_exception(handler_bci); // jump to handler |
741 return; // No more handling to be done here! |
739 return; // No more handling to be done here! |
742 } |
740 } |
743 |
741 |
744 // %%% The following logic replicates make_from_klass_unique. |
742 // Get the handler's klass |
745 // TO DO: Replace by a subroutine call. Then generalize |
|
746 // the type check, as noted in the next "%%%" comment. |
|
747 |
|
748 ciInstanceKlass* klass = handler->catch_klass(); |
743 ciInstanceKlass* klass = handler->catch_klass(); |
749 if (UseUniqueSubclasses) { |
744 |
750 // (We use make_from_klass because it respects UseUniqueSubclasses.) |
745 if (!klass->is_loaded()) { // klass is not loaded? |
751 const TypeOopPtr* tp = TypeOopPtr::make_from_klass(klass); |
746 // fall through into catch_call_exceptions which will emit a |
752 klass = tp->klass()->as_instance_klass(); |
747 // handler with an uncommon trap. |
753 } |
748 break; |
754 |
749 } |
755 // Get the handler's klass |
750 |
756 if (!klass->is_loaded()) // klass is not loaded? |
|
757 break; // Must call Rethrow! |
|
758 if (klass->is_interface()) // should not happen, but... |
751 if (klass->is_interface()) // should not happen, but... |
759 break; // bail out |
752 break; // bail out |
760 // See if the loaded exception klass has no subtypes |
753 |
761 if (klass->has_subklass()) |
754 // Check the type of the exception against the catch type |
762 break; // Cannot easily do precise test ==> Rethrow |
|
763 |
|
764 // %%% Now that subclass checking is very fast, we need to rewrite |
|
765 // this section and remove the option "DeutschShiffmanExceptions". |
|
766 // The exception processing chain should be a normal typecase pattern, |
|
767 // with a bailout to the interpreter only in the case of unloaded |
|
768 // classes. (The bailout should mark the method non-entrant.) |
|
769 // This rewrite should be placed in GraphKit::, not Parse::. |
|
770 |
|
771 // Add a dependence; if any subclass added we need to recompile |
|
772 // %%% should use stronger assert_unique_concrete_subtype instead |
|
773 if (!klass->is_final()) { |
|
774 C->dependencies()->assert_leaf_type(klass); |
|
775 } |
|
776 |
|
777 // Implement precise test |
|
778 const TypeKlassPtr *tk = TypeKlassPtr::make(klass); |
755 const TypeKlassPtr *tk = TypeKlassPtr::make(klass); |
779 Node* con = _gvn.makecon(tk); |
756 Node* con = _gvn.makecon(tk); |
780 Node* cmp = _gvn.transform( new (C, 3) CmpPNode(ex_klass_node, con) ); |
757 Node* not_subtype_ctrl = gen_subtype_check(ex_klass_node, con); |
781 Node* bol = _gvn.transform( new (C, 2) BoolNode(cmp, BoolTest::ne) ); |
758 if (!stopped()) { |
782 { BuildCutout unless(this, bol, PROB_LIKELY(0.7f)); |
759 PreserveJVMState pjvms(this); |
783 const TypeInstPtr* tinst = TypeInstPtr::make_exact(TypePtr::NotNull, klass); |
760 const TypeInstPtr* tinst = TypeOopPtr::make_from_klass_unique(klass)->cast_to_ptr_type(TypePtr::NotNull)->is_instptr(); |
|
761 assert(klass->has_subklass() || tinst->klass_is_exact(), "lost exactness"); |
784 Node* ex_oop = _gvn.transform(new (C, 2) CheckCastPPNode(control(), ex_node, tinst)); |
762 Node* ex_oop = _gvn.transform(new (C, 2) CheckCastPPNode(control(), ex_node, tinst)); |
785 push_ex_oop(ex_oop); // Push exception oop for handler |
763 push_ex_oop(ex_oop); // Push exception oop for handler |
786 #ifndef PRODUCT |
764 #ifndef PRODUCT |
787 if (PrintOpto && WizardMode) { |
765 if (PrintOpto && WizardMode) { |
788 tty->print(" Catching inline exception bci:%d -> handler_bci:%d -- ", bci(), handler_bci); |
766 tty->print(" Catching inline exception bci:%d -> handler_bci:%d -- ", bci(), handler_bci); |
790 tty->cr(); |
768 tty->cr(); |
791 } |
769 } |
792 #endif |
770 #endif |
793 merge_exception(handler_bci); |
771 merge_exception(handler_bci); |
794 } |
772 } |
|
773 set_control(not_subtype_ctrl); |
795 |
774 |
796 // Come here if exception does not match handler. |
775 // Come here if exception does not match handler. |
797 // Carry on with more handler checks. |
776 // Carry on with more handler checks. |
798 --remaining; |
777 --remaining; |
799 } |
778 } |
800 |
779 |
801 assert(!stopped(), "you should return if you finish the chain"); |
780 assert(!stopped(), "you should return if you finish the chain"); |
802 |
|
803 if (remaining == 1) { |
|
804 // Further checks do not matter. |
|
805 } |
|
806 |
|
807 if (can_rerun_bytecode()) { |
|
808 // Do not push_ex_oop here! |
|
809 // Re-executing the bytecode will reproduce the throwing condition. |
|
810 bool must_throw = true; |
|
811 uncommon_trap(Deoptimization::Reason_unhandled, |
|
812 Deoptimization::Action_none, |
|
813 (ciKlass*)NULL, (const char*)NULL, // default args |
|
814 must_throw); |
|
815 return; |
|
816 } |
|
817 |
781 |
818 // Oops, need to call into the VM to resolve the klasses at runtime. |
782 // Oops, need to call into the VM to resolve the klasses at runtime. |
819 // Note: This call must not deoptimize, since it is not a real at this bci! |
783 // Note: This call must not deoptimize, since it is not a real at this bci! |
820 kill_dead_locals(); |
784 kill_dead_locals(); |
821 |
785 |