Commit 2a19c775 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[sparkplug] Reserve size for bytecode offset table

Based on some test compiles (of three.js and jquery) we can get a decent
estimate of expected bytecode offset table size for a given bytecode
size. Reserve this expected size to avoid resize overhead.

Bug: v8:11420
Change-Id: I8288b01fa796e765a20b11219687fa3d23272416
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2843354Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74093}
parent 14794929
......@@ -4,6 +4,7 @@
// TODO(v8:11421): Remove #if once baseline compiler is ported to other
// architectures.
#include "src/base/bits.h"
#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || \
V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_RISCV64
......@@ -258,6 +259,13 @@ BaselineCompiler::BaselineCompiler(
zone_(isolate->allocator(), ZONE_NAME),
labels_(zone_.NewArray<BaselineLabels*>(bytecode_->length())) {
MemsetPointer(labels_, nullptr, bytecode_->length());
// Empirically determined expected size of the offset table at the 95th %ile,
// based on the size of the bytecode, to be:
//
// 16 + (bytecode size) / 4
bytecode_offset_table_builder_.Reserve(
base::bits::RoundUpToPowerOfTwo(16 + bytecode_->Size() / 4));
}
#define __ basm_.
......
......@@ -42,6 +42,8 @@ class BytecodeOffsetTableBuilder {
template <typename LocalIsolate>
Handle<ByteArray> ToBytecodeOffsetTable(LocalIsolate* isolate);
void Reserve(size_t size) { bytes_.reserve(size); }
private:
size_t previous_pc_ = 0;
std::vector<byte> bytes_;
......
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