diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc index eaa6c5dd55f..046c5e35c90 100644 --- a/runtime/vm/exceptions.cc +++ b/runtime/vm/exceptions.cc @@ -607,14 +607,6 @@ NO_SANITIZE_SAFE_STACK // This function manipulates the safestack pointer. bool clear_deopt_at_target) { ASSERT(thread->execution_state() == Thread::kThreadInVM); -#if defined(DART_DYNAMIC_MODULES) - Interpreter* interpreter = thread->interpreter(); - if ((interpreter != nullptr) && interpreter->HasFrame(frame_pointer)) { - interpreter->JumpToFrame(program_counter, stack_pointer, frame_pointer, - thread); - } -#endif // defined(DART_DYNAMIC_MODULES) - const uword fp_for_clearing = (clear_deopt_at_target ? frame_pointer + 1 : frame_pointer); ClearLazyDeopts(thread, fp_for_clearing); @@ -623,6 +615,14 @@ NO_SANITIZE_SAFE_STACK // This function manipulates the safestack pointer. // in the previous frames. StackResource::Unwind(thread); +#if defined(DART_DYNAMIC_MODULES) + Interpreter* interpreter = thread->interpreter(); + if ((interpreter != nullptr) && interpreter->HasFrame(frame_pointer)) { + interpreter->JumpToFrame(program_counter, stack_pointer, frame_pointer, + thread); + } +#endif // defined(DART_DYNAMIC_MODULES) + // If execution exited generated code through FFI then exit the safepoint // and transition back to kThreadInGenerated execution state. JumpToFrame // stub will transfer control directly to the exception handler and bypass diff --git a/runtime/vm/simulator_riscv.cc b/runtime/vm/simulator_riscv.cc index 5526c2040d7..b59e7a8382c 100644 --- a/runtime/vm/simulator_riscv.cc +++ b/runtime/vm/simulator_riscv.cc @@ -439,11 +439,6 @@ void Simulator::JumpToFrame(uword pc, uword sp, uword fp, Thread* thread) { } ASSERT(buf != nullptr); - // The C++ caller has not cleaned up the stack memory of C++ frames. - // Prepare for unwinding frames by destroying all the stack resources - // in the previous C++ frames. - StackResource::Unwind(thread); - // Keep the following code in sync with `StubCode::JumpToFrameStub()`. // Unwind the C++ stack and continue simulation in the target frame.