From 011462c43882974ca9c556373b5097f808093e5d Mon Sep 17 00:00:00 2001 From: Yudi Zheng Date: Wed, 9 Dec 2020 09:56:04 +0100 Subject: [PATCH] Set exception_seen accordingly in the runtime. --- src/hotspot/share/runtime/deoptimization.cpp | 12 +++++++++++ src/hotspot/share/runtime/sharedRuntime.cpp | 22 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 095c22bb316d0..20a29459be796 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -1731,6 +1731,18 @@ address Deoptimization::deoptimize_for_missing_exception_handler(CompiledMethod* frame runtime_frame = thread->last_frame(); frame caller_frame = runtime_frame.sender(®_map); assert(caller_frame.cb()->as_compiled_method_or_null() == cm, "expect top frame compiled method"); + vframe* vf = vframe::new_vframe(&caller_frame, ®_map, thread); + compiledVFrame* cvf = compiledVFrame::cast(vf); + ScopeDesc* imm_scope = cvf->scope(); + MethodData* imm_mdo = get_method_data(thread, methodHandle(thread, imm_scope->method()), true); + if (imm_mdo != NULL) { + ProfileData* pdata = imm_mdo->allocate_bci_to_data(imm_scope->bci(), NULL); + if (pdata != NULL && pdata->is_BitData()) { + BitData* bit_data = (BitData*) pdata; + bit_data->set_exception_seen(); + } + } + Deoptimization::deoptimize(thread, caller_frame, Deoptimization::Reason_not_compiled_exception_handler); MethodData* trap_mdo = get_method_data(thread, methodHandle(thread, cm->method()), true); diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 80a84ccbf9aac..5ec17e2e11d97 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -599,6 +599,28 @@ void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Handle h_ address bcp = method()->bcp_from(vfst.bci()); JvmtiExport::post_exception_throw(thread, method(), bcp, h_exception()); } + +#if INCLUDE_JVMCI + if (EnableJVMCI) { + vframeStream vfst(thread, true); + methodHandle method = methodHandle(thread, vfst.method()); + int bci = vfst.bci(); + MethodData* trap_mdo = method->method_data(); + if (trap_mdo != NULL) { + // Set exception_seen if the exceptional bytecode is an invoke + Bytecode_invoke call = Bytecode_invoke_check(method, bci); + if (call.is_valid()) { + ResourceMark rm(thread); + ProfileData* pdata = trap_mdo->allocate_bci_to_data(bci, NULL); + if (pdata != NULL && pdata->is_BitData()) { + BitData* bit_data = (BitData*) pdata; + bit_data->set_exception_seen(); + } + } + } + } +#endif + Exceptions::_throw(thread, __FILE__, __LINE__, h_exception); }