[liftoff] Simplify ParallelRegisterMove

We often want to pass a list of moves of fixed length. Instead of
constructing an array on the caller's stack and passing it via
{ArrayVector}, we should just pass it via {std::initializer_list}. This
also avoids to spell out the internal name
{LiftoffAssembler::ParallelRegisterMoveTuple}.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: Ibe7ac5a5a02686533333cb45652cbb2b99ad9c60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2287498
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68799}
This commit is contained in:
Clemens Backes 2020-07-09 13:48:05 +02:00 committed by Commit Bot
parent 6327b26105
commit 05298900ff
5 changed files with 31 additions and 38 deletions

View File

@ -949,9 +949,8 @@ void LiftoffAssembler::AtomicLoad(LiftoffRegister dst, Register src_addr,
ldrexd(dst_low, dst_high, actual_addr);
dmb(ISH);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{
{dst, LiftoffRegister::ForPair(dst_low, dst_high), kWasmI64}};
ParallelRegisterMove(ArrayVector(reg_moves));
ParallelRegisterMove(
{{dst, LiftoffRegister::ForPair(dst_low, dst_high), kWasmI64}});
}
void LiftoffAssembler::AtomicStore(Register dst_addr, Register offset_reg,
@ -1071,15 +1070,13 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm,
__ SpillRegisters(dst_addr, offset, result_low, result_high, new_value_low,
new_value_high, store_result, expected_low, expected_high);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{
{LiftoffRegister::ForPair(new_value_low, new_value_high), new_value,
kWasmI64},
{LiftoffRegister::ForPair(expected_low, expected_high), expected,
kWasmI64},
{LiftoffRegister(dst_addr), LiftoffRegister(dst_addr_reg), kWasmI32},
{LiftoffRegister(offset),
LiftoffRegister(offset_reg != no_reg ? offset_reg : offset), kWasmI32}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
__ ParallelRegisterMove(
{{LiftoffRegister::ForPair(new_value_low, new_value_high), new_value,
kWasmI64},
{LiftoffRegister::ForPair(expected_low, expected_high), expected,
kWasmI64},
{dst_addr, dst_addr_reg, kWasmI32},
{offset, offset_reg != no_reg ? offset_reg : offset, kWasmI32}});
{
UseScratchRegisterScope temps(lasm);
@ -1106,9 +1103,8 @@ inline void AtomicI64CompareExchange(LiftoffAssembler* lasm,
__ dmb(ISH);
__ bind(&done);
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves_result[]{
{result, LiftoffRegister::ForPair(result_low, result_high), kWasmI64}};
__ ParallelRegisterMove(ArrayVector(reg_moves_result));
__ ParallelRegisterMove(
{{result, LiftoffRegister::ForPair(result_low, result_high), kWasmI64}});
}
#undef __
} // namespace liftoff

View File

@ -707,12 +707,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr,
}
// Spill all these registers if they are still holding other values.
liftoff::SpillRegisters(lasm, old_hi, old_lo, new_hi, base, offset);
{
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{
{LiftoffRegister::ForPair(base, offset),
LiftoffRegister::ForPair(dst_addr, offset_reg), kWasmI64}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
}
__ ParallelRegisterMove(
{{LiftoffRegister::ForPair(base, offset),
LiftoffRegister::ForPair(dst_addr, offset_reg), kWasmI64}});
Operand dst_op_lo = Operand(base, offset, times_1, offset_imm);
Operand dst_op_hi = Operand(base, offset, times_1, offset_imm + 4);
@ -759,12 +756,9 @@ inline void AtomicBinop64(LiftoffAssembler* lasm, Binop op, Register dst_addr,
// Restore the root register, and we are done.
__ pop(kRootRegister);
{
// Move the result into the correct registers.
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{
{result, LiftoffRegister::ForPair(old_lo, old_hi), kWasmI64}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
}
// Move the result into the correct registers.
__ ParallelRegisterMove(
{{result, LiftoffRegister::ForPair(old_lo, old_hi), kWasmI64}});
}
#undef __
@ -1346,10 +1340,9 @@ void LiftoffAssembler::emit_i64_mul(LiftoffRegister dst, LiftoffRegister lhs,
liftoff::SpillRegisters(this, dst_hi, dst_lo, lhs_hi, rhs_lo);
// Move lhs and rhs into the respective registers.
ParallelRegisterMoveTuple reg_moves[]{
{LiftoffRegister::ForPair(lhs_lo, lhs_hi), lhs, kWasmI64},
{LiftoffRegister::ForPair(rhs_lo, rhs_hi), rhs, kWasmI64}};
ParallelRegisterMove(ArrayVector(reg_moves));
ParallelRegisterMove(
{{LiftoffRegister::ForPair(lhs_lo, lhs_hi), lhs, kWasmI64},
{LiftoffRegister::ForPair(rhs_lo, rhs_hi), rhs, kWasmI64}});
// First mul: lhs_hi' = lhs_hi * rhs_lo.
imul(lhs_hi, rhs_lo);

View File

@ -867,7 +867,7 @@ void LiftoffAssembler::Move(LiftoffRegister dst, LiftoffRegister src,
}
void LiftoffAssembler::ParallelRegisterMove(
Vector<ParallelRegisterMoveTuple> tuples) {
Vector<const ParallelRegisterMoveTuple> tuples) {
StackTransferRecipe stack_transfers(this);
for (auto tuple : tuples) {
if (tuple.dst == tuple.src) continue;

View File

@ -452,7 +452,13 @@ class LiftoffAssembler : public TurboAssembler {
ParallelRegisterMoveTuple(Dst dst, Src src, ValueType type)
: dst(dst), src(src), type(type) {}
};
void ParallelRegisterMove(Vector<ParallelRegisterMoveTuple>);
void ParallelRegisterMove(Vector<const ParallelRegisterMoveTuple>);
void ParallelRegisterMove(
std::initializer_list<ParallelRegisterMoveTuple> moves) {
ParallelRegisterMove(VectorOf(moves));
}
void MoveToReturnLocations(const FunctionSig*,
compiler::CallDescriptor* descriptor);

View File

@ -3216,11 +3216,9 @@ class LiftoffCompiler {
WasmAtomicNotifyDescriptor descriptor;
DCHECK_EQ(0, descriptor.GetStackParameterCount());
DCHECK_EQ(2, descriptor.GetRegisterParameterCount());
LiftoffAssembler::ParallelRegisterMoveTuple reg_moves[]{
{LiftoffRegister(descriptor.GetRegisterParameter(0)),
LiftoffRegister(index), kWasmI32},
{LiftoffRegister(descriptor.GetRegisterParameter(1)), count, kWasmI32}};
__ ParallelRegisterMove(ArrayVector(reg_moves));
__ ParallelRegisterMove(
{{descriptor.GetRegisterParameter(0), index, kWasmI32},
{descriptor.GetRegisterParameter(1), count, kWasmI32}});
__ CallRuntimeStub(WasmCode::kWasmAtomicNotify);
RegisterDebugSideTableEntry(DebugSideTableBuilder::kDidSpill);