From: yangguo@chromium.org Date: Wed, 10 Sep 2014 12:38:12 +0000 (+0000) Subject: Rename ascii to one-byte where applicable. X-Git-Tag: upstream/4.7.83~7010 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e670fd05e439145b3f46dd2c54d332044a72954;p=platform%2Fupstream%2Fv8.git Rename ascii to one-byte where applicable. R=dcarney@chromium.org, marja@chromium.org Review URL: https://codereview.chromium.org/559913002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23840 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8.h b/include/v8.h index 2eaae7d..d6fbf67 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1648,7 +1648,7 @@ class V8_EXPORT String : public Name { enum Encoding { UNKNOWN_ENCODING = 0x1, TWO_BYTE_ENCODING = 0x0, - ASCII_ENCODING = 0x4, + ASCII_ENCODING = 0x4, // TODO(yangguo): deprecate this. ONE_BYTE_ENCODING = 0x4 }; /** @@ -1704,7 +1704,8 @@ class V8_EXPORT String : public Name { NO_OPTIONS = 0, HINT_MANY_WRITES_EXPECTED = 1, NO_NULL_TERMINATION = 2, - PRESERVE_ASCII_NULL = 4, + PRESERVE_ASCII_NULL = 4, // TODO(yangguo): deprecate this. + PRESERVE_ONE_BYTE_NULL = 4, // Used by WriteUtf8 to replace orphan surrogate code units with the // unicode replacement character. Needs to be set to guarantee valid UTF-8 // output. @@ -1738,9 +1739,12 @@ class V8_EXPORT String : public Name { bool IsExternal() const; /** - * Returns true if the string is both external and ASCII + * Returns true if the string is both external and one-byte. */ - bool IsExternalAscii() const; + bool IsExternalOneByte() const; + + // TODO(yangguo): deprecate this. + bool IsExternalAscii() const { return IsExternalOneByte(); } class V8_EXPORT ExternalStringResourceBase { // NOLINT public: @@ -1795,33 +1799,32 @@ class V8_EXPORT String : public Name { }; /** - * An ExternalAsciiStringResource is a wrapper around an ASCII + * An ExternalOneByteStringResource is a wrapper around an one-byte * string buffer that resides outside V8's heap. Implement an - * ExternalAsciiStringResource to manage the life cycle of the + * ExternalOneByteStringResource to manage the life cycle of the * underlying buffer. Note that the string data must be immutable - * and that the data must be strict (7-bit) ASCII, not Latin-1 or - * UTF-8, which would require special treatment internally in the - * engine and, in the case of UTF-8, do not allow efficient indexing. - * Use String::New or convert to 16 bit data for non-ASCII. + * and that the data must be Latin-1 and not UTF-8, which would require + * special treatment internally in the engine and do not allow efficient + * indexing. Use String::New or convert to 16 bit data for non-Latin1. */ - class V8_EXPORT ExternalAsciiStringResource + class V8_EXPORT ExternalOneByteStringResource : public ExternalStringResourceBase { public: /** * Override the destructor to manage the life cycle of the underlying * buffer. */ - virtual ~ExternalAsciiStringResource() {} + virtual ~ExternalOneByteStringResource() {} /** The string data from the underlying buffer.*/ virtual const char* data() const = 0; - /** The number of ASCII characters in the string.*/ + /** The number of Latin-1 characters in the string.*/ virtual size_t length() const = 0; protected: - ExternalAsciiStringResource() {} + ExternalOneByteStringResource() {} }; - typedef ExternalAsciiStringResource ExternalOneByteStringResource; + typedef ExternalOneByteStringResource ExternalAsciiStringResource; /** * If the string is an external string, return the ExternalStringResourceBase @@ -1838,10 +1841,15 @@ class V8_EXPORT String : public Name { V8_INLINE ExternalStringResource* GetExternalStringResource() const; /** - * Get the ExternalAsciiStringResource for an external ASCII string. - * Returns NULL if IsExternalAscii() doesn't return true. + * Get the ExternalOneByteStringResource for an external one-byte string. + * Returns NULL if IsExternalOneByte() doesn't return true. */ - const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; + const ExternalOneByteStringResource* GetExternalOneByteStringResource() const; + + // TODO(yangguo): deprecate this. + const ExternalAsciiStringResource* GetExternalAsciiStringResource() const { + return GetExternalOneByteStringResource(); + } V8_INLINE static String* Cast(v8::Value* obj); @@ -1898,7 +1906,7 @@ class V8_EXPORT String : public Name { bool MakeExternal(ExternalStringResource* resource); /** - * Creates a new external string using the ASCII data defined in the given + * Creates a new external string using the one-byte data defined in the given * resource. When the external string is no longer live on V8's heap the * resource will be disposed by calling its Dispose method. The caller of * this function should not otherwise delete or modify the resource. Neither @@ -1906,7 +1914,7 @@ class V8_EXPORT String : public Name { * destructor of the external string resource. */ static Local NewExternal(Isolate* isolate, - ExternalAsciiStringResource* resource); + ExternalOneByteStringResource* resource); /** * Associate an external string resource with this string by transforming it @@ -1917,7 +1925,7 @@ class V8_EXPORT String : public Name { * The string is not modified if the operation fails. See NewExternal for * information on the lifetime of the resource. */ - bool MakeExternal(ExternalAsciiStringResource* resource); + bool MakeExternal(ExternalOneByteStringResource* resource); /** * Returns true if this string can be made external. @@ -3874,11 +3882,11 @@ class V8_EXPORT TypeSwitch : public Data { // --- Extensions --- -class V8_EXPORT ExternalAsciiStringResourceImpl - : public String::ExternalAsciiStringResource { +class V8_EXPORT ExternalOneByteStringResourceImpl + : public String::ExternalOneByteStringResource { public: - ExternalAsciiStringResourceImpl() : data_(0), length_(0) {} - ExternalAsciiStringResourceImpl(const char* data, size_t length) + ExternalOneByteStringResourceImpl() : data_(0), length_(0) {} + ExternalOneByteStringResourceImpl(const char* data, size_t length) : data_(data), length_(length) {} const char* data() const { return data_; } size_t length() const { return length_; } @@ -3908,7 +3916,7 @@ class V8_EXPORT Extension { // NOLINT const char* name() const { return name_; } size_t source_length() const { return source_length_; } - const String::ExternalAsciiStringResource* source() const { + const String::ExternalOneByteStringResource* source() const { return &source_; } int dependency_count() { return dep_count_; } const char** dependencies() { return deps_; } @@ -3918,7 +3926,7 @@ class V8_EXPORT Extension { // NOLINT private: const char* name_; size_t source_length_; // expected to initialize before source_ - ExternalAsciiStringResourceImpl source_; + ExternalOneByteStringResourceImpl source_; int dep_count_; const char** deps_; bool auto_enable_; @@ -5681,7 +5689,7 @@ class Internals { static const int kFullStringRepresentationMask = 0x07; static const int kStringEncodingMask = 0x4; static const int kExternalTwoByteRepresentationTag = 0x02; - static const int kExternalAsciiRepresentationTag = 0x06; + static const int kExternalOneByteRepresentationTag = 0x06; static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; static const int kAmountOfExternalAllocatedMemoryOffset = @@ -6352,7 +6360,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase( int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; *encoding_out = static_cast(type & I::kStringEncodingMask); ExternalStringResourceBase* resource = NULL; - if (type == I::kExternalAsciiRepresentationTag || + if (type == I::kExternalOneByteRepresentationTag || type == I::kExternalTwoByteRepresentationTag) { void* value = I::ReadField(obj, I::kStringResourceOffset); resource = static_cast(value); diff --git a/src/accessors.cc b/src/accessors.cc index a1a89d3..011372c 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -358,7 +358,7 @@ void Accessors::ScriptColumnOffsetSetter( Handle Accessors::ScriptColumnOffsetInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("column_offset"))); + STATIC_CHAR_VECTOR("column_offset"))); return MakeAccessor(isolate, name, &ScriptColumnOffsetGetter, @@ -394,8 +394,8 @@ void Accessors::ScriptIdSetter( Handle Accessors::ScriptIdInfo( Isolate* isolate, PropertyAttributes attributes) { - Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("id"))); + Handle name( + isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("id"))); return MakeAccessor(isolate, name, &ScriptIdGetter, @@ -502,7 +502,7 @@ void Accessors::ScriptLineOffsetSetter( Handle Accessors::ScriptLineOffsetInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("line_offset"))); + STATIC_CHAR_VECTOR("line_offset"))); return MakeAccessor(isolate, name, &ScriptLineOffsetGetter, @@ -538,8 +538,8 @@ void Accessors::ScriptTypeSetter( Handle Accessors::ScriptTypeInfo( Isolate* isolate, PropertyAttributes attributes) { - Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("type"))); + Handle name( + isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("type"))); return MakeAccessor(isolate, name, &ScriptTypeGetter, @@ -577,7 +577,7 @@ void Accessors::ScriptCompilationTypeSetter( Handle Accessors::ScriptCompilationTypeInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("compilation_type"))); + STATIC_CHAR_VECTOR("compilation_type"))); return MakeAccessor(isolate, name, &ScriptCompilationTypeGetter, @@ -622,7 +622,7 @@ void Accessors::ScriptLineEndsSetter( Handle Accessors::ScriptLineEndsInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("line_ends"))); + STATIC_CHAR_VECTOR("line_ends"))); return MakeAccessor(isolate, name, &ScriptLineEndsGetter, @@ -730,7 +730,7 @@ void Accessors::ScriptContextDataSetter( Handle Accessors::ScriptContextDataInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("context_data"))); + STATIC_CHAR_VECTOR("context_data"))); return MakeAccessor(isolate, name, &ScriptContextDataGetter, @@ -777,7 +777,7 @@ void Accessors::ScriptEvalFromScriptSetter( Handle Accessors::ScriptEvalFromScriptInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("eval_from_script"))); + STATIC_CHAR_VECTOR("eval_from_script"))); return MakeAccessor(isolate, name, &ScriptEvalFromScriptGetter, @@ -823,7 +823,7 @@ void Accessors::ScriptEvalFromScriptPositionSetter( Handle Accessors::ScriptEvalFromScriptPositionInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("eval_from_script_position"))); + STATIC_CHAR_VECTOR("eval_from_script_position"))); return MakeAccessor(isolate, name, &ScriptEvalFromScriptPositionGetter, @@ -869,7 +869,7 @@ void Accessors::ScriptEvalFromFunctionNameSetter( Handle Accessors::ScriptEvalFromFunctionNameInfo( Isolate* isolate, PropertyAttributes attributes) { Handle name(isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("eval_from_function_name"))); + STATIC_CHAR_VECTOR("eval_from_function_name"))); return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, diff --git a/src/api.cc b/src/api.cc index 06a8f79..4e10def 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4079,7 +4079,7 @@ Handle Function::GetDisplayName() const { i::Handle func = Utils::OpenHandle(this); i::Handle property_name = isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("displayName")); + STATIC_CHAR_VECTOR("displayName")); i::Handle value = i::JSObject::GetDataProperty(func, property_name); @@ -4317,7 +4317,7 @@ class Utf8LengthHelper : public i::AllStatic { void VisitOneByteString(const uint8_t* chars, int length) { int utf8_length = 0; - // Add in length 1 for each non-ASCII character. + // Add in length 1 for each non-Latin1 character. for (int i = 0; i < length; i++) { utf8_length += *chars++ >> 7; } @@ -4719,7 +4719,7 @@ int String::WriteUtf8(char* buffer, // First check that the buffer is large enough. int utf8_bytes = v8::Utf8Length(*str, str->GetIsolate()); if (utf8_bytes <= capacity) { - // ASCII fast path. + // one-byte fast path. if (utf8_bytes == string_length) { WriteOneByte(reinterpret_cast(buffer), 0, capacity, options); if (nchars_ref != NULL) *nchars_ref = string_length; @@ -4798,9 +4798,9 @@ bool v8::String::IsExternal() const { } -bool v8::String::IsExternalAscii() const { +bool v8::String::IsExternalOneByte() const { i::Handle str = Utils::OpenHandle(this); - return i::StringShape(*str).IsExternalAscii(); + return i::StringShape(*str).IsExternalOneByte(); } @@ -4823,11 +4823,11 @@ void v8::String::VerifyExternalStringResourceBase( i::Handle str = Utils::OpenHandle(this); const v8::String::ExternalStringResourceBase* expected; Encoding expectedEncoding; - if (i::StringShape(*str).IsExternalAscii()) { + if (i::StringShape(*str).IsExternalOneByte()) { const void* resource = - i::Handle::cast(str)->resource(); + i::Handle::cast(str)->resource(); expected = reinterpret_cast(resource); - expectedEncoding = ASCII_ENCODING; + expectedEncoding = ONE_BYTE_ENCODING; } else if (i::StringShape(*str).IsExternalTwoByte()) { const void* resource = i::Handle::cast(str)->resource(); @@ -4835,20 +4835,20 @@ void v8::String::VerifyExternalStringResourceBase( expectedEncoding = TWO_BYTE_ENCODING; } else { expected = NULL; - expectedEncoding = str->IsOneByteRepresentation() ? ASCII_ENCODING - : TWO_BYTE_ENCODING; + expectedEncoding = + str->IsOneByteRepresentation() ? ONE_BYTE_ENCODING : TWO_BYTE_ENCODING; } CHECK_EQ(expected, value); CHECK_EQ(expectedEncoding, encoding); } -const v8::String::ExternalAsciiStringResource* -v8::String::GetExternalAsciiStringResource() const { +const v8::String::ExternalOneByteStringResource* +v8::String::GetExternalOneByteStringResource() const { i::Handle str = Utils::OpenHandle(this); - if (i::StringShape(*str).IsExternalAscii()) { + if (i::StringShape(*str).IsExternalOneByte()) { const void* resource = - i::Handle::cast(str)->resource(); - return reinterpret_cast(resource); + i::Handle::cast(str)->resource(); + return reinterpret_cast(resource); } else { return NULL; } @@ -5470,12 +5470,12 @@ static i::Handle NewExternalStringHandle( } -static i::Handle NewExternalAsciiStringHandle( - i::Isolate* isolate, - v8::String::ExternalAsciiStringResource* resource) { +static i::Handle NewExternalOneByteStringHandle( + i::Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { // We do not expect this to fail. Change this if it does. - return isolate->factory()->NewExternalStringFromAscii( - resource).ToHandleChecked(); + return isolate->factory() + ->NewExternalStringFromOneByte(resource) + .ToHandleChecked(); } @@ -5520,22 +5520,21 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { Local v8::String::NewExternal( - Isolate* isolate, - v8::String::ExternalAsciiStringResource* resource) { + Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { i::Isolate* i_isolate = reinterpret_cast(isolate); EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); LOG_API(i_isolate, "String::NewExternal"); ENTER_V8(i_isolate); CHECK(resource && resource->data()); i::Handle result = - NewExternalAsciiStringHandle(i_isolate, resource); + NewExternalOneByteStringHandle(i_isolate, resource); i_isolate->heap()->external_string_table()->AddString(*result); return Utils::ToLocal(result); } bool v8::String::MakeExternal( - v8::String::ExternalAsciiStringResource* resource) { + v8::String::ExternalOneByteStringResource* resource) { i::Handle obj = Utils::OpenHandle(this); i::Isolate* isolate = obj->GetIsolate(); if (i::StringShape(*obj).IsExternal()) { @@ -6944,7 +6943,7 @@ Local Debug::GetMirror(v8::Handle obj) { i::Handle debug( isolate_debug->debug_context()->global_object()); i::Handle name = isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("MakeMirror")); + STATIC_CHAR_VECTOR("MakeMirror")); i::Handle fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); i::Handle fun = i::Handle::cast(fun_obj); diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index f1e8c6d..3391686 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -688,19 +688,19 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) { masm, lhs, rhs, &flat_string_check, &slow); } - // Check for both being sequential ASCII strings, and inline if that is the - // case. + // Check for both being sequential one-byte strings, + // and inline if that is the case. __ bind(&flat_string_check); - __ JumpIfNonSmisNotBothSequentialAsciiStrings(lhs, rhs, r2, r3, &slow); + __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, r2, r3, &slow); __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, r2, r3); if (cc == eq) { - StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, r2, r3, r4); + StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, r2, r3, r4); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, r2, r3, r4, - r5); + StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, r2, r3, r4, + r5); } // Never falls through to here. @@ -2037,7 +2037,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { STATIC_ASSERT(kTwoByteStringTag == 0); __ and_(r0, r0, Operand(kStringEncodingMask)); __ mov(r3, Operand(r0, ASR, 2), SetCC); - __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne); + __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset), + ne); __ ldr(r6, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq); // (E) Carry on. String handling is done. @@ -2048,7 +2049,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ JumpIfSmi(r6, &runtime); // r1: previous index - // r3: encoding of subject string (1 if ASCII, 0 if two_byte); + // r3: encoding of subject string (1 if one_byte, 0 if two_byte); // r6: code // subject: Subject string // regexp_data: RegExp data (FixedArray) @@ -2091,7 +2092,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ str(r0, MemOperand(sp, 1 * kPointerSize)); // For arguments 4 and 3 get string length, calculate start of string data and - // calculate the shift of the index (0 for ASCII and 1 for two byte). + // calculate the shift of the index (0 for one-byte and 1 for two-byte). __ add(r7, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); __ eor(r3, r3, Operand(1)); // Load the length from the original subject string from the previous stack @@ -2724,11 +2725,6 @@ void CallICStub::GenerateMiss(MacroAssembler* masm, IC::UtilityId id) { // StringCharCodeAtGenerator void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { - Label flat_string; - Label ascii_string; - Label got_char_code; - Label sliced_string; - // If the receiver is a smi trigger the non-string case. __ JumpIfSmi(object_, receiver_not_string_); @@ -2827,7 +2823,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ b(ne, &slow_case_); __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); - // At this point code register contains smi tagged ASCII char code. + // At this point code register contains smi tagged one-byte char code. __ add(result_, result_, Operand::PointerOffsetFromSmiKey(code_)); __ ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); __ CompareRoot(result_, Heap::kUndefinedValueRootIndex); @@ -2853,10 +2849,7 @@ void StringCharFromCodeGenerator::GenerateSlow( } -enum CopyCharactersFlags { - COPY_ASCII = 1, - DEST_ALWAYS_ALIGNED = 2 -}; +enum CopyCharactersFlags { COPY_ONE_BYTE = 1, DEST_ALWAYS_ALIGNED = 2 }; void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, @@ -3017,7 +3010,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); __ tst(r1, Operand(kStringEncodingMask)); __ b(eq, &two_byte_slice); - __ AllocateAsciiSlicedString(r0, r2, r6, r4, &runtime); + __ AllocateOneByteSlicedString(r0, r2, r6, r4, &runtime); __ jmp(&set_slice_header); __ bind(&two_byte_slice); __ AllocateTwoByteSlicedString(r0, r2, r6, r4, &runtime); @@ -3060,8 +3053,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { __ tst(r1, Operand(kStringEncodingMask)); __ b(eq, &two_byte_sequential); - // Allocate and copy the resulting ASCII string. - __ AllocateAsciiString(r0, r2, r4, r6, r1, &runtime); + // Allocate and copy the resulting one-byte string. + __ AllocateOneByteString(r0, r2, r4, r6, r1, &runtime); // Locate first character of substring to copy. __ add(r5, r5, r3); @@ -3120,11 +3113,9 @@ void SubStringStub::Generate(MacroAssembler* masm) { } -void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, - Register left, Register right, - Register scratch1, - Register scratch2, - Register scratch3) { +void StringHelper::GenerateFlatOneByteStringEquals( + MacroAssembler* masm, Register left, Register right, Register scratch1, + Register scratch2, Register scratch3) { Register length = scratch1; // Compare lengths. @@ -3148,9 +3139,8 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, // Compare characters. __ bind(&compare_chars); - GenerateAsciiCharsCompareLoop(masm, - left, right, length, scratch2, scratch3, - &strings_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3, + &strings_not_equal); // Characters are equal. __ mov(r0, Operand(Smi::FromInt(EQUAL))); @@ -3158,7 +3148,7 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, } -void StringHelper::GenerateCompareFlatAsciiStrings( +void StringHelper::GenerateCompareFlatOneByteStrings( MacroAssembler* masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3, Register scratch4) { Label result_not_equal, compare_lengths; @@ -3174,9 +3164,8 @@ void StringHelper::GenerateCompareFlatAsciiStrings( __ b(eq, &compare_lengths); // Compare loop. - GenerateAsciiCharsCompareLoop(masm, - left, right, min_length, scratch2, scratch4, - &result_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, + scratch4, &result_not_equal); // Compare lengths - strings up to min-length are equal. __ bind(&compare_lengths); @@ -3192,7 +3181,7 @@ void StringHelper::GenerateCompareFlatAsciiStrings( } -void StringHelper::GenerateAsciiCharsCompareLoop( +void StringHelper::GenerateOneByteCharsCompareLoop( MacroAssembler* masm, Register left, Register right, Register length, Register scratch1, Register scratch2, Label* chars_not_equal) { // Change index to run from -length to -1 by adding length to string @@ -3240,13 +3229,13 @@ void StringCompareStub::Generate(MacroAssembler* masm) { __ bind(¬_same); - // Check that both objects are sequential ASCII strings. - __ JumpIfNotBothSequentialAsciiStrings(r1, r0, r2, r3, &runtime); + // Check that both objects are sequential one-byte strings. + __ JumpIfNotBothSequentialOneByteStrings(r1, r0, r2, r3, &runtime); - // Compare flat ASCII strings natively. Remove arguments from stack first. + // Compare flat one-byte strings natively. Remove arguments from stack first. __ IncrementCounter(counters->string_compare_native(), 1, r2, r3); __ add(sp, sp, Operand(2 * kPointerSize)); - StringHelper::GenerateCompareFlatAsciiStrings(masm, r1, r0, r2, r3, r4, r5); + StringHelper::GenerateCompareFlatOneByteStrings(masm, r1, r0, r2, r3, r4, r5); // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) // tagged as a small integer. @@ -3512,18 +3501,18 @@ void CompareICStub::GenerateStrings(MacroAssembler* masm) { __ Ret(eq); } - // Check that both strings are sequential ASCII. + // Check that both strings are sequential one-byte. Label runtime; - __ JumpIfBothInstanceTypesAreNotSequentialAscii( - tmp1, tmp2, tmp3, tmp4, &runtime); + __ JumpIfBothInstanceTypesAreNotSequentialOneByte(tmp1, tmp2, tmp3, tmp4, + &runtime); - // Compare flat ASCII strings. Returns when done. + // Compare flat one-byte strings. Returns when done. if (equality) { - StringHelper::GenerateFlatAsciiStringEquals(masm, left, right, tmp1, tmp2, - tmp3); + StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1, tmp2, + tmp3); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2, - tmp3, tmp4); + StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1, + tmp2, tmp3, tmp4); } // Handle more complex cases in runtime. diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index c8d30e7..e7f6610 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -25,31 +25,22 @@ class StringHelper : public AllStatic { Register scratch, String::Encoding encoding); - // Compares two flat ASCII strings and returns result in r0. - static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, - Register left, - Register right, + // Compares two flat one-byte strings and returns result in r0. + static void GenerateCompareFlatOneByteStrings( + MacroAssembler* masm, Register left, Register right, Register scratch1, + Register scratch2, Register scratch3, Register scratch4); + + // Compares two flat one-byte strings for equality and returns result in r0. + static void GenerateFlatOneByteStringEquals(MacroAssembler* masm, + Register left, Register right, Register scratch1, Register scratch2, - Register scratch3, - Register scratch4); - - // Compares two flat ASCII strings for equality and returns result in r0. - static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, - Register left, - Register right, - Register scratch1, - Register scratch2, - Register scratch3); + Register scratch3); private: - static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, - Register left, - Register right, - Register length, - Register scratch1, - Register scratch2, - Label* chars_not_equal); + static void GenerateOneByteCharsCompareLoop( + MacroAssembler* masm, Register left, Register right, Register length, + Register scratch1, Register scratch2, Label* chars_not_equal); DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); }; diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index cdc40a4..d050399 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -759,16 +759,16 @@ void StringCharLoadGenerator::Generate(MacroAssembler* masm, __ b(ne, call_runtime); __ ldr(string, FieldMemOperand(string, ExternalString::kResourceDataOffset)); - Label ascii, done; + Label one_byte, done; __ bind(&check_encoding); STATIC_ASSERT(kTwoByteStringTag == 0); __ tst(result, Operand(kStringEncodingMask)); - __ b(ne, &ascii); + __ b(ne, &one_byte); // Two-byte string. __ ldrh(result, MemOperand(string, index, LSL, 1)); __ jmp(&done); - __ bind(&ascii); - // Ascii string. + __ bind(&one_byte); + // One-byte string. __ ldrb(result, MemOperand(string, index)); __ bind(&done); } diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index f5dff15..dfd0e61 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -3823,7 +3823,7 @@ void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { } -void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { +void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) { Label bailout, done, one_char_separator, long_separator, non_trivial_array, not_size_one_array, loop, empty_separator_loop, one_char_separator_loop, one_char_separator_loop_entry, long_separator_loop; @@ -3870,7 +3870,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { __ ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset)); array = no_reg; // End of array's live range. - // Check that all array elements are sequential ASCII strings, and + // Check that all array elements are sequential one-byte strings, and // accumulate the sum of their lengths, as a smi-encoded value. __ mov(string_length, Operand::Zero()); __ add(element, @@ -3886,14 +3886,14 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // elements_end: Array end. if (generate_debug_code_) { __ cmp(array_length, Operand::Zero()); - __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); + __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin); } __ bind(&loop); __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); __ JumpIfSmi(string, &bailout); __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch, scratch, &bailout); __ ldr(scratch, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); __ add(string_length, string_length, Operand(scratch), SetCC); __ b(vs, &bailout); @@ -3914,11 +3914,11 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // string_length: Sum of string lengths (smi). // elements: FixedArray of strings. - // Check that the separator is a flat ASCII string. + // Check that the separator is a flat one-byte string. __ JumpIfSmi(separator, &bailout); __ ldr(scratch, FieldMemOperand(separator, HeapObject::kMapOffset)); __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch, scratch, &bailout); // Add (separator length times array_length) - separator length to the // string_length to get the length of the result string. array_length is not @@ -3947,12 +3947,10 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // separator: Separator string // string_length: Length of result string (not smi) // array_length: Length of the array. - __ AllocateAsciiString(result, - string_length, - scratch, - string, // used as scratch - elements_end, // used as scratch - &bailout); + __ AllocateOneByteString(result, string_length, scratch, + string, // used as scratch + elements_end, // used as scratch + &bailout); // Prepare for looping. Set up elements_end to end of the array. Set // result_pos to the position of the result where to write the first // character. @@ -3991,7 +3989,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // One-character separator case __ bind(&one_char_separator); - // Replace separator with its ASCII character value. + // Replace separator with its one-byte character value. __ ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); // Jump into the loop after the code that copies the separator, so the first // element is not preceded by a separator @@ -4002,7 +4000,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // result_pos: the position to which we are currently copying characters. // element: Current array element. // elements_end: Array end. - // separator: Single separator ASCII char (in lower byte). + // separator: Single separator one-byte char (in lower byte). // Copy the separator character to the result. __ strb(separator, MemOperand(result_pos, 1, PostIndex)); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index ab1e454..37e6d20 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2721,7 +2721,7 @@ void LCodeGen::EmitClassOfTest(Label* is_true, // Objects with a non-function constructor have class 'Object'. __ CompareObjectType(temp, temp2, temp2, JS_FUNCTION_TYPE); - if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Object"))) { + if (class_name->IsOneByteEqualTo(STATIC_CHAR_VECTOR("Object"))) { __ b(ne, is_true); } else { __ b(ne, is_false); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index f9d2fdd..92615e1 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -1990,12 +1990,10 @@ void MacroAssembler::AllocateTwoByteString(Register result, } -void MacroAssembler::AllocateAsciiString(Register result, - Register length, - Register scratch1, - Register scratch2, - Register scratch3, - Label* gc_required) { +void MacroAssembler::AllocateOneByteString(Register result, Register length, + Register scratch1, Register scratch2, + Register scratch3, + Label* gc_required) { // Calculate the number of bytes needed for the characters in the string while // observing object alignment. DCHECK((SeqOneByteString::kHeaderSize & kObjectAlignmentMask) == 0); @@ -2004,7 +2002,7 @@ void MacroAssembler::AllocateAsciiString(Register result, Operand(kObjectAlignmentMask + SeqOneByteString::kHeaderSize)); and_(scratch1, scratch1, Operand(~kObjectAlignmentMask)); - // Allocate ASCII string in new space. + // Allocate one-byte string in new space. Allocate(scratch1, result, scratch2, @@ -2013,11 +2011,8 @@ void MacroAssembler::AllocateAsciiString(Register result, TAG_OBJECT); // Set the map, length and hash field. - InitializeNewString(result, - length, - Heap::kAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -2037,11 +2032,10 @@ void MacroAssembler::AllocateTwoByteConsString(Register result, } -void MacroAssembler::AllocateAsciiConsString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required) { +void MacroAssembler::AllocateOneByteConsString(Register result, Register length, + Register scratch1, + Register scratch2, + Label* gc_required) { Allocate(ConsString::kSize, result, scratch1, @@ -2049,11 +2043,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kConsAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -2073,19 +2064,16 @@ void MacroAssembler::AllocateTwoByteSlicedString(Register result, } -void MacroAssembler::AllocateAsciiSlicedString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required) { +void MacroAssembler::AllocateOneByteSlicedString(Register result, + Register length, + Register scratch1, + Register scratch2, + Label* gc_required) { Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kSlicedAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -3184,39 +3172,30 @@ void MacroAssembler::LookupNumberStringCache(Register object, } -void MacroAssembler::JumpIfNonSmisNotBothSequentialAsciiStrings( - Register first, - Register second, - Register scratch1, - Register scratch2, +void MacroAssembler::JumpIfNonSmisNotBothSequentialOneByteStrings( + Register first, Register second, Register scratch1, Register scratch2, Label* failure) { - // Test that both first and second are sequential ASCII strings. + // Test that both first and second are sequential one-byte strings. // Assume that they are non-smis. ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); - JumpIfBothInstanceTypesAreNotSequentialAscii(scratch1, - scratch2, - scratch1, - scratch2, - failure); + JumpIfBothInstanceTypesAreNotSequentialOneByte(scratch1, scratch2, scratch1, + scratch2, failure); } -void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure) { +void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register first, + Register second, + Register scratch1, + Register scratch2, + Label* failure) { // Check that neither is a smi. and_(scratch1, first, Operand(second)); JumpIfSmi(scratch1, failure); - JumpIfNonSmisNotBothSequentialAsciiStrings(first, - second, - scratch1, - scratch2, - failure); + JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, + scratch2, failure); } @@ -3386,34 +3365,31 @@ void MacroAssembler::RestoreFPRegs(Register location, Register scratch) { } -void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii( - Register first, - Register second, - Register scratch1, - Register scratch2, +void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte( + Register first, Register second, Register scratch1, Register scratch2, Label* failure) { - const int kFlatAsciiStringMask = + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - and_(scratch1, first, Operand(kFlatAsciiStringMask)); - and_(scratch2, second, Operand(kFlatAsciiStringMask)); - cmp(scratch1, Operand(kFlatAsciiStringTag)); + and_(scratch1, first, Operand(kFlatOneByteStringMask)); + and_(scratch2, second, Operand(kFlatOneByteStringMask)); + cmp(scratch1, Operand(kFlatOneByteStringTag)); // Ignore second test if first test failed. - cmp(scratch2, Operand(kFlatAsciiStringTag), eq); + cmp(scratch2, Operand(kFlatOneByteStringTag), eq); b(ne, failure); } -void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(Register type, - Register scratch, - Label* failure) { - const int kFlatAsciiStringMask = +void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(Register type, + Register scratch, + Label* failure) { + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - and_(scratch, type, Operand(kFlatAsciiStringMask)); - cmp(scratch, Operand(kFlatAsciiStringTag)); + and_(scratch, type, Operand(kFlatOneByteStringMask)); + cmp(scratch, Operand(kFlatOneByteStringTag)); b(ne, failure); } @@ -3827,8 +3803,8 @@ void MacroAssembler::EnsureNotWhite( mov(length, Operand(ExternalString::kSize), LeaveCC, ne); b(ne, &is_data_object); - // Sequential string, either ASCII or UC16. - // For ASCII (char-size of 1) we shift the smi tag away to get the length. + // Sequential string, either Latin1 or UC16. + // For Latin1 (char-size of 1) we shift the smi tag away to get the length. // For UC16 (char-size of 2) we just leave the smi tag in place, thereby // getting the length multiplied by 2. DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4); diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index f6673ca..057591a 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -753,32 +753,25 @@ class MacroAssembler: public Assembler { Register scratch2, Register scratch3, Label* gc_required); - void AllocateAsciiString(Register result, - Register length, - Register scratch1, - Register scratch2, - Register scratch3, - Label* gc_required); + void AllocateOneByteString(Register result, Register length, + Register scratch1, Register scratch2, + Register scratch3, Label* gc_required); void AllocateTwoByteConsString(Register result, Register length, Register scratch1, Register scratch2, Label* gc_required); - void AllocateAsciiConsString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required); + void AllocateOneByteConsString(Register result, Register length, + Register scratch1, Register scratch2, + Label* gc_required); void AllocateTwoByteSlicedString(Register result, Register length, Register scratch1, Register scratch2, Label* gc_required); - void AllocateAsciiSlicedString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required); + void AllocateOneByteSlicedString(Register result, Register length, + Register scratch1, Register scratch2, + Label* gc_required); // Allocates a heap number or jumps to the gc_required label if the young // space is full and a scavenge is needed. All registers are clobbered also @@ -1321,36 +1314,31 @@ class MacroAssembler: public Assembler { Register scratch3, Label* not_found); - // Checks if both objects are sequential ASCII strings and jumps to label + // Checks if both objects are sequential one-byte strings and jumps to label // if either is not. Assumes that neither object is a smi. - void JumpIfNonSmisNotBothSequentialAsciiStrings(Register object1, - Register object2, - Register scratch1, - Register scratch2, - Label* failure); + void JumpIfNonSmisNotBothSequentialOneByteStrings(Register object1, + Register object2, + Register scratch1, + Register scratch2, + Label* failure); - // Checks if both objects are sequential ASCII strings and jumps to label + // Checks if both objects are sequential one-byte strings and jumps to label // if either is not. - void JumpIfNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* not_flat_ascii_strings); + void JumpIfNotBothSequentialOneByteStrings(Register first, Register second, + Register scratch1, + Register scratch2, + Label* not_flat_one_byte_strings); - // Checks if both instance types are sequential ASCII strings and jumps to + // Checks if both instance types are sequential one-byte strings and jumps to // label if either is not. - void JumpIfBothInstanceTypesAreNotSequentialAscii( - Register first_object_instance_type, - Register second_object_instance_type, - Register scratch1, - Register scratch2, - Label* failure); - - // Check if instance type is sequential ASCII string and jump to label if + void JumpIfBothInstanceTypesAreNotSequentialOneByte( + Register first_object_instance_type, Register second_object_instance_type, + Register scratch1, Register scratch2, Label* failure); + + // Check if instance type is sequential one-byte string and jump to label if // it is not. - void JumpIfInstanceTypeIsNotSequentialAscii(Register type, - Register scratch, - Label* failure); + void JumpIfInstanceTypeIsNotSequentialOneByte(Register type, Register scratch, + Label* failure); void JumpIfNotUniqueName(Register reg, Label* not_unique_name); diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc index 8480f45..f4918fe 100644 --- a/src/arm/regexp-macro-assembler-arm.cc +++ b/src/arm/regexp-macro-assembler-arm.cc @@ -238,7 +238,7 @@ void RegExpMacroAssemblerARM::CheckNotBackReferenceIgnoreCase( __ cmn(r1, Operand(current_input_offset())); BranchOrBacktrack(gt, on_no_match); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { Label success; Label fail; Label loop_check; @@ -354,7 +354,7 @@ void RegExpMacroAssemblerARM::CheckNotBackReference( Label loop; __ bind(&loop); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ ldrb(r3, MemOperand(r0, char_size(), PostIndex)); __ ldrb(r4, MemOperand(r2, char_size(), PostIndex)); } else { @@ -443,7 +443,7 @@ void RegExpMacroAssemblerARM::CheckBitInTable( Handle table, Label* on_bit_set) { __ mov(r0, Operand(table)); - if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) { + if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { __ and_(r1, current_character(), Operand(kTableSize - 1)); __ add(r1, r1, Operand(ByteArray::kHeaderSize - kHeapObjectTag)); } else { @@ -464,7 +464,7 @@ bool RegExpMacroAssemblerARM::CheckSpecialCharacterClass(uc16 type, switch (type) { case 's': // Match space-characters - if (mode_ == ASCII) { + if (mode_ == LATIN1) { // One byte space characters are '\t'..'\r', ' ' and \u00a0. Label success; __ cmp(current_character(), Operand(' ')); @@ -518,7 +518,7 @@ bool RegExpMacroAssemblerARM::CheckSpecialCharacterClass(uc16 type, // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c __ sub(r0, r0, Operand(0x0b)); __ cmp(r0, Operand(0x0c - 0x0b)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { BranchOrBacktrack(hi, on_no_match); } else { Label done; @@ -534,8 +534,8 @@ bool RegExpMacroAssemblerARM::CheckSpecialCharacterClass(uc16 type, return true; } case 'w': { - if (mode_ != ASCII) { - // Table is 128 entries, so all ASCII characters can be tested. + if (mode_ != LATIN1) { + // Table is 256 entries, so all Latin1 characters can be tested. __ cmp(current_character(), Operand('z')); BranchOrBacktrack(hi, on_no_match); } @@ -548,8 +548,8 @@ bool RegExpMacroAssemblerARM::CheckSpecialCharacterClass(uc16 type, } case 'W': { Label done; - if (mode_ != ASCII) { - // Table is 128 entries, so all ASCII characters can be tested. + if (mode_ != LATIN1) { + // Table is 256 entries, so all Latin1 characters can be tested. __ cmp(current_character(), Operand('z')); __ b(hi, &done); } @@ -558,7 +558,7 @@ bool RegExpMacroAssemblerARM::CheckSpecialCharacterClass(uc16 type, __ ldrb(r0, MemOperand(r0, current_character())); __ cmp(r0, Operand::Zero()); BranchOrBacktrack(ne, on_no_match); - if (mode_ != ASCII) { + if (mode_ != LATIN1) { __ bind(&done); } return true; @@ -1067,7 +1067,7 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address, Handle subject(frame_entry(re_frame, kInputString)); // Current string. - bool is_ascii = subject->IsOneByteRepresentationUnderneath(); + bool is_one_byte = subject->IsOneByteRepresentationUnderneath(); DCHECK(re_code->instruction_start() <= *return_address); DCHECK(*return_address <= @@ -1098,8 +1098,8 @@ int RegExpMacroAssemblerARM::CheckStackGuardState(Address* return_address, } // String might have changed. - if (subject_tmp->IsOneByteRepresentation() != is_ascii) { - // If we changed between an ASCII and an UC16 string, the specialized + if (subject_tmp->IsOneByteRepresentation() != is_one_byte) { + // If we changed between an Latin1 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). return RETRY; @@ -1249,7 +1249,7 @@ void RegExpMacroAssemblerARM::LoadCurrentCharacterUnchecked(int cp_offset, DCHECK(characters == 1); } - if (mode_ == ASCII) { + if (mode_ == LATIN1) { if (characters == 4) { __ ldr(current_character(), MemOperand(end_of_input_address(), offset)); } else if (characters == 2) { diff --git a/src/arm/regexp-macro-assembler-arm.h b/src/arm/regexp-macro-assembler-arm.h index fef8413..7414e54 100644 --- a/src/arm/regexp-macro-assembler-arm.h +++ b/src/arm/regexp-macro-assembler-arm.h @@ -190,7 +190,7 @@ class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler { MacroAssembler* masm_; - // Which mode to generate code for (ASCII or UC16). + // Which mode to generate code for (Latin1 or UC16). Mode mode_; // One greater than maximal register index actually used. diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index 1096de7..6cd7043 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -603,19 +603,20 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) { &flat_string_check, &slow); } - // Check for both being sequential ASCII strings, and inline if that is the - // case. + // Check for both being sequential one-byte strings, + // and inline if that is the case. __ Bind(&flat_string_check); - __ JumpIfBothInstanceTypesAreNotSequentialAscii(lhs_type, rhs_type, x14, - x15, &slow); + __ JumpIfBothInstanceTypesAreNotSequentialOneByte(lhs_type, rhs_type, x14, + x15, &slow); __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, x10, x11); if (cond == eq) { - StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12); + StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, x10, x11, + x12); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12, - x13); + StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, x10, x11, + x12, x13); } // Never fall through to here. @@ -2106,7 +2107,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { // w0 string_type type of subject string // x2 jsstring_length subject string length // x3 jsregexp_object JSRegExp object - // w4 string_encoding ASCII or UC16 + // w4 string_encoding Latin1 or UC16 // w5 sliced_string_offset if the string is a SlicedString // offset to the underlying string // w6 string_representation groups attributes of the string: @@ -2304,17 +2305,17 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { STATIC_ASSERT(kStringEncodingMask == 0x04); // Find the code object based on the assumptions above. - // kDataAsciiCodeOffset and kDataUC16CodeOffset are adjacent, adds an offset + // kDataOneByteCodeOffset and kDataUC16CodeOffset are adjacent, adds an offset // of kPointerSize to reach the latter. - DCHECK_EQ(JSRegExp::kDataAsciiCodeOffset + kPointerSize, + DCHECK_EQ(JSRegExp::kDataOneByteCodeOffset + kPointerSize, JSRegExp::kDataUC16CodeOffset); __ Mov(x10, kPointerSize); - // We will need the encoding later: ASCII = 0x04 - // UC16 = 0x00 + // We will need the encoding later: Latin1 = 0x04 + // UC16 = 0x00 __ Ands(string_encoding, string_type, kStringEncodingMask); __ CzeroX(x10, ne); __ Add(x10, regexp_data, x10); - __ Ldr(code_object, FieldMemOperand(x10, JSRegExp::kDataAsciiCodeOffset)); + __ Ldr(code_object, FieldMemOperand(x10, JSRegExp::kDataOneByteCodeOffset)); // (E) Carry on. String handling is done. @@ -2357,13 +2358,13 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ Ldr(length, UntagSmiFieldMemOperand(subject, String::kLengthOffset)); // Handle UC16 encoding, two bytes make one character. - // string_encoding: if ASCII: 0x04 - // if UC16: 0x00 + // string_encoding: if Latin1: 0x04 + // if UC16: 0x00 STATIC_ASSERT(kStringEncodingMask == 0x04); __ Ubfx(string_encoding, string_encoding, 2, 1); __ Eor(string_encoding, string_encoding, 1); - // string_encoding: if ASCII: 0 - // if UC16: 1 + // string_encoding: if Latin1: 0 + // if UC16: 1 // Convert string positions from characters to bytes. // Previous index is in x1. @@ -3159,7 +3160,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ B(hi, &slow_case_); __ LoadRoot(result_, Heap::kSingleCharacterStringCacheRootIndex); - // At this point code register contains smi tagged ASCII char code. + // At this point code register contains smi tagged one-byte char code. __ Add(result_, result_, Operand::UntagSmiAndScale(code_, kPointerSizeLog2)); __ Ldr(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); __ JumpIfRoot(result_, Heap::kUndefinedValueRootIndex, &slow_case_); @@ -3405,17 +3406,18 @@ void CompareICStub::GenerateStrings(MacroAssembler* masm) { __ Bind(¬_internalized_strings); } - // Check that both strings are sequential ASCII. + // Check that both strings are sequential one-byte. Label runtime; - __ JumpIfBothInstanceTypesAreNotSequentialAscii( - lhs_type, rhs_type, x12, x13, &runtime); + __ JumpIfBothInstanceTypesAreNotSequentialOneByte(lhs_type, rhs_type, x12, + x13, &runtime); - // Compare flat ASCII strings. Returns when done. + // Compare flat one-byte strings. Returns when done. if (equality) { - StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, x10, x11, x12); + StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, x10, x11, + x12); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, x10, x11, x12, - x13); + StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, x10, x11, + x12, x13); } // Handle more complex cases in runtime. @@ -3662,8 +3664,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); __ Tbz(input_type, MaskToBit(kStringEncodingMask), &two_byte_slice); - __ AllocateAsciiSlicedString(result_string, result_length, x3, x4, - &runtime); + __ AllocateOneByteSlicedString(result_string, result_length, x3, x4, + &runtime); __ B(&set_slice_header); __ Bind(&two_byte_slice); @@ -3713,12 +3715,12 @@ void SubStringStub::Generate(MacroAssembler* masm) { SeqOneByteString::kHeaderSize - kHeapObjectTag); __ Bind(&allocate_result); - // Sequential ASCII string. Allocate the result. + // Sequential one-byte string. Allocate the result. STATIC_ASSERT((kOneByteStringTag & kStringEncodingMask) != 0); __ Tbz(input_type, MaskToBit(kStringEncodingMask), &two_byte_sequential); - // Allocate and copy the resulting ASCII string. - __ AllocateAsciiString(result_string, result_length, x3, x4, x5, &runtime); + // Allocate and copy the resulting one-byte string. + __ AllocateOneByteString(result_string, result_length, x3, x4, x5, &runtime); // Locate first character of substring to copy. __ Add(substring_char0, unpacked_char0, from); @@ -3771,11 +3773,9 @@ void SubStringStub::Generate(MacroAssembler* masm) { } -void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, - Register left, Register right, - Register scratch1, - Register scratch2, - Register scratch3) { +void StringHelper::GenerateFlatOneByteStringEquals( + MacroAssembler* masm, Register left, Register right, Register scratch1, + Register scratch2, Register scratch3) { DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3)); Register result = x0; Register left_length = scratch1; @@ -3803,8 +3803,8 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, // Compare characters. Falls through if all characters are equal. __ Bind(&compare_chars); - GenerateAsciiCharsCompareLoop(masm, left, right, left_length, scratch2, - scratch3, &strings_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, left_length, scratch2, + scratch3, &strings_not_equal); // Characters in strings are equal. __ Mov(result, Smi::FromInt(EQUAL)); @@ -3812,7 +3812,7 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, } -void StringHelper::GenerateCompareFlatAsciiStrings( +void StringHelper::GenerateCompareFlatOneByteStrings( MacroAssembler* masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3, Register scratch4) { DCHECK(!AreAliased(left, right, scratch1, scratch2, scratch3, scratch4)); @@ -3829,9 +3829,8 @@ void StringHelper::GenerateCompareFlatAsciiStrings( __ Cbz(min_length, &compare_lengths); // Compare loop. - GenerateAsciiCharsCompareLoop(masm, - left, right, min_length, scratch2, scratch4, - &result_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, + scratch4, &result_not_equal); // Compare lengths - strings up to min-length are equal. __ Bind(&compare_lengths); @@ -3853,7 +3852,7 @@ void StringHelper::GenerateCompareFlatAsciiStrings( } -void StringHelper::GenerateAsciiCharsCompareLoop( +void StringHelper::GenerateOneByteCharsCompareLoop( MacroAssembler* masm, Register left, Register right, Register length, Register scratch1, Register scratch2, Label* chars_not_equal) { DCHECK(!AreAliased(left, right, length, scratch1, scratch2)); @@ -3903,14 +3902,14 @@ void StringCompareStub::Generate(MacroAssembler* masm) { __ Bind(¬_same); - // Check that both objects are sequential ASCII strings. - __ JumpIfEitherIsNotSequentialAsciiStrings(left, right, x12, x13, &runtime); + // Check that both objects are sequential one-byte strings. + __ JumpIfEitherIsNotSequentialOneByteStrings(left, right, x12, x13, &runtime); - // Compare flat ASCII strings natively. Remove arguments from stack first, + // Compare flat one-byte strings natively. Remove arguments from stack first, // as this function will generate a return. __ IncrementCounter(counters->string_compare_native(), 1, x3, x4); - StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, x12, x13, - x14, x15); + StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, x12, x13, + x14, x15); __ Bind(&runtime); diff --git a/src/arm64/code-stubs-arm64.h b/src/arm64/code-stubs-arm64.h index 88936dd..c2e15e0 100644 --- a/src/arm64/code-stubs-arm64.h +++ b/src/arm64/code-stubs-arm64.h @@ -14,23 +14,22 @@ void ArrayNativeCode(MacroAssembler* masm, Label* call_generic_code); class StringHelper : public AllStatic { public: - // Compares two flat ASCII strings and returns result in x0. - static void GenerateCompareFlatAsciiStrings( + // Compares two flat one-byte strings and returns result in x0. + static void GenerateCompareFlatOneByteStrings( MacroAssembler* masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3, Register scratch4); - // Compare two flat ASCII strings for equality and returns result in x0. - static void GenerateFlatAsciiStringEquals(MacroAssembler* masm, Register left, - Register right, Register scratch1, - Register scratch2, - Register scratch3); + // Compare two flat one-byte strings for equality and returns result in x0. + static void GenerateFlatOneByteStringEquals(MacroAssembler* masm, + Register left, Register right, + Register scratch1, + Register scratch2, + Register scratch3); private: - static void GenerateAsciiCharsCompareLoop(MacroAssembler* masm, Register left, - Register right, Register length, - Register scratch1, - Register scratch2, - Label* chars_not_equal); + static void GenerateOneByteCharsCompareLoop( + MacroAssembler* masm, Register left, Register right, Register length, + Register scratch1, Register scratch2, Label* chars_not_equal); DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); }; diff --git a/src/arm64/codegen-arm64.cc b/src/arm64/codegen-arm64.cc index 16b6d3b..91eaba7 100644 --- a/src/arm64/codegen-arm64.cc +++ b/src/arm64/codegen-arm64.cc @@ -485,15 +485,15 @@ void StringCharLoadGenerator::Generate(MacroAssembler* masm, __ B(ne, call_runtime); __ Ldr(string, FieldMemOperand(string, ExternalString::kResourceDataOffset)); - Label ascii, done; + Label one_byte, done; __ Bind(&check_encoding); STATIC_ASSERT(kTwoByteStringTag == 0); - __ TestAndBranchIfAnySet(result, kStringEncodingMask, &ascii); + __ TestAndBranchIfAnySet(result, kStringEncodingMask, &one_byte); // Two-byte string. __ Ldrh(result, MemOperand(string, index, SXTW, 1)); __ B(&done); - __ Bind(&ascii); - // Ascii string. + __ Bind(&one_byte); + // One-byte string. __ Ldrb(result, MemOperand(string, index, SXTW)); __ Bind(&done); } diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 75a6500..198e781 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -3506,8 +3506,8 @@ void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { } -void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { - ASM_LOCATION("FullCodeGenerator::EmitFastAsciiArrayJoin"); +void FullCodeGenerator::EmitFastOneByteArrayJoin(CallRuntime* expr) { + ASM_LOCATION("FullCodeGenerator::EmitFastOneByteArrayJoin"); ZoneList* args = expr->arguments(); DCHECK(args->length() == 2); @@ -3559,7 +3559,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // Get the FixedArray containing array's elements. __ Ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset)); - // Check that all array elements are sequential ASCII strings, and + // Check that all array elements are sequential one-byte strings, and // accumulate the sum of their lengths. __ Mov(string_length, 0); __ Add(element, elements, FixedArray::kHeaderSize - kHeapObjectTag); @@ -3574,14 +3574,14 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // elements_end: Array end. if (FLAG_debug_code) { __ Cmp(array_length, 0); - __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); + __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin); } __ Bind(&loop); __ Ldr(string, MemOperand(element, kPointerSize, PostIndex)); __ JumpIfSmi(string, &bailout); __ Ldr(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); __ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout); __ Ldrsw(scratch1, UntagSmiFieldMemOperand(string, SeqOneByteString::kLengthOffset)); __ Adds(string_length, string_length, scratch1); @@ -3603,11 +3603,11 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // string_length: Sum of string lengths (not smi). // elements: FixedArray of strings. - // Check that the separator is a flat ASCII string. + // Check that the separator is a flat one-byte string. __ JumpIfSmi(separator, &bailout); __ Ldr(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); __ Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout); // Add (separator length times array_length) - separator length to the // string_length to get the length of the result string. @@ -3627,13 +3627,13 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // separator: Separator string // string_length: Length of result string (not smi) // array_length: Length of the array (not smi). - __ AllocateAsciiString(result, string_length, scratch1, scratch2, scratch3, - &bailout); + __ AllocateOneByteString(result, string_length, scratch1, scratch2, scratch3, + &bailout); // Prepare for looping. Set up elements_end to end of the array. Set // result_pos to the position of the result where to write the first // character. - // TODO(all): useless unless AllocateAsciiString trashes the register. + // TODO(all): useless unless AllocateOneByteString trashes the register. __ Add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); __ Add(result_pos, result, SeqOneByteString::kHeaderSize - kHeapObjectTag); @@ -3661,7 +3661,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // One-character separator case __ Bind(&one_char_separator); - // Replace separator with its ASCII character value. + // Replace separator with its one-byte character value. __ Ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); // Jump into the loop after the code that copies the separator, so the first // element is not preceded by a separator @@ -3672,7 +3672,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // result_pos: the position to which we are currently copying characters. // element: Current array element. // elements_end: Array end. - // separator: Single separator ASCII char (in lower byte). + // separator: Single separator one-byte char (in lower byte). // Copy the separator character to the result. __ Strb(separator, MemOperand(result_pos, 1, PostIndex)); diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc index b7c3db0..60f417d 100644 --- a/src/arm64/macro-assembler-arm64.cc +++ b/src/arm64/macro-assembler-arm64.cc @@ -2701,14 +2701,9 @@ void MacroAssembler::FillFields(Register dst, } -void MacroAssembler::JumpIfEitherIsNotSequentialAsciiStrings( - Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure, - SmiCheckType smi_check) { - +void MacroAssembler::JumpIfEitherIsNotSequentialOneByteStrings( + Register first, Register second, Register scratch1, Register scratch2, + Label* failure, SmiCheckType smi_check) { if (smi_check == DO_SMI_CHECK) { JumpIfEitherSmi(first, second, failure); } else if (emit_debug_code()) { @@ -2723,67 +2718,58 @@ void MacroAssembler::JumpIfEitherIsNotSequentialAsciiStrings( Bind(¬_smi); } - // Test that both first and second are sequential ASCII strings. + // Test that both first and second are sequential one-byte strings. Ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); Ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); Ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); Ldrb(scratch2, FieldMemOperand(scratch2, Map::kInstanceTypeOffset)); - JumpIfEitherInstanceTypeIsNotSequentialAscii(scratch1, - scratch2, - scratch1, - scratch2, - failure); + JumpIfEitherInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, scratch1, + scratch2, failure); } -void MacroAssembler::JumpIfEitherInstanceTypeIsNotSequentialAscii( - Register first, - Register second, - Register scratch1, - Register scratch2, +void MacroAssembler::JumpIfEitherInstanceTypeIsNotSequentialOneByte( + Register first, Register second, Register scratch1, Register scratch2, Label* failure) { DCHECK(!AreAliased(scratch1, second)); DCHECK(!AreAliased(scratch1, scratch2)); - static const int kFlatAsciiStringMask = + static const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - static const int kFlatAsciiStringTag = ASCII_STRING_TYPE; - And(scratch1, first, kFlatAsciiStringMask); - And(scratch2, second, kFlatAsciiStringMask); - Cmp(scratch1, kFlatAsciiStringTag); - Ccmp(scratch2, kFlatAsciiStringTag, NoFlag, eq); + static const int kFlatOneByteStringTag = ONE_BYTE_STRING_TYPE; + And(scratch1, first, kFlatOneByteStringMask); + And(scratch2, second, kFlatOneByteStringMask); + Cmp(scratch1, kFlatOneByteStringTag); + Ccmp(scratch2, kFlatOneByteStringTag, NoFlag, eq); B(ne, failure); } -void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(Register type, - Register scratch, - Label* failure) { - const int kFlatAsciiStringMask = +void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(Register type, + Register scratch, + Label* failure) { + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - And(scratch, type, kFlatAsciiStringMask); - Cmp(scratch, kFlatAsciiStringTag); + And(scratch, type, kFlatOneByteStringMask); + Cmp(scratch, kFlatOneByteStringTag); B(ne, failure); } -void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialAscii( - Register first, - Register second, - Register scratch1, - Register scratch2, +void MacroAssembler::JumpIfBothInstanceTypesAreNotSequentialOneByte( + Register first, Register second, Register scratch1, Register scratch2, Label* failure) { DCHECK(!AreAliased(first, second, scratch1, scratch2)); - const int kFlatAsciiStringMask = + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - And(scratch1, first, kFlatAsciiStringMask); - And(scratch2, second, kFlatAsciiStringMask); - Cmp(scratch1, kFlatAsciiStringTag); - Ccmp(scratch2, kFlatAsciiStringTag, NoFlag, eq); + And(scratch1, first, kFlatOneByteStringMask); + And(scratch2, second, kFlatOneByteStringMask); + Cmp(scratch1, kFlatOneByteStringTag); + Ccmp(scratch2, kFlatOneByteStringTag, NoFlag, eq); B(ne, failure); } @@ -3575,12 +3561,10 @@ void MacroAssembler::AllocateTwoByteString(Register result, } -void MacroAssembler::AllocateAsciiString(Register result, - Register length, - Register scratch1, - Register scratch2, - Register scratch3, - Label* gc_required) { +void MacroAssembler::AllocateOneByteString(Register result, Register length, + Register scratch1, Register scratch2, + Register scratch3, + Label* gc_required) { DCHECK(!AreAliased(result, length, scratch1, scratch2, scratch3)); // Calculate the number of bytes needed for the characters in the string while // observing object alignment. @@ -3589,7 +3573,7 @@ void MacroAssembler::AllocateAsciiString(Register result, Add(scratch1, length, kObjectAlignmentMask + SeqOneByteString::kHeaderSize); Bic(scratch1, scratch1, kObjectAlignmentMask); - // Allocate ASCII string in new space. + // Allocate one-byte string in new space. Allocate(scratch1, result, scratch2, @@ -3598,11 +3582,8 @@ void MacroAssembler::AllocateAsciiString(Register result, TAG_OBJECT); // Set the map, length and hash field. - InitializeNewString(result, - length, - Heap::kAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -3622,11 +3603,10 @@ void MacroAssembler::AllocateTwoByteConsString(Register result, } -void MacroAssembler::AllocateAsciiConsString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required) { +void MacroAssembler::AllocateOneByteConsString(Register result, Register length, + Register scratch1, + Register scratch2, + Label* gc_required) { Allocate(ConsString::kSize, result, scratch1, @@ -3634,11 +3614,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kConsAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -3659,20 +3636,17 @@ void MacroAssembler::AllocateTwoByteSlicedString(Register result, } -void MacroAssembler::AllocateAsciiSlicedString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required) { +void MacroAssembler::AllocateOneByteSlicedString(Register result, + Register length, + Register scratch1, + Register scratch2, + Label* gc_required) { DCHECK(!AreAliased(result, length, scratch1, scratch2)); Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kSlicedAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kSlicedOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -4793,8 +4767,8 @@ void MacroAssembler::EnsureNotWhite( Mov(length_scratch, ExternalString::kSize); TestAndBranchIfAnySet(instance_type, kExternalStringTag, &is_data_object); - // Sequential string, either ASCII or UC16. - // For ASCII (char-size of 1) we shift the smi tag away to get the length. + // Sequential string, either Latin1 or UC16. + // For Latin1 (char-size of 1) we shift the smi tag away to get the length. // For UC16 (char-size of 2) we just leave the smi tag in place, thereby // getting the length multiplied by 2. DCHECK(kOneByteStringTag == 4 && kStringEncodingMask == 4); diff --git a/src/arm64/macro-assembler-arm64.h b/src/arm64/macro-assembler-arm64.h index 1505800..8d5f4fc 100644 --- a/src/arm64/macro-assembler-arm64.h +++ b/src/arm64/macro-assembler-arm64.h @@ -1056,39 +1056,28 @@ class MacroAssembler : public Assembler { // ---- String Utilities ---- - // Jump to label if either object is not a sequential ASCII string. + // Jump to label if either object is not a sequential one-byte string. // Optionally perform a smi check on the objects first. - void JumpIfEitherIsNotSequentialAsciiStrings( - Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure, - SmiCheckType smi_check = DO_SMI_CHECK); + void JumpIfEitherIsNotSequentialOneByteStrings( + Register first, Register second, Register scratch1, Register scratch2, + Label* failure, SmiCheckType smi_check = DO_SMI_CHECK); - // Check if instance type is sequential ASCII string and jump to label if + // Check if instance type is sequential one-byte string and jump to label if // it is not. - void JumpIfInstanceTypeIsNotSequentialAscii(Register type, - Register scratch, - Label* failure); + void JumpIfInstanceTypeIsNotSequentialOneByte(Register type, Register scratch, + Label* failure); - // Checks if both instance types are sequential ASCII strings and jumps to + // Checks if both instance types are sequential one-byte strings and jumps to // label if either is not. - void JumpIfEitherInstanceTypeIsNotSequentialAscii( - Register first_object_instance_type, - Register second_object_instance_type, - Register scratch1, - Register scratch2, - Label* failure); + void JumpIfEitherInstanceTypeIsNotSequentialOneByte( + Register first_object_instance_type, Register second_object_instance_type, + Register scratch1, Register scratch2, Label* failure); - // Checks if both instance types are sequential ASCII strings and jumps to + // Checks if both instance types are sequential one-byte strings and jumps to // label if either is not. - void JumpIfBothInstanceTypesAreNotSequentialAscii( - Register first_object_instance_type, - Register second_object_instance_type, - Register scratch1, - Register scratch2, - Label* failure); + void JumpIfBothInstanceTypesAreNotSequentialOneByte( + Register first_object_instance_type, Register second_object_instance_type, + Register scratch1, Register scratch2, Label* failure); void JumpIfNotUniqueName(Register type, Label* not_unique_name); @@ -1370,32 +1359,25 @@ class MacroAssembler : public Assembler { Register scratch2, Register scratch3, Label* gc_required); - void AllocateAsciiString(Register result, - Register length, - Register scratch1, - Register scratch2, - Register scratch3, - Label* gc_required); + void AllocateOneByteString(Register result, Register length, + Register scratch1, Register scratch2, + Register scratch3, Label* gc_required); void AllocateTwoByteConsString(Register result, Register length, Register scratch1, Register scratch2, Label* gc_required); - void AllocateAsciiConsString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required); + void AllocateOneByteConsString(Register result, Register length, + Register scratch1, Register scratch2, + Label* gc_required); void AllocateTwoByteSlicedString(Register result, Register length, Register scratch1, Register scratch2, Label* gc_required); - void AllocateAsciiSlicedString(Register result, - Register length, - Register scratch1, - Register scratch2, - Label* gc_required); + void AllocateOneByteSlicedString(Register result, Register length, + Register scratch1, Register scratch2, + Label* gc_required); // Allocates a heap number or jumps to the gc_required label if the young // space is full and a scavenge is needed. diff --git a/src/arm64/regexp-macro-assembler-arm64.cc b/src/arm64/regexp-macro-assembler-arm64.cc index 432d956..e9a485d 100644 --- a/src/arm64/regexp-macro-assembler-arm64.cc +++ b/src/arm64/regexp-macro-assembler-arm64.cc @@ -260,7 +260,7 @@ void RegExpMacroAssemblerARM64::CheckCharacters(Vector str, } for (int i = 0; i < str.length(); i++) { - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ Ldrb(w10, MemOperand(characters_address, 1, PostIndex)); DCHECK(str[i] <= String::kMaxOneByteCharCode); } else { @@ -307,7 +307,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase( __ Cmn(capture_length, current_input_offset()); BranchOrBacktrack(gt, on_no_match); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { Label success; Label fail; Label loop_check; @@ -447,7 +447,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReference( Label loop; __ Bind(&loop); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ Ldrb(w10, MemOperand(capture_start_address, 1, PostIndex)); __ Ldrb(w11, MemOperand(current_position_address, 1, PostIndex)); } else { @@ -530,7 +530,7 @@ void RegExpMacroAssemblerARM64::CheckBitInTable( Handle table, Label* on_bit_set) { __ Mov(x11, Operand(table)); - if ((mode_ != ASCII) || (kTableMask != String::kMaxOneByteCharCode)) { + if ((mode_ != LATIN1) || (kTableMask != String::kMaxOneByteCharCode)) { __ And(w10, current_character(), kTableMask); __ Add(w10, w10, ByteArray::kHeaderSize - kHeapObjectTag); } else { @@ -548,7 +548,7 @@ bool RegExpMacroAssemblerARM64::CheckSpecialCharacterClass(uc16 type, switch (type) { case 's': // Match space-characters - if (mode_ == ASCII) { + if (mode_ == LATIN1) { // One byte space characters are '\t'..'\r', ' ' and \u00a0. Label success; // Check for ' ' or 0x00a0. @@ -611,8 +611,8 @@ bool RegExpMacroAssemblerARM64::CheckSpecialCharacterClass(uc16 type, return true; } case 'w': { - if (mode_ != ASCII) { - // Table is 128 entries, so all ASCII characters can be tested. + if (mode_ != LATIN1) { + // Table is 256 entries, so all Latin1 characters can be tested. CompareAndBranchOrBacktrack(current_character(), 'z', hi, on_no_match); } ExternalReference map = ExternalReference::re_word_character_map(); @@ -623,8 +623,8 @@ bool RegExpMacroAssemblerARM64::CheckSpecialCharacterClass(uc16 type, } case 'W': { Label done; - if (mode_ != ASCII) { - // Table is 128 entries, so all ASCII characters can be tested. + if (mode_ != LATIN1) { + // Table is 256 entries, so all Latin1 characters can be tested. __ Cmp(current_character(), 'z'); __ B(hi, &done); } @@ -1315,7 +1315,7 @@ int RegExpMacroAssemblerARM64::CheckStackGuardState(Address* return_address, Handle subject(frame_entry(re_frame, kInput)); // Current string. - bool is_ascii = subject->IsOneByteRepresentationUnderneath(); + bool is_one_byte = subject->IsOneByteRepresentationUnderneath(); DCHECK(re_code->instruction_start() <= *return_address); DCHECK(*return_address <= @@ -1346,8 +1346,8 @@ int RegExpMacroAssemblerARM64::CheckStackGuardState(Address* return_address, } // String might have changed. - if (subject_tmp->IsOneByteRepresentation() != is_ascii) { - // If we changed between an ASCII and an UC16 string, the specialized + if (subject_tmp->IsOneByteRepresentation() != is_one_byte) { + // If we changed between an Latin1 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). return RETRY; @@ -1675,7 +1675,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset, offset = w10; } - if (mode_ == ASCII) { + if (mode_ == LATIN1) { if (characters == 4) { __ Ldr(current_character(), MemOperand(input_end(), offset, SXTW)); } else if (characters == 2) { diff --git a/src/arm64/regexp-macro-assembler-arm64.h b/src/arm64/regexp-macro-assembler-arm64.h index a27cff0..632c513 100644 --- a/src/arm64/regexp-macro-assembler-arm64.h +++ b/src/arm64/regexp-macro-assembler-arm64.h @@ -265,7 +265,7 @@ class RegExpMacroAssemblerARM64: public NativeRegExpMacroAssembler { MacroAssembler* masm_; - // Which mode to generate code for (ASCII or UC16). + // Which mode to generate code for (LATIN1 or UC16). Mode mode_; // One greater than maximal register index actually used. diff --git a/src/array.js b/src/array.js index cf99ace..3d4a066 100644 --- a/src/array.js +++ b/src/array.js @@ -144,7 +144,7 @@ function Join(array, length, separator, convert) { elements[elements_length++] = e; } elements.length = elements_length; - var result = %_FastAsciiArrayJoin(elements, ''); + var result = %_FastOneByteArrayJoin(elements, ''); if (!IS_UNDEFINED(result)) return result; return %StringBuilderConcat(elements, elements_length, ''); } @@ -168,7 +168,7 @@ function Join(array, length, separator, convert) { elements[i] = e; } } - var result = %_FastAsciiArrayJoin(elements, separator); + var result = %_FastOneByteArrayJoin(elements, separator); if (!IS_UNDEFINED(result)) return result; return %StringBuilderJoin(elements, length, separator); @@ -375,7 +375,7 @@ function ArrayJoin(separator) { separator = NonStringToString(separator); } - var result = %_FastAsciiArrayJoin(array, separator); + var result = %_FastOneByteArrayJoin(array, separator); if (!IS_UNDEFINED(result)) return result; return Join(array, length, separator, ConvertToString); diff --git a/src/ast-value-factory.cc b/src/ast-value-factory.cc index 7b51589..ea8474f 100644 --- a/src/ast-value-factory.cc +++ b/src/ast-value-factory.cc @@ -249,7 +249,7 @@ const AstRawString* AstValueFactory::GetTwoByteString( const AstRawString* AstValueFactory::GetString(Handle literal) { DisallowHeapAllocation no_gc; String::FlatContent content = literal->GetFlatContent(); - if (content.IsAscii()) { + if (content.IsOneByte()) { return GetOneByteString(content.ToOneByteVector()); } DCHECK(content.IsTwoByte()); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index bf5c23e..dbf6e0e 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -54,9 +54,9 @@ Handle Bootstrapper::NativesSourceLookup(int index) { source.start(), source.length()); // We do not expect this to throw an exception. Change this if it does. - Handle source_code = - isolate_->factory()->NewExternalStringFromAscii( - resource).ToHandleChecked(); + Handle source_code = isolate_->factory() + ->NewExternalStringFromOneByte(resource) + .ToHandleChecked(); heap->natives_source_cache()->set(index, *source_code); } Handle cached_source(heap->natives_source_cache()->get(index), @@ -511,7 +511,7 @@ Handle Genesis::CreateEmptyFunction(Isolate* isolate) { // Allocate the empty function as the prototype for function ECMAScript // 262 15.3.4. Handle empty_string = - factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); + factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); Handle code(isolate->builtins()->builtin(Builtins::kEmptyFunction)); Handle empty_function = factory->NewFunctionWithoutPrototype( empty_string, code); @@ -526,7 +526,7 @@ Handle Genesis::CreateEmptyFunction(Isolate* isolate) { empty_function->set_map(*empty_function_map); // --- E m p t y --- - Handle source = factory->NewStringFromStaticAscii("() {}"); + Handle source = factory->NewStringFromStaticChars("() {}"); Handle