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

[liftoff][cleanup] Replace loop by straight-line code

This removes a loop that runs exactly one or two times by straight-line
code for the two cases. This should make it more readable and easier to
maintain.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: I242bc4a7f7333b04ec39e79dc530625fb5e2305f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2287505Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68800}
parent 05298900
......@@ -467,32 +467,34 @@ class LiftoffCompiler {
// Returns the number of inputs processed (1 or 2).
uint32_t ProcessParameter(ValueType type, uint32_t input_idx) {
const int num_lowered_params = 1 + needs_gp_reg_pair(type);
ValueType lowered_type = needs_gp_reg_pair(type) ? kWasmI32 : type;
RegClass rc = reg_class_for(lowered_type);
// Initialize to anything, will be set in the loop and used afterwards.
LiftoffRegister reg = kGpCacheRegList.GetFirstRegSet();
LiftoffRegList pinned;
for (int pair_idx = 0; pair_idx < num_lowered_params; ++pair_idx) {
compiler::LinkageLocation param_loc =
descriptor_->GetInputLocation(input_idx + pair_idx);
// Initialize to anything, will be set in both arms of the if.
LiftoffRegister in_reg = kGpCacheRegList.GetFirstRegSet();
if (param_loc.IsRegister()) {
DCHECK(!param_loc.IsAnyRegister());
in_reg = LiftoffRegister::from_external_code(rc, type,
param_loc.AsRegister());
} else if (param_loc.IsCallerFrameSlot()) {
in_reg = __ GetUnusedRegister(rc, pinned);
__ LoadCallerFrameSlot(in_reg, -param_loc.AsCallerFrameSlot(),
lowered_type);
const bool needs_pair = needs_gp_reg_pair(type);
const ValueType reg_type = needs_pair ? kWasmI32 : type;
const RegClass rc = reg_class_for(reg_type);
auto LoadToReg = [this, reg_type, rc](compiler::LinkageLocation location,
LiftoffRegList pinned) {
if (location.IsRegister()) {
DCHECK(!location.IsAnyRegister());
return LiftoffRegister::from_external_code(rc, reg_type,
location.AsRegister());
}
reg = pair_idx == 0 ? in_reg
: LiftoffRegister::ForPair(reg.gp(), in_reg.gp());
pinned.set(reg);
DCHECK(location.IsCallerFrameSlot());
LiftoffRegister reg = __ GetUnusedRegister(rc, pinned);
__ LoadCallerFrameSlot(reg, -location.AsCallerFrameSlot(), reg_type);
return reg;
};
LiftoffRegister reg =
LoadToReg(descriptor_->GetInputLocation(input_idx), {});
if (needs_pair) {
LiftoffRegister reg2 =
LoadToReg(descriptor_->GetInputLocation(input_idx + 1),
LiftoffRegList::ForRegs(reg));
reg = LiftoffRegister::ForPair(reg.gp(), reg2.gp());
}
__ PushRegister(type, reg);
return num_lowered_params;
return needs_pair ? 2 : 1;
}
void StackCheck(WasmCodePosition position) {
......
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