[wasm-gc][liftoff] GetUnusedRegister before fetching stack slots

GetUnusedRegister may spill registers and thus modify stack slots.
Therefore, we have to call it before fetching stack slots.
This is another instance of
https://chromium-review.googlesource.com/c/v8/v8/+/3217199.

Bug: v8:7748
Change-Id: I9ff28b26f2dce93ef7b71c1100d9bf88f7c2f7c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3226327
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77414}
This commit is contained in:
Manos Koukoutos 2021-10-15 10:37:36 +00:00 committed by V8 LUCI CQ
parent e8c3a329f3
commit 5f6c9fc57b

View File

@ -5218,9 +5218,6 @@ class LiftoffCompiler {
LiftoffRegister elem_size_reg =
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
LiftoffAssembler::VarState rtt_var =
__ cache_state()->stack_state.end()[-1];
__ LoadConstant(elem_size_reg, WasmValue(element_size_bytes(elem_kind)));
LiftoffAssembler::VarState elem_size_var(kI32, elem_size_reg, 0);
@ -5230,6 +5227,9 @@ class LiftoffCompiler {
WasmValue(static_cast<int32_t>(elements.size())));
LiftoffAssembler::VarState length_var(kI32, length_reg, 0);
LiftoffAssembler::VarState rtt_var =
__ cache_state()->stack_state.end()[-1];
CallRuntimeStub(WasmCode::kWasmAllocateArray_Uninitialized,
MakeSig::Returns(kRef).Params(rtt_kind, kI32, kI32),
{rtt_var, length_var, elem_size_var},