Commit 090c7821 authored by adamk's avatar adamk Committed by Commit bot

Give ComputeCapacityForSerialization a minimum capacity

This avoids DCHECK failures when passing 0 as the at_least_space_for
argument to HashTableBase::New (allowing converting code from non-serialized
to serialized without changing callsites).

Review URL: https://codereview.chromium.org/1134573002

Cr-Commit-Position: refs/heads/master@{#28321}
parent 250f591c
...@@ -3116,7 +3116,7 @@ void Heap::CreateInitialObjects() { ...@@ -3116,7 +3116,7 @@ void Heap::CreateInitialObjects() {
TENURED)); TENURED));
Handle<SeededNumberDictionary> slow_element_dictionary = Handle<SeededNumberDictionary> slow_element_dictionary =
SeededNumberDictionary::New(isolate(), 1, TENURED); SeededNumberDictionary::New(isolate(), 0, TENURED);
slow_element_dictionary->set_requires_slow_elements(); slow_element_dictionary->set_requires_slow_elements();
set_empty_slow_element_dictionary(*slow_element_dictionary); set_empty_slow_element_dictionary(*slow_element_dictionary);
......
...@@ -3260,15 +3260,14 @@ DescriptorArray::WhitenessWitness::~WhitenessWitness() { ...@@ -3260,15 +3260,14 @@ DescriptorArray::WhitenessWitness::~WhitenessWitness() {
int HashTableBase::ComputeCapacity(int at_least_space_for) { int HashTableBase::ComputeCapacity(int at_least_space_for) {
const int kMinCapacity = 4; const int kMinCapacity = 4;
int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2);
if (capacity < kMinCapacity) { return Max(capacity, kMinCapacity);
capacity = kMinCapacity; // Guarantee min capacity.
}
return capacity;
} }
int HashTableBase::ComputeCapacityForSerialization(int at_least_space_for) { int HashTableBase::ComputeCapacityForSerialization(int at_least_space_for) {
return base::bits::RoundUpToPowerOfTwo32(at_least_space_for); const int kMinCapacity = 1;
int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for);
return Max(capacity, kMinCapacity);
} }
......
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