Rename IsAsciiRepresentation

This is a straight rename:

IsAsciiRepresentation -> IsOneByteRepresentation
IsAsciiRepresentationUnderneath -> IsOneByteRepresentationUnderneath
AllocateRawAsciiString -> AllocateRawOneByteString
AllocateStringFromAscii -> AllocateStringFromOneByte

R=yangguo@chromium.org,
BUG=

Review URL: https://chromiumcodereview.appspot.com/11308066
Patch from Dan Carney <dcarney@google.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13023 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2012-11-21 10:01:05 +00:00
parent 67c9e9d065
commit 36f5b6d41f
21 changed files with 89 additions and 86 deletions

View File

@ -3850,7 +3850,7 @@ static int RecursivelySerializeToUtf8(i::String* string,
int32_t* last_character) {
int utf8_bytes = 0;
while (true) {
if (string->IsAsciiRepresentation()) {
if (string->IsOneByteRepresentation()) {
i::String::WriteToFlat(string, buffer, start, end);
*last_character = unibrow::Utf16::kNoPreviousCharacter;
return utf8_bytes + end - start;
@ -3950,7 +3950,7 @@ int String::WriteUtf8(char* buffer,
FlattenString(str); // Flatten the string for efficiency.
}
int string_length = str->length();
if (str->IsAsciiRepresentation()) {
if (str->IsOneByteRepresentation()) {
int len;
if (capacity == -1) {
capacity = str->length() + 1;
@ -4084,7 +4084,7 @@ int String::WriteAscii(char* buffer,
FlattenString(str); // Flatten the string for efficiency.
}
if (str->IsAsciiRepresentation()) {
if (str->IsOneByteRepresentation()) {
// WriteToFlat is faster than using the StringInputBuffer.
if (length == -1) length = str->length() + 1;
int len = i::Min(length, str->length() - start);
@ -4199,7 +4199,7 @@ void v8::String::VerifyExternalStringResourceBase(
expectedEncoding = TWO_BYTE_ENCODING;
} else {
expected = NULL;
expectedEncoding = str->IsAsciiRepresentation() ? ASCII_ENCODING
expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING
: TWO_BYTE_ENCODING;
}
CHECK_EQ(expected, value);

View File

@ -1150,7 +1150,7 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address,
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
ASSERT(re_code->instruction_start() <= *return_address);
ASSERT(*return_address <=
@ -1181,7 +1181,7 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address,
}
// String might have changed.
if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
// If we changed between an ASCII and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).

View File

@ -1341,7 +1341,7 @@ bool Genesis::CompileScriptCached(Vector<const char> name,
// If we can't find the function in the cache, we compile a new
// function and insert it into the cache.
if (cache == NULL || !cache->Lookup(name, &function_info)) {
ASSERT(source->IsAsciiRepresentation());
ASSERT(source->IsOneByteRepresentation());
Handle<String> script_name = factory->NewStringFromUtf8(name);
function_info = Compiler::Compile(
source,

View File

@ -93,7 +93,7 @@ v8::Handle<v8::Value> ExternalizeStringExtension::Externalize(
return v8::ThrowException(v8::String::New(
"externalizeString() can't externalize twice."));
}
if (string->IsAsciiRepresentation() && !force_two_byte) {
if (string->IsOneByteRepresentation() && !force_two_byte) {
char* data = new char[string->length()];
String::WriteToFlat(*string, data, 0, string->length());
SimpleAsciiStringResource* resource = new SimpleAsciiStringResource(
@ -127,7 +127,8 @@ v8::Handle<v8::Value> ExternalizeStringExtension::IsAscii(
return v8::ThrowException(v8::String::New(
"isAsciiString() requires a single string argument."));
}
return Utils::OpenHandle(*args[0].As<v8::String>())->IsAsciiRepresentation() ?
return
Utils::OpenHandle(*args[0].As<v8::String>())->IsOneByteRepresentation() ?
v8::True() : v8::False();
}

View File

@ -200,7 +200,7 @@ Handle<String> Factory::NewStringFromAscii(Vector<const char> string,
PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateStringFromAscii(string, pretenure),
isolate()->heap()->AllocateStringFromOneByte(string, pretenure),
String);
}
@ -226,7 +226,7 @@ Handle<SeqOneByteString> Factory::NewRawOneByteString(int length,
PretenureFlag pretenure) {
CALL_HEAP_FUNCTION(
isolate(),
isolate()->heap()->AllocateRawAsciiString(length, pretenure),
isolate()->heap()->AllocateRawOneByteString(length, pretenure),
SeqOneByteString);
}

View File

@ -915,7 +915,7 @@ int Utf8LengthHelper(String* input,
int total = 0;
bool dummy;
while (true) {
if (input->IsAsciiRepresentation()) {
if (input->IsOneByteRepresentation()) {
*starts_with_surrogate = false;
return total + to - from;
}
@ -948,14 +948,14 @@ int Utf8LengthHelper(String* input,
} else {
if (first_length > from) {
// Left hand side is shorter.
if (first->IsAsciiRepresentation()) {
if (first->IsOneByteRepresentation()) {
total += first_length - from;
*starts_with_surrogate = false;
starts_with_surrogate = &dummy;
input = second;
from = 0;
to -= first_length;
} else if (second->IsAsciiRepresentation()) {
} else if (second->IsOneByteRepresentation()) {
followed_by_surrogate = false;
total += to - first_length;
input = first;

View File

@ -91,7 +91,7 @@ MaybeObject* Heap::AllocateStringFromUtf8(Vector<const char> str,
if (non_ascii_start >= 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);
return AllocateStringFromOneByte(str, pretenure);
}
// Non-ASCII and we need to decode.
return AllocateStringFromUtf8Slow(str, non_ascii_start, pretenure);

View File

@ -2805,7 +2805,7 @@ bool Heap::CreateInitialObjects() {
set_termination_exception(obj);
// Allocate the empty string.
{ MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED);
{ MaybeObject* maybe_obj = AllocateRawOneByteString(0, TENURED);
if (!maybe_obj->ToObject(&obj)) return false;
}
set_empty_string(String::cast(obj));
@ -3177,7 +3177,7 @@ MaybeObject* Heap::NumberToString(Object* number,
}
Object* js_string;
MaybeObject* maybe_js_string = AllocateStringFromAscii(CStrVector(str));
MaybeObject* maybe_js_string = AllocateStringFromOneByte(CStrVector(str));
if (maybe_js_string->ToObject(&js_string)) {
SetNumberStringCache(number, String::cast(js_string));
}
@ -3351,7 +3351,7 @@ MUST_USE_RESULT static inline MaybeObject* MakeOrFindTwoCharacterString(
} else if ((c1 | c2) <= String::kMaxAsciiCharCodeU) { // We can do this
ASSERT(IsPowerOf2(String::kMaxAsciiCharCodeU + 1)); // because of this.
Object* result;
{ MaybeObject* maybe_result = heap->AllocateRawAsciiString(2);
{ MaybeObject* maybe_result = heap->AllocateRawOneByteString(2);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
char* dest = SeqOneByteString::cast(result)->GetChars();
@ -3393,8 +3393,8 @@ MaybeObject* Heap::AllocateConsString(String* first, String* second) {
return MakeOrFindTwoCharacterString(this, c1, c2);
}
bool first_is_ascii = first->IsAsciiRepresentation();
bool second_is_ascii = second->IsAsciiRepresentation();
bool first_is_ascii = first->IsOneByteRepresentation();
bool second_is_ascii = second->IsOneByteRepresentation();
bool is_ascii = first_is_ascii && second_is_ascii;
// Make sure that an out of memory exception is thrown if the length
@ -3424,7 +3424,7 @@ MaybeObject* Heap::AllocateConsString(String* first, String* second) {
ASSERT(second->IsFlat());
if (is_ascii) {
Object* result;
{ MaybeObject* maybe_result = AllocateRawAsciiString(length);
{ MaybeObject* maybe_result = AllocateRawOneByteString(length);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
// Copy the characters into the new object.
@ -3448,7 +3448,7 @@ MaybeObject* Heap::AllocateConsString(String* first, String* second) {
} else {
if (is_ascii_data_in_two_byte_string) {
Object* result;
{ MaybeObject* maybe_result = AllocateRawAsciiString(length);
{ MaybeObject* maybe_result = AllocateRawOneByteString(length);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
// Copy the characters into the new object.
@ -3519,16 +3519,16 @@ MaybeObject* Heap::AllocateSubString(String* buffer,
// WriteToFlat takes care of the case when an indirect string has a
// different encoding from its underlying string. These encodings may
// differ because of externalization.
bool is_ascii = buffer->IsAsciiRepresentation();
bool is_ascii = buffer->IsOneByteRepresentation();
{ MaybeObject* maybe_result = is_ascii
? AllocateRawAsciiString(length, pretenure)
? AllocateRawOneByteString(length, pretenure)
: AllocateRawTwoByteString(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
String* string_result = String::cast(result);
// Copy the characters into the new object.
if (is_ascii) {
ASSERT(string_result->IsAsciiRepresentation());
ASSERT(string_result->IsOneByteRepresentation());
char* dest = SeqOneByteString::cast(string_result)->GetChars();
String::WriteToFlat(buffer, dest, start, end);
} else {
@ -3553,7 +3553,7 @@ MaybeObject* Heap::AllocateSubString(String* buffer,
// indirect ASCII string is pointing to a two-byte string, the two-byte char
// codes of the underlying string must still fit into ASCII (because
// externalization must not change char codes).
{ Map* map = buffer->IsAsciiRepresentation()
{ Map* map = buffer->IsOneByteRepresentation()
? sliced_ascii_string_map()
: sliced_string_map();
MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
@ -4559,7 +4559,7 @@ MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor,
}
MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
MaybeObject* Heap::AllocateStringFromOneByte(Vector<const char> string,
PretenureFlag pretenure) {
int length = string.length();
if (length == 1) {
@ -4567,7 +4567,7 @@ MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string,
}
Object* result;
{ MaybeObject* maybe_result =
AllocateRawAsciiString(string.length(), pretenure);
AllocateRawOneByteString(string.length(), pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
@ -4625,7 +4625,7 @@ MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string,
const uc16* start = string.start();
if (String::IsAscii(start, length)) {
MaybeObject* maybe_result = AllocateRawAsciiString(length, pretenure);
MaybeObject* maybe_result = AllocateRawOneByteString(length, pretenure);
if (!maybe_result->ToObject(&result)) return maybe_result;
CopyChars(SeqOneByteString::cast(result)->GetChars(), start, length);
} else { // It's not an ASCII string.
@ -4726,7 +4726,8 @@ MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer,
}
MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) {
MaybeObject* Heap::AllocateRawOneByteString(int length,
PretenureFlag pretenure) {
if (length < 0 || length > SeqOneByteString::kMaxLength) {
return Failure::OutOfMemoryException();
}

View File

@ -706,7 +706,7 @@ class Heap {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
MUST_USE_RESULT MaybeObject* AllocateStringFromAscii(
MUST_USE_RESULT MaybeObject* AllocateStringFromOneByte(
Vector<const char> str,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT inline MaybeObject* AllocateStringFromUtf8(
@ -750,7 +750,7 @@ class Heap {
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
MUST_USE_RESULT MaybeObject* AllocateRawAsciiString(
MUST_USE_RESULT MaybeObject* AllocateRawOneByteString(
int length,
PretenureFlag pretenure = NOT_TENURED);
MUST_USE_RESULT MaybeObject* AllocateRawTwoByteString(

View File

@ -1197,7 +1197,7 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address,
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
ASSERT(re_code->instruction_start() <= *return_address);
ASSERT(*return_address <=
@ -1228,7 +1228,7 @@ int RegExpMacroAssemblerIA32::CheckStackGuardState(Address* return_address,
}
// String might have changed.
if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
// If we changed between an ASCII and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).

View File

@ -529,7 +529,7 @@ int RegExpImpl::IrregexpPrepare(Handle<JSRegExp> regexp,
if (!subject->IsFlat()) FlattenString(subject);
// Check the asciiness of the underlying storage.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
if (!EnsureCompiledIrregexp(regexp, subject, is_ascii)) return -1;
#ifdef V8_INTERPRETED_REGEXP
@ -560,7 +560,7 @@ int RegExpImpl::IrregexpExecRaw(Handle<JSRegExp> regexp,
ASSERT(index <= subject->length());
ASSERT(subject->IsFlat());
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
#ifndef V8_INTERPRETED_REGEXP
ASSERT(output_size >= (IrregexpNumberOfCaptures(*irregexp) + 1) * 2);
@ -596,7 +596,7 @@ int RegExpImpl::IrregexpExecRaw(Handle<JSRegExp> regexp,
// being internal and external, and even between being ASCII and UC16,
// but the characters are always the same).
IrregexpPrepare(regexp, subject);
is_ascii = subject->IsAsciiRepresentationUnderneath();
is_ascii = subject->IsOneByteRepresentationUnderneath();
} while (true);
UNREACHABLE();
return RE_EXCEPTION;

View File

@ -257,7 +257,7 @@ void LogMessageBuilder::AppendDetailed(String* str, bool show_impl_info) {
if (len > 0x1000)
len = 0x1000;
if (show_impl_info) {
Append(str->IsAsciiRepresentation() ? 'a' : '2');
Append(str->IsOneByteRepresentation() ? 'a' : '2');
if (StringShape(str).IsExternal())
Append('e');
if (StringShape(str).IsSymbol())

View File

@ -1155,7 +1155,7 @@ int RegExpMacroAssemblerMIPS::CheckStackGuardState(Address* return_address,
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
ASSERT(re_code->instruction_start() <= *return_address);
ASSERT(*return_address <=
@ -1186,7 +1186,7 @@ int RegExpMacroAssemblerMIPS::CheckStackGuardState(Address* return_address,
}
// String might have changed.
if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
// If we changed between an ASCII and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).

View File

@ -232,7 +232,7 @@ bool Object::IsSeqString() {
bool Object::IsSeqOneByteString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential() &&
String::cast(this)->IsAsciiRepresentation();
String::cast(this)->IsOneByteRepresentation();
}
@ -252,7 +252,7 @@ bool Object::IsExternalString() {
bool Object::IsExternalAsciiString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
String::cast(this)->IsAsciiRepresentation();
String::cast(this)->IsOneByteRepresentation();
}
@ -295,7 +295,7 @@ bool StringShape::IsSymbol() {
}
bool String::IsAsciiRepresentation() {
bool String::IsOneByteRepresentation() {
uint32_t type = map()->instance_type();
return (type & kStringEncodingMask) == kOneByteStringTag;
}
@ -307,7 +307,7 @@ bool String::IsTwoByteRepresentation() {
}
bool String::IsAsciiRepresentationUnderneath() {
bool String::IsOneByteRepresentationUnderneath() {
uint32_t type = map()->instance_type();
STATIC_ASSERT(kIsIndirectStringTag != 0);
STATIC_ASSERT((kIsIndirectStringMask & kStringEncodingMask) == 0);
@ -318,7 +318,7 @@ bool String::IsAsciiRepresentationUnderneath() {
case kTwoByteStringTag:
return false;
default: // Cons or sliced string. Need to go deeper.
return GetUnderlying()->IsAsciiRepresentation();
return GetUnderlying()->IsOneByteRepresentation();
}
}
@ -2496,7 +2496,7 @@ void String::Set(int index, uint16_t value) {
ASSERT(index >= 0 && index < length());
ASSERT(StringShape(this).IsSequential());
return this->IsAsciiRepresentation()
return this->IsOneByteRepresentation()
? SeqOneByteString::cast(this)->SeqOneByteStringSet(index, value)
: SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value);
}
@ -4119,7 +4119,7 @@ bool Script::HasValidSource() {
if (!src->IsString()) return true;
String* src_str = String::cast(src);
if (!StringShape(src_str).IsExternal()) return true;
if (src_str->IsAsciiRepresentation()) {
if (src_str->IsOneByteRepresentation()) {
return ExternalAsciiString::cast(src)->resource() != NULL;
} else if (src_str->IsTwoByteRepresentation()) {
return ExternalTwoByteString::cast(src)->resource() != NULL;

View File

@ -894,8 +894,9 @@ MaybeObject* String::SlowTryFlatten(PretenureFlag pretenure) {
int len = length();
Object* object;
String* result;
if (IsAsciiRepresentation()) {
{ MaybeObject* maybe_object = heap->AllocateRawAsciiString(len, tenure);
if (IsOneByteRepresentation()) {
{ MaybeObject* maybe_object =
heap->AllocateRawOneByteString(len, tenure);
if (!maybe_object->ToObject(&object)) return maybe_object;
}
result = String::cast(object);
@ -954,7 +955,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
if (size < ExternalString::kShortSize) {
return false;
}
bool is_ascii = this->IsAsciiRepresentation();
bool is_ascii = this->IsOneByteRepresentation();
bool is_symbol = this->IsSymbol();
// Morph the object to an external string by adjusting the map and
@ -6626,7 +6627,7 @@ const uc16* String::GetTwoByteData() {
const uc16* String::GetTwoByteData(unsigned start) {
ASSERT(!IsAsciiRepresentationUnderneath());
ASSERT(!IsOneByteRepresentationUnderneath());
switch (StringShape(this).representation_tag()) {
case kSeqStringTag:
return SeqTwoByteString::cast(this)->SeqTwoByteStringGetData(start);
@ -6878,7 +6879,7 @@ const unibrow::byte* String::ReadBlock(String* input,
}
switch (StringShape(input).representation_tag()) {
case kSeqStringTag:
if (input->IsAsciiRepresentation()) {
if (input->IsOneByteRepresentation()) {
SeqOneByteString* str = SeqOneByteString::cast(input);
return str->SeqOneByteStringReadBlock(&rbb->remaining,
offset_ptr,
@ -6895,7 +6896,7 @@ const unibrow::byte* String::ReadBlock(String* input,
offset_ptr,
max_chars);
case kExternalStringTag:
if (input->IsAsciiRepresentation()) {
if (input->IsOneByteRepresentation()) {
return ExternalAsciiString::cast(input)->ExternalAsciiStringReadBlock(
&rbb->remaining,
offset_ptr,
@ -7027,7 +7028,7 @@ void String::ReadBlockIntoBuffer(String* input,
switch (StringShape(input).representation_tag()) {
case kSeqStringTag:
if (input->IsAsciiRepresentation()) {
if (input->IsOneByteRepresentation()) {
SeqOneByteString::cast(input)->SeqOneByteStringReadBlockIntoBuffer(rbb,
offset_ptr,
max_chars);
@ -7044,7 +7045,7 @@ void String::ReadBlockIntoBuffer(String* input,
max_chars);
return;
case kExternalStringTag:
if (input->IsAsciiRepresentation()) {
if (input->IsOneByteRepresentation()) {
ExternalAsciiString::cast(input)->
ExternalAsciiStringReadBlockIntoBuffer(rbb, offset_ptr, max_chars);
} else {

View File

@ -7220,13 +7220,13 @@ class String: public HeapObject {
// be ASCII encoded. This might be the case even if the string is
// two-byte. Such strings may appear when the embedder prefers
// two-byte external representations even for ASCII data.
inline bool IsAsciiRepresentation();
inline bool IsOneByteRepresentation();
inline bool IsTwoByteRepresentation();
// Cons and slices have an encoding flag that may not represent the actual
// encoding of the underlying string. This is taken into account here.
// Requires: this->IsFlat()
inline bool IsAsciiRepresentationUnderneath();
inline bool IsOneByteRepresentationUnderneath();
inline bool IsTwoByteRepresentationUnderneath();
// NOTE: this should be considered only a hint. False negatives are

View File

@ -77,7 +77,7 @@ const byte* NativeRegExpMacroAssembler::StringCharacterPosition(
ASSERT(subject->IsExternalString() || subject->IsSeqString());
ASSERT(start_index >= 0);
ASSERT(start_index <= subject->length());
if (subject->IsAsciiRepresentation()) {
if (subject->IsOneByteRepresentation()) {
const byte* address;
if (StringShape(subject).IsExternal()) {
const char* data = ExternalAsciiString::cast(subject)->GetChars();
@ -133,7 +133,7 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match(
slice_offset = slice->offset();
}
// Ensure that an underlying string has the same ASCII-ness.
bool is_ascii = subject_ptr->IsAsciiRepresentation();
bool is_ascii = subject_ptr->IsOneByteRepresentation();
ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
// String is now either Sequential or External
int char_size_shift = is_ascii ? 0 : 1;

View File

@ -2353,7 +2353,7 @@ class ReplacementStringBuilder {
array_builder_(heap->isolate(), estimated_part_count),
subject_(subject),
character_count_(0),
is_ascii_(subject->IsAsciiRepresentation()) {
is_ascii_(subject->IsOneByteRepresentation()) {
// Require a non-zero initial size. Ensures that doubling the size to
// extend the array will work.
ASSERT(estimated_part_count > 0);
@ -2393,7 +2393,7 @@ class ReplacementStringBuilder {
int length = string->length();
ASSERT(length > 0);
AddElement(*string);
if (!string->IsAsciiRepresentation()) {
if (!string->IsOneByteRepresentation()) {
is_ascii_ = false;
}
IncrementCharacterCount(length);
@ -3760,7 +3760,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) {
}
char* str = DoubleToRadixCString(value, radix);
MaybeObject* result =
isolate->heap()->AllocateStringFromAscii(CStrVector(str));
isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
DeleteArray(str);
return result;
}
@ -3785,7 +3785,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) {
RUNTIME_ASSERT(f >= 0);
char* str = DoubleToFixedCString(value, f);
MaybeObject* res =
isolate->heap()->AllocateStringFromAscii(CStrVector(str));
isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
DeleteArray(str);
return res;
}
@ -3810,7 +3810,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) {
RUNTIME_ASSERT(f >= -1 && f <= 20);
char* str = DoubleToExponentialCString(value, f);
MaybeObject* res =
isolate->heap()->AllocateStringFromAscii(CStrVector(str));
isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
DeleteArray(str);
return res;
}
@ -3835,7 +3835,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) {
RUNTIME_ASSERT(f >= 1 && f <= 21);
char* str = DoubleToPrecisionCString(value, f);
MaybeObject* res =
isolate->heap()->AllocateStringFromAscii(CStrVector(str));
isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
DeleteArray(str);
return res;
}
@ -5088,7 +5088,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) {
MaybeObject* maybe_object = NULL;
if (i == length) { // The string is ASCII.
maybe_object = isolate->heap()->AllocateRawAsciiString(length);
maybe_object = isolate->heap()->AllocateRawOneByteString(length);
} else { // The string is not ASCII.
maybe_object = isolate->heap()->AllocateRawTwoByteString(length);
}
@ -5182,7 +5182,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) {
}
Object* o;
{ MaybeObject* maybe_o =
isolate->heap()->AllocateRawAsciiString(escaped_length);
isolate->heap()->AllocateRawOneByteString(escaped_length);
if (!maybe_o->ToObject(&o)) return maybe_o;
}
String* destination = String::cast(o);
@ -5290,7 +5290,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) {
Object* o;
{ MaybeObject* maybe_o =
ascii ?
isolate->heap()->AllocateRawAsciiString(unescaped_length) :
isolate->heap()->AllocateRawOneByteString(unescaped_length) :
isolate->heap()->AllocateRawTwoByteString(unescaped_length);
if (!maybe_o->ToObject(&o)) return maybe_o;
}
@ -5389,7 +5389,7 @@ MaybeObject* AllocateRawString<SeqTwoByteString>(Isolate* isolate, int length) {
template <>
MaybeObject* AllocateRawString<SeqOneByteString>(Isolate* isolate, int length) {
return isolate->heap()->AllocateRawAsciiString(length);
return isolate->heap()->AllocateRawOneByteString(length);
}
@ -5720,8 +5720,8 @@ MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
// might break in the future if we implement more context and locale
// dependent upper/lower conversions.
Object* o;
{ MaybeObject* maybe_o = s->IsAsciiRepresentation()
? isolate->heap()->AllocateRawAsciiString(length)
{ MaybeObject* maybe_o = s->IsOneByteRepresentation()
? isolate->heap()->AllocateRawOneByteString(length)
: isolate->heap()->AllocateRawTwoByteString(length);
if (!maybe_o->ToObject(&o)) return maybe_o;
}
@ -5954,7 +5954,7 @@ MUST_USE_RESULT static MaybeObject* ConvertCase(
// dependent upper/lower conversions.
if (s->IsSeqOneByteString()) {
Object* o;
{ MaybeObject* maybe_o = isolate->heap()->AllocateRawAsciiString(length);
{ MaybeObject* maybe_o = isolate->heap()->AllocateRawOneByteString(length);
if (!maybe_o->ToObject(&o)) return maybe_o;
}
SeqOneByteString* result = SeqOneByteString::cast(o);
@ -6161,7 +6161,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) {
Handle<FixedArray> elements;
int position = 0;
if (s->IsFlat() && s->IsAsciiRepresentation()) {
if (s->IsFlat() && s->IsOneByteRepresentation()) {
// Try using cached chars where possible.
Object* obj;
{ MaybeObject* maybe_obj =
@ -6534,7 +6534,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
if (ascii) {
{ MaybeObject* maybe_object =
isolate->heap()->AllocateRawAsciiString(length);
isolate->heap()->AllocateRawOneByteString(length);
if (!maybe_object->ToObject(&object)) return maybe_object;
}
SeqOneByteString* answer = SeqOneByteString::cast(object);
@ -6696,7 +6696,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
// Find total length of join result.
int string_length = 0;
bool is_ascii = separator->IsAsciiRepresentation();
bool is_ascii = separator->IsOneByteRepresentation();
int max_string_length;
if (is_ascii) {
max_string_length = SeqOneByteString::kMaxLength;
@ -6713,7 +6713,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
RUNTIME_ASSERT(elements->get(i + 1)->IsString());
String* string = String::cast(elements->get(i + 1));
int length = string->length();
if (is_ascii && !string->IsAsciiRepresentation()) {
if (is_ascii && !string->IsOneByteRepresentation()) {
is_ascii = false;
max_string_length = SeqTwoByteString::kMaxLength;
}
@ -6749,7 +6749,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) {
if (is_ascii) {
MaybeObject* result_allocation =
isolate->heap()->AllocateRawAsciiString(string_length);
isolate->heap()->AllocateRawOneByteString(string_length);
if (result_allocation->IsFailure()) return result_allocation;
SeqOneByteString* result_string =
SeqOneByteString::cast(result_allocation->ToObjectUnchecked());
@ -12930,7 +12930,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) {
const char* version_string = v8::V8::GetVersion();
return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string),
return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string),
NOT_TENURED);
}

View File

@ -1305,7 +1305,7 @@ int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address,
Handle<String> subject(frame_entry<String*>(re_frame, kInputString));
// Current string.
bool is_ascii = subject->IsAsciiRepresentationUnderneath();
bool is_ascii = subject->IsOneByteRepresentationUnderneath();
ASSERT(re_code->instruction_start() <= *return_address);
ASSERT(*return_address <=
@ -1336,7 +1336,7 @@ int RegExpMacroAssemblerX64::CheckStackGuardState(Address* return_address,
}
// String might have changed.
if (subject_tmp->IsAsciiRepresentation() != is_ascii) {
if (subject_tmp->IsOneByteRepresentation() != is_ascii) {
// If we changed between an ASCII and an UC16 string, the specialized
// code cannot be used, and we need to restart regexp matching from
// scratch (including, potentially, compiling a new version of the code).

View File

@ -66,7 +66,7 @@ static MaybeObject* AllocateAfterFailures() {
// Old data space.
SimulateFullSpace(heap->old_data_space());
CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure());
CHECK(!heap->AllocateRawOneByteString(100, TENURED)->IsFailure());
// Old pointer space.
SimulateFullSpace(heap->old_pointer_space());

View File

@ -12626,7 +12626,7 @@ static void MorphAString(i::String* string,
AsciiVectorResource* ascii_resource,
UC16VectorResource* uc16_resource) {
CHECK(i::StringShape(string).IsExternal());
if (string->IsAsciiRepresentation()) {
if (string->IsOneByteRepresentation()) {
// Check old map is not symbol or long.
CHECK(string->map() == HEAP->external_ascii_string_map());
// Morph external string to be TwoByte string.
@ -15785,13 +15785,13 @@ THREADED_TEST(TwoByteStringInAsciiCons) {
CHECK(result->IsString());
i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result));
int length = string->length();
CHECK(string->IsAsciiRepresentation());
CHECK(string->IsOneByteRepresentation());
FlattenString(string);
i::Handle<i::String> flat_string = FlattenGetString(string);
CHECK(string->IsAsciiRepresentation());
CHECK(flat_string->IsAsciiRepresentation());
CHECK(string->IsOneByteRepresentation());
CHECK(flat_string->IsOneByteRepresentation());
// Create external resource.
uint16_t* uc16_buffer = new uint16_t[length + 1];
@ -15810,7 +15810,7 @@ THREADED_TEST(TwoByteStringInAsciiCons) {
// ASCII characters). This is a valid sequence of steps, and it can happen
// in real pages.
CHECK(string->IsAsciiRepresentation());
CHECK(string->IsOneByteRepresentation());
i::ConsString* cons = i::ConsString::cast(*string);
CHECK_EQ(0, cons->second()->length());
CHECK(cons->first()->IsTwoByteRepresentation());