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}
This commit is contained in:
verwaest 2016-04-28 03:08:35 -07:00 committed by Commit bot
parent 941f553574
commit b7be3cf551

View File

@ -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;
}