974 // the runtime stubs checks this on exit. |
974 // the runtime stubs checks this on exit. |
975 assert(thread->exception_oop() != NULL, "exception oop is found"); |
975 assert(thread->exception_oop() != NULL, "exception oop is found"); |
976 address handler_address = NULL; |
976 address handler_address = NULL; |
977 |
977 |
978 Handle exception(thread, thread->exception_oop()); |
978 Handle exception(thread, thread->exception_oop()); |
|
979 address pc = thread->exception_pc(); |
|
980 |
|
981 // Clear out the exception oop and pc since looking up an |
|
982 // exception handler can cause class loading, which might throw an |
|
983 // exception and those fields are expected to be clear during |
|
984 // normal bytecode execution. |
|
985 thread->clear_exception_oop_and_pc(); |
979 |
986 |
980 if (TraceExceptions) { |
987 if (TraceExceptions) { |
981 trace_exception(exception(), thread->exception_pc(), ""); |
988 trace_exception(exception(), pc, ""); |
982 } |
989 } |
|
990 |
983 // for AbortVMOnException flag |
991 // for AbortVMOnException flag |
984 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); |
992 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); |
985 |
993 |
986 #ifdef ASSERT |
994 #ifdef ASSERT |
987 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
995 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { |
988 // should throw an exception here |
996 // should throw an exception here |
989 ShouldNotReachHere(); |
997 ShouldNotReachHere(); |
990 } |
998 } |
991 #endif |
999 #endif |
992 |
|
993 |
1000 |
994 // new exception handling: this method is entered only from adapters |
1001 // new exception handling: this method is entered only from adapters |
995 // exceptions from compiled java methods are handled in compiled code |
1002 // exceptions from compiled java methods are handled in compiled code |
996 // using rethrow node |
1003 // using rethrow node |
997 |
1004 |
998 address pc = thread->exception_pc(); |
|
999 nm = CodeCache::find_nmethod(pc); |
1005 nm = CodeCache::find_nmethod(pc); |
1000 assert(nm != NULL, "No NMethod found"); |
1006 assert(nm != NULL, "No NMethod found"); |
1001 if (nm->is_native_method()) { |
1007 if (nm->is_native_method()) { |
1002 fatal("Native mathod should not have path to exception handling"); |
1008 fatal("Native method should not have path to exception handling"); |
1003 } else { |
1009 } else { |
1004 // we are switching to old paradigm: search for exception handler in caller_frame |
1010 // we are switching to old paradigm: search for exception handler in caller_frame |
1005 // instead in exception handler of caller_frame.sender() |
1011 // instead in exception handler of caller_frame.sender() |
1006 |
1012 |
1007 if (JvmtiExport::can_post_on_exceptions()) { |
1013 if (JvmtiExport::can_post_on_exceptions()) { |
1344 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); |
1350 tty->print("%d [Exception (%s): ", trace_exception_counter, msg); |
1345 exception_oop->print_value(); |
1351 exception_oop->print_value(); |
1346 tty->print(" in "); |
1352 tty->print(" in "); |
1347 CodeBlob* blob = CodeCache::find_blob(exception_pc); |
1353 CodeBlob* blob = CodeCache::find_blob(exception_pc); |
1348 if (blob->is_nmethod()) { |
1354 if (blob->is_nmethod()) { |
1349 ((nmethod*)blob)->method()->print_value(); |
1355 nmethod* nm = blob->as_nmethod_or_null(); |
|
1356 nm->method()->print_value(); |
1350 } else if (blob->is_runtime_stub()) { |
1357 } else if (blob->is_runtime_stub()) { |
1351 tty->print("<runtime-stub>"); |
1358 tty->print("<runtime-stub>"); |
1352 } else { |
1359 } else { |
1353 tty->print("<unknown>"); |
1360 tty->print("<unknown>"); |
1354 } |
1361 } |