Internalize string constants in code assembler

This avoids generation of duplicate strings. Especially debug builds
suffer from this and generate 16000+ strings, mostly for CSA_ASSERT
and CAST statements. Deduplicating these trims that down to roughly
1000 strings.

Release builds are affected at a smaller scale. There, we have roughly
100 duplicate strings in the snapshot.

Bug: v8:6666
Change-Id: I688d3b97431b8cea1e98983eab5f07278dae91a0
Reviewed-on: https://chromium-review.googlesource.com/931041
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51472}
This commit is contained in:
jgruber 2018-02-22 11:11:06 +01:00 committed by Commit Bot
parent aa7ccc233c
commit 7a80dbdbec

View File

@ -270,8 +270,9 @@ TNode<HeapObject> CodeAssembler::UntypedHeapConstant(
}
TNode<String> CodeAssembler::StringConstant(const char* str) {
return UncheckedCast<String>(
HeapConstant(factory()->NewStringFromAsciiChecked(str, TENURED)));
Handle<String> internalized_string =
factory()->InternalizeOneByteString(OneByteVector(str));
return UncheckedCast<String>(HeapConstant(internalized_string));
}
TNode<Oddball> CodeAssembler::BooleanConstant(bool value) {