Commit a2f3a097 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[liftoff] Prefer kWasmInstanceRegister for instance cache

The wasm instance will initially be in kWasmInstanceRegister, and for
each call we also need to put it in that register. Hence, when getting a
new register to cache the instance, prefer that register, if it is
available.

R=thibaudm@chromium.org

Bug: v8:11336
Change-Id: Ie7026c4c7c5e4b825b9ab310839f0273bd3ce7f1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2743885
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73303}
parent e0cbacc7
......@@ -271,11 +271,17 @@ class LiftoffAssembler : public TurboAssembler {
Register TrySetCachedInstanceRegister(LiftoffRegList pinned) {
DCHECK_EQ(no_reg, cached_instance);
LiftoffRegList candidates = kGpCacheRegList.MaskOut(pinned);
if (!has_unused_register(candidates)) return no_reg;
SetInstanceCacheRegister(unused_register(candidates).gp());
DCHECK_NE(no_reg, cached_instance);
return cached_instance;
LiftoffRegList available_regs =
kGpCacheRegList.MaskOut(pinned).MaskOut(used_registers);
if (available_regs.is_empty()) return no_reg;
// Prefer the {kWasmInstanceRegister}, because that's where the instance
// initially is, and where it needs to be for calls.
Register new_cache_reg = available_regs.has(kWasmInstanceRegister)
? kWasmInstanceRegister
: available_regs.GetFirstRegSet().gp();
SetInstanceCacheRegister(new_cache_reg);
DCHECK_EQ(new_cache_reg, cached_instance);
return new_cache_reg;
}
void ClearCachedInstanceRegister() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment