diff -r f4b2d5b83ebf -r d19dc5b10fbb src/hotspot/share/code/compiledMethod.cpp --- a/src/hotspot/share/code/compiledMethod.cpp Fri Jun 07 09:16:11 2019 -0700 +++ b/src/hotspot/share/code/compiledMethod.cpp Fri Jun 07 10:26:21 2019 -0700 @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "code/compiledIC.hpp" #include "code/compiledMethod.inline.hpp" +#include "code/exceptionHandlerTable.hpp" #include "code/scopeDesc.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" @@ -37,8 +38,10 @@ #include "oops/methodData.hpp" #include "oops/method.inline.hpp" #include "prims/methodHandles.hpp" +#include "runtime/deoptimization.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" +#include "runtime/sharedRuntime.hpp" CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, @@ -638,6 +641,46 @@ os::is_readable_pointer(method->signature()); } +address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { + // Exception happened outside inline-cache check code => we are inside + // an active nmethod => use cpc to determine a return address + int exception_offset = pc - code_begin(); + int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); +#ifdef ASSERT + if (cont_offset == 0) { + Thread* thread = Thread::current(); + ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY + HandleMark hm(thread); + ResourceMark rm(thread); + CodeBlob* cb = CodeCache::find_blob(pc); + assert(cb != NULL && cb == this, ""); + ttyLocker ttyl; + tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); + print(); + method()->print_codes(); + print_code(); + print_pcs(); + } +#endif + if (cont_offset == 0) { + // Let the normal error handling report the exception + return NULL; + } + if (cont_offset == exception_offset) { +#if INCLUDE_JVMCI + Deoptimization::DeoptReason deopt_reason = for_div0_check ? Deoptimization::Reason_div0_check : Deoptimization::Reason_null_check; + JavaThread *thread = JavaThread::current(); + thread->set_jvmci_implicit_exception_pc(pc); + thread->set_pending_deoptimization(Deoptimization::make_trap_request(deopt_reason, + Deoptimization::Action_reinterpret)); + return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); +#else + ShouldNotReachHere(); +#endif + } + return code_begin() + cont_offset; +} + class HasEvolDependency : public MetadataClosure { bool _has_evol_dependency; public: