Revision: 18081
Author: [email protected]
Date: Tue Nov 26 14:21:46 2013 UTC
Log: 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.
[email protected]
BUG=323041
LOG=Y
Review URL: https://codereview.chromium.org/88173002
http://code.google.com/p/v8/source/detail?r=18081
Modified:
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/heap.cc Fri Nov 22 10:52:15 2013 UTC
+++ /branches/bleeding_edge/src/heap.cc Tue Nov 26 14:21:46 2013 UTC
@@ -3968,7 +3968,12 @@
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
@@ -3978,9 +3983,6 @@
uint16_t c2 = buffer->Get(start + 1);
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() ||
@@ -4981,7 +4983,7 @@
MaybeObject* Heap::AllocateStringFromOneByte(Vector<const uint8_t> string,
- PretenureFlag pretenure) {
+ PretenureFlag pretenure) {
int length = string.length();
if (length == 1) {
return Heap::LookupSingleCharacterStringFromCode(string[0]);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Nov 26 12:29:47 2013 UTC
+++ /branches/bleeding_edge/src/runtime.cc Tue Nov 26 14:21:46 2013 UTC
@@ -4463,10 +4463,6 @@
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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.