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

Commit 7cf506a

Browse files
author
Yuri Nesterenko
committed
8262134: compiler/uncommontrap/TestDeoptOOM.java failed with "guarantee(false) failed: wrong number of expression stack elements during deopt"
Backport-of: 32139c1a8aae51c0869f41be57580ff4463913d2
1 parent e93cf85 commit 7cf506a

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

src/hotspot/share/c1/c1_IR.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ CodeEmitInfo::CodeEmitInfo(ValueStack* stack, XHandlers* exception_handlers, boo
190190
, _oop_map(NULL)
191191
, _stack(stack)
192192
, _is_method_handle_invoke(false)
193-
, _deoptimize_on_exception(deoptimize_on_exception) {
193+
, _deoptimize_on_exception(deoptimize_on_exception)
194+
, _force_reexecute(false) {
194195
assert(_stack != NULL, "must be non null");
195196
}
196197

@@ -202,7 +203,8 @@ CodeEmitInfo::CodeEmitInfo(CodeEmitInfo* info, ValueStack* stack)
202203
, _oop_map(NULL)
203204
, _stack(stack == NULL ? info->_stack : stack)
204205
, _is_method_handle_invoke(info->_is_method_handle_invoke)
205-
, _deoptimize_on_exception(info->_deoptimize_on_exception) {
206+
, _deoptimize_on_exception(info->_deoptimize_on_exception)
207+
, _force_reexecute(info->_force_reexecute) {
206208

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

src/hotspot/share/c1/c1_IR.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,15 @@ class IRScopeDebugInfo: public CompilationResourceObj {
232232
//Whether we should reexecute this bytecode for deopt
233233
bool should_reexecute();
234234

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

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

288+
bool force_reexecute() const { return _force_reexecute; }
289+
void set_force_reexecute() { _force_reexecute = true; }
290+
288291
int interpreter_frame_size() const;
292+
289293
};
290294

291295

src/hotspot/share/c1/c1_LIRAssembler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void LIR_Assembler::patching_epilog(PatchingStub* patch, LIR_PatchCode patch_cod
4141
while ((intx) _masm->pc() - (intx) patch->pc_start() < NativeGeneralJump::instruction_size) {
4242
_masm->nop();
4343
}
44+
info->set_force_reexecute();
4445
patch->install(_masm, patch_code, obj, info);
4546
append_code_stub(patch);
4647

src/hotspot/share/runtime/deoptimization.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
688688
// at an uncommon trap for an invoke (where the compiler
689689
// generates debug info before the invoke has executed)
690690
Bytecodes::Code cur_code = str.next();
691+
Bytecodes::Code next_code = Bytecodes::_shouldnotreachhere;
691692
if (Bytecodes::is_invoke(cur_code)) {
692693
Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
693694
cur_invoke_parameter_size = invoke.size_of_parameters();
@@ -696,7 +697,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
696697
}
697698
}
698699
if (str.bci() < max_bci) {
699-
Bytecodes::Code next_code = str.next();
700+
next_code = str.next();
700701
if (next_code >= 0) {
701702
// The interpreter oop map generator reports results before
702703
// the current bytecode has executed except in the case of
@@ -746,6 +747,10 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
746747
// Print out some information that will help us debug the problem
747748
tty->print_cr("Wrong number of expression stack elements during deoptimization");
748749
tty->print_cr(" Error occurred while verifying frame %d (0..%d, 0 is topmost)", i, cur_array->frames() - 1);
750+
tty->print_cr(" Current code %s", Bytecodes::name(cur_code));
751+
if (try_next_mask) {
752+
tty->print_cr(" Next code %s", Bytecodes::name(next_code));
753+
}
749754
tty->print_cr(" Fabricated interpreter frame had %d expression stack elements",
750755
iframe->interpreter_frame_expression_stack_size());
751756
tty->print_cr(" Interpreter oop map had %d expression stack elements", mask.expression_stack_size());

test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
/*
2525
* @test
2626
* @bug 8174954
27+
* @bug 8262134
2728
* @library /test/lib
2829
* @modules java.base/jdk.internal.org.objectweb.asm
2930
* @compile -XDignore.symbol.file BSMCalledTwice.java
3031
* @run main BSMCalledTwice
32+
* @run main/othervm -Xcomp -XX:CompileCommand=compileonly,TestC::* -XX:+DeoptimizeALot -XX:+VerifyStack BSMCalledTwice
3133
*/
3234

3335
import java.io.File;

0 commit comments

Comments
 (0)