Change tests for string type in RegExpExecStub on all platforms.
Review URL: http://codereview.chromium.org/2772004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4854 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
8c9958e560
commit
317dcabe84
@ -9248,15 +9248,11 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
|
||||
// regexp_data: RegExp data (FixedArray)
|
||||
// Check the representation and encoding of the subject string.
|
||||
Label seq_string;
|
||||
const int kStringRepresentationEncodingMask =
|
||||
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
|
||||
__ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset));
|
||||
__ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset));
|
||||
__ and_(r1, r0, Operand(kStringRepresentationEncodingMask));
|
||||
// First check for sequential string.
|
||||
ASSERT_EQ(0, kStringTag);
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
__ tst(r1, Operand(kIsNotStringMask | kStringRepresentationMask));
|
||||
// First check for flat string.
|
||||
__ tst(r0, Operand(kIsNotStringMask | kStringRepresentationMask));
|
||||
ASSERT_EQ(0, kStringTag | kSeqStringTag);
|
||||
__ b(eq, &seq_string);
|
||||
|
||||
// subject: Subject string
|
||||
@ -9266,8 +9262,9 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
|
||||
// string. In that case the subject string is just the first part of the cons
|
||||
// string. Also in this case the first part of the cons string is known to be
|
||||
// a sequential string or an external string.
|
||||
__ and_(r0, r0, Operand(kStringRepresentationMask));
|
||||
__ cmp(r0, Operand(kConsStringTag));
|
||||
ASSERT(kExternalStringTag !=0);
|
||||
ASSERT_EQ(0, kConsStringTag & kExternalStringTag);
|
||||
__ tst(r0, Operand(kIsNotStringMask | kExternalStringTag));
|
||||
__ b(ne, &runtime);
|
||||
__ ldr(r0, FieldMemOperand(subject, ConsString::kSecondOffset));
|
||||
__ LoadRoot(r1, Heap::kEmptyStringRootIndex);
|
||||
@ -9276,25 +9273,20 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
|
||||
__ ldr(subject, FieldMemOperand(subject, ConsString::kFirstOffset));
|
||||
__ ldr(r0, FieldMemOperand(subject, HeapObject::kMapOffset));
|
||||
__ ldrb(r0, FieldMemOperand(r0, Map::kInstanceTypeOffset));
|
||||
// Is first part a flat string?
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
__ tst(r0, Operand(kStringRepresentationMask));
|
||||
__ b(nz, &runtime);
|
||||
__ and_(r1, r0, Operand(kStringRepresentationEncodingMask));
|
||||
|
||||
__ bind(&seq_string);
|
||||
// r1: suject string type & kStringRepresentationEncodingMask
|
||||
// subject: Subject string
|
||||
// regexp_data: RegExp data (FixedArray)
|
||||
// Check that the irregexp code has been generated for an ascii string. If
|
||||
// it has, the field contains a code object otherwise it contains the hole.
|
||||
#ifdef DEBUG
|
||||
const int kSeqAsciiString = kStringTag | kSeqStringTag | kAsciiStringTag;
|
||||
const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag;
|
||||
CHECK_EQ(4, kSeqAsciiString);
|
||||
CHECK_EQ(0, kSeqTwoByteString);
|
||||
#endif
|
||||
// r0: Instance type of subject string
|
||||
ASSERT_EQ(4, kAsciiStringTag);
|
||||
ASSERT_EQ(0, kTwoByteStringTag);
|
||||
// Find the code object based on the assumptions above.
|
||||
__ mov(r3, Operand(r1, ASR, 2), SetCC);
|
||||
__ and_(r0, r0, Operand(kStringEncodingMask));
|
||||
__ mov(r3, Operand(r0, ASR, 2), SetCC);
|
||||
__ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataAsciiCodeOffset), ne);
|
||||
__ ldr(r7, FieldMemOperand(regexp_data, JSRegExp::kDataUC16CodeOffset), eq);
|
||||
|
||||
|
@ -11305,58 +11305,58 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
|
||||
|
||||
// ecx: RegExp data (FixedArray)
|
||||
// Check the representation and encoding of the subject string.
|
||||
Label seq_string, seq_two_byte_string, check_code;
|
||||
const int kStringRepresentationEncodingMask =
|
||||
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
|
||||
Label seq_ascii_string, seq_two_byte_string, check_code;
|
||||
__ mov(eax, Operand(esp, kSubjectOffset));
|
||||
__ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
|
||||
__ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
|
||||
__ and_(ebx, kStringRepresentationEncodingMask);
|
||||
// First check for sequential string.
|
||||
ASSERT_EQ(0, kStringTag);
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
// First check for flat two byte string.
|
||||
__ and_(ebx,
|
||||
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask);
|
||||
ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag);
|
||||
__ j(zero, &seq_two_byte_string);
|
||||
// Any other flat string must be a flat ascii string.
|
||||
__ test(Operand(ebx),
|
||||
Immediate(kIsNotStringMask | kStringRepresentationMask));
|
||||
__ j(zero, &seq_string);
|
||||
__ j(zero, &seq_ascii_string);
|
||||
|
||||
// Check for flat cons string.
|
||||
// A flat cons string is a cons string where the second part is the empty
|
||||
// string. In that case the subject string is just the first part of the cons
|
||||
// string. Also in this case the first part of the cons string is known to be
|
||||
// a sequential string or an external string.
|
||||
__ and_(ebx, kStringRepresentationMask);
|
||||
__ cmp(ebx, kConsStringTag);
|
||||
__ j(not_equal, &runtime);
|
||||
ASSERT(kExternalStringTag !=0);
|
||||
ASSERT_EQ(0, kConsStringTag & kExternalStringTag);
|
||||
__ test(Operand(ebx),
|
||||
Immediate(kIsNotStringMask | kExternalStringTag));
|
||||
__ j(not_zero, &runtime);
|
||||
// String is a cons string.
|
||||
__ mov(edx, FieldOperand(eax, ConsString::kSecondOffset));
|
||||
__ cmp(Operand(edx), Factory::empty_string());
|
||||
__ j(not_equal, &runtime);
|
||||
__ mov(eax, FieldOperand(eax, ConsString::kFirstOffset));
|
||||
__ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
|
||||
__ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
__ test(ebx, Immediate(kStringRepresentationMask));
|
||||
// String is a cons string with empty second part.
|
||||
// eax: first part of cons string.
|
||||
// ebx: map of first part of cons string.
|
||||
// Is first part a flat two byte string?
|
||||
__ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset),
|
||||
kStringRepresentationMask | kStringEncodingMask);
|
||||
ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag);
|
||||
__ j(zero, &seq_two_byte_string);
|
||||
// Any other flat string must be ascii.
|
||||
__ test_b(FieldOperand(ebx, Map::kInstanceTypeOffset),
|
||||
kStringRepresentationMask);
|
||||
__ j(not_zero, &runtime);
|
||||
__ and_(ebx, kStringRepresentationEncodingMask);
|
||||
|
||||
__ bind(&seq_string);
|
||||
// eax: subject string (sequential either ascii to two byte)
|
||||
// ebx: suject string type & kStringRepresentationEncodingMask
|
||||
__ bind(&seq_ascii_string);
|
||||
// eax: subject string (flat ascii)
|
||||
// ecx: RegExp data (FixedArray)
|
||||
// Check that the irregexp code has been generated for an ascii string. If
|
||||
// it has, the field contains a code object otherwise it contains the hole.
|
||||
const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag;
|
||||
__ cmp(ebx, kSeqTwoByteString);
|
||||
__ j(equal, &seq_two_byte_string);
|
||||
if (FLAG_debug_code) {
|
||||
__ cmp(ebx, kStringTag | kSeqStringTag | kAsciiStringTag);
|
||||
__ Check(equal, "Expected sequential ascii string");
|
||||
}
|
||||
__ mov(edx, FieldOperand(ecx, JSRegExp::kDataAsciiCodeOffset));
|
||||
__ Set(edi, Immediate(1)); // Type is ascii.
|
||||
__ jmp(&check_code);
|
||||
|
||||
__ bind(&seq_two_byte_string);
|
||||
// eax: subject string
|
||||
// eax: subject string (flat two byte)
|
||||
// ecx: RegExp data (FixedArray)
|
||||
__ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset));
|
||||
__ Set(edi, Immediate(0)); // Type is two byte.
|
||||
@ -12897,7 +12897,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
|
||||
__ j(zero, &string_add_runtime);
|
||||
|
||||
__ bind(&make_flat_ascii_string);
|
||||
// Both strings are ascii strings. As they are short they are both flat.
|
||||
// Both strings are ascii strings. As they are short they are both flat.
|
||||
// ebx: length of resulting flat string as a smi
|
||||
__ SmiUntag(ebx);
|
||||
__ AllocateAsciiString(eax, ebx, ecx, edx, edi, &string_add_runtime);
|
||||
|
@ -8601,59 +8601,58 @@ void RegExpExecStub::Generate(MacroAssembler* masm) {
|
||||
__ cmpl(rdx, rax);
|
||||
__ j(greater, &runtime);
|
||||
|
||||
// ecx: RegExp data (FixedArray)
|
||||
// rcx: RegExp data (FixedArray)
|
||||
// Check the representation and encoding of the subject string.
|
||||
Label seq_string, seq_two_byte_string, check_code;
|
||||
const int kStringRepresentationEncodingMask =
|
||||
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask;
|
||||
Label seq_ascii_string, seq_two_byte_string, check_code;
|
||||
__ movq(rax, Operand(rsp, kSubjectOffset));
|
||||
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
|
||||
__ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset));
|
||||
__ andb(rbx, Immediate(kStringRepresentationEncodingMask));
|
||||
// First check for sequential string.
|
||||
ASSERT_EQ(0, kStringTag);
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
// First check for flat two byte string.
|
||||
__ andb(rbx, Immediate(
|
||||
kIsNotStringMask | kStringRepresentationMask | kStringEncodingMask));
|
||||
ASSERT_EQ(0, kStringTag | kSeqStringTag | kTwoByteStringTag);
|
||||
__ j(zero, &seq_two_byte_string);
|
||||
// Any other flat string must be a flat ascii string.
|
||||
__ testb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask));
|
||||
__ j(zero, &seq_string);
|
||||
__ j(zero, &seq_ascii_string);
|
||||
|
||||
// Check for flat cons string.
|
||||
// A flat cons string is a cons string where the second part is the empty
|
||||
// string. In that case the subject string is just the first part of the cons
|
||||
// string. Also in this case the first part of the cons string is known to be
|
||||
// a sequential string or an external string.
|
||||
__ andb(rbx, Immediate(kStringRepresentationMask));
|
||||
__ cmpb(rbx, Immediate(kConsStringTag));
|
||||
__ j(not_equal, &runtime);
|
||||
ASSERT(kExternalStringTag !=0);
|
||||
ASSERT_EQ(0, kConsStringTag & kExternalStringTag);
|
||||
__ testb(rbx, Immediate(kIsNotStringMask | kExternalStringTag));
|
||||
__ j(not_zero, &runtime);
|
||||
// String is a cons string.
|
||||
__ movq(rdx, FieldOperand(rax, ConsString::kSecondOffset));
|
||||
__ Cmp(rdx, Factory::empty_string());
|
||||
__ j(not_equal, &runtime);
|
||||
__ movq(rax, FieldOperand(rax, ConsString::kFirstOffset));
|
||||
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
|
||||
__ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset));
|
||||
ASSERT_EQ(0, kSeqStringTag);
|
||||
__ testb(rbx, Immediate(kStringRepresentationMask));
|
||||
// String is a cons string with empty second part.
|
||||
// eax: first part of cons string.
|
||||
// ebx: map of first part of cons string.
|
||||
// Is first part a flat two byte string?
|
||||
__ testb(FieldOperand(rbx, Map::kInstanceTypeOffset),
|
||||
Immediate(kStringRepresentationMask | kStringEncodingMask));
|
||||
ASSERT_EQ(0, kSeqStringTag | kTwoByteStringTag);
|
||||
__ j(zero, &seq_two_byte_string);
|
||||
// Any other flat string must be ascii.
|
||||
__ testb(FieldOperand(rbx, Map::kInstanceTypeOffset),
|
||||
Immediate(kStringRepresentationMask));
|
||||
__ j(not_zero, &runtime);
|
||||
__ andb(rbx, Immediate(kStringRepresentationEncodingMask));
|
||||
|
||||
__ bind(&seq_string);
|
||||
// rax: subject string (sequential either ascii to two byte)
|
||||
// rbx: suject string type & kStringRepresentationEncodingMask
|
||||
__ bind(&seq_ascii_string);
|
||||
// rax: subject string (sequential ascii)
|
||||
// rcx: RegExp data (FixedArray)
|
||||
// Check that the irregexp code has been generated for an ascii string. If
|
||||
// it has, the field contains a code object otherwise it contains the hole.
|
||||
const int kSeqTwoByteString = kStringTag | kSeqStringTag | kTwoByteStringTag;
|
||||
__ cmpb(rbx, Immediate(kSeqTwoByteString));
|
||||
__ j(equal, &seq_two_byte_string);
|
||||
if (FLAG_debug_code) {
|
||||
__ cmpb(rbx, Immediate(kStringTag | kSeqStringTag | kAsciiStringTag));
|
||||
__ Check(equal, "Expected sequential ascii string");
|
||||
}
|
||||
__ movq(r12, FieldOperand(rcx, JSRegExp::kDataAsciiCodeOffset));
|
||||
__ Set(rdi, 1); // Type is ascii.
|
||||
__ jmp(&check_code);
|
||||
|
||||
__ bind(&seq_two_byte_string);
|
||||
// rax: subject string
|
||||
// rax: subject string (flat two-byte)
|
||||
// rcx: RegExp data (FixedArray)
|
||||
__ movq(r12, FieldOperand(rcx, JSRegExp::kDataUC16CodeOffset));
|
||||
__ Set(rdi, 0); // Type is two byte.
|
||||
|
Loading…
Reference in New Issue
Block a user