Commit 14794929 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[arm] Use SmallVector for pending constant pool

Since there usually aren't many pending 32-bit constants, we can avoid
the cost of malloc/free for most compiles by using a base::SmallVector
instead of std::vector.

I picked a value of 32 entries as the SmallVector's inline size, based
on compiling three.js and jquery with Sparkplug, and printing the size
of the constant pool when emitted. 93% of emitted constant pools had
<=32 entries.

Bug: v8:11420
Change-Id: I7d62da74c60feae08f8a4b16b1e7f93ea69d2c95
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2840447Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74092}
parent b2494609
......@@ -534,7 +534,6 @@ Assembler::Assembler(const AssemblerOptions& options,
: AssemblerBase(options, std::move(buffer)),
pending_32_bit_constants_(),
scratch_register_list_(ip.bit()) {
pending_32_bit_constants_.reserve(kMinNumPendingConstants);
reloc_info_writer.Reposition(buffer_start_ + buffer_->size(), pc_);
next_buffer_check_ = 0;
const_pool_blocked_nesting_ = 0;
......@@ -5267,7 +5266,7 @@ void Assembler::ConstantPoolAddEntry(int position, RelocInfo::Mode rmode,
}
}
pending_32_bit_constants_.push_back(entry);
pending_32_bit_constants_.emplace_back(entry);
// Make sure the constant pool is not emitted in place of the next
// instruction for which we just recorded relocation info.
......
......@@ -45,6 +45,7 @@
#include <memory>
#include <vector>
#include "src/base/small-vector.h"
#include "src/codegen/arm/constants-arm.h"
#include "src/codegen/arm/register-arm.h"
#include "src/codegen/assembler.h"
......@@ -1153,8 +1154,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// PC-relative loads, thereby defining a maximum distance between the
// instruction and the accessed constant.
static constexpr int kMaxDistToIntPool = 4 * KB;
// All relocations could be integer, it therefore acts as the limit.
static constexpr int kMinNumPendingConstants = 4;
// Experimentally derived as sufficient for ~95% of compiles.
static constexpr int kTypicalNumPending32Constants = 32;
static constexpr int kMaxNumPending32Constants =
kMaxDistToIntPool / kInstrSize;
......@@ -1258,7 +1259,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// pending relocation entry per instruction.
// The buffers of pending constant pool entries.
std::vector<ConstantPoolEntry> pending_32_bit_constants_;
base::SmallVector<ConstantPoolEntry, kTypicalNumPending32Constants>
pending_32_bit_constants_;
// Scratch registers available for use by the Assembler.
RegList scratch_register_list_;
......
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