On Wed, 29 Apr 2026 16:22:28 GMT, Patricio Chilano Mateo
<[email protected]> wrote:
>> Serguei Spitsyn has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> review: (1) remove unneeded assert, (2) simplify one statement in
>> JvmtiEnvBase::set_frame_pop
>
> src/hotspot/share/prims/jvmtiEnvBase.cpp line 1378:
>
>> 1376: if (state->is_virtual() && (thread == nullptr ||
>> !thread->is_vthread_mounted())) { // unmounted virtual thread
>> 1377: // set pending frame deoptimization to process at mount
>> transition
>> 1378: state->vthread_pending_deopts()->append(frame_number);
>
> I’ve been trying to understand why we need to save the deopt request and
> process it later for the unmounted case, instead of just deoptimizing the
> frame in the heap as we do below. So I tested that small change and hit this
> [assertion](https://github.com/openjdk/jdk/blob/44313a453702d968d24c494de84c4a0a5892a18b/src/hotspot/share/runtime/continuationFreezeThaw.cpp#L1907)
> while running test `ThreadStateTest.java`. Is that what you run into that
> led to this solution? This can happen in the mounted case below too though.
> The problem is that the deoptimized frame could be in a `stackChunk` that was
> freezed in the fast path, but the `stackChunk` code doesn't expect
> deoptimized frames in that case. In this failing test case, we are later
> thawing the deoptimized frame along with all the other ones in the thaw fast
> path (full chunk thaw), and then without getting to return to the deoptimized
> frame we freeze again, hitting this assertion.
> One way of fixing this could be to add a new method to the `stackChunk` class
> to mark it as having mixed frames:
>
> inline void stackChunkOopDesc::force_slow_path() {
> #if INCLUDE_ZGC || INCLUDE_SHENANDOAHGC
> if (UseZGC || UseShenandoahGC) {
> relativize_derived_pointers_concurrently();
> }
> #endif
> set_flag(FLAG_HAS_INTERPRETED_FRAMES, true);
> }
>
> And we could do:
>
> fr = jvf->stack_chunk()->derelativize(fr);
> fr.deoptimize(nullptr);
> jvf->stack_chunk()->force_slow_path();
Thank you a lot for this suggestion. Will test it now.
I do not remember now what exact assert that forced me to implement this
over-complicated approach with deferred deopt's for the unmounted case. It
would be great to get rid of it, so I really appreciate your help here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28407#discussion_r3164088089