Chromium Code Reviews| Index: src/heap-inl.h |
| diff --git a/src/heap-inl.h b/src/heap-inl.h |
| index 4a827fef176fd57cafb2c929bb834cd229737aaa..8046b1975d91d3f8bb3ceaa2577a27963c1e532e 100644 |
| --- a/src/heap-inl.h |
| +++ b/src/heap-inl.h |
| @@ -83,9 +83,14 @@ void PromotionQueue::ActivateGuardIfOnTheSamePage() { |
| MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
| - PretenureFlag pretenure) { |
| - // Check for ASCII first since this is the common case. |
| - if (String::IsAscii(str.start(), str.length())) { |
| + PretenureFlag pretenure, |
| + String::AsciiHint ascii_hint) { |
| + if ((ascii_hint == String::MAYBE_ASCII && |
| + String::IsAscii(str.start(), str.length())) || |
| + ascii_hint == String::STRICT_ASCII) { |
| + // Assert that the strict ascii hint is correct. |
|
Erik Corry
2012/08/21 12:21:34
ascii -> ASCII
here and below
Yang
2012/08/21 13:06:20
Done.
|
| + ASSERT(ascii_hint != String::STRICT_ASCII || |
| + String::IsAscii(str.start(), str.length())); |
| // If the string is ASCII, we do not need to convert the characters |
| // since UTF8 is backwards compatible with ASCII. |
| return AllocateStringFromAscii(str, pretenure); |
| @@ -95,6 +100,24 @@ MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str, |
| } |
| +MaybeObject* Heap::AllocateStringFromLatin1(Vector<const char> str, |
| + PretenureFlag pretenure, |
| + String::AsciiHint ascii_hint) { |
| + if ((ascii_hint == String::MAYBE_ASCII && |
| + String::IsAscii(str.start(), str.length())) || |
| + ascii_hint == String::STRICT_ASCII) { |
| + // Assert that the strict ascii hint is correct. |
| + ASSERT(ascii_hint != String::STRICT_ASCII || |
| + String::IsAscii(str.start(), str.length())); |
| + // If the string is ASCII, we do not need to convert the characters |
| + // since Latin1 is backwards compatible with ASCII. |
| + return AllocateStringFromAscii(str, pretenure); |
| + } |
| + // Non-ASCII and we need to decode. |
| + return AllocateStringFromLatin1Slow(str, pretenure); |
| +} |
| + |
| + |
| MaybeObject* Heap::AllocateSymbol(Vector<const char> str, |
| int chars, |
| uint32_t hash_field) { |