__ JumpIfNotSmi(ebx, &runtime);
__ cmp(ebx, FieldOperand(edx, String::kLengthOffset));
__ j(above_equal, &runtime);
- __ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset));
+ __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset));
__ Move(ecx, Immediate(1)); // Type is one byte.
// (E) Carry on. String handling is done.
// eax: subject string
// ebx: previous index (smi)
// edx: code
- // ecx: encoding of subject string (1 if ASCII, 0 if two_byte);
+ // ecx: encoding of subject string (1 if one_byte, 0 if two_byte);
// All checks done. Now push arguments for native regexp code.
Counters* counters = isolate()->counters();
__ IncrementCounter(counters->regexp_entry_native(), 1);
// esi: original subject string
// eax: underlying subject string
// ebx: previous index
- // ecx: encoding of subject string (1 if ASCII 0 if two_byte);
+ // ecx: encoding of subject string (1 if one_byte 0 if two_byte);
// edx: code
// Argument 4: End of string data
// Argument 3: Start of string data
__ bind(&check_for_strings);
- __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx,
- &check_unequal_objects);
+ __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx,
+ &check_unequal_objects);
- // Inline comparison of ASCII strings.
+ // Inline comparison of one-byte strings.
if (cc == equal) {
- StringHelper::GenerateFlatAsciiStringEquals(masm, edx, eax, ecx, ebx);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, edx, eax, ecx, ebx);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx,
- edi);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
+ edi);
}
#ifdef DEBUG
__ Abort(kUnexpectedFallThroughFromStringComparison);
STATIC_ASSERT(kSmiTag == 0);
STATIC_ASSERT(kSmiTagSize == 1);
STATIC_ASSERT(kSmiShiftSize == 0);
- // At this point code register contains smi tagged ASCII char code.
+ // At this point code register contains smi tagged one byte char code.
__ mov(result_, FieldOperand(result_,
code_, times_half_pointer_size,
FixedArray::kHeaderSize));
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ test(ebx, Immediate(kStringEncodingMask));
__ j(zero, &two_byte_slice, Label::kNear);
- __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime);
+ __ AllocateOneByteSlicedString(eax, ebx, no_reg, &runtime);
__ jmp(&set_slice_header, Label::kNear);
__ bind(&two_byte_slice);
__ AllocateTwoByteSlicedString(eax, ebx, no_reg, &runtime);
__ test_b(ebx, kStringEncodingMask);
__ j(zero, &two_byte_sequential);
- // Sequential ASCII string. Allocate the result.
- __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime_drop_two);
+ // Sequential one byte string. Allocate the result.
+ __ AllocateOneByteString(eax, ecx, ebx, edx, edi, &runtime_drop_two);
// eax: result string
// ecx: result string length
}
-void StringHelper::GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left, Register right,
- Register scratch1,
- Register scratch2) {
+void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
+ Register left,
+ Register right,
+ Register scratch1,
+ Register scratch2) {
Register length = scratch1;
// Compare lengths.
// Compare characters.
__ bind(&compare_chars);
- GenerateAsciiCharsCompareLoop(masm, left, right, length, scratch2,
- &strings_not_equal, Label::kNear);
+ GenerateOneByteCharsCompareLoop(masm, left, right, length, scratch2,
+ &strings_not_equal, Label::kNear);
// Characters are equal.
__ Move(eax, Immediate(Smi::FromInt(EQUAL)));
}
-void StringHelper::GenerateCompareFlatAsciiStrings(
+void StringHelper::GenerateCompareFlatOneByteStrings(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3) {
Counters* counters = masm->isolate()->counters();
// Compare characters.
Label result_not_equal;
- GenerateAsciiCharsCompareLoop(masm, left, right, min_length, scratch2,
- &result_not_equal, Label::kNear);
+ GenerateOneByteCharsCompareLoop(masm, left, right, min_length, scratch2,
+ &result_not_equal, Label::kNear);
// Compare lengths - strings up to min-length are equal.
__ bind(&compare_lengths);
}
-void StringHelper::GenerateAsciiCharsCompareLoop(
+void StringHelper::GenerateOneByteCharsCompareLoop(
MacroAssembler* masm, Register left, Register right, Register length,
Register scratch, Label* chars_not_equal,
Label::Distance chars_not_equal_near) {
__ bind(¬_same);
- // Check that both objects are sequential ASCII strings.
- __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime);
+ // Check that both objects are sequential one-byte strings.
+ __ JumpIfNotBothSequentialOneByteStrings(edx, eax, ecx, ebx, &runtime);
- // Compare flat ASCII strings.
+ // Compare flat one-byte strings.
// Drop arguments from the stack.
__ pop(ecx);
__ add(esp, Immediate(2 * kPointerSize));
__ push(ecx);
- StringHelper::GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, edx, eax, ecx, ebx,
+ edi);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
// tagged as a small integer.
__ bind(&do_compare);
}
- // Check that both strings are sequential ASCII.
+ // Check that both strings are sequential one-byte.
Label runtime;
- __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime);
+ __ JumpIfNotBothSequentialOneByteStrings(left, right, tmp1, tmp2, &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);
+ StringHelper::GenerateFlatOneByteStringEquals(masm, left, right, tmp1,
+ tmp2);
} else {
- StringHelper::GenerateCompareFlatAsciiStrings(masm, left, right, tmp1, tmp2,
- tmp3);
+ StringHelper::GenerateCompareFlatOneByteStrings(masm, left, right, tmp1,
+ tmp2, tmp3);
}
// Handle more complex cases in runtime.
Register scratch,
String::Encoding encoding);
- // Compares two flat ASCII strings and returns result in eax.
- static void GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
+ // Compares two flat one byte strings and returns result in eax.
+ static void GenerateCompareFlatOneByteStrings(MacroAssembler* masm,
+ Register left, Register right,
+ Register scratch1,
+ Register scratch2,
+ Register scratch3);
+
+ // Compares two flat one byte strings for equality and returns result in eax.
+ static void GenerateFlatOneByteStringEquals(MacroAssembler* masm,
Register left, Register right,
Register scratch1,
- Register scratch2,
- Register scratch3);
-
- // Compares two flat ASCII strings for equality and returns result in eax.
- static void GenerateFlatAsciiStringEquals(MacroAssembler* masm,
- Register left,
- Register right,
- Register scratch1,
- Register scratch2);
+ Register scratch2);
private:
- static void GenerateAsciiCharsCompareLoop(
- MacroAssembler* masm,
- Register left,
- Register right,
- Register length,
- Register scratch,
- Label* chars_not_equal,
+ static void GenerateOneByteCharsCompareLoop(
+ MacroAssembler* masm, Register left, Register right, Register length,
+ Register scratch, Label* chars_not_equal,
Label::Distance chars_not_equal_near = Label::kFar);
DISALLOW_IMPLICIT_CONSTRUCTORS(StringHelper);
__ j(zero, &seq_string, Label::kNear);
// Handle external strings.
- Label ascii_external, done;
+ Label one_byte_external, done;
if (FLAG_debug_code) {
// Assert that we do not have a cons or slice (indirect strings) here.
// Sequential strings have already been ruled out.
STATIC_ASSERT(kTwoByteStringTag == 0);
__ test_b(result, kStringEncodingMask);
__ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset));
- __ j(not_equal, &ascii_external, Label::kNear);
+ __ j(not_equal, &one_byte_external, Label::kNear);
// Two-byte string.
__ movzx_w(result, Operand(result, index, times_2, 0));
__ jmp(&done, Label::kNear);
- __ bind(&ascii_external);
- // Ascii string.
+ __ bind(&one_byte_external);
+ // One-byte string.
__ movzx_b(result, Operand(result, index, times_1, 0));
__ jmp(&done, Label::kNear);
- // Dispatch on the encoding: ASCII or two-byte.
- Label ascii;
+ // Dispatch on the encoding: one-byte or two-byte.
+ Label one_byte;
__ bind(&seq_string);
STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0);
STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
__ test(result, Immediate(kStringEncodingMask));
- __ j(not_zero, &ascii, Label::kNear);
+ __ j(not_zero, &one_byte, Label::kNear);
// Two-byte string.
// Load the two-byte character code into the result register.
SeqTwoByteString::kHeaderSize));
__ jmp(&done, Label::kNear);
- // Ascii string.
+ // One-byte string.
// Load the byte into the result register.
- __ bind(&ascii);
+ __ bind(&one_byte);
__ movzx_b(result, FieldOperand(string,
index,
times_1,
}
-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,
loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
array = no_reg;
- // 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.
__ Move(index, Immediate(0));
__ Move(string_length, Immediate(0));
// scratch, string_length, elements.
if (generate_debug_code_) {
__ cmp(index, array_length);
- __ Assert(less, kNoEmptyArraysHereInEmitFastAsciiArrayJoin);
+ __ Assert(less, kNoEmptyArraysHereInEmitFastOneByteArrayJoin);
}
__ bind(&loop);
__ mov(string, FieldOperand(elements,
// string_length: Sum of string lengths, as a smi.
// elements: FixedArray of strings.
- // Check that the separator is a flat ASCII string.
+ // Check that the separator is a flat one-byte string.
__ mov(string, separator_operand);
__ JumpIfSmi(string, &bailout);
__ mov(scratch, FieldOperand(string, HeapObject::kMapOffset));
// Live registers and stack values:
// string_length
// elements
- __ AllocateAsciiString(result_pos, string_length, scratch,
- index, string, &bailout);
+ __ AllocateOneByteString(result_pos, string_length, scratch, index, string,
+ &bailout);
__ mov(result_operand, result_pos);
__ lea(result_pos, FieldOperand(result_pos, SeqOneByteString::kHeaderSize));
// One-character separator case
__ bind(&one_char_separator);
- // Replace separator with its ASCII character value.
+ // Replace separator with its one-byte character value.
__ mov_b(scratch, FieldOperand(string, SeqOneByteString::kHeaderSize));
__ mov_b(separator_operand, scratch);
}
-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);
add(scratch1, Immediate(kObjectAlignmentMask));
and_(scratch1, Immediate(~kObjectAlignmentMask));
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(SeqOneByteString::kHeaderSize,
times_1,
scratch1,
// Set the map, length and hash field.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->ascii_string_map()));
+ Immediate(isolate()->factory()->one_byte_string_map()));
mov(scratch1, length);
SmiTag(scratch1);
mov(FieldOperand(result, String::kLengthOffset), scratch1);
}
-void MacroAssembler::AllocateAsciiString(Register result,
- int length,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteString(Register result, int length,
+ Register scratch1, Register scratch2,
+ Label* gc_required) {
DCHECK(length > 0);
- // Allocate ASCII string in new space.
+ // Allocate one-byte string in new space.
Allocate(SeqOneByteString::SizeFor(length), result, scratch1, scratch2,
gc_required, TAG_OBJECT);
// Set the map, length and hash field.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->ascii_string_map()));
+ Immediate(isolate()->factory()->one_byte_string_map()));
mov(FieldOperand(result, String::kLengthOffset),
Immediate(Smi::FromInt(length)));
mov(FieldOperand(result, String::kHashFieldOffset),
}
-void MacroAssembler::AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteConsString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
Allocate(ConsString::kSize,
result,
scratch1,
// Set the map. The other fields are left uninitialized.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->cons_ascii_string_map()));
+ Immediate(isolate()->factory()->cons_one_byte_string_map()));
}
}
-void MacroAssembler::AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required) {
+void MacroAssembler::AllocateOneByteSlicedString(Register result,
+ Register scratch1,
+ Register scratch2,
+ Label* gc_required) {
// Allocate heap number in new space.
Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
TAG_OBJECT);
// Set the map. The other fields are left uninitialized.
mov(FieldOperand(result, HeapObject::kMapOffset),
- Immediate(isolate()->factory()->sliced_ascii_string_map()));
+ Immediate(isolate()->factory()->sliced_one_byte_string_map()));
}
}
-void MacroAssembler::JumpIfInstanceTypeIsNotSequentialAscii(
- Register instance_type,
- Register scratch,
- Label* failure) {
+void MacroAssembler::JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch, Label* failure) {
if (!scratch.is(instance_type)) {
mov(scratch, instance_type);
}
}
-void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register object1,
- Register object2,
- Register scratch1,
- Register scratch2,
- Label* failure) {
+void MacroAssembler::JumpIfNotBothSequentialOneByteStrings(Register object1,
+ Register object2,
+ Register scratch1,
+ Register scratch2,
+ Label* failure) {
// Check that both objects are not smis.
STATIC_ASSERT(kSmiTag == 0);
mov(scratch1, object1);
movzx_b(scratch1, FieldOperand(scratch1, Map::kInstanceTypeOffset));
movzx_b(scratch2, FieldOperand(scratch2, Map::kInstanceTypeOffset));
- // Check that both are flat ASCII strings.
- const int kFlatAsciiStringMask =
+ // Check that both are flat one-byte strings.
+ const int kFlatOneByteStringMask =
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
- const int kFlatAsciiStringTag =
+ const int kFlatOneByteStringTag =
kStringTag | kOneByteStringTag | kSeqStringTag;
// Interleave bits from both instance types and compare them in one check.
- DCHECK_EQ(0, kFlatAsciiStringMask & (kFlatAsciiStringMask << 3));
- and_(scratch1, kFlatAsciiStringMask);
- and_(scratch2, kFlatAsciiStringMask);
+ DCHECK_EQ(0, kFlatOneByteStringMask & (kFlatOneByteStringMask << 3));
+ and_(scratch1, kFlatOneByteStringMask);
+ and_(scratch2, kFlatOneByteStringMask);
lea(scratch1, Operand(scratch1, scratch2, times_8, 0));
- cmp(scratch1, kFlatAsciiStringTag | (kFlatAsciiStringTag << 3));
+ cmp(scratch1, kFlatOneByteStringTag | (kFlatOneByteStringTag << 3));
j(not_equal, failure);
}
jmp(&is_data_object, Label::kNear);
bind(¬_external);
- // Sequential string, either ASCII or UC16.
+ // Sequential string, either Latin1 or UC16.
DCHECK(kOneByteStringTag == 0x04);
and_(length, Immediate(kStringEncodingMask));
xor_(length, Immediate(kStringEncodingMask));
add(length, Immediate(0x04));
- // Value now either 4 (if ASCII) or 8 (if UC16), i.e., char-size shifted
+ // Value now either 4 (if Latin1) or 8 (if UC16), i.e., char-size shifted
// by 2. If we multiply the string length as smi by this, it still
// won't overflow a 32-bit value.
DCHECK_EQ(SeqOneByteString::kMaxSize, SeqTwoByteString::kMaxSize);
Register scratch2,
Register scratch3,
Label* gc_required);
- void AllocateAsciiString(Register result,
- Register length,
- Register scratch1,
- Register scratch2,
- Register scratch3,
- Label* gc_required);
- void AllocateAsciiString(Register result,
- int length,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteString(Register result, Register length,
+ Register scratch1, Register scratch2,
+ Register scratch3, Label* gc_required);
+ void AllocateOneByteString(Register result, int length, Register scratch1,
+ Register scratch2, Label* gc_required);
// Allocate a raw cons string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiConsString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteConsString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// Allocate a raw sliced string object. Only the map field of the result is
// initialized.
Register scratch1,
Register scratch2,
Label* gc_required);
- void AllocateAsciiSlicedString(Register result,
- Register scratch1,
- Register scratch2,
- Label* gc_required);
+ void AllocateOneByteSlicedString(Register result, Register scratch1,
+ Register scratch2, Label* gc_required);
// Copy memory, byte-by-byte, from source to destination. Not optimized for
// long or aligned copies.
Register scratch2,
Label* not_found);
- // Check whether the instance type represents a flat ASCII string. Jump to the
- // label if not. If the instance type can be scratched specify same register
- // for both instance type and scratch.
- void JumpIfInstanceTypeIsNotSequentialAscii(Register instance_type,
- Register scratch,
- Label* on_not_flat_ascii_string);
+ // Check whether the instance type represents a flat one-byte string. Jump to
+ // the label if not. If the instance type can be scratched specify same
+ // register for both instance type and scratch.
+ void JumpIfInstanceTypeIsNotSequentialOneByte(
+ Register instance_type, Register scratch,
+ Label* on_not_flat_one_byte_string);
- // 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 object1,
- Register object2,
- Register scratch1,
- Register scratch2,
- Label* on_not_flat_ascii_strings);
+ void JumpIfNotBothSequentialOneByteStrings(
+ Register object1, Register object2, Register scratch1, Register scratch2,
+ Label* on_not_flat_one_byte_strings);
// Checks if the given register or operand is a unique name
void JumpIfNotUniqueName(Register reg, Label* not_unique_name,
__ add(eax, ebx);
BranchOrBacktrack(greater, on_no_match);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
Label success;
Label fail;
Label loop_increment;
Label loop;
__ bind(&loop);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
__ movzx_b(eax, Operand(edx, 0));
__ cmpb_al(Operand(ebx, 0));
} else {
Label* on_bit_set) {
__ mov(eax, Immediate(table));
Register index = current_character();
- if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) {
+ if (mode_ != LATIN1 || kTableMask != String::kMaxOneByteCharCode) {
__ mov(ebx, kTableSize - 1);
__ and_(ebx, current_character());
index = ebx;
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(), ' ');
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(), Immediate('z'));
BranchOrBacktrack(above, on_no_match);
}
}
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(), Immediate('z'));
__ j(above, &done);
}
__ test_b(current_character(),
Operand::StaticArray(current_character(), times_1, word_map));
BranchOrBacktrack(not_zero, on_no_match);
- if (mode_ != ASCII) {
+ if (mode_ != LATIN1) {
__ bind(&done);
}
return true;
// See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c
__ sub(eax, Immediate(0x0b));
__ cmp(eax, 0x0c - 0x0b);
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
BranchOrBacktrack(above, on_no_match);
} else {
Label done;
Handle<String> subject(frame_entry<String*>(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 <=
}
// 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;
void RegExpMacroAssemblerX87::LoadCurrentCharacterUnchecked(int cp_offset,
int characters) {
- if (mode_ == ASCII) {
+ if (mode_ == LATIN1) {
if (characters == 4) {
__ mov(current_character(), Operand(esi, edi, times_1, cp_offset));
} else if (characters == 2) {
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.