[vm] Fix ActivationFrame::GetParameter for suspendable functions

TEST=ci

Change-Id: I483a2cd834de3f88728e3b8f498a4d748d387305
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252402
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2022-07-21 17:04:55 +00:00 committed by Commit Bot
parent 78befdd841
commit c50ec0a7d6

View file

@ -949,12 +949,11 @@ ObjectPtr ActivationFrame::GetParameter(intptr_t index) {
return Object::null();
}
if (function().NumOptionalParameters() > 0) {
// If the function has optional parameters, the first positional parameter
// can be in a number of places in the caller's frame depending on how many
// were actually supplied at the call site, but they are copied to a fixed
// place in the callee's frame.
if (function().MakesCopyOfParameters()) {
// Function parameters are copied to a fixed place in the callee's frame.
if (function().IsSuspendableFunction()) {
++index; // Skip slot reserved for :suspend_state variable.
}
return GetVariableValue(LocalVarAddress(
fp(), runtime_frame_layout.FrameSlotForVariableIndex(-index)));
} else {