Commit 4240cd25 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Flatten cons string for single character substrings.

For substrings of non-flat cons strings, we bail out
to runtime. For single character substrings, we forget
to flatten it. This causes successive bailouts.

R=bmeurer@chromium.org
BUG=323041
LOG=Y

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18081 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 57a0c1fe
......@@ -3968,7 +3968,12 @@ MaybeObject* Heap::AllocateSubString(String* buffer,
int length = end - start;
if (length <= 0) {
return empty_string();
} else if (length == 1) {
}
// Make an attempt to flatten the buffer to reduce access time.
buffer = buffer->TryFlattenGetString();
if (length == 1) {
return LookupSingleCharacterStringFromCode(buffer->Get(start));
} else if (length == 2) {
// Optimization for 2-byte strings often used as keys in a decompression
......@@ -3979,9 +3984,6 @@ MaybeObject* Heap::AllocateSubString(String* buffer,
return MakeOrFindTwoCharacterString(this, c1, c2);
}
// Make an attempt to flatten the buffer to reduce access time.
buffer = buffer->TryFlattenGetString();
if (!FLAG_string_slices ||
!buffer->IsFlat() ||
length < SlicedString::kMinLength ||
......
......@@ -4463,10 +4463,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
RUNTIME_ASSERT(start >= 0);
RUNTIME_ASSERT(end <= value->length());
isolate->counters()->sub_string_runtime()->Increment();
if (end - start == 1) {
return isolate->heap()->LookupSingleCharacterStringFromCode(
value->Get(start));
}
return value->SubString(start, end);
}
......
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