Commit 57168634 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[liftoff][wasm-simd] Specify alignment requirements

Declare an inline method for the various backends to define based on
alignment requirements. That way backends that might take a performance
hit when data is not naturally aligned can specify the requirements.

With this requirement defined, we can then specify that SIMD values
require 16 bytes on the stack.

This also opens up the possibility of storing 32-bit values in 32-bits,
rather than the fixed kStackSlotSize.

Bug: v8:9909
Change-Id: I9f35c08cc91fb493a81af296d72a603dcafaf644
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1974961Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65675}
parent acc96e1f
......@@ -289,7 +289,22 @@ void LiftoffAssembler::FinishCode() { CheckConstPool(true, false); }
void LiftoffAssembler::AbortCompilation() { AbortedCodeGeneration(); }
uint32_t LiftoffAssembler::SlotSizeForType(ValueType type) {
switch (type) {
case kWasmS128:
return ValueTypes::ElementSizeInBytes(type);
default:
return kStackSlotSize;
}
}
bool LiftoffAssembler::NeedsAlignment(ValueType type) {
switch (type) {
case kWasmS128:
return true;
default:
// No alignment because all other types are kStackSlotSize.
return false;
}
}
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
......
......@@ -178,9 +178,23 @@ void LiftoffAssembler::AbortCompilation() { AbortedCodeGeneration(); }
uint32_t LiftoffAssembler::SlotSizeForType(ValueType type) {
// TODO(zhin): Unaligned access typically take additional cycles, we should do
// some performance testing to see how big an effect it will take. When we add
// SIMD we will have to add logic for alignment too.
// some performance testing to see how big an effect it will take.
switch (type) {
case kWasmS128:
return ValueTypes::ElementSizeInBytes(type);
default:
return kStackSlotSize;
}
}
bool LiftoffAssembler::NeedsAlignment(ValueType type) {
switch (type) {
case kWasmS128:
return true;
default:
// No alignment because all other types are kStackSlotSize.
return false;
}
}
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
......
......@@ -198,6 +198,8 @@ uint32_t LiftoffAssembler::SlotSizeForType(ValueType type) {
return ValueTypes::ElementSizeInBytes(type);
}
bool LiftoffAssembler::NeedsAlignment(ValueType type) { return false; }
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
RelocInfo::Mode rmode) {
switch (value.type()) {
......
......@@ -283,7 +283,11 @@ class LiftoffAssembler : public TurboAssembler {
LiftoffRegister PopToRegister(LiftoffRegList pinned = {});
uint32_t NextSpillOffset(ValueType type) {
return TopSpillOffset() + SlotSizeForType(type);
uint32_t offset = TopSpillOffset() + SlotSizeForType(type);
if (NeedsAlignment(type)) {
offset = RoundUp(offset, SlotSizeForType(type));
}
return offset;
}
uint32_t TopSpillOffset() {
......@@ -415,6 +419,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void FinishCode();
inline void AbortCompilation();
inline static uint32_t SlotSizeForType(ValueType type);
inline static bool NeedsAlignment(ValueType type);
inline void LoadConstant(LiftoffRegister, WasmValue,
RelocInfo::Mode rmode = RelocInfo::NONE);
......
......@@ -181,6 +181,8 @@ uint32_t LiftoffAssembler::SlotSizeForType(ValueType type) {
return ValueTypes::ElementSizeInBytes(type);
}
bool LiftoffAssembler::NeedsAlignment(ValueType type) { return false; }
void LiftoffAssembler::LoadConstant(LiftoffRegister reg, WasmValue value,
RelocInfo::Mode rmode) {
switch (value.type()) {
......
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