[vm] Fix JumpToFrame for dynamic modules

Change 8085a97a63 moved commonly
invoked StackResource::Unwind(...) from several different code
paths (simulators & interpreter) into Exceptions::JumpToFrame.

However the change did not account for the order of operations
in Exceptions::JumpToFrame which broke interpreter. This CL
fixes that by moving Interpreter::JumpToFrame under
StackResource::Unwind(...).

We also forgot to remove StackResource::Unwind from RISC-V
simulator - but that's benign because calling it the second
time simply does nothing.

TEST=vm-aot-dyn-linux-debug-x64

Change-Id: Ia93fc6997b768180fbbb5e54bb0c0fd5c713a244
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421060
Commit-Queue: Slava Egorov <vegorov@google.com>
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
Vyacheslav Egorov
2025-04-08 03:15:49 -07:00
committed by Commit Queue
parent 678c4ac77f
commit 76581515c1
2 changed files with 8 additions and 13 deletions
+8 -8
View File
@@ -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
-5
View File
@@ -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.