From a7d4f2fda17278cc75122b03f81cb35c3b32abbd Mon Sep 17 00:00:00 2001 From: "paul.lind@imgtec.com" Date: Wed, 10 Sep 2014 19:18:28 +0000 Subject: [PATCH] MIPS: Rename ascii to one-byte where applicable. Port r23840 (5463c43) BUG= R=paul.lind@imgtec.com Review URL: https://codereview.chromium.org/542193003 Patch from Balazs Kilvady . git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23848 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/code-stubs-mips.cc | 80 ++++++------- src/mips/code-stubs-mips.h | 35 ++---- src/mips/codegen-mips.cc | 8 +- src/mips/full-codegen-mips.cc | 26 ++-- src/mips/macro-assembler-mips.cc | 124 ++++++++------------ src/mips/macro-assembler-mips.h | 70 +++++------ src/mips/regexp-macro-assembler-mips.cc | 32 ++--- src/mips/regexp-macro-assembler-mips.h | 2 +- src/mips64/code-stubs-mips64.cc | 86 ++++++-------- src/mips64/code-stubs-mips64.h | 35 ++---- src/mips64/codegen-mips64.cc | 8 +- src/mips64/full-codegen-mips64.cc | 26 ++-- src/mips64/macro-assembler-mips64.cc | 124 ++++++++------------ src/mips64/macro-assembler-mips64.h | 72 +++++------- src/mips64/regexp-macro-assembler-mips64.cc | 32 ++--- src/mips64/regexp-macro-assembler-mips64.h | 2 +- 16 files changed, 320 insertions(+), 442 deletions(-) diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 899f278f4..96098fcee 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -745,19 +745,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, a2, a3, &slow); + __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, a2, a3, &slow); __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2, a3); if (cc == eq) { - StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, a2, a3, t0); + StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, a2, a3, t0); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, a2, a3, t0, - t1); + StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, a2, a3, t0, + t1); } // Never falls through to here. @@ -2156,8 +2156,8 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { STATIC_ASSERT(kStringEncodingMask == 4); STATIC_ASSERT(kOneByteStringTag == 4); STATIC_ASSERT(kTwoByteStringTag == 0); - __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for ASCII. - __ lw(t9, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset)); + __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for one-byte. + __ lw(t9, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset)); __ sra(a3, a0, 2); // a3 is 1 for ASCII, 0 for UC16 (used below). __ lw(t1, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset)); __ Movz(t9, t1, a0); // If UC16 (a0 is 0), replace t9 w/kDataUC16CodeOffset. @@ -2170,7 +2170,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ JumpIfSmi(t9, &runtime); // a1: previous index - // a3: encoding of subject string (1 if ASCII, 0 if two_byte); + // a3: encoding of subject string (1 if one_byte, 0 if two_byte); // t9: code // subject: Subject string // regexp_data: RegExp data (FixedArray) @@ -2225,7 +2225,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ sw(a0, 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). __ Addu(t2, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); __ Xor(a3, a3, Operand(1)); // 1 for 2-byte str, 0 for 1-byte. // Load the length from the original subject string from the previous stack @@ -2860,11 +2860,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; - DCHECK(!t0.is(index_)); DCHECK(!t0.is(result_)); DCHECK(!t0.is(object_)); @@ -2976,7 +2971,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ Branch(&slow_case_, ne, t0, Operand(zero_reg)); __ 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. STATIC_ASSERT(kSmiTag == 0); __ sll(t0, code_, kPointerSizeLog2 - kSmiTagSize); __ Addu(result_, result_, t0); @@ -3005,10 +3000,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, @@ -3172,7 +3164,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); __ And(t0, a1, Operand(kStringEncodingMask)); __ Branch(&two_byte_slice, eq, t0, Operand(zero_reg)); - __ AllocateAsciiSlicedString(v0, a2, t2, t3, &runtime); + __ AllocateOneByteSlicedString(v0, a2, t2, t3, &runtime); __ jmp(&set_slice_header); __ bind(&two_byte_slice); __ AllocateTwoByteSlicedString(v0, a2, t2, t3, &runtime); @@ -3216,7 +3208,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { __ Branch(&two_byte_sequential, eq, t0, Operand(zero_reg)); // Allocate and copy the resulting ASCII string. - __ AllocateAsciiString(v0, a2, t0, t2, t3, &runtime); + __ AllocateOneByteString(v0, a2, t0, t2, t3, &runtime); // Locate first character of substring to copy. __ Addu(t1, t1, a3); @@ -3275,11 +3267,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. @@ -3304,9 +3294,8 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, // Compare characters. __ bind(&compare_chars); - GenerateAsciiCharsCompareLoop(masm, - left, right, length, scratch2, scratch3, v0, - &strings_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3, + v0, &strings_not_equal); // Characters are equal. __ Ret(USE_DELAY_SLOT); @@ -3314,7 +3303,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; @@ -3330,9 +3319,8 @@ void StringHelper::GenerateCompareFlatAsciiStrings( __ Branch(&compare_lengths, eq, min_length, Operand(zero_reg)); // Compare loop. - GenerateAsciiCharsCompareLoop(masm, - left, right, min_length, scratch2, scratch4, v0, - &result_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, + scratch4, v0, &result_not_equal); // Compare lengths - strings up to min-length are equal. __ bind(&compare_lengths); @@ -3355,7 +3343,7 @@ void StringHelper::GenerateCompareFlatAsciiStrings( } -void StringHelper::GenerateAsciiCharsCompareLoop( +void StringHelper::GenerateOneByteCharsCompareLoop( MacroAssembler* masm, Register left, Register right, Register length, Register scratch1, Register scratch2, Register scratch3, Label* chars_not_equal) { @@ -3405,13 +3393,13 @@ void StringCompareStub::Generate(MacroAssembler* masm) { __ bind(¬_same); - // Check that both objects are sequential ASCII strings. - __ JumpIfNotBothSequentialAsciiStrings(a1, a0, a2, a3, &runtime); + // Check that both objects are sequential one-byte strings. + __ JumpIfNotBothSequentialOneByteStrings(a1, a0, a2, a3, &runtime); // Compare flat ASCII strings natively. Remove arguments from stack first. __ IncrementCounter(counters->string_compare_native(), 1, a2, a3); __ Addu(sp, sp, Operand(2 * kPointerSize)); - StringHelper::GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, t0, t1); + StringHelper::GenerateCompareFlatOneByteStrings(masm, a1, a0, a2, a3, t0, t1); __ bind(&runtime); __ TailCallRuntime(Runtime::kStringCompare, 2, 1); @@ -3704,18 +3692,18 @@ void CompareICStub::GenerateStrings(MacroAssembler* masm) { __ bind(&is_symbol); } - // 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/mips/code-stubs-mips.h b/src/mips/code-stubs-mips.h index 125de1cd8..6f075bc33 100644 --- a/src/mips/code-stubs-mips.h +++ b/src/mips/code-stubs-mips.h @@ -25,32 +25,23 @@ class StringHelper : public AllStatic { Register scratch, String::Encoding encoding); - // Compare two flat ASCII strings and returns result in v0. - static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, - Register left, - Register right, + // Compares two flat one-byte strings and returns result in v0. + 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 v0. + 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 v0. - 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, - Register scratch3, - Label* chars_not_equal); + static void GenerateOneByteCharsCompareLoop( + MacroAssembler* masm, Register left, Register right, Register length, + Register scratch1, Register scratch2, Register scratch3, + Label* chars_not_equal); DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); }; diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc index fa504123e..0ecac19b4 100644 --- a/src/mips/codegen-mips.cc +++ b/src/mips/codegen-mips.cc @@ -1059,18 +1059,18 @@ void StringCharLoadGenerator::Generate(MacroAssembler* masm, __ Branch(call_runtime, ne, at, Operand(zero_reg)); __ lw(string, FieldMemOperand(string, ExternalString::kResourceDataOffset)); - Label ascii, done; + Label one_byte, done; __ bind(&check_encoding); STATIC_ASSERT(kTwoByteStringTag == 0); __ And(at, result, Operand(kStringEncodingMask)); - __ Branch(&ascii, ne, at, Operand(zero_reg)); + __ Branch(&one_byte, ne, at, Operand(zero_reg)); // Two-byte string. __ sll(at, index, 1); __ Addu(at, string, at); __ lhu(result, MemOperand(at)); __ jmp(&done); - __ bind(&ascii); - // Ascii string. + __ bind(&one_byte); + // One_byte string. __ Addu(at, string, index); __ lbu(result, MemOperand(at)); __ bind(&done); diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc index e5ef9ec69..7c055436f 100644 --- a/src/mips/full-codegen-mips.cc +++ b/src/mips/full-codegen-mips.cc @@ -3835,7 +3835,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, @@ -3885,7 +3885,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { __ lw(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, zero_reg); __ Addu(element, @@ -3901,8 +3901,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // element: Current array element. // elements_end: Array end. if (generate_debug_code_) { - __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin, - array_length, Operand(zero_reg)); + __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin, array_length, + Operand(zero_reg)); } __ bind(&loop); __ lw(string, MemOperand(element)); @@ -3910,7 +3910,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { __ JumpIfSmi(string, &bailout); __ lw(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout); __ lw(scratch1, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); __ AdduAndCheckForOverflow(string_length, string_length, scratch1, scratch3); __ BranchOnOverflow(&bailout, scratch3); @@ -3929,11 +3929,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); __ lw(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); __ lbu(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. array_length is not @@ -3961,12 +3961,8 @@ 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, - scratch1, - scratch2, - elements_end, - &bailout); + __ AllocateOneByteString(result, string_length, scratch1, scratch2, + elements_end, &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. @@ -4005,7 +4001,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. __ lbu(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. @@ -4016,7 +4012,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. __ sb(separator, MemOperand(result_pos)); diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index f884cda59..e7940f444 100644 --- a/src/mips/macro-assembler-mips.cc +++ b/src/mips/macro-assembler-mips.cc @@ -3497,12 +3497,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); @@ -3510,7 +3508,7 @@ void MacroAssembler::AllocateAsciiString(Register result, addiu(scratch1, length, 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, @@ -3519,11 +3517,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); } @@ -3542,11 +3537,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, @@ -3554,11 +3548,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kConsAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -3578,19 +3569,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); } @@ -5340,71 +5328,59 @@ 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. lw(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); lw(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); lbu(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. STATIC_ASSERT(kSmiTag == 0); And(scratch1, first, Operand(second)); JumpIfSmi(scratch1, failure); - JumpIfNonSmisNotBothSequentialAsciiStrings(first, - second, - scratch1, - scratch2, - failure); + JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, + scratch2, 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) { - const int kFlatAsciiStringMask = + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - DCHECK(kFlatAsciiStringTag <= 0xffff); // Ensure this fits 16-bit immed. - andi(scratch1, first, kFlatAsciiStringMask); - Branch(failure, ne, scratch1, Operand(kFlatAsciiStringTag)); - andi(scratch2, second, kFlatAsciiStringMask); - Branch(failure, ne, scratch2, Operand(kFlatAsciiStringTag)); + DCHECK(kFlatOneByteStringTag <= 0xffff); // Ensure this fits 16-bit immed. + andi(scratch1, first, kFlatOneByteStringMask); + Branch(failure, ne, scratch1, Operand(kFlatOneByteStringTag)); + andi(scratch2, second, kFlatOneByteStringMask); + Branch(failure, ne, scratch2, Operand(kFlatOneByteStringTag)); } -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)); - Branch(failure, ne, scratch, Operand(kFlatAsciiStringTag)); + And(scratch, type, Operand(kFlatOneByteStringMask)); + Branch(failure, ne, scratch, Operand(kFlatOneByteStringTag)); } @@ -5807,8 +5783,8 @@ void MacroAssembler::EnsureNotWhite( bind(&skip); } - // 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/mips/macro-assembler-mips.h b/src/mips/macro-assembler-mips.h index b8c881a2e..5a7905c7e 100644 --- a/src/mips/macro-assembler-mips.h +++ b/src/mips/macro-assembler-mips.h @@ -518,32 +518,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 @@ -1481,18 +1474,14 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT // Checks if both instance types are sequential ASCII 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); - // 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); void JumpIfNotUniqueName(Register reg, Label* not_unique_name); @@ -1502,21 +1491,20 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT Register scratch, uint32_t encoding_mask); - // Test that both first and second are sequential ASCII strings. - // Assume that they are non-smis. - void JumpIfNonSmisNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure); - - // Test that both first and second are sequential ASCII strings. - // Check that they are non-smis. - void JumpIfNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure); + // 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 JumpIfNonSmisNotBothSequentialOneByteStrings(Register first, + Register second, + Register scratch1, + Register scratch2, + Label* failure); + + // Checks if both objects are sequential one-byte strings and jumps to label + // if either is not. + void JumpIfNotBothSequentialOneByteStrings(Register first, Register second, + Register scratch1, + Register scratch2, + Label* not_flat_one_byte_strings); void ClampUint8(Register output_reg, Register input_reg); diff --git a/src/mips/regexp-macro-assembler-mips.cc b/src/mips/regexp-macro-assembler-mips.cc index 6f9852292..dbc12a079 100644 --- a/src/mips/regexp-macro-assembler-mips.cc +++ b/src/mips/regexp-macro-assembler-mips.cc @@ -241,7 +241,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase( // Check that there are enough characters left in the input. BranchOrBacktrack(on_no_match, gt, t5, Operand(zero_reg)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { Label success; Label fail; Label loop_check; @@ -365,7 +365,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReference( Label loop; __ bind(&loop); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ lbu(a3, MemOperand(a0, 0)); __ addiu(a0, a0, char_size()); __ lbu(t0, MemOperand(a2, 0)); @@ -446,7 +446,7 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable( Handle table, Label* on_bit_set) { __ li(a0, Operand(table)); - if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) { + if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { __ And(a1, current_character(), Operand(kTableSize - 1)); __ Addu(a0, a0, a1); } else { @@ -465,7 +465,7 @@ bool RegExpMacroAssemblerMIPS::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; __ Branch(&success, eq, current_character(), Operand(' ')); @@ -482,12 +482,12 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, // The emitted code for generic character classes is good enough. return false; case 'd': - // Match ASCII digits ('0'..'9'). + // Match Latin1 digits ('0'..'9'). __ Subu(a0, current_character(), Operand('0')); BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0')); return true; case 'D': - // Match non ASCII-digits. + // Match non Latin1-digits. __ Subu(a0, current_character(), Operand('0')); BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0')); return true; @@ -511,7 +511,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, __ Xor(a0, current_character(), Operand(0x01)); // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c. __ Subu(a0, a0, Operand(0x0b)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { BranchOrBacktrack(on_no_match, hi, a0, Operand(0x0c - 0x0b)); } else { Label done; @@ -526,8 +526,8 @@ bool RegExpMacroAssemblerMIPS::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. BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z')); } ExternalReference map = ExternalReference::re_word_character_map(); @@ -539,8 +539,8 @@ bool RegExpMacroAssemblerMIPS::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. __ Branch(&done, hi, current_character(), Operand('z')); } ExternalReference map = ExternalReference::re_word_character_map(); @@ -548,7 +548,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, __ Addu(a0, a0, current_character()); __ lbu(a0, MemOperand(a0, 0)); BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); - if (mode_ != ASCII) { + if (mode_ != LATIN1) { __ bind(&done); } return true; @@ -1126,7 +1126,7 @@ int RegExpMacroAssemblerMIPS::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 <= @@ -1157,8 +1157,8 @@ int RegExpMacroAssemblerMIPS::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; @@ -1308,7 +1308,7 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, // must only be used to load a single character at a time. DCHECK(characters == 1); __ Addu(t5, end_of_input_address(), Operand(offset)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ lbu(current_character(), MemOperand(t5, 0)); } else { DCHECK(mode_ == UC16); diff --git a/src/mips/regexp-macro-assembler-mips.h b/src/mips/regexp-macro-assembler-mips.h index ddf484cbb..c7d8f6dcf 100644 --- a/src/mips/regexp-macro-assembler-mips.h +++ b/src/mips/regexp-macro-assembler-mips.h @@ -197,7 +197,7 @@ class RegExpMacroAssemblerMIPS: 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/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index bb81a4f8c..29313a90a 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -740,19 +740,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, a2, a3, &slow); + __ JumpIfNonSmisNotBothSequentialOneByteStrings(lhs, rhs, a2, a3, &slow); __ IncrementCounter(isolate()->counters()->string_compare_native(), 1, a2, a3); if (cc == eq) { - StringHelper::GenerateFlatAsciiStringEquals(masm, lhs, rhs, a2, a3, a4); + StringHelper::GenerateFlatOneByteStringEquals(masm, lhs, rhs, a2, a3, a4); } else { - StringHelper::GenerateCompareFlatAsciiStrings(masm, lhs, rhs, a2, a3, a4, - a5); + StringHelper::GenerateCompareFlatOneByteStrings(masm, lhs, rhs, a2, a3, a4, + a5); } // Never falls through to here. @@ -2157,9 +2157,9 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { STATIC_ASSERT(kStringEncodingMask == 4); STATIC_ASSERT(kOneByteStringTag == 4); STATIC_ASSERT(kTwoByteStringTag == 0); - __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for ASCII. - __ ld(t9, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset)); - __ dsra(a3, a0, 2); // a3 is 1 for ASCII, 0 for UC16 (used below). + __ And(a0, a0, Operand(kStringEncodingMask)); // Non-zero for one_byte. + __ ld(t9, FieldMemOperand(regexp_data, JSRegExp::kDataOneByteCodeOffset)); + __ dsra(a3, a0, 2); // a3 is 1 for one_byte, 0 for UC16 (used below). __ ld(a5, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset)); __ Movz(t9, a5, a0); // If UC16 (a0 is 0), replace t9 w/kDataUC16CodeOffset. @@ -2171,7 +2171,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { __ JumpIfSmi(t9, &runtime); // a1: previous index - // a3: encoding of subject string (1 if ASCII, 0 if two_byte); + // a3: encoding of subject string (1 if one_byte, 0 if two_byte); // t9: code // subject: Subject string // regexp_data: RegExp data (FixedArray) @@ -2256,7 +2256,7 @@ void RegExpExecStub::Generate(MacroAssembler* masm) { } // 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). + // and calculate the shift of the index (0 for one_byte and 1 for two byte). __ Daddu(t2, subject, Operand(SeqString::kHeaderSize - kHeapObjectTag)); __ Xor(a3, a3, Operand(1)); // 1 for 2-byte str, 0 for 1-byte. // Load the length from the original subject string from the previous stack @@ -2748,11 +2748,6 @@ void CallConstructStub::Generate(MacroAssembler* masm) { // StringCharCodeAtGenerator. void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { - Label flat_string; - Label ascii_string; - Label got_char_code; - Label sliced_string; - DCHECK(!a4.is(index_)); DCHECK(!a4.is(result_)); DCHECK(!a4.is(object_)); @@ -3010,7 +3005,7 @@ void StringCharFromCodeGenerator::GenerateFast(MacroAssembler* masm) { __ 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. STATIC_ASSERT(kSmiTag == 0); __ SmiScale(a4, code_, kPointerSizeLog2); __ Daddu(result_, result_, a4); @@ -3039,10 +3034,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, @@ -3210,7 +3202,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); __ And(a4, a1, Operand(kStringEncodingMask)); __ Branch(&two_byte_slice, eq, a4, Operand(zero_reg)); - __ AllocateAsciiSlicedString(v0, a2, a6, a7, &runtime); + __ AllocateOneByteSlicedString(v0, a2, a6, a7, &runtime); __ jmp(&set_slice_header); __ bind(&two_byte_slice); __ AllocateTwoByteSlicedString(v0, a2, a6, a7, &runtime); @@ -3253,8 +3245,8 @@ void SubStringStub::Generate(MacroAssembler* masm) { __ And(a4, a1, Operand(kStringEncodingMask)); __ Branch(&two_byte_sequential, eq, a4, Operand(zero_reg)); - // Allocate and copy the resulting ASCII string. - __ AllocateAsciiString(v0, a2, a4, a6, a7, &runtime); + // Allocate and copy the resulting one_byte string. + __ AllocateOneByteString(v0, a2, a4, a6, a7, &runtime); // Locate first character of substring to copy. __ Daddu(a5, a5, a3); @@ -3312,11 +3304,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. @@ -3341,9 +3331,8 @@ void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm, // Compare characters. __ bind(&compare_chars); - GenerateAsciiCharsCompareLoop(masm, - left, right, length, scratch2, scratch3, v0, - &strings_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2, scratch3, + v0, &strings_not_equal); // Characters are equal. __ Ret(USE_DELAY_SLOT); @@ -3351,7 +3340,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; @@ -3367,9 +3356,8 @@ void StringHelper::GenerateCompareFlatAsciiStrings( __ Branch(&compare_lengths, eq, min_length, Operand(zero_reg)); // Compare loop. - GenerateAsciiCharsCompareLoop(masm, - left, right, min_length, scratch2, scratch4, v0, - &result_not_equal); + GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2, + scratch4, v0, &result_not_equal); // Compare lengths - strings up to min-length are equal. __ bind(&compare_lengths); @@ -3392,7 +3380,7 @@ void StringHelper::GenerateCompareFlatAsciiStrings( } -void StringHelper::GenerateAsciiCharsCompareLoop( +void StringHelper::GenerateOneByteCharsCompareLoop( MacroAssembler* masm, Register left, Register right, Register length, Register scratch1, Register scratch2, Register scratch3, Label* chars_not_equal) { @@ -3442,13 +3430,13 @@ void StringCompareStub::Generate(MacroAssembler* masm) { __ bind(¬_same); - // Check that both objects are sequential ASCII strings. - __ JumpIfNotBothSequentialAsciiStrings(a1, a0, a2, a3, &runtime); + // Check that both objects are sequential one_byte strings. + __ JumpIfNotBothSequentialOneByteStrings(a1, a0, a2, a3, &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, a2, a3); __ Daddu(sp, sp, Operand(2 * kPointerSize)); - StringHelper::GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, a4, a5); + StringHelper::GenerateCompareFlatOneByteStrings(masm, a1, a0, a2, a3, a4, a5); __ bind(&runtime); __ TailCallRuntime(Runtime::kStringCompare, 2, 1); @@ -3741,18 +3729,18 @@ void CompareICStub::GenerateStrings(MacroAssembler* masm) { __ bind(&is_symbol); } - // 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/mips64/code-stubs-mips64.h b/src/mips64/code-stubs-mips64.h index a07ffae00..86f4ab6fa 100644 --- a/src/mips64/code-stubs-mips64.h +++ b/src/mips64/code-stubs-mips64.h @@ -25,32 +25,23 @@ class StringHelper : public AllStatic { Register scratch, String::Encoding encoding); - // Compare two flat ASCII strings and returns result in v0. - static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm, - Register left, - Register right, + // Compares two flat one-byte strings and returns result in v0. + 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 v0. + 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 v0. - 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, - Register scratch3, - Label* chars_not_equal); + static void GenerateOneByteCharsCompareLoop( + MacroAssembler* masm, Register left, Register right, Register length, + Register scratch1, Register scratch2, Register scratch3, + Label* chars_not_equal); private: DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper); diff --git a/src/mips64/codegen-mips64.cc b/src/mips64/codegen-mips64.cc index 8533ede55..fb395f756 100644 --- a/src/mips64/codegen-mips64.cc +++ b/src/mips64/codegen-mips64.cc @@ -948,18 +948,18 @@ void StringCharLoadGenerator::Generate(MacroAssembler* masm, __ Branch(call_runtime, ne, at, Operand(zero_reg)); __ ld(string, FieldMemOperand(string, ExternalString::kResourceDataOffset)); - Label ascii, done; + Label one_byte, done; __ bind(&check_encoding); STATIC_ASSERT(kTwoByteStringTag == 0); __ And(at, result, Operand(kStringEncodingMask)); - __ Branch(&ascii, ne, at, Operand(zero_reg)); + __ Branch(&one_byte, ne, at, Operand(zero_reg)); // Two-byte string. __ dsll(at, index, 1); __ Daddu(at, string, at); __ lhu(result, MemOperand(at)); __ jmp(&done); - __ bind(&ascii); - // Ascii string. + __ bind(&one_byte); + // One_byte string. __ Daddu(at, string, index); __ lbu(result, MemOperand(at)); __ bind(&done); diff --git a/src/mips64/full-codegen-mips64.cc b/src/mips64/full-codegen-mips64.cc index 53415991c..082303967 100644 --- a/src/mips64/full-codegen-mips64.cc +++ b/src/mips64/full-codegen-mips64.cc @@ -3835,7 +3835,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, @@ -3885,7 +3885,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { __ ld(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, zero_reg); __ Daddu(element, @@ -3901,8 +3901,8 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { // element: Current array element. // elements_end: Array end. if (generate_debug_code_) { - __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin, - array_length, Operand(zero_reg)); + __ Assert(gt, kNoEmptyArraysHereInEmitFastOneByteArrayJoin, array_length, + Operand(zero_reg)); } __ bind(&loop); __ ld(string, MemOperand(element)); @@ -3910,7 +3910,7 @@ void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { __ JumpIfSmi(string, &bailout); __ ld(scratch1, FieldMemOperand(string, HeapObject::kMapOffset)); __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); - __ JumpIfInstanceTypeIsNotSequentialAscii(scratch1, scratch2, &bailout); + __ JumpIfInstanceTypeIsNotSequentialOneByte(scratch1, scratch2, &bailout); __ ld(scratch1, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); __ AdduAndCheckForOverflow(string_length, string_length, scratch1, scratch3); __ BranchOnOverflow(&bailout, scratch3); @@ -3929,11 +3929,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); __ ld(scratch1, FieldMemOperand(separator, HeapObject::kMapOffset)); __ lbu(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. array_length is not @@ -3961,12 +3961,8 @@ 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, - scratch1, - scratch2, - elements_end, - &bailout); + __ AllocateOneByteString(result, string_length, scratch1, scratch2, + elements_end, &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. @@ -4005,7 +4001,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. __ lbu(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. @@ -4016,7 +4012,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. __ sb(separator, MemOperand(result_pos)); diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc index cd595c788..020ffe9f4 100644 --- a/src/mips64/macro-assembler-mips64.cc +++ b/src/mips64/macro-assembler-mips64.cc @@ -3406,12 +3406,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); @@ -3420,7 +3418,7 @@ void MacroAssembler::AllocateAsciiString(Register result, 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, @@ -3429,11 +3427,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); } @@ -3452,11 +3447,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, @@ -3464,11 +3458,8 @@ void MacroAssembler::AllocateAsciiConsString(Register result, gc_required, TAG_OBJECT); - InitializeNewString(result, - length, - Heap::kConsAsciiStringMapRootIndex, - scratch1, - scratch2); + InitializeNewString(result, length, Heap::kConsOneByteStringMapRootIndex, + scratch1, scratch2); } @@ -3488,19 +3479,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); } @@ -5301,71 +5289,59 @@ 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. ld(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); ld(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); lbu(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. STATIC_ASSERT(kSmiTag == 0); And(scratch1, first, Operand(second)); JumpIfSmi(scratch1, failure); - JumpIfNonSmisNotBothSequentialAsciiStrings(first, - second, - scratch1, - scratch2, - failure); + JumpIfNonSmisNotBothSequentialOneByteStrings(first, second, scratch1, + scratch2, 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) { - const int kFlatAsciiStringMask = + const int kFlatOneByteStringMask = kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask; - const int kFlatAsciiStringTag = + const int kFlatOneByteStringTag = kStringTag | kOneByteStringTag | kSeqStringTag; - DCHECK(kFlatAsciiStringTag <= 0xffff); // Ensure this fits 16-bit immed. - andi(scratch1, first, kFlatAsciiStringMask); - Branch(failure, ne, scratch1, Operand(kFlatAsciiStringTag)); - andi(scratch2, second, kFlatAsciiStringMask); - Branch(failure, ne, scratch2, Operand(kFlatAsciiStringTag)); + DCHECK(kFlatOneByteStringTag <= 0xffff); // Ensure this fits 16-bit immed. + andi(scratch1, first, kFlatOneByteStringMask); + Branch(failure, ne, scratch1, Operand(kFlatOneByteStringTag)); + andi(scratch2, second, kFlatOneByteStringMask); + Branch(failure, ne, scratch2, Operand(kFlatOneByteStringTag)); } -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)); - Branch(failure, ne, scratch, Operand(kFlatAsciiStringTag)); + And(scratch, type, Operand(kFlatOneByteStringMask)); + Branch(failure, ne, scratch, Operand(kFlatOneByteStringTag)); } @@ -5790,8 +5766,8 @@ void MacroAssembler::EnsureNotWhite( bind(&skip); } - // 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/mips64/macro-assembler-mips64.h b/src/mips64/macro-assembler-mips64.h index 89ae1e50f..2bf8c3398 100644 --- a/src/mips64/macro-assembler-mips64.h +++ b/src/mips64/macro-assembler-mips64.h @@ -539,32 +539,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 @@ -1550,20 +1543,16 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT Register scratch3, Label* not_found); - // 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); - // 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); void JumpIfNotUniqueName(Register reg, Label* not_unique_name); @@ -1573,21 +1562,20 @@ const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT Register scratch, uint32_t encoding_mask); - // Test that both first and second are sequential ASCII strings. - // Assume that they are non-smis. - void JumpIfNonSmisNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure); - - // Test that both first and second are sequential ASCII strings. - // Check that they are non-smis. - void JumpIfNotBothSequentialAsciiStrings(Register first, - Register second, - Register scratch1, - Register scratch2, - Label* failure); + // 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 JumpIfNonSmisNotBothSequentialOneByteStrings(Register first, + Register second, + Register scratch1, + Register scratch2, + Label* failure); + + // Checks if both objects are sequential one-byte strings and jumps to label + // if either is not. + void JumpIfNotBothSequentialOneByteStrings(Register first, Register second, + Register scratch1, + Register scratch2, + Label* not_flat_one_byte_strings); void ClampUint8(Register output_reg, Register input_reg); diff --git a/src/mips64/regexp-macro-assembler-mips64.cc b/src/mips64/regexp-macro-assembler-mips64.cc index 578a3adb7..b20cab982 100644 --- a/src/mips64/regexp-macro-assembler-mips64.cc +++ b/src/mips64/regexp-macro-assembler-mips64.cc @@ -277,7 +277,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReferenceIgnoreCase( // Check that there are enough characters left in the input. BranchOrBacktrack(on_no_match, gt, t1, Operand(zero_reg)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { Label success; Label fail; Label loop_check; @@ -401,7 +401,7 @@ void RegExpMacroAssemblerMIPS::CheckNotBackReference( Label loop; __ bind(&loop); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ lbu(a3, MemOperand(a0, 0)); __ daddiu(a0, a0, char_size()); __ lbu(a4, MemOperand(a2, 0)); @@ -482,7 +482,7 @@ void RegExpMacroAssemblerMIPS::CheckBitInTable( Handle table, Label* on_bit_set) { __ li(a0, Operand(table)); - if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) { + if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) { __ And(a1, current_character(), Operand(kTableSize - 1)); __ Daddu(a0, a0, a1); } else { @@ -501,7 +501,7 @@ bool RegExpMacroAssemblerMIPS::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; __ Branch(&success, eq, current_character(), Operand(' ')); @@ -518,12 +518,12 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, // The emitted code for generic character classes is good enough. return false; case 'd': - // Match ASCII digits ('0'..'9'). + // Match Latin1 digits ('0'..'9'). __ Dsubu(a0, current_character(), Operand('0')); BranchOrBacktrack(on_no_match, hi, a0, Operand('9' - '0')); return true; case 'D': - // Match non ASCII-digits. + // Match non Latin1-digits. __ Dsubu(a0, current_character(), Operand('0')); BranchOrBacktrack(on_no_match, ls, a0, Operand('9' - '0')); return true; @@ -547,7 +547,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, __ Xor(a0, current_character(), Operand(0x01)); // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c. __ Dsubu(a0, a0, Operand(0x0b)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { BranchOrBacktrack(on_no_match, hi, a0, Operand(0x0c - 0x0b)); } else { Label done; @@ -562,8 +562,8 @@ bool RegExpMacroAssemblerMIPS::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. BranchOrBacktrack(on_no_match, hi, current_character(), Operand('z')); } ExternalReference map = ExternalReference::re_word_character_map(); @@ -575,8 +575,8 @@ bool RegExpMacroAssemblerMIPS::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. __ Branch(&done, hi, current_character(), Operand('z')); } ExternalReference map = ExternalReference::re_word_character_map(); @@ -584,7 +584,7 @@ bool RegExpMacroAssemblerMIPS::CheckSpecialCharacterClass(uc16 type, __ Daddu(a0, a0, current_character()); __ lbu(a0, MemOperand(a0, 0)); BranchOrBacktrack(on_no_match, ne, a0, Operand(zero_reg)); - if (mode_ != ASCII) { + if (mode_ != LATIN1) { __ bind(&done); } return true; @@ -1172,7 +1172,7 @@ int RegExpMacroAssemblerMIPS::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 <= @@ -1203,8 +1203,8 @@ int RegExpMacroAssemblerMIPS::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; @@ -1354,7 +1354,7 @@ void RegExpMacroAssemblerMIPS::LoadCurrentCharacterUnchecked(int cp_offset, // must only be used to load a single character at a time. DCHECK(characters == 1); __ Daddu(t1, end_of_input_address(), Operand(offset)); - if (mode_ == ASCII) { + if (mode_ == LATIN1) { __ lbu(current_character(), MemOperand(t1, 0)); } else { DCHECK(mode_ == UC16); diff --git a/src/mips64/regexp-macro-assembler-mips64.h b/src/mips64/regexp-macro-assembler-mips64.h index 647e4150c..dd4e8a93b 100644 --- a/src/mips64/regexp-macro-assembler-mips64.h +++ b/src/mips64/regexp-macro-assembler-mips64.h @@ -240,7 +240,7 @@ class RegExpMacroAssemblerMIPS: 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. -- 2.34.1