Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

8262134: compiler/uncommontrap/TestDeoptOOM.java failed with "guarantee(false) failed: wrong number of expression stack elements during deopt" #370

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/hotspot/share/c1/c1_IR.cpp
Expand Up @@ -190,7 +190,8 @@ CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, boo
, _oop_map(NULL)
, _stack(stack)
, _is_method_handle_invoke(false)
, _deoptimize_on_exception(deoptimize_on_exception) {
, _deoptimize_on_exception(deoptimize_on_exception)
, _force_reexecute(false) {
assert(_stack != NULL, "must be non null");
}

Expand All @@ -202,7 +203,8 @@ CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
, _oop_map(NULL)
, _stack(stack == NULL ? info->_stack : stack)
, _is_method_handle_invoke(info->_is_method_handle_invoke)
, _deoptimize_on_exception(info->_deoptimize_on_exception) {
, _deoptimize_on_exception(info->_deoptimize_on_exception)
, _force_reexecute(info->_force_reexecute) {

// deep copy of exception handlers
if (info->_exception_handlers != NULL) {
Expand All @@ -214,7 +216,8 @@ CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
void CodeEmitInfo::record_debug_info(DebugInformationRecorder* recorder, int pc_offset) {
// record the safepoint before recording the debug info for enclosing scopes
recorder->add_safepoint(pc_offset, _oop_map->deep_copy());
_scope_debug_info->record_debug_info(recorder, pc_offset, true/*topmost*/, _is_method_handle_invoke);
bool reexecute = _force_reexecute || _scope_debug_info->should_reexecute();
_scope_debug_info->record_debug_info(recorder, pc_offset, reexecute, _is_method_handle_invoke);
recorder->end_safepoint(pc_offset);
}

Expand Down
10 changes: 7 additions & 3 deletions src/hotspot/share/c1/c1_IR.hpp
Expand Up @@ -232,16 +232,15 @@ class IRScopeDebugInfo: public CompilationResourceObj {
//Whether we should reexecute this bytecode for deopt
bool should_reexecute();

void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool topmost, bool is_method_handle_invoke = false) {
void record_debug_info(DebugInformationRecorder* recorder, int pc_offset, bool reexecute, bool is_method_handle_invoke = false) {
if (caller() != NULL) {
// Order is significant: Must record caller first.
caller()->record_debug_info(recorder, pc_offset, false/*topmost*/);
caller()->record_debug_info(recorder, pc_offset, false/*reexecute*/);
}
DebugToken* locvals = recorder->create_scope_values(locals());
DebugToken* expvals = recorder->create_scope_values(expressions());
DebugToken* monvals = recorder->create_monitor_values(monitors());
// reexecute allowed only for the topmost frame
bool reexecute = topmost ? should_reexecute() : false;
bool return_oop = false; // This flag will be ignored since it used only for C2 with escape analysis.
bool rethrow_exception = false;
recorder->describe_scope(pc_offset, methodHandle(), scope()->method(), bci(), reexecute, rethrow_exception, is_method_handle_invoke, return_oop, locvals, expvals, monvals);
Expand All @@ -259,6 +258,7 @@ class CodeEmitInfo: public CompilationResourceObj {
ValueStack* _stack; // used by deoptimization (contains also monitors
bool _is_method_handle_invoke; // true if the associated call site is a MethodHandle call site.
bool _deoptimize_on_exception;
bool _force_reexecute; // force the reexecute flag on, used for patching stub

FrameMap* frame_map() const { return scope()->compilation()->frame_map(); }
Compilation* compilation() const { return scope()->compilation(); }
Expand All @@ -285,7 +285,11 @@ class CodeEmitInfo: public CompilationResourceObj {
bool is_method_handle_invoke() const { return _is_method_handle_invoke; }
void set_is_method_handle_invoke(bool x) { _is_method_handle_invoke = x; }

bool force_reexecute() const { return _force_reexecute; }
void set_force_reexecute() { _force_reexecute = true; }

int interpreter_frame_size() const;

};


Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/c1/c1_LIRAssembler.cpp
Expand Up @@ -41,6 +41,7 @@ void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_cod
while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeGeneralJump::instruction_size) {
_masm->nop();
}
info->set_force_reexecute();
patch->install(_masm, patch_code, obj, info);
append_code_stub(patch);

Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/runtime/deoptimization.cpp
Expand Up @@ -688,6 +688,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
// at an uncommon trap for an invoke (where the compiler
// generates debug info before the invoke has executed)
Bytecodes::Code cur_code = str.next();
Bytecodes::Code next_code = Bytecodes::_shouldnotreachhere;
if (Bytecodes::is_invoke(cur_code)) {
Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
cur_invoke_parameter_size = invoke.size_of_parameters();
Expand All @@ -696,7 +697,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
}
}
if (str.bci() < max_bci) {
Bytecodes::Code next_code = str.next();
next_code = str.next();
if (next_code >= 0) {
// The interpreter oop map generator reports results before
// the current bytecode has executed except in the case of
Expand Down Expand Up @@ -746,6 +747,10 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
// Print out some information that will help us debug the problem
tty->print_cr("Wrong number of expression stack elements during deoptimization");
tty->print_cr(" Error occurred while verifying frame %d (0..%d, 0 is topmost)", i, cur_array->frames() - 1);
tty->print_cr(" Current code %s", Bytecodes::name(cur_code));
if (try_next_mask) {
tty->print_cr(" Next code %s", Bytecodes::name(next_code));
}
tty->print_cr(" Fabricated interpreter frame had %d expression stack elements",
iframe->interpreter_frame_expression_stack_size());
tty->print_cr(" Interpreter oop map had %d expression stack elements", mask.expression_stack_size());
Expand Down
Expand Up @@ -24,10 +24,12 @@
/*
* @test
* @bug 8174954
* @bug 8262134
* @library /test/lib
* @modules java.base/jdk.internal.org.objectweb.asm
* @compile -XDignore.symbol.file BSMCalledTwice.java
* @run main BSMCalledTwice
* @run main/othervm -Xcomp -XX:CompileCommand=compileonly,TestC::* -XX:+DeoptimizeALot -XX:+VerifyStack BSMCalledTwice
*/

import java.io.File;
Expand Down