Skip to content

Commit feee12a

Browse files
pchilanocoleenp
authored andcommitted
8368002: [lworld] Crash in ThawBase::remove_top_compiled_frame_from_chunk
Reviewed-by: coleenp
1 parent 6f5dc65 commit feee12a

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

src/hotspot/share/runtime/continuationFreezeThaw.cpp

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ class ThawBase : public StackObj {
19611961
void clear_chunk(stackChunkOop chunk);
19621962
template<bool check_stub>
19631963
int remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &argsize);
1964-
int remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& scfs, stackChunkOop chunk, int &argsize);
1964+
int remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& scfs, int &argsize);
19651965
void copy_from_chunk(intptr_t* from, intptr_t* to, int size);
19661966

19671967
void thaw_lockstack(stackChunkOop chunk);
@@ -2072,45 +2072,18 @@ inline void ThawBase::clear_chunk(stackChunkOop chunk) {
20722072
chunk->set_max_thawing_size(0);
20732073
}
20742074

2075-
int ThawBase::remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& f, stackChunkOop chunk, int &argsize) {
2076-
DEBUG_ONLY(intptr_t* const chunk_sp = chunk->start_address() + chunk->sp();)
2075+
int ThawBase::remove_scalarized_frames(StackChunkFrameStream<ChunkFrames::CompiledOnly>& f, int &argsize) {
20772076
intptr_t* top = f.sp();
20782077

2079-
while (f.cb()->as_nmethod_or_null()->needs_stack_repair()) {
2078+
while (f.cb()->as_nmethod()->needs_stack_repair()) {
20802079
f.next(SmallRegisterMap::instance(), false /* stop */);
20812080
}
20822081
assert(!f.is_done(), "");
20832082
assert(f.is_compiled(), "");
20842083

20852084
intptr_t* bottom = f.sp() + f.cb()->frame_size();
20862085
argsize = f.stack_argsize();
2087-
int frames_size = bottom - top;
2088-
2089-
f.next(SmallRegisterMap::instance(), true /* stop */);
2090-
bool empty = f.is_done();
2091-
assert(!empty || argsize == chunk->argsize(), "");
2092-
2093-
if (empty) {
2094-
clear_chunk(chunk);
2095-
} else {
2096-
chunk->set_sp(chunk->sp() + frames_size);
2097-
chunk->set_max_thawing_size(chunk->max_thawing_size() - frames_size);
2098-
// We set chunk->pc to the return pc into the next frame
2099-
chunk->set_pc(f.pc());
2100-
#ifdef ASSERT
2101-
{
2102-
intptr_t* retaddr_slot = (chunk_sp
2103-
+ frames_size
2104-
- frame::sender_sp_ret_address_offset());
2105-
assert(f.pc() == ContinuationHelper::return_address_at(retaddr_slot),
2106-
"unexpected pc");
2107-
}
2108-
#endif
2109-
}
2110-
assert(empty == chunk->is_empty(), "");
2111-
// returns the size required to store the frame on stack, and because it is a
2112-
// compiled frame, it must include a copy of the arguments passed by the caller
2113-
return frames_size + argsize + frame::metadata_words_at_top;
2086+
return bottom - top;
21142087
}
21152088

21162089
template<bool check_stub>
@@ -2121,10 +2094,6 @@ int ThawBase::remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &arg
21212094
assert(chunk_sp == f.sp(), "");
21222095
assert(chunk_sp == f.unextended_sp(), "");
21232096

2124-
if (f.cb()->as_nmethod_or_null()->needs_stack_repair()) {
2125-
return remove_scalarized_frames(f, chunk, argsize);
2126-
}
2127-
21282097
int frame_size = f.cb()->frame_size();
21292098
argsize = f.stack_argsize();
21302099

@@ -2138,15 +2107,21 @@ int ThawBase::remove_top_compiled_frame_from_chunk(stackChunkOop chunk, int &arg
21382107

21392108
f.get_cb();
21402109
assert(f.is_compiled(), "");
2141-
frame_size += f.cb()->frame_size();
2142-
argsize = f.stack_argsize();
2143-
21442110
if (f.cb()->as_nmethod()->is_marked_for_deoptimization()) {
21452111
// The caller of the runtime stub when the continuation is preempted is not at a
21462112
// Java call instruction, and so cannot rely on nmethod patching for deopt.
21472113
log_develop_trace(continuations)("Deoptimizing runtime stub caller");
21482114
f.to_frame().deoptimize(nullptr); // the null thread simply avoids the assertion in deoptimize which we're not set up for
21492115
}
2116+
2117+
if (f.cb()->as_nmethod()->needs_stack_repair()) {
2118+
frame_size += remove_scalarized_frames(f, argsize);
2119+
} else {
2120+
frame_size += f.cb()->frame_size();
2121+
argsize = f.stack_argsize();
2122+
}
2123+
} else if (f.cb()->as_nmethod()->needs_stack_repair()) {
2124+
frame_size = remove_scalarized_frames(f, argsize);
21502125
}
21512126

21522127
f.next(SmallRegisterMap::instance(), true /* stop */);

0 commit comments

Comments
 (0)