Commit 5ac2a5d2 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Revert r12430, r12432, r12433 (basic support for Latin1).

BUG=

Review URL: https://chromiumcodereview.appspot.com/10905075

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12438 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0c24942b
This diff is collapsed.
This diff is collapsed.
......@@ -204,23 +204,10 @@ Handle<String> Factory::NewStringFromAscii(Vector<const char> string,
}
Handle<String> Factory::NewStringFromUtf8(Vector<const char> string,
PretenureFlag pretenure,
String::AsciiHint ascii_hint) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateStringFromUtf8(
string, pretenure, ascii_hint),
String);
}
Handle<String> Factory::NewStringFromLatin1(Vector<const char> string,
PretenureFlag pretenure,
String::AsciiHint ascii_hint) {
PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateStringFromLatin1(
string, pretenure, ascii_hint),
isolate()->heap()->AllocateStringFromUtf8(string, pretenure),
String);
}
......
......@@ -120,13 +120,7 @@ class Factory {
// flags in the parser.
Handle<String> NewStringFromUtf8(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED,
String::AsciiHint ascii_hint = String::MAYBE_ASCII);
Handle<String> NewStringFromLatin1(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED,
String::AsciiHint ascii_hint = String::MAYBE_ASCII);
PretenureFlag pretenure = NOT_TENURED);
Handle<String> NewStringFromTwoByte(
Vector<const uc16> str,
......
......@@ -83,14 +83,9 @@ void PromotionQueue::ActivateGuardIfOnTheSamePage() {
MaybeObject* Heap::AllocateStringFromUtf8(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::ASCII) {
// Assert that the ASCII-hint is correct.
ASSERT(ascii_hint != String::ASCII ||
String::IsAscii(str.start(), str.length()));
PretenureFlag pretenure) {
// Check for ASCII first since this is the common case.
if (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);
......@@ -100,24 +95,6 @@ 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::ASCII) {
// Assert that the strict ASCII-hint is correct.
ASSERT(ascii_hint != String::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) {
......
......@@ -48,7 +48,6 @@
#include "snapshot.h"
#include "store-buffer.h"
#include "v8threads.h"
#include "v8utils.h"
#include "vm-state-inl.h"
#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
#include "regexp-macro-assembler.h"
......@@ -4391,8 +4390,7 @@ MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
PretenureFlag pretenure) {
int length = string.length();
if (length == 1) {
if (string.length() == 1) {
return Heap::LookupSingleCharacterStringFromCode(string[0]);
}
Object* result;
......@@ -4401,10 +4399,11 @@ MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
if (!maybe_result->ToObject(&result)) return maybe_result;
}
isolate_->counters()->string_length_ascii()->Increment(length);
// Copy the characters into the new object.
CopyChars(SeqAsciiString::cast(result)->GetChars(), string.start(), length);
SeqAsciiString* string_result = SeqAsciiString::cast(result);
for (int i = 0; i < string.length(); i++) {
string_result->SeqAsciiStringSet(i, string[i]);
}
return result;
}
......@@ -4431,63 +4430,41 @@ MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string,
if (!maybe_result->ToObject(&result)) return maybe_result;
}
isolate_->counters()->string_length_utf8()->Increment(chars);
// Convert and copy the characters into the new object.
SeqTwoByteString* twobyte = SeqTwoByteString::cast(result);
String* string_result = String::cast(result);
decoder->Reset(string.start(), string.length());
int i = 0;
while (i < chars) {
uint32_t r = decoder->GetNext();
if (r > unibrow::Utf16::kMaxNonSurrogateCharCode) {
twobyte->SeqTwoByteStringSet(i++, unibrow::Utf16::LeadSurrogate(r));
twobyte->SeqTwoByteStringSet(i++, unibrow::Utf16::TrailSurrogate(r));
string_result->Set(i++, unibrow::Utf16::LeadSurrogate(r));
string_result->Set(i++, unibrow::Utf16::TrailSurrogate(r));
} else {
twobyte->SeqTwoByteStringSet(i++, r);
string_result->Set(i++, r);
}
}
return result;
}
MaybeObject* Heap::AllocateStringFromLatin1Slow(Vector<const char> string,
PretenureFlag pretenure) {
int chars = string.length();
Object* result;
{ MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
isolate_->counters()->string_length_latin1()->Increment(chars);
// Convert and copy the characters into the new object.
SeqTwoByteString* string_result = SeqTwoByteString::cast(result);
CopyChars(string_result->GetChars(),
reinterpret_cast<const unsigned char*>(string.start()),
chars);
return result;
}
MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string,
PretenureFlag pretenure) {
// Check if the string is an ASCII string.
Object* result;
int length = string.length();
const uc16* start = string.start();
if (String::IsAscii(start, length)) {
MaybeObject* maybe_result = AllocateRawAsciiString(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
isolate_->counters()->string_length_ascii()->Increment(length);
CopyChars(SeqAsciiString::cast(result)->GetChars(), start, length);
MaybeObject* maybe_result;
if (String::IsAscii(string.start(), string.length())) {
maybe_result = AllocateRawAsciiString(string.length(), pretenure);
} else { // It's not an ASCII string.
MaybeObject* maybe_result = AllocateRawTwoByteString(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
isolate_->counters()->string_length_utf16()->Increment(length);
CopyChars(SeqTwoByteString::cast(result)->GetChars(), start, length);
maybe_result = AllocateRawTwoByteString(string.length(), pretenure);
}
Object* result;
if (!maybe_result->ToObject(&result)) return maybe_result;
// Copy the characters into the new object, which may be either ASCII or
// UTF-16.
String* string_result = String::cast(result);
for (int i = 0; i < string.length(); i++) {
string_result->Set(i, string[i]);
}
return result;
}
......
......@@ -678,17 +678,9 @@ class Heap {
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT inline MaybeObject* AllocateStringFromUtf8(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED,
String::AsciiHint ascii_hint = String::MAYBE_ASCII);
MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT inline MaybeObject* AllocateStringFromLatin1(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED,
String::AsciiHint ascii_hint = String::MAYBE_ASCII);
MUST_USE_RESULT MaybeObject* AllocateStringFromLatin1Slow(
MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte(
......
......@@ -7128,10 +7128,6 @@ class String: public HeapObject {
friend class String;
};
enum AsciiHint { MAYBE_ASCII = 0,
ASCII = 1,
NOT_ASCII = 2 };
// Get and set the length of the string.
inline int length();
inline void set_length(int value);
......
......@@ -252,10 +252,6 @@ namespace internal {
SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
SC(string_compare_native, V8.StringCompareNative) \
SC(string_compare_runtime, V8.StringCompareRuntime) \
SC(string_length_utf8, V8.StringLengthUtf8) \
SC(string_length_ascii, V8.StringLengthAScii) \
SC(string_length_latin1, V8.StringLengthLatin1) \
SC(string_length_utf16, V8.StringLengthUtf16) \
SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
SC(regexp_entry_native, V8.RegExpEntryNative) \
SC(number_to_string_native, V8.NumberToStringNative) \
......
This diff is collapsed.
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