[wasm] Some minor performance improvements

This adds a few annotations and minor optimizations to improve
performance of decoding and Liftoff compilation.

R=dlehmann@chromium.org

Bug: v8:13565, v8:13673
Change-Id: Icf582d72c35db68228bcecea0a8c2ab3f8f0d340
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4198138
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Daniel Lehmann <dlehmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85524}
This commit is contained in:
Clemens Backes 2023-01-27 17:29:40 +01:00 committed by V8 LUCI CQ
parent ea6c05d2c3
commit b0d8319803
4 changed files with 20 additions and 5 deletions

View File

@ -582,7 +582,7 @@ class LiftoffAssembler : public TurboAssembler {
}
void PushConstant(ValueKind kind, int32_t i32_const) {
DCHECK(kind == kI32 || kind == kI64);
V8_ASSUME(kind == kI32 || kind == kI64);
cache_state_.stack_state.emplace_back(kind, i32_const,
NextSpillOffset(kind));
}

View File

@ -528,8 +528,14 @@ class Decoder {
return result;
}
IntType result;
// Do not pass {length} to the slow path, because clang assumes that the
// pointer might be stored and the value clobbered later.
// TODO(clemensb): Return value+length from the slow path once
// https://reviews.llvm.org/D141020 is available.
uint32_t unaliased_length;
read_leb_slowpath<IntType, ValidationTag, trace, size_in_bits>(
pc, length, name, &result);
pc, &unaliased_length, name, &result);
*length = unaliased_length;
return result;
}

View File

@ -4255,7 +4255,7 @@ class WasmFullDecoder : public WasmDecoder<ValidationTag, decoding_mode> {
bool CheckStaticallyOutOfBounds(uintptr_t size, uintptr_t offset) {
const bool statically_oob = !base::IsInBounds<uintptr_t>(
offset, size, this->module_->max_memory_size);
if (statically_oob) {
if (V8_UNLIKELY(statically_oob)) {
CALL_INTERFACE_IF_OK_AND_REACHABLE(Trap, TrapReason::kTrapMemOutOfBounds);
SetSucceedingCodeDynamicallyUnreachable();
}

View File

@ -772,8 +772,8 @@ class LoadType {
: val_(val) {}
constexpr LoadTypeValue value() const { return val_; }
constexpr unsigned size_log_2() const { return kLoadSizeLog2[val_]; }
constexpr unsigned size() const { return 1 << size_log_2(); }
constexpr uint8_t size_log_2() const { return kLoadSizeLog2[val_]; }
constexpr uint8_t size() const { return kLoadSize[val_]; }
constexpr ValueType value_type() const { return kValueType[val_]; }
constexpr MachineType mem_type() const { return kMemType[val_]; }
@ -801,6 +801,15 @@ class LoadType {
private:
const LoadTypeValue val_;
static constexpr uint8_t kLoadSize[] = {
// MSVC wants a static_cast here.
#define LOAD_SIZE(_, __, memtype) \
static_cast<uint8_t>( \
ElementSizeInBytes(MachineType::memtype().representation())),
FOREACH_LOAD_TYPE(LOAD_SIZE)
#undef LOAD_SIZE
};
static constexpr uint8_t kLoadSizeLog2[] = {
// MSVC wants a static_cast here.
#define LOAD_SIZE(_, __, memtype) \