Commit 20d5fba3 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

Reland "[runtime] Decrease StringTable shrink limit"

- Allow deserializer to add entries to the StringTable without
  causing a gc.

This is a reland of 868ed8ee

Original change's description:
> [runtime] Decrease StringTable shrink limit
>
> Given that we have not seen any regressions yet we're trying a more aggressive
> limit.
>
> Bug: chromium:818642, v8:5443
> Change-Id: Ic45001ed6c042fc31cbba0d417d5060d2de8fb3a
> Reviewed-on: https://chromium-review.googlesource.com/975126
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#52145}

Bug: chromium:818642, v8:5443
Change-Id: I051c6a79e59ec40cf87cab5bf06c4c449f8113d0
Reviewed-on: https://chromium-review.googlesource.com/975643
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52242}
parent 171993c7
...@@ -17065,20 +17065,28 @@ Handle<String> StringTable::LookupKey(Isolate* isolate, StringTableKey* key) { ...@@ -17065,20 +17065,28 @@ Handle<String> StringTable::LookupKey(Isolate* isolate, StringTableKey* key) {
table = StringTable::CautiousShrink(table); table = StringTable::CautiousShrink(table);
// Adding new string. Grow table if needed. // Adding new string. Grow table if needed.
table = StringTable::EnsureCapacity(table, 1); table = StringTable::EnsureCapacity(table, 1);
isolate->heap()->SetRootStringTable(*table);
return AddKeyNoResize(isolate, key);
}
Handle<String> StringTable::AddKeyNoResize(Isolate* isolate,
StringTableKey* key) {
Handle<StringTable> table = isolate->factory()->string_table();
DCHECK(table->HasSufficientCapacityToAdd(1));
// Create string object. // Create string object.
Handle<String> string = key->AsHandle(isolate); Handle<String> string = key->AsHandle(isolate);
// There must be no attempts to internalize strings that could throw // There must be no attempts to internalize strings that could throw
// InvalidStringLength error. // InvalidStringLength error.
CHECK(!string.is_null()); CHECK(!string.is_null());
DCHECK(string->HasHashCode()); DCHECK(string->HasHashCode());
DCHECK_EQ(table->FindEntry(key), kNotFound);
// Add the new string and return it along with the string table. // Add the new string and return it along with the string table.
entry = table->FindInsertionEntry(key->Hash()); int entry = table->FindInsertionEntry(key->Hash());
table->set(EntryToIndex(entry), *string); table->set(EntryToIndex(entry), *string);
table->ElementAdded(); table->ElementAdded();
isolate->heap()->SetRootStringTable(*table);
return Handle<String>::cast(string); return Handle<String>::cast(string);
} }
......
...@@ -61,6 +61,7 @@ class StringTable : public HashTable<StringTable, StringTableShape> { ...@@ -61,6 +61,7 @@ class StringTable : public HashTable<StringTable, StringTableShape> {
V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate, V8_EXPORT_PRIVATE static Handle<String> LookupString(Isolate* isolate,
Handle<String> key); Handle<String> key);
static Handle<String> LookupKey(Isolate* isolate, StringTableKey* key); static Handle<String> LookupKey(Isolate* isolate, StringTableKey* key);
static Handle<String> AddKeyNoResize(Isolate* isolate, StringTableKey* key);
static String* ForwardStringIfExists(Isolate* isolate, StringTableKey* key, static String* ForwardStringIfExists(Isolate* isolate, StringTableKey* key,
String* string); String* string);
...@@ -78,7 +79,7 @@ class StringTable : public HashTable<StringTable, StringTableShape> { ...@@ -78,7 +79,7 @@ class StringTable : public HashTable<StringTable, StringTableShape> {
DECL_CAST(StringTable) DECL_CAST(StringTable)
static const int kMaxEmptyFactor = 16; static const int kMaxEmptyFactor = 8;
static const int kMinCapacity = 2048; static const int kMinCapacity = 2048;
static const int kMinShrinkCapacity = kMinCapacity; static const int kMinShrinkCapacity = kMinCapacity;
......
...@@ -102,9 +102,10 @@ void ObjectDeserializer::CommitPostProcessedObjects() { ...@@ -102,9 +102,10 @@ void ObjectDeserializer::CommitPostProcessedObjects() {
StringTable::EnsureCapacityForDeserialization( StringTable::EnsureCapacityForDeserialization(
isolate(), static_cast<int>(new_internalized_strings().size())); isolate(), static_cast<int>(new_internalized_strings().size()));
for (Handle<String> string : new_internalized_strings()) { for (Handle<String> string : new_internalized_strings()) {
DisallowHeapAllocation no_gc;
StringTableInsertionKey key(*string); StringTableInsertionKey key(*string);
DCHECK_NULL(StringTable::ForwardStringIfExists(isolate(), &key, *string)); DCHECK_NULL(StringTable::ForwardStringIfExists(isolate(), &key, *string));
StringTable::LookupKey(isolate(), &key); StringTable::AddKeyNoResize(isolate(), &key);
} }
Heap* heap = isolate()->heap(); Heap* heap = isolate()->heap();
......
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