927 // No action needed.
928 return;
929 }
930 const TypeInstPtr* ex_type = _gvn.type(ex_node)->isa_instptr();
931 NOT_PRODUCT(if (ex_type==nullptr) tty->print_cr("*** Exception not InstPtr"));
932 if (ex_type == nullptr)
933 ex_type = TypeOopPtr::make_from_klass(env()->Throwable_klass())->is_instptr();
934
935 // determine potential exception handlers
936 ciExceptionHandlerStream handlers(method(), bci(),
937 ex_type->instance_klass(),
938 ex_type->klass_is_exact());
939
940 // Start executing from the given throw state. (Keep its stack, for now.)
941 // Get the exception oop as known at compile time.
942 ex_node = use_exception_state(ex_map);
943
944 // Get the exception oop klass from its header
945 Node* ex_klass_node = nullptr;
946 if (has_exception_handler() && !ex_type->klass_is_exact()) {
947 Node* p = basic_plus_adr( ex_node, ex_node, oopDesc::klass_offset_in_bytes());
948 ex_klass_node = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));
949
950 // Compute the exception klass a little more cleverly.
951 // Obvious solution is to simple do a LoadKlass from the 'ex_node'.
952 // However, if the ex_node is a PhiNode, I'm going to do a LoadKlass for
953 // each arm of the Phi. If I know something clever about the exceptions
954 // I'm loading the class from, I can replace the LoadKlass with the
955 // klass constant for the exception oop.
956 if (ex_node->is_Phi()) {
957 ex_klass_node = new PhiNode(ex_node->in(0), TypeInstKlassPtr::OBJECT);
958 for (uint i = 1; i < ex_node->req(); i++) {
959 Node* ex_in = ex_node->in(i);
960 if (ex_in == top() || ex_in == nullptr) {
961 // This path was not taken.
962 ex_klass_node->init_req(i, top());
963 continue;
964 }
965 Node* p = basic_plus_adr(ex_in, ex_in, oopDesc::klass_offset_in_bytes());
966 Node* k = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));
967 ex_klass_node->init_req( i, k );
968 }
969 ex_klass_node = _gvn.transform(ex_klass_node);
970 }
971 }
972
973 // Scan the exception table for applicable handlers.
974 // If none, we can call rethrow() and be done!
975 // If precise (loaded with no subklasses), insert a D.S. style
976 // pointer compare to the correct handler and loop back.
977 // If imprecise, switch to the Rethrow VM-call style handling.
978
979 int remaining = handlers.count_remaining();
980
981 // iterate through all entries sequentially
982 for (;!handlers.is_done(); handlers.next()) {
983 ciExceptionHandler* handler = handlers.handler();
984
985 if (handler->is_rethrow()) {
986 // If we fell off the end of the table without finding an imprecise
|
927 // No action needed.
928 return;
929 }
930 const TypeInstPtr* ex_type = _gvn.type(ex_node)->isa_instptr();
931 NOT_PRODUCT(if (ex_type==nullptr) tty->print_cr("*** Exception not InstPtr"));
932 if (ex_type == nullptr)
933 ex_type = TypeOopPtr::make_from_klass(env()->Throwable_klass())->is_instptr();
934
935 // determine potential exception handlers
936 ciExceptionHandlerStream handlers(method(), bci(),
937 ex_type->instance_klass(),
938 ex_type->klass_is_exact());
939
940 // Start executing from the given throw state. (Keep its stack, for now.)
941 // Get the exception oop as known at compile time.
942 ex_node = use_exception_state(ex_map);
943
944 // Get the exception oop klass from its header
945 Node* ex_klass_node = nullptr;
946 if (has_exception_handler() && !ex_type->klass_is_exact()) {
947 Node* p = basic_plus_adr( ex_node, ex_node, Type::klass_offset());
948 ex_klass_node = _gvn.transform(LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));
949
950 // Compute the exception klass a little more cleverly.
951 // Obvious solution is to simple do a LoadKlass from the 'ex_node'.
952 // However, if the ex_node is a PhiNode, I'm going to do a LoadKlass for
953 // each arm of the Phi. If I know something clever about the exceptions
954 // I'm loading the class from, I can replace the LoadKlass with the
955 // klass constant for the exception oop.
956 if (ex_node->is_Phi()) {
957 ex_klass_node = new PhiNode(ex_node->in(0), TypeInstKlassPtr::OBJECT);
958 for (uint i = 1; i < ex_node->req(); i++) {
959 Node* ex_in = ex_node->in(i);
960 if (ex_in == top() || ex_in == nullptr) {
961 // This path was not taken.
962 ex_klass_node->init_req(i, top());
963 continue;
964 }
965 Node* p = basic_plus_adr(ex_in, ex_in, Type::klass_offset());
966 Node* k = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeInstKlassPtr::OBJECT));
967 ex_klass_node->init_req( i, k );
968 }
969 ex_klass_node = _gvn.transform(ex_klass_node);
970 }
971 }
972
973 // Scan the exception table for applicable handlers.
974 // If none, we can call rethrow() and be done!
975 // If precise (loaded with no subklasses), insert a D.S. style
976 // pointer compare to the correct handler and loop back.
977 // If imprecise, switch to the Rethrow VM-call style handling.
978
979 int remaining = handlers.count_remaining();
980
981 // iterate through all entries sequentially
982 for (;!handlers.is_done(); handlers.next()) {
983 ciExceptionHandler* handler = handlers.handler();
984
985 if (handler->is_rethrow()) {
986 // If we fell off the end of the table without finding an imprecise
|