Commit b7be3cf5 authored by verwaest's avatar verwaest Committed by Commit bot

Turn sliced strings into flat cons-strings upon internalization

Flat cons-strings point directly to the internalized version of the string. This makes reinternalization much faster.

BUG=

Review-Url: https://codereview.chromium.org/1932663002
Cr-Commit-Position: refs/heads/master@{#35852}
parent 941f5535
......@@ -17232,6 +17232,16 @@ Handle<String> StringTable::LookupString(Isolate* isolate,
Handle<ConsString> cons = Handle<ConsString>::cast(string);
cons->set_first(*result);
cons->set_second(isolate->heap()->empty_string());
} else if (string->IsSlicedString()) {
STATIC_ASSERT(ConsString::kSize == SlicedString::kSize);
DisallowHeapAllocation no_gc;
bool one_byte = result->IsOneByteRepresentation();
Handle<Map> map = one_byte ? isolate->factory()->cons_one_byte_string_map()
: isolate->factory()->cons_string_map();
string->set_map(*map);
Handle<ConsString> cons = Handle<ConsString>::cast(string);
cons->set_first(*result);
cons->set_second(isolate->heap()->empty_string());
}
return result;
}
......
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