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
This commit is contained in:
parent
57a0c1fec3
commit
4240cd2506
12
src/heap.cc
12
src/heap.cc
@ -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 ||
|
||||
@ -4981,7 +4983,7 @@ MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
|
||||
|
||||
|
||||
MaybeObject* Heap::AllocateStringFromOneByte(Vector<const uint8_t> string,
|
||||
PretenureFlag pretenure) {
|
||||
PretenureFlag pretenure) {
|
||||
int length = string.length();
|
||||
if (length == 1) {
|
||||
return Heap::LookupSingleCharacterStringFromCode(string[0]);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user