Commit ae56aa0a authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[utils] Outline growing of GrowableBitVector

This change alone reduces the overall compile time of the reproducer
from the linked issue by >30%.

R=jkummerow@chromium.org

Bug: v8:13063
Change-Id: I5ac69ab6ec2f1427b1511181664d34f4b1d26f93
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3760451Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81714}
parent 07add521
......@@ -342,7 +342,7 @@ class GrowableBitVector {
}
void Add(int value, Zone* zone) {
EnsureCapacity(value, zone);
if (V8_UNLIKELY(!InBitsRange(value))) Grow(value, zone);
bits_.Add(value);
}
......@@ -363,12 +363,12 @@ class GrowableBitVector {
bool InBitsRange(int value) const { return bits_.length() > value; }
void EnsureCapacity(int value, Zone* zone) {
if (InBitsRange(value)) return;
V8_NOINLINE void Grow(int needed_value, Zone* zone) {
DCHECK(!InBitsRange(needed_value));
int new_length =
base::bits::RoundUpToPowerOfTwo32(static_cast<uint32_t>(value));
base::bits::RoundUpToPowerOfTwo32(static_cast<uint32_t>(needed_value));
new_length = std::min(new_length, kInitialLength);
while (new_length <= value) new_length *= 2;
while (new_length <= needed_value) new_length *= 2;
bits_.Resize(new_length, zone);
}
......
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