Mercurial > hg > graal-jvmci-8
diff src/share/vm/runtime/deoptimization.cpp @ 22712:3c1edc9c60d8
Let fetch_unroll_info override the exec_mode and handle rethrowing scopes
Scopes with rethrow_exception set to true need to be handled
for all types of deoptimization, not just for uncommon traps.
This change moves their handling from uncommon_trap_inner to
fetch_unroll_info_helper and uses exception_oop and exec_mode
Unpack_exception rather than setting a pending execption.
fetch_unroll_info_helper can now override the exec_mode by
passing it through the UnrollBlock.
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Thu, 29 Oct 2015 16:11:45 +0100 |
parents | 6832e10a0b97 |
children | ba7846fcb814 |
line wrap: on
line diff
--- a/src/share/vm/runtime/deoptimization.cpp Thu Oct 29 15:21:55 2015 +0100 +++ b/src/share/vm/runtime/deoptimization.cpp Thu Oct 29 16:11:45 2015 +0100 @@ -106,7 +106,8 @@ int number_of_frames, intptr_t* frame_sizes, address* frame_pcs, - BasicType return_type) { + BasicType return_type, + int exec_mode) { _size_of_deoptimized_frame = size_of_deoptimized_frame; _caller_adjustment = caller_adjustment; _caller_actual_parameters = caller_actual_parameters; @@ -122,6 +123,8 @@ _sender_sp_temp = 0; _total_frame_sizes = size_of_frames(); + assert(exec_mode >= 0 && exec_mode < Unpack_LIMIT, "Unexpected exec_mode"); + _exec_mode = exec_mode; } @@ -166,7 +169,7 @@ // ResetNoHandleMark and HandleMark were removed from it. The actual reallocation // of previously eliminated objects occurs in realloc_objects, which is // called from the method fetch_unroll_info_helper below. -JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info(JavaThread* thread)) +JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info(JavaThread* thread, int exec_mode)) // It is actually ok to allocate handles in a leaf method. It causes no safepoints, // but makes the entry a little slower. There is however a little dance we have to // do in debug mode to get around the NoHandleMark code in the JRT_LEAF macro @@ -180,12 +183,12 @@ } thread->inc_in_deopt_handler(); - return fetch_unroll_info_helper(thread); + return fetch_unroll_info_helper(thread, exec_mode); JRT_END // This is factored, since it is both called from a JRT_LEAF (deoptimization) and a JRT_ENTRY (uncommon_trap) -Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread* thread) { +Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread* thread, int exec_mode) { // Note: there is a safepoint safety issue here. No matter whether we enter // via vanilla deopt or uncommon trap we MUST NOT stop at a safepoint once @@ -224,6 +227,21 @@ assert(vf->is_compiled_frame(), "Wrong frame type"); chunk->push(compiledVFrame::cast(vf)); +#ifdef INCLUDE_JVMCI + ScopeDesc* trap_scope = chunk->at(0)->scope(); + Handle exceptionObject; + if (trap_scope->rethrow_exception()) { + if (PrintDeoptimizationDetails) { + tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_scope->method()->method_holder()->name()->as_C_string(), trap_scope->method()->name()->as_C_string(), trap_scope->bci()); + } + GrowableArray<ScopeValue*>* expressions = trap_scope->expressions(); + guarantee(expressions != NULL && expressions->length() > 0, "must have exception to throw"); + ScopeValue* topOfStack = expressions->top(); + exceptionObject = StackValue::create_stack_value(&deoptee, &map, topOfStack)->get_obj(); + assert(exceptionObject() != NULL, "exception oop can not be null"); + } +#endif + bool realloc_failures = false; #if defined(COMPILER2) || INCLUDE_JVMCI @@ -512,13 +530,21 @@ assert(CodeCache::find_blob_unsafe(frame_pcs[0]) != NULL, "bad pc"); #endif // SHARK +#ifdef INCLUDE_JVMCI + if (exceptionObject() != NULL) { + thread->set_exception_oop(exceptionObject()); + exec_mode = Unpack_exception; + } +#endif + UnrollBlock* info = new UnrollBlock(array->frame_size() * BytesPerWord, caller_adjustment * BytesPerWord, caller_was_method_handle ? 0 : callee_parameters, number_of_frames, frame_sizes, frame_pcs, - return_type); + return_type, + exec_mode); // On some platforms, we need a way to pass some platform dependent // information to the unpacking code so the skeletal frames come out // correct (initial fp value, unextended sp, ...) @@ -1514,17 +1540,6 @@ Bytecodes::Code trap_bc = trap_method->java_code_at(trap_bci); - if (trap_scope->rethrow_exception()) { - if (PrintDeoptimizationDetails) { - tty->print_cr("Exception to be rethrown in the interpreter for method %s::%s at bci %d", trap_method->method_holder()->name()->as_C_string(), trap_method->name()->as_C_string(), trap_bci); - } - GrowableArray<ScopeValue*>* expressions = trap_scope->expressions(); - guarantee(expressions != NULL, "must have exception to throw"); - ScopeValue* topOfStack = expressions->top(); - Handle topOfStackObj = StackValue::create_stack_value(&fr, ®_map, topOfStack)->get_obj(); - THREAD->set_pending_exception(topOfStackObj(), NULL, 0); - } - // Record this event in the histogram. gather_statistics(reason, action, trap_bc); @@ -2013,7 +2028,7 @@ ignore_maybe_prior_recompile); } -Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request) { +Deoptimization::UnrollBlock* Deoptimization::uncommon_trap(JavaThread* thread, jint trap_request, jint exec_mode) { if (TraceDeoptimization) { tty->print("Uncommon trap "); } @@ -2022,7 +2037,7 @@ // This enters VM and may safepoint uncommon_trap_inner(thread, trap_request); } - return fetch_unroll_info_helper(thread); + return fetch_unroll_info_helper(thread, exec_mode); } // Local derived constants.